From 79ca4f1a1a2a3be0d94d915bb1f9c4e622353b09 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Sat, 9 Dec 2023 03:23:19 +0000 Subject: [PATCH] Automatically generate packages from configurations --- flake.nix | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 367dac2..353941e 100644 --- a/flake.nix +++ b/flake.nix @@ -7,17 +7,23 @@ outputs = { self, nixpkgs, utils }: let supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; in (utils.lib.eachSystem supportedSystems (system: - let pkgs = import nixpkgs { inherit system; }; + let + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) lib; + makeImage = conf: + (conf.extendModules { + modules = [{ + config.nixpkgs = { + hostPlatform.system = conf.config.nixpkgs.system; + buildPlatform.system = system; + }; + }]; + }).config.system.build.sdImage; in { formatter = pkgs.nixfmt; - packages.pi4-sdimage = (self.nixosConfigurations.pi4.extendModules { - modules = [{ - config.nixpkgs = { - hostPlatform.system = "aarch64-linux"; - buildPlatform.system = system; - }; - }]; - }).config.system.build.sdImage; + packages = lib.mapAttrs' + (name: value: lib.nameValuePair "${name}-sdimage" (makeImage value)) + self.nixosConfigurations; })) // { nixosModules.minify = { ... }: { disabledModules = [ "profiles/base.nix" ]; @@ -27,7 +33,7 @@ }; }; - nixosConfigurations.pi4 = nixpkgs.lib.nixosSystem { + nixosConfigurations.aarch64-rpi = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = [ self.nixosModules.minify