diff --git a/flake.lock b/flake.lock index 464432c..d62c9ee 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,43 @@ { "nodes": { + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1708091384, + "narHash": "sha256-dTGGw2y8wvfjr+J9CjQbfdulOq72hUG17HXVNxpH1yE=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "0a0187794ac7f7a1e62cda3dabf8dc041f868790", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -113,6 +151,7 @@ }, "root": { "inputs": { + "deploy-rs": "deploy-rs", "home-manager": "home-manager", "nix-fast-build": "nix-fast-build", "nixpkgs": "nixpkgs", @@ -140,6 +179,21 @@ "type": "github" } }, + "systems": { + "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": [ @@ -160,6 +214,24 @@ "repo": "treefmt-nix", "type": "github" } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 9e32a47..f74eb44 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,24 @@ # The `@` syntax here is used to alias the attribute set of the # inputs's parameter, making it convenient to use inside the function. - outputs = { self, nixpkgs, home-manager, ... }@inputs: { + outputs = { self, nixpkgs, home-manager, ... }@inputs: + let + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "x86_64-linux" + ]; + in + { + pkgs = forAllSystems (localSystem: import nixpkgs { + inherit localSystem; + config = { + allowUnfree = true; + allowAliases = true; + }; + }); + + packages = forAllSystems (import ./packages inputs); + nixosConfigurations = { "durincore" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; @@ -87,5 +104,6 @@ ]; }; }; + }; } diff --git a/packages/default.nix b/packages/default.nix new file mode 100644 index 0000000..fb20f68 --- /dev/null +++ b/packages/default.nix @@ -0,0 +1,28 @@ +{ + self, + nix-fast-build, + ... +}: +hostPlatform: + +let + inherit (self.pkgs.${hostPlatform}) callPackage lib linkFarm; + + nixosDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations; + darwinDrvs = lib.mapAttrs (_: darwin: darwin.system) self.darwinConfigurations; + hostDrvs = nixosDrvs // darwinDrvs; + + compatHosts = lib.filterAttrs (_: host: host.hostPlatform == hostPlatform) self.hosts; + compatHostDrvs = lib.mapAttrs + (name: _: hostDrvs.${name}) + compatHosts; + + compatHostsFarm = linkFarm "hosts-${hostPlatform}" (lib.mapAttrsToList (name: path: { inherit name path; }) compatHostDrvs); +in +compatHostDrvs +// (lib.optionalAttrs (compatHosts != { }) { + default = compatHostsFarm; +}) // { + inherit (nix-fast-build.packages.${hostPlatform}) nix-fast-build; + inherit (self.pkgs.${hostPlatform}) cachix nix-eval-jobs; +} \ No newline at end of file