add image generation

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
ahuston-0 2024-06-03 11:27:04 -04:00 committed by Alice Huston
parent 16a2f66612
commit 55b7e407f1
4 changed files with 59 additions and 0 deletions

37
flake.lock generated
View File

@ -267,6 +267,42 @@
"type": "github" "type": "github"
} }
}, },
"nixlib": {
"locked": {
"lastModified": 1712450863,
"narHash": "sha256-K6IkdtMtq9xktmYPj0uaYc8NsIqHuaAoRBaMgu9Fvrw=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "3c62b6a12571c9a7f65ab037173ee153d539905f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1716210724,
"narHash": "sha256-iqQa3omRcHGpWb1ds75jS9ruA5R39FTmAkeR3J+ve1w=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "d14b286322c7f4f897ca4b1726ce38cb68596c94",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1717248095, "lastModified": 1717248095,
@ -403,6 +439,7 @@
"hyprland-contrib": "hyprland-contrib", "hyprland-contrib": "hyprland-contrib",
"nix": "nix", "nix": "nix",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nixos-generators": "nixos-generators",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixos-modules": "nixos-modules", "nixos-modules": "nixos-modules",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",

View File

@ -74,6 +74,10 @@
url = "github:Mic92/nix-index-database"; url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-modules = { nixos-modules = {
url = "github:SuperSandro2000/nixos-modules"; url = "github:SuperSandro2000/nixos-modules";

View File

@ -3,8 +3,15 @@ let
inherit (inputs.nixpkgs.lib) mapAttrs; inherit (inputs.nixpkgs.lib) mapAttrs;
getCfg = _: cfg: cfg.config.system.build.toplevel; getCfg = _: cfg: cfg.config.system.build.toplevel;
getFormat =
_: cfg: format:
cfg.config.formats.${format};
imageWrapper = format: mapAttrs getFormat outputs.nixosConfigurations format;
in in
{ {
inherit (outputs) formatter devShells; inherit (outputs) formatter devShells;
hosts = mapAttrs getCfg outputs.nixosConfigurations; hosts = mapAttrs getCfg outputs.nixosConfigurations;
install-isos = imageWrapper "install-iso";
isos = imageWrapper "iso";
qcow = imageWrapper "qcow";
} }

11
modules/generators.nix Normal file
View File

@ -0,0 +1,11 @@
{
config,
lib,
pkgs,
inputs,
...
}:
{
imports = [ inputs.nixos-generators.nixosModules.all-formats ];
}