mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
config: update image generation step
It doesn't allow setting up system modularly so we'll have to do this on our own which is easy enough since it's already done once.
This commit is contained in:
parent
d55865beb0
commit
c1d8be29b0
@ -315,6 +315,7 @@
|
||||
# A function that generates a Nix module from host metadata.
|
||||
hostSpecificModule = host: metadata: let
|
||||
modules = metadata.modules or [];
|
||||
host = metadata._name or host;
|
||||
in
|
||||
{ lib, ... }: {
|
||||
imports = modules ++ [
|
||||
@ -421,18 +422,17 @@
|
||||
images =
|
||||
forAllSystems (system:
|
||||
let
|
||||
images' = lib.filterAttrs (host: metadata: system == metadata._system) (listImagesWithSystems images);
|
||||
images' = lib.filterAttrs (host: metadata: (system == metadata._system) && (metadata.format != null)) (listImagesWithSystems images);
|
||||
in
|
||||
lib.mapAttrs'
|
||||
(host: metadata:
|
||||
let
|
||||
name = metadata._name;
|
||||
nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
|
||||
pkgs = import inputs.${nixpkgs-channel} {};
|
||||
format = metadata.format or "iso";
|
||||
in
|
||||
lib.nameValuePair name (mkImage {
|
||||
inherit format pkgs;
|
||||
inherit nixpkgs-channel format;
|
||||
extraModules = [ (hostSpecificModule host metadata) ];
|
||||
}))
|
||||
images');
|
||||
|
@ -39,12 +39,23 @@ in
|
||||
};
|
||||
|
||||
# A thin wrapper around the nixos-generators `nixosGenerate` function.
|
||||
mkImage = { pkgs ? null, extraModules ? [ ], format ? "iso" }:
|
||||
inputs.nixos-generators.nixosGenerate {
|
||||
inherit pkgs format;
|
||||
lib = pkgs.lib.extend extendLib;
|
||||
modules = extraModules;
|
||||
mkImage = { nixpkgs-channel ? "nixpkgs", extraModules ? [ ], format ? "iso" }: let
|
||||
nixpkgs = inputs.${nixpkgs-channel};
|
||||
|
||||
# A modified version of `nixosSystem` from nixpkgs flake similar to the
|
||||
# one found in mkHost.
|
||||
nixosSystem = args: import "${nixpkgs}/nixos/lib/eval-config.nix" args;
|
||||
|
||||
image = nixosSystem {
|
||||
lib = nixpkgs.lib.extend extendLib;
|
||||
modules = extraModules ++ [ inputs.nixos-generators.nixosModules.${format} ];
|
||||
|
||||
# We're also setting this up modularly so we'll have to pass these as
|
||||
# null.
|
||||
system = null;
|
||||
};
|
||||
in
|
||||
image.config.system.build.${image.config.formatAttr};
|
||||
|
||||
# A function to modify the given table of declarative setups (i.e., hosts,
|
||||
# users) to have its own system attribute and its name.
|
||||
|
Loading…
Reference in New Issue
Block a user