Install disko in the ISOs.
This commit is contained in:
75
nix/configuration/roles/disko/default.nix
Normal file
75
nix/configuration/roles/disko/default.nix
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
self,
|
||||
this_nixos_config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
flakeOutPaths =
|
||||
let
|
||||
collector =
|
||||
parent:
|
||||
map (
|
||||
child:
|
||||
[ child.outPath ] ++ (if child ? inputs && child.inputs != { } then (collector child) else [ ])
|
||||
) (lib.attrValues parent.inputs);
|
||||
in
|
||||
lib.unique (lib.flatten (collector self));
|
||||
dependencies = [
|
||||
# this_nixos_config.config.system.build.toplevel
|
||||
this_nixos_config.config.system.build.diskoScript
|
||||
# this_nixos_config.config.system.build.diskoScript.drvPath
|
||||
this_nixos_config.pkgs.stdenv.drvPath
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/f2fd33a198a58c4f3d53213f01432e4d88474956/nixos/modules/system/activation/top-level.nix#L342
|
||||
this_nixos_config.pkgs.perlPackages.ConfigIniFiles
|
||||
this_nixos_config.pkgs.perlPackages.FileSlurp
|
||||
|
||||
(this_nixos_config.pkgs.closureInfo { rootPaths = [ ]; }).drvPath
|
||||
]
|
||||
++ flakeOutPaths;
|
||||
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
options.me = {
|
||||
disko.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether we want to install disko.";
|
||||
};
|
||||
|
||||
disko.offline.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether we want to install disko.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.me.disko.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
disko
|
||||
];
|
||||
}
|
||||
(lib.mkIf config.me.disko.offline.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
(pkgs.writeShellScriptBin "install-nixos-unattended" ''
|
||||
set -xeuo pipefail
|
||||
IFS=$'\n\t'
|
||||
exec ${pkgs.disko}/bin/disko-install --flake '${self}#${config.networking.hostName}' --disk main '/dev/nvme0n1'
|
||||
'')
|
||||
];
|
||||
|
||||
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user