diff options
Diffstat (limited to 'lib/call-machine.nix')
-rw-r--r-- | lib/call-machine.nix | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/call-machine.nix b/lib/call-machine.nix new file mode 100644 index 00000000..0844e4eb --- /dev/null +++ b/lib/call-machine.nix @@ -0,0 +1,65 @@ +path: { system ? builtins.currentSystem }: + +let + nixpkgs = import ../nixpkgs-path.nix; + + eval = import "${nixpkgs}/nixos/lib/eval-config.nix" { + inherit system; + modules = [ path ] ++ import ../modules/module-list.nix; + }; + + iso = let + isoModule = "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix"; + wrapIso = { config, pkgs, lib, ... }@attrs: let + isoEval = (import isoModule attrs); + isoEvalcfg = isoEval.config or {}; + bootcfg = isoEvalcfg.boot or {}; + fscfg = isoEvalcfg.fileSystems or {}; + in { + options = isoEval.options or {}; + imports = isoEval.imports or []; + config = isoEvalcfg // { + boot = bootcfg // lib.optionalAttrs (bootcfg ? loader) { + loader = lib.mkForce bootcfg.loader; + }; + fileSystems = lib.mapAttrs (lib.const lib.mkForce) fscfg // { + "/boot" = lib.mkForce (fscfg."/boot" or { + device = "none"; + fsType = "none"; + options = "noauto"; + }); + }; + }; + }; + in import "${nixpkgs}/nixos/lib/eval-config.nix" { + inherit system; + modules = [ + config wrapIso + ( + { lib, ... }: let + name = eval.config.networking.hostName; + upperName = lib.toUpper name; + in rec { + isoImage.isoName = "${name}.iso"; + isoImage.volumeID = builtins.substring 0 11 "${upperName}_LIVE"; + isoImage.makeEfiBootable = true; + isoImage.makeUsbBootable = true; + isoImage.appendToMenuLabel = " \"${name}\" Live System"; + } + ) + ]; + }; + + config = { + imports = [ path ] ++ import ../modules/module-list.nix; + }; + + vm = (import "${nixpkgs}/nixos" { + inherit system; + configuration = config; + }).vm; + +in { + build = eval.config.system.build.toplevel; + inherit config eval iso vm; +} |