diff options
author | Franck Cuny <franck@fcuny.net> | 2023-12-04 07:35:44 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2023-12-04 07:35:44 -0800 |
commit | 67edd7ba89d98e7534394dab674360da99f40e3d (patch) | |
tree | 6575bfbe152b84f94e931d7c95235fcd996a1847 | |
parent | formatting a few files with treefmt (diff) | |
download | world-67edd7ba89d98e7534394dab674360da99f40e3d.tar.gz |
update to 23.11 and break down flakes
Update to 23.11 for both nix and home-manager. Break down the flake in multiple parts (hosts, devshell) so that they are easier to maintain. The main reason to start this is because `nix flake check` was failing, the flake was not correct.
-rw-r--r-- | flake.lock | 187 | ||||
-rw-r--r-- | flake.nix | 156 | ||||
-rw-r--r-- | flake/devshell.nix | 41 | ||||
-rw-r--r-- | flake/mba.nix | 20 |
4 files changed, 264 insertions, 140 deletions
diff --git a/flake.lock b/flake.lock index 517b65f..a7a92f3 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,25 @@ "type": "github" } }, + "devshell": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + }, + "locked": { + "lastModified": 1701697687, + "narHash": "sha256-dLLE5wQBVv+pIb4bWmKFSw2DvLVyuEk0F7ng6hpZPSU=", + "owner": "numtide", + "repo": "devshell", + "rev": "c3bd77911391eb1638af6ce773de86da57ee6df5", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -36,9 +55,45 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "futils": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { "lastModified": 1694529238, @@ -82,31 +137,81 @@ ] }, "locked": { - "lastModified": 1700392168, - "narHash": "sha256-v5LprEFx3u4+1vmds9K0/i7sHjT0IYGs7u9v54iz/OA=", + "lastModified": 1700814205, + "narHash": "sha256-lWqDPKHRbQfi+zNIivf031BUeyciVOtwCwTjyrhDB5g=", "owner": "nix-community", "repo": "home-manager", - "rev": "28535c3a34d79071f2ccb68671971ce0c0984d7e", + "rev": "aeb2232d7a32530d3448318790534d196bf9427a", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-23.05", + "ref": "release-23.11", "repo": "home-manager", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1701389149, - "narHash": "sha256-rU1suTIEd5DGCaAXKW6yHoCfR1mnYjOXQFOaH7M23js=", + "lastModified": 1677383253, + "narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5de0b32be6e85dc1a9404c75131316e4ffbc634c", + "rev": "9952d6bc395f5841262b006fbace8dd7e143b634", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1701540982, + "narHash": "sha256-5ajSy6ODgGmAbmymRdHnjfVnuVrACjI8wXoGVvrtvww=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6386d8aafc28b3a7ed03880a57bdc6eb4465491d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1701539137, + "narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d", + "type": "github" + }, + "original": { + "owner": "nixos", "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" @@ -115,16 +220,12 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": [ - "futils" - ], + "flake-utils": "flake-utils", "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" ], - "nixpkgs-stable": [ - "nixpkgs" - ] + "nixpkgs-stable": "nixpkgs-stable" }, "locked": { "lastModified": 1700922917, @@ -136,7 +237,6 @@ }, "original": { "owner": "cachix", - "ref": "master", "repo": "pre-commit-hooks.nix", "type": "github" } @@ -144,10 +244,13 @@ "root": { "inputs": { "darwin": "darwin", + "devshell": "devshell", + "flake-parts": "flake-parts", "futils": "futils", "home-manager": "home-manager", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks", + "treefmt-nix": "treefmt-nix" } }, "systems": { @@ -164,6 +267,56 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1699786194, + "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 072ad80..8994fc9 100644 --- a/flake.nix +++ b/flake.nix @@ -2,23 +2,11 @@ description = "personal NixOS configurations"; inputs = { - nixpkgs = { - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - ref = "nixos-23.05"; - }; - - futils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; home-manager = { - type = "github"; - owner = "nix-community"; - repo = "home-manager"; - ref = "release-23.05"; - inputs = { - nixpkgs.follows = "nixpkgs"; - }; + url = "github:nix-community/home-manager/release-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; }; darwin = { @@ -26,124 +14,46 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + pre-commit-hooks = { - type = "github"; - owner = "cachix"; - repo = "pre-commit-hooks.nix"; - ref = "master"; - inputs = { - flake-utils.follows = "futils"; - nixpkgs.follows = "nixpkgs"; - nixpkgs-stable.follows = "nixpkgs"; - }; + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; }; - }; - # Output config, or config for NixOS system - outputs = inputs@{ self, darwin, home-manager, ... }: - let - myLib = import ./nix inputs; - lib = inputs.nixpkgs.lib // builtins; - supportedSystems = [ "aarch64-darwin" ]; - forAllSystems = lib.genAttrs supportedSystems; + devshell.url = "github:numtide/devshell"; - # Nixpkgs instantiated for supported system types. - nixpkgsFor = forAllSystems (system: - import inputs.nixpkgs { - inherit system; - config = { allowUnfree = true; }; - }); - in - { - templates = import ./templates; + # utils + futils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; - checks = forAllSystems (system: - let pkgs = nixpkgsFor.${system}; + # Output config, or config for NixOS system + outputs = inputs@{ self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + flake = + let + mba = import ./flake/mba.nix { + inherit (inputs) nixpkgs home-manager darwin; + inherit inputs; + }; in { - pre-commit-check = inputs.pre-commit-hooks.lib."${system}".run { - src = ./.; - hooks = { - nixpkgs-fmt.enable = true; - trailing-whitespace = { - enable = true; - entry = - "${pkgs.python3Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer"; - types = [ "text" ]; - }; - - end-of-file-fixer = { - enable = true; - entry = - "${pkgs.python3Packages.pre-commit-hooks}/bin/end-of-file-fixer"; - types = [ "text" ]; - }; - - check-executables-have-shebangs = { - entry = - "${pkgs.python3Packages.pre-commit-hooks}/bin/check-executables-have-shebangs"; - types = [ "text" "executable" ]; - }; - - check-json = { - enable = true; - entry = "${pkgs.python3Packages.pre-commit-hooks}/bin/check-json"; - types = [ "json" ]; - }; - - check-toml = { - enable = true; - entry = "${pkgs.python3Packages.pre-commit-hooks}/bin/check-toml"; - types = [ "toml" ]; - }; - - check-yaml = { - enable = true; - entry = "${pkgs.python3Packages.pre-commit-hooks}/bin/check-yaml --allow-multiple-documents"; - types = [ "yaml" ]; - }; - - shellcheck = { - enable = true; - files = "\\.sh$"; - types_or = [ "file" ]; - }; - }; + darwinConfigurations = { + mba-fcuny = mba.system; }; - }); - - devShells = forAllSystems (system: { - default = inputs.nixpkgs.legacyPackages.${system}.mkShell { - name = "fcuny-configuration-on-${system}-system"; - buildInputs = with inputs.nixpkgs.legacyPackages.${system}.pkgs; [ - gitAndTools.pre-commit - nixfmt - nixpkgs-fmt - rnix-lsp - home-manager - git - nixos-rebuild - ]; - inherit (self.checks.${system}.pre-commit-check) shellHook; }; - }); - packages = forAllSystems (system: - let pkgs = nixpkgsFor.${system}; - in - { - inherit (inputs.futils.lib) filterPackages flattenTree; - tools = import ./tools { inherit pkgs; }; - }); + systems = [ + "aarch64-darwin" + "x86_64-linux" + ]; - darwinConfigurations = { - "mba-fcuny" = darwin.lib.darwinSystem { - system = "aarch64-darwin"; - modules = [ - home-manager.darwinModules.home-manager - ./hosts/mba - ]; - }; - }; + imports = [ + ./flake/devshell.nix + ]; }; } diff --git a/flake/devshell.nix b/flake/devshell.nix new file mode 100644 index 0000000..f096bfe --- /dev/null +++ b/flake/devshell.nix @@ -0,0 +1,41 @@ +{ inputs, ... }: { + imports = [ + inputs.devshell.flakeModule + inputs.treefmt-nix.flakeModule + inputs.pre-commit-hooks.flakeModule + ]; + + perSystem = { config, pkgs, inputs', ... }: { + devShells.default = pkgs.mkShell { + name = "dotfiles"; + + packages = [ + ]; + + TREEFMT_CONFIG_FILE = config.treefmt.build.configFile; + }; + + treefmt = { + projectRootFile = ".git/config"; + + # list of supported programs + # https://github.com/numtide/treefmt-nix + programs = { + nixpkgs-fmt.enable = true; + shfmt.enable = true; + yamlfmt.enable = true; + taplo.enable = true; + }; + }; + + pre-commit = { + settings = { + hooks = { + # deadnix.enable = true; + shellcheck.enable = true; + treefmt.enable = true; + }; + }; + }; + }; +} diff --git a/flake/mba.nix b/flake/mba.nix new file mode 100644 index 0000000..60ac876 --- /dev/null +++ b/flake/mba.nix @@ -0,0 +1,20 @@ +{ nixpkgs, home-manager, darwin, inputs, ... }: + +let + default-system = "aarch64-darwin"; + + nixpkgsConfig = { + config = { + allowUnfree = true; + }; + }; +in +{ + system = darwin.lib.darwinSystem { + system = default-system; + modules = [ + ../hosts/mba + home-manager.darwinModules.home-manager + ]; + }; +} |