From 55b7e407f1d819ce7747f512e606c5a2242768ed Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Mon, 3 Jun 2024 11:27:04 -0400 Subject: [PATCH] add image generation Signed-off-by: ahuston-0 --- flake.lock | 37 +++++++++++++++++++++++++++++++++++++ flake.nix | 4 ++++ hydra/jobs.nix | 7 +++++++ modules/generators.nix | 11 +++++++++++ 4 files changed, 59 insertions(+) create mode 100644 modules/generators.nix diff --git a/flake.lock b/flake.lock index 9b5b7e8..0435799 100644 --- a/flake.lock +++ b/flake.lock @@ -267,6 +267,42 @@ "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": { "locked": { "lastModified": 1717248095, @@ -403,6 +439,7 @@ "hyprland-contrib": "hyprland-contrib", "nix": "nix", "nix-index-database": "nix-index-database", + "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", "nixos-modules": "nixos-modules", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 99e766d..4556079 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,10 @@ url = "github:Mic92/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixos-modules = { url = "github:SuperSandro2000/nixos-modules"; diff --git a/hydra/jobs.nix b/hydra/jobs.nix index cb70d1b..7b65d76 100644 --- a/hydra/jobs.nix +++ b/hydra/jobs.nix @@ -3,8 +3,15 @@ let inherit (inputs.nixpkgs.lib) mapAttrs; getCfg = _: cfg: cfg.config.system.build.toplevel; + getFormat = + _: cfg: format: + cfg.config.formats.${format}; + imageWrapper = format: mapAttrs getFormat outputs.nixosConfigurations format; in { inherit (outputs) formatter devShells; hosts = mapAttrs getCfg outputs.nixosConfigurations; + install-isos = imageWrapper "install-iso"; + isos = imageWrapper "iso"; + qcow = imageWrapper "qcow"; } diff --git a/modules/generators.nix b/modules/generators.nix new file mode 100644 index 0000000..0faf0a7 --- /dev/null +++ b/modules/generators.nix @@ -0,0 +1,11 @@ +{ + config, + lib, + pkgs, + inputs, + ... +}: + +{ + imports = [ inputs.nixos-generators.nixosModules.all-formats ]; +}