diff --git a/flake.lock b/flake.lock index 80a0b42..379b33d 100644 --- a/flake.lock +++ b/flake.lock @@ -311,6 +311,24 @@ } }, "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-parts_2": { "inputs": { "nixpkgs-lib": [ "neovim-nightly-overlay", @@ -331,7 +349,7 @@ "type": "github" } }, - "flake-parts_2": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "neovim-nightly-overlay", @@ -550,7 +568,7 @@ }, "hercules-ci-effects": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" @@ -678,7 +696,7 @@ "neovim-nightly-overlay": { "inputs": { "flake-compat": "flake-compat_5", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "hercules-ci-effects": "hercules-ci-effects", "neovim-flake": "neovim-flake", "nixpkgs": [ @@ -702,7 +720,7 @@ "nix-colors": { "inputs": { "base16-schemes": "base16-schemes", - "nixpkgs-lib": "nixpkgs-lib" + "nixpkgs-lib": "nixpkgs-lib_2" }, "locked": { "lastModified": 1695388192, @@ -777,6 +795,28 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "jovian-nixos", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690328911, + "narHash": "sha256-fxtExYk+aGf2YbjeWQ8JY9/n9dwuEt+ma1eUFzF8Jeo=", + "owner": "zhaofengli", + "repo": "nix-github-actions", + "rev": "96df4a39c52f53cb7098b923224d8ce941b64747", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "ref": "matrix-name", + "repo": "nix-github-actions", + "type": "github" + } + }, "nix-monitored": { "inputs": { "nix-filter": "nix-filter", @@ -854,6 +894,24 @@ } }, "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-lib_2": { "locked": { "lastModified": 1694911725, "narHash": "sha256-8YqI+YU1DGclEjHsnrrGfqsQg3Wyga1DfTbJrN3Ud0c=", @@ -1070,9 +1128,11 @@ "deploy-rs": "deploy-rs", "disko": "disko", "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts", "hardware": "hardware", "home-manager": "home-manager", "impermanence": "impermanence", + "jovian-nixos": "jovian-nixos", "lib-net": "lib-net", "mac-app-util": "mac-app-util", "neovim-nightly-overlay": "neovim-nightly-overlay", diff --git a/flake.nix b/flake.nix index e8fb143..6bd6ebd 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,10 @@ url = "github:nixos/nixpkgs/nixos-unstable"; }; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + }; + # Nix on Droid nix-on-droid = { url = "github:t184256/nix-on-droid/release-23.05"; @@ -118,98 +122,81 @@ }; outputs = - { self - , nixpkgs - , nix-on-droid - , nix-darwin - , mac-app-util - , home-manager - , impermanence - , lib-net - , nix-monitored - , disko - , deploy-rs - , agenix - , ragenix - , agenix-rekey - , nur - , spicetify-nix - , hardware - , nix-colors - , neovim-nightly-overlay - , zig-overlay - , zls-overlay - , wired - , ... - } @ inputs: + inputs: let + inherit (inputs) self; inherit (self) outputs; util = import ./util { inherit inputs outputs; }; in - { - inherit self; + inputs.flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, flake-parts-lib, ... }: { + systems = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; - # Packages (`nix build`) - packages = util.forEachPkgs (pkgs: - import ./pkgs { inherit pkgs; } - ); + perSystem = { pkgs, ... }: { + # Packages (`nix build`) + packages = import ./pkgs { inherit pkgs; }; - # Apps (`nix run`) - apps = util.forEachPkgs (pkgs: - import ./apps { inherit pkgs; } - ); + # Apps (`nix run`) + apps = import ./apps { inherit pkgs; }; - # Dev Shells (`nix develop`) - devShells = util.forEachPkgs (pkgs: - import ./shells { inherit pkgs inputs outputs; } - ); + # Dev Shells (`nix develop`) + devShells = import ./shells { inherit pkgs inputs outputs; }; - # Formatter - formatter = util.forEachPkgs (pkgs: - pkgs.nixpkgs-fmt - ); - - # Templates - templates = import ./templates { - inherit inputs outputs; + # Formatter (`nix fmt`) + formatter = pkgs.nixpkgs-fmt; }; - # Overlays - overlays = import ./overlays { - inherit inputs outputs; - }; + flake = { + inherit self; - # Machines - inherit (util) - machines - homeManagerMachines - nixDarwinMachines - nixOnDroidMachines - nixosMachines; - - # Modules - inherit (util) - nixosModules - nixOnDroidModules - nixDarwinModules - homeManagerModules; - - # Configurations - nixosConfigurations = util.autoNixosConfigurations; - nixOnDroidConfigurations = util.autoNixOnDroidConfigurations; - darwinConfigurations = util.autoDarwinConfigurations; - homeConfigurations = util.autoHomeConfigurations; - - # Secrets - agenix-rekey = agenix-rekey.configure { - userFlake = self; - nodes = { - inherit (self.nixosConfigurations) jeeves; + # Templates + templates = import ./templates { + inherit inputs outputs; }; - }; - # Deploy.rs nodes - deploy.nodes = util.deploy.autoNodes; - checks = util.autoChecks; - }; + # Overlays + overlays = import ./overlays { + inherit inputs outputs; + }; + + # Machines + inherit (util) + machines + homeManagerMachines + nixDarwinMachines + nixOnDroidMachines + nixosMachines; + + # Modules + inherit (util) + nixosModules + nixOnDroidModules + nixDarwinModules + homeManagerModules + flakeModules; + + # Configurations + nixosConfigurations = util.autoNixosConfigurations; + nixOnDroidConfigurations = util.autoNixOnDroidConfigurations; + darwinConfigurations = util.autoDarwinConfigurations; + homeConfigurations = util.autoHomeConfigurations; + + # Secrets + agenix-rekey = inputs.agenix-rekey.configure { + userFlake = self; + nodes = { + inherit (self.nixosConfigurations) jeeves; + }; + }; + + # Deploy.rs nodes + deploy.nodes = util.deploy.autoNodes; + checks = util.autoChecks; + }; + }); } diff --git a/modules/flake/README.md b/modules/flake/README.md new file mode 100644 index 0000000..6fc3a00 --- /dev/null +++ b/modules/flake/README.md @@ -0,0 +1,5 @@ +Add your reusable flake modules to this directory () + +These are considered modules: +- files, ending in `.nix` (excluding `default.nix`) +- directories, containing `default.nix` diff --git a/util/default.nix b/util/default.nix index 6dacff6..df70e60 100644 --- a/util/default.nix +++ b/util/default.nix @@ -34,20 +34,6 @@ rec { # NOTE: Implying last argument is the output of `recurseDir` hasDirectories = allSatisfy lib.isAttrs; - # pkgs helpers - forEachSystem = lib.genAttrs [ - "aarch64-linux" - "i686-linux" - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - - forEachPkgs = f: - forEachSystem - (system: - f nixpkgs.legacyPackages.${system}); - # Modules helpers createModules = baseDir: { passthru ? { inherit inputs outputs; }, ... }: lib.pipe baseDir [ @@ -103,6 +89,7 @@ rec { nixOnDroidModules = createModules ../modules/nix-on-droid { }; nixDarwinModules = createModules ../modules/nix-darwin { }; homeManagerModules = createModules ../modules/home-manager { }; + flakeModules = createModules ../modules/flake { }; # Machines machines = recurseDir ../machines;