2024-04-21 19:22:47 +00:00
|
|
|
{ flake
|
|
|
|
, flakeAttr
|
|
|
|
, diskMappings
|
|
|
|
, extraSystemConfig ? { }
|
|
|
|
, writeEfiBootEntries ? false
|
|
|
|
, rootMountPoint ? "/mnt"
|
|
|
|
,
|
2024-02-27 19:41:22 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
originalSystem = (builtins.getFlake "${flake}").nixosConfigurations."${flakeAttr}";
|
2024-04-15 17:41:32 +00:00
|
|
|
lib = originalSystem.pkgs.lib;
|
2024-02-27 19:41:22 +00:00
|
|
|
|
2024-04-15 17:41:32 +00:00
|
|
|
deviceName =
|
|
|
|
name:
|
|
|
|
if diskMappings ? ${name} then
|
|
|
|
diskMappings.${name}
|
|
|
|
else
|
|
|
|
throw "No device passed for disk '${name}'. Pass `--disk ${name} /dev/name` via commandline";
|
2024-02-27 19:41:22 +00:00
|
|
|
|
2024-04-21 19:22:47 +00:00
|
|
|
modifiedDisks = builtins.mapAttrs
|
|
|
|
(
|
|
|
|
name: value:
|
|
|
|
let
|
|
|
|
dev = deviceName name;
|
|
|
|
in
|
|
|
|
value
|
|
|
|
// {
|
|
|
|
device = dev;
|
|
|
|
content = value.content // {
|
|
|
|
device = dev;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
|
|
|
originalSystem.config.disko.devices.disk;
|
2024-04-15 17:41:32 +00:00
|
|
|
|
|
|
|
# filter all nixos module internal attributes
|
|
|
|
cleanedDisks = lib.filterAttrsRecursive (n: _: !lib.hasPrefix "_" n) modifiedDisks;
|
|
|
|
|
|
|
|
diskoSystem = originalSystem.extendModules {
|
|
|
|
modules = [
|
|
|
|
{
|
2024-02-27 19:41:22 +00:00
|
|
|
disko.rootMountPoint = rootMountPoint;
|
|
|
|
disko.devices.disk = lib.mkVMOverride cleanedDisks;
|
2024-04-15 17:41:32 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
installSystem = originalSystem.extendModules {
|
|
|
|
modules = [
|
|
|
|
(
|
|
|
|
{ lib, ... }:
|
|
|
|
{
|
|
|
|
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
|
|
|
|
boot.loader.grub.devices = lib.mkVMOverride diskoSystem.config.boot.loader.grub.devices;
|
2024-04-21 19:22:47 +00:00
|
|
|
} // extraSystemConfig
|
2024-04-15 17:41:32 +00:00
|
|
|
)
|
|
|
|
];
|
|
|
|
};
|
2024-02-27 19:41:22 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
installToplevel = installSystem.config.system.build.toplevel;
|
|
|
|
inherit (diskoSystem.config.system.build) formatScript mountScript diskoScript;
|
|
|
|
}
|