2024-02-27 19:41:22 +00:00
|
|
|
{ flake
|
|
|
|
, flakeAttr
|
|
|
|
, diskMappings
|
2024-03-05 07:23:33 +00:00
|
|
|
, writeEfiBootEntries ? false
|
2024-02-27 19:41:22 +00:00
|
|
|
, rootMountPoint ? "/mnt"
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
originalSystem = (builtins.getFlake "${flake}").nixosConfigurations."${flakeAttr}";
|
|
|
|
diskoSystem =
|
|
|
|
let
|
2024-03-11 12:53:07 +00:00
|
|
|
lib = originalSystem.pkgs.lib;
|
2024-02-27 19:41:22 +00:00
|
|
|
|
|
|
|
modifiedDisks = builtins.mapAttrs
|
|
|
|
(name: value: let
|
|
|
|
dev = if diskMappings ? ${name} then
|
|
|
|
diskMappings.${name}
|
|
|
|
else
|
2024-03-05 13:27:01 +00:00
|
|
|
throw "No device passed for disk '${name}'. Pass `--disk ${name} /dev/name` via commandline";
|
2024-02-27 19:41:22 +00:00
|
|
|
in value // {
|
|
|
|
device = dev;
|
|
|
|
content = value.content // { device = dev; };
|
|
|
|
})
|
|
|
|
originalSystem.config.disko.devices.disk;
|
|
|
|
|
|
|
|
cleanedDisks = lib.filterAttrsRecursive (n: _: !lib.hasPrefix "_" n) modifiedDisks;
|
|
|
|
in
|
|
|
|
originalSystem.extendModules {
|
|
|
|
modules = [{
|
|
|
|
disko.rootMountPoint = rootMountPoint;
|
|
|
|
disko.devices.disk = lib.mkVMOverride cleanedDisks;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
installSystem = originalSystem.extendModules {
|
|
|
|
modules = [({ lib, ... }: {
|
2024-03-05 07:23:33 +00:00
|
|
|
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
|
2024-02-27 19:41:22 +00:00
|
|
|
boot.loader.grub.devices = lib.mkVMOverride diskoSystem.config.boot.loader.grub.devices;
|
|
|
|
})];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
installToplevel = installSystem.config.system.build.toplevel;
|
|
|
|
inherit (diskoSystem.config.system.build) formatScript mountScript diskoScript;
|
|
|
|
}
|