mirror of
https://github.com/nix-community/disko.git
synced 2026-12-03 06:23:28 +01:00
fix systemd.initrd being default now breaking disko (#1311)
an alternative to https://github.com/nix-community/disko/pull/1304 This introduces a new globals argument which can be used to pass in different global state into the disko type. Makes the fix a little bit cleaner.
This commit is contained in:
11 files changed
+86
-50
No files matched your search
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
lib ? import <nixpkgs/lib>,
|
lib ? import <nixpkgs/lib>,
|
||||||
rootMountPoint ? "/mnt",
|
rootMountPoint ? "/mnt",
|
||||||
|
canToggleSystemdInitrd ? true,
|
||||||
checked ? false,
|
checked ? false,
|
||||||
diskoLib ? import ./lib { inherit lib rootMountPoint; },
|
diskoLib ? import ./lib { inherit lib rootMountPoint canToggleSystemdInitrd; },
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
eval =
|
eval =
|
||||||
|
|||||||
+19
-2
@@ -4,6 +4,7 @@
|
|||||||
makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>,
|
makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>,
|
||||||
eval-config ? import <nixpkgs/nixos/lib/eval-config.nix>,
|
eval-config ? import <nixpkgs/nixos/lib/eval-config.nix>,
|
||||||
qemu-common ? import <nixpkgs/nixos/lib/qemu-common.nix>,
|
qemu-common ? import <nixpkgs/nixos/lib/qemu-common.nix>,
|
||||||
|
canToggleSystemdInitrd ? true,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# qemu-common is a function that takes { lib, stdenv } and returns QEMU utilities
|
# qemu-common is a function that takes { lib, stdenv } and returns QEMU utilities
|
||||||
@@ -22,6 +23,7 @@ let
|
|||||||
makeTest
|
makeTest
|
||||||
eval-config
|
eval-config
|
||||||
qemu-common-lib
|
qemu-common-lib
|
||||||
|
diskoLib
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
# like lib.types.oneOf but instead of a list takes an attrset
|
# like lib.types.oneOf but instead of a list takes an attrset
|
||||||
@@ -480,7 +482,8 @@ let
|
|||||||
postUnmountHook = diskoLib.mkHook "shell commands to run after unmount";
|
postUnmountHook = diskoLib.mkHook "shell commands to run after unmount";
|
||||||
};
|
};
|
||||||
config._module.args = {
|
config._module.args = {
|
||||||
inherit diskoLib rootMountPoint;
|
inherit diskoLib;
|
||||||
|
globals = { inherit rootMountPoint canToggleSystemdInitrd; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -646,6 +649,17 @@ let
|
|||||||
*/
|
*/
|
||||||
vmToolsSupportsCustomQemu = final_lib: lib.versionAtLeast final_lib.version "24.11.20240709";
|
vmToolsSupportsCustomQemu = final_lib: lib.versionAtLeast final_lib.version "24.11.20240709";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Checks whether `boot.initrd.systemd.enable` can still be defined in a NixOS configuration.
|
||||||
|
|
||||||
|
NixOS 26.11 removed scripted initrd and replaced the option with `mkRemovedOptionModule`,
|
||||||
|
which declares an untyped option whose definition fails an assertion.
|
||||||
|
Real, hidden or renamed declarations keep their bool type.
|
||||||
|
|
||||||
|
systemdInitrdToggleable :: options -> bool
|
||||||
|
*/
|
||||||
|
systemdInitrdToggleable = options: (options.boot.initrd.systemd.enable.type.name or null) == "bool";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Checks whether vmTools supports the kernelModules argument.
|
Checks whether vmTools supports the kernelModules argument.
|
||||||
Older nixpkgs versions only supported overriding `kernel` with an aggregated modules tree.
|
Older nixpkgs versions only supported overriding `kernel` with an aggregated modules tree.
|
||||||
@@ -1168,7 +1182,10 @@ let
|
|||||||
lib.listToAttrs (map (option: lib.nameValuePair option type.options.${option}) options);
|
lib.listToAttrs (map (option: lib.nameValuePair option type.options.${option}) options);
|
||||||
|
|
||||||
typesSerializerLib = {
|
typesSerializerLib = {
|
||||||
rootMountPoint = "";
|
globals = {
|
||||||
|
rootMountPoint = "";
|
||||||
|
canToggleSystemdInitrd = true;
|
||||||
|
};
|
||||||
options = null;
|
options = null;
|
||||||
config = {
|
config = {
|
||||||
_module = {
|
_module = {
|
||||||
|
|||||||
+18
-4
@@ -3,6 +3,7 @@
|
|||||||
makeTest,
|
makeTest,
|
||||||
eval-config,
|
eval-config,
|
||||||
qemu-common-lib,
|
qemu-common-lib,
|
||||||
|
diskoLib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@@ -120,7 +121,16 @@ let
|
|||||||
# so /dev/vdb becomes /dev/vda etc.
|
# so /dev/vdb becomes /dev/vda etc.
|
||||||
testConfigBooted = testLib.prepareDiskoConfig diskoConfigWithArgs testLib.devices;
|
testConfigBooted = testLib.prepareDiskoConfig diskoConfigWithArgs testLib.devices;
|
||||||
|
|
||||||
tsp-generator = pkgs.callPackage ../. { checked = true; };
|
# direct mode feeds tsp-config straight into NixOS, so probe the options of the nixpkgs under test
|
||||||
|
tsp-generator = pkgs.callPackage ../. {
|
||||||
|
checked = true;
|
||||||
|
canToggleSystemdInitrd =
|
||||||
|
diskoLib.systemdInitrdToggleable
|
||||||
|
(eval-config {
|
||||||
|
modules = [ ];
|
||||||
|
system = pkgs.stdenv.hostPlatform.system;
|
||||||
|
}).options;
|
||||||
|
};
|
||||||
tsp-format = (tsp-generator._cliFormat testConfigInstall) pkgs;
|
tsp-format = (tsp-generator._cliFormat testConfigInstall) pkgs;
|
||||||
tsp-mount = (tsp-generator._cliMount testConfigInstall) pkgs;
|
tsp-mount = (tsp-generator._cliMount testConfigInstall) pkgs;
|
||||||
tsp-unmount = (tsp-generator._cliUnmount testConfigInstall) pkgs;
|
tsp-unmount = (tsp-generator._cliUnmount testConfigInstall) pkgs;
|
||||||
@@ -129,7 +139,11 @@ let
|
|||||||
num-disks = builtins.length (lib.attrNames testConfigBooted.disko.devices.disk);
|
num-disks = builtins.length (lib.attrNames testConfigBooted.disko.devices.disk);
|
||||||
|
|
||||||
installed-system =
|
installed-system =
|
||||||
{ config, ... }:
|
{ config, options, ... }:
|
||||||
|
let
|
||||||
|
# boot.initrd.systemd.enable throws once removed (NixOS 26.11+), where stage 1 is always systemd
|
||||||
|
systemdInitrd = !diskoLib.systemdInitrdToggleable options || config.boot.initrd.systemd.enable;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(lib.optionalAttrs (testMode == "direct") tsp-config)
|
(lib.optionalAttrs (testMode == "direct") tsp-config)
|
||||||
@@ -146,10 +160,10 @@ let
|
|||||||
documentation.enable = false;
|
documentation.enable = false;
|
||||||
hardware.enableAllFirmware = lib.mkForce false;
|
hardware.enableAllFirmware = lib.mkForce false;
|
||||||
# FIXME: we don't have an systemd in stage-1 equialvent for this
|
# FIXME: we don't have an systemd in stage-1 equialvent for this
|
||||||
boot.initrd.preDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
boot.initrd.preDeviceCommands = lib.mkIf (!systemdInitrd) ''
|
||||||
echo -n 'secretsecret' > /tmp/secret.key
|
echo -n 'secretsecret' > /tmp/secret.key
|
||||||
'';
|
'';
|
||||||
boot.initrd.secrets = lib.mkIf config.boot.initrd.systemd.enable {
|
boot.initrd.secrets = lib.mkIf systemdInitrd {
|
||||||
"/tmp/secret.key" = pkgs.writeText "secret.key" "secretsecret";
|
"/tmp/secret.key" = pkgs.writeText "secret.key" "secretsecret";
|
||||||
};
|
};
|
||||||
boot.consoleLogLevel = lib.mkForce 100;
|
boot.consoleLogLevel = lib.mkForce 100;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
lib,
|
lib,
|
||||||
options,
|
options,
|
||||||
parent,
|
parent,
|
||||||
rootMountPoint,
|
globals,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
@@ -226,10 +226,10 @@
|
|||||||
subvolume:
|
subvolume:
|
||||||
lib.optionalAttrs (subvolume.mountpoint != null) {
|
lib.optionalAttrs (subvolume.mountpoint != null) {
|
||||||
${subvolume.mountpoint} = ''
|
${subvolume.mountpoint} = ''
|
||||||
if ! findmnt "${rootMountPoint}${subvolume.mountpoint}" >&2 2>&1; then
|
if ! findmnt "${globals.rootMountPoint}${subvolume.mountpoint}" >&2 2>&1; then
|
||||||
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||||
# necessitating running `mkdir` here.
|
# necessitating running `mkdir` here.
|
||||||
mkdir -p "${rootMountPoint}${subvolume.mountpoint}";
|
mkdir -p "${globals.rootMountPoint}${subvolume.mountpoint}";
|
||||||
${lib.optionalString (config.passwordFile != null) ''
|
${lib.optionalString (config.passwordFile != null) ''
|
||||||
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||||
test -d "/sys/fs/bcachefs/${config.uuid}";
|
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||||
@@ -249,7 +249,7 @@
|
|||||||
)
|
)
|
||||||
}" \
|
}" \
|
||||||
"/dev/disk/by-uuid/${config.uuid}" \
|
"/dev/disk/by-uuid/${config.uuid}" \
|
||||||
"${rootMountPoint}${subvolume.mountpoint}";
|
"${globals.rootMountPoint}${subvolume.mountpoint}";
|
||||||
fi;
|
fi;
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@@ -260,10 +260,10 @@
|
|||||||
subvolumeMounts
|
subvolumeMounts
|
||||||
// lib.optionalAttrs (config.mountpoint != null) {
|
// lib.optionalAttrs (config.mountpoint != null) {
|
||||||
${config.mountpoint} = ''
|
${config.mountpoint} = ''
|
||||||
if ! findmnt "${rootMountPoint}${config.mountpoint}" >&2 2>&1; then
|
if ! findmnt "${globals.rootMountPoint}${config.mountpoint}" >&2 2>&1; then
|
||||||
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||||
# necessitating running `mkdir` here.
|
# necessitating running `mkdir` here.
|
||||||
mkdir -p "${rootMountPoint}${config.mountpoint}";
|
mkdir -p "${globals.rootMountPoint}${config.mountpoint}";
|
||||||
${lib.optionalString (config.passwordFile != null) ''
|
${lib.optionalString (config.passwordFile != null) ''
|
||||||
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||||
test -d "/sys/fs/bcachefs/${config.uuid}";
|
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||||
@@ -273,7 +273,7 @@
|
|||||||
-t bcachefs \
|
-t bcachefs \
|
||||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||||
"/dev/disk/by-uuid/${config.uuid}" \
|
"/dev/disk/by-uuid/${config.uuid}" \
|
||||||
"${rootMountPoint}${config.mountpoint}";
|
"${globals.rootMountPoint}${config.mountpoint}";
|
||||||
fi;
|
fi;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -287,8 +287,8 @@
|
|||||||
_: subvolume:
|
_: subvolume:
|
||||||
lib.optionalAttrs (subvolume.mountpoint != null) {
|
lib.optionalAttrs (subvolume.mountpoint != null) {
|
||||||
${subvolume.mountpoint} = ''
|
${subvolume.mountpoint} = ''
|
||||||
if findmnt "UUID=${config.uuid}" "${rootMountPoint}${subvolume.mountpoint}" >&2 2>&1; then
|
if findmnt "UUID=${config.uuid}" "${globals.rootMountPoint}${subvolume.mountpoint}" >&2 2>&1; then
|
||||||
umount "${rootMountPoint}${subvolume.mountpoint}";
|
umount "${globals.rootMountPoint}${subvolume.mountpoint}";
|
||||||
fi;
|
fi;
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@@ -299,8 +299,8 @@
|
|||||||
subvolumeMounts
|
subvolumeMounts
|
||||||
// lib.optionalAttrs (config.mountpoint != null) {
|
// lib.optionalAttrs (config.mountpoint != null) {
|
||||||
${config.mountpoint} = ''
|
${config.mountpoint} = ''
|
||||||
if findmnt "UUID=${config.uuid}" "${rootMountPoint}${config.mountpoint}" >&2 2>&1; then
|
if findmnt "UUID=${config.uuid}" "${globals.rootMountPoint}${config.mountpoint}" >&2 2>&1; then
|
||||||
umount "${rootMountPoint}${config.mountpoint}";
|
umount "${globals.rootMountPoint}${config.mountpoint}";
|
||||||
fi;
|
fi;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
+9
-9
@@ -3,7 +3,7 @@
|
|||||||
options,
|
options,
|
||||||
diskoLib,
|
diskoLib,
|
||||||
lib,
|
lib,
|
||||||
rootMountPoint,
|
globals,
|
||||||
parent,
|
parent,
|
||||||
device,
|
device,
|
||||||
...
|
...
|
||||||
@@ -197,8 +197,8 @@ in
|
|||||||
(subvol.mountpoint != null)
|
(subvol.mountpoint != null)
|
||||||
{
|
{
|
||||||
${subvol.mountpoint} = ''
|
${subvol.mountpoint} = ''
|
||||||
if ! findmnt "${config.device}" "${rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then
|
if ! findmnt "${config.device}" "${globals.rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then
|
||||||
mount "${config.device}" "${rootMountPoint}${subvol.mountpoint}" \
|
mount "${config.device}" "${globals.rootMountPoint}${subvol.mountpoint}" \
|
||||||
${
|
${
|
||||||
lib.concatMapStringsSep " " (opt: "-o ${opt}") (subvol.mountOptions ++ [ "subvol=${subvol.name}" ])
|
lib.concatMapStringsSep " " (opt: "-o ${opt}") (subvol.mountOptions ++ [ "subvol=${subvol.name}" ])
|
||||||
} \
|
} \
|
||||||
@@ -213,8 +213,8 @@ in
|
|||||||
subvolMounts
|
subvolMounts
|
||||||
// lib.optionalAttrs (config.mountpoint != null) {
|
// lib.optionalAttrs (config.mountpoint != null) {
|
||||||
${config.mountpoint} = ''
|
${config.mountpoint} = ''
|
||||||
if ! findmnt "${config.device}" "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
if ! findmnt "${config.device}" "${globals.rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||||
mount "${config.device}" "${rootMountPoint}${config.mountpoint}" \
|
mount "${config.device}" "${globals.rootMountPoint}${config.mountpoint}" \
|
||||||
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||||
-o X-mount.mkdir
|
-o X-mount.mkdir
|
||||||
fi
|
fi
|
||||||
@@ -230,8 +230,8 @@ in
|
|||||||
_: subvol:
|
_: subvol:
|
||||||
lib.optionalAttrs (subvol.mountpoint != null) {
|
lib.optionalAttrs (subvol.mountpoint != null) {
|
||||||
${subvol.mountpoint} = ''
|
${subvol.mountpoint} = ''
|
||||||
if findmnt "${config.device}" "${rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then
|
if findmnt "${config.device}" "${globals.rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then
|
||||||
umount "${rootMountPoint}${subvol.mountpoint}"
|
umount "${globals.rootMountPoint}${subvol.mountpoint}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@@ -242,8 +242,8 @@ in
|
|||||||
subvolMounts
|
subvolMounts
|
||||||
// lib.optionalAttrs (config.mountpoint != null) {
|
// lib.optionalAttrs (config.mountpoint != null) {
|
||||||
${config.mountpoint} = ''
|
${config.mountpoint} = ''
|
||||||
if findmnt "${config.device}" "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
if findmnt "${config.device}" "${globals.rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||||
umount "${rootMountPoint}${config.mountpoint}"
|
umount "${globals.rootMountPoint}${config.mountpoint}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
options,
|
options,
|
||||||
lib,
|
lib,
|
||||||
diskoLib,
|
diskoLib,
|
||||||
rootMountPoint,
|
globals,
|
||||||
parent,
|
parent,
|
||||||
device,
|
device,
|
||||||
...
|
...
|
||||||
@@ -64,8 +64,8 @@
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = lib.optionalAttrs (config.mountpoint != null) {
|
default = lib.optionalAttrs (config.mountpoint != null) {
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if ! findmnt "${config.device}" "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
if ! findmnt "${config.device}" "${globals.rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
mount "${config.device}" "${rootMountPoint}${config.mountpoint}" \
|
mount "${config.device}" "${globals.rootMountPoint}${config.mountpoint}" \
|
||||||
-t "${config.format}" \
|
-t "${config.format}" \
|
||||||
${lib.concatMapStringsSep " " (opt: "-o ${lib.escapeShellArg opt}") config.mountOptions} \
|
${lib.concatMapStringsSep " " (opt: "-o ${lib.escapeShellArg opt}") config.mountOptions} \
|
||||||
-o X-mount.mkdir
|
-o X-mount.mkdir
|
||||||
@@ -77,8 +77,8 @@
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = lib.optionalAttrs (config.mountpoint != null) {
|
default = lib.optionalAttrs (config.mountpoint != null) {
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if findmnt "${config.device}" "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
if findmnt "${config.device}" "${globals.rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
umount "${rootMountPoint}${config.mountpoint}"
|
umount "${globals.rootMountPoint}${config.mountpoint}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-4
@@ -3,6 +3,7 @@
|
|||||||
options,
|
options,
|
||||||
lib,
|
lib,
|
||||||
diskoLib,
|
diskoLib,
|
||||||
|
globals,
|
||||||
parent,
|
parent,
|
||||||
device,
|
device,
|
||||||
...
|
...
|
||||||
@@ -359,12 +360,13 @@ in
|
|||||||
crypttabExtraOpts = lib.mkIf config.enrollFido2 [ "fido2-device=auto" ];
|
crypttabExtraOpts = lib.mkIf config.enrollFido2 [ "fido2-device=auto" ];
|
||||||
}
|
}
|
||||||
// config.settings;
|
// config.settings;
|
||||||
|
|
||||||
# If FIDO2 is used, systemd stage 1 is absolutely necessary.
|
|
||||||
# Should we turn this into an assertion?
|
|
||||||
boot.initrd.systemd.enable = lib.mkIf config.enrollFido2 true;
|
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
# FIDO2 unlock requires systemd stage 1. NixOS 26.11+ always uses it and has removed the option,
|
||||||
|
# so only define it where it can still be toggled.
|
||||||
|
++ (lib.optional (config.initrdUnlock && config.enrollFido2 && globals.canToggleSystemdInitrd) {
|
||||||
|
boot.initrd.systemd.enable = true;
|
||||||
|
})
|
||||||
++ (lib.optional (config.content != null) config.content._config);
|
++ (lib.optional (config.content != null) config.content._config);
|
||||||
description = "NixOS configuration";
|
description = "NixOS configuration";
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-6
@@ -3,7 +3,7 @@
|
|||||||
config,
|
config,
|
||||||
options,
|
options,
|
||||||
diskoLib,
|
diskoLib,
|
||||||
rootMountPoint,
|
globals,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -60,12 +60,12 @@ in
|
|||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
isBindMount = builtins.elem "bind" config.mountOptions;
|
isBindMount = builtins.elem "bind" config.mountOptions;
|
||||||
device = if isBindMount then "${rootMountPoint}${config.device}" else config.device;
|
device = if isBindMount then "${globals.rootMountPoint}${config.device}" else config.device;
|
||||||
in
|
in
|
||||||
lib.optionalAttrs (config.mountpoint != null) {
|
lib.optionalAttrs (config.mountpoint != null) {
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
if ! findmnt ${config.fsType} "${globals.rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||||
mount -t ${config.fsType} "${device}" "${rootMountPoint}${config.mountpoint}" \
|
mount -t ${config.fsType} "${device}" "${globals.rootMountPoint}${config.mountpoint}" \
|
||||||
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||||
-o X-mount.mkdir
|
-o X-mount.mkdir
|
||||||
fi
|
fi
|
||||||
@@ -76,8 +76,8 @@ in
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = lib.optionalAttrs (config.mountpoint != null) {
|
default = lib.optionalAttrs (config.mountpoint != null) {
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
if findmnt ${config.fsType} "${globals.rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||||
umount "${rootMountPoint}${config.mountpoint}"
|
umount "${globals.rootMountPoint}${config.mountpoint}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
options,
|
options,
|
||||||
lib,
|
lib,
|
||||||
diskoLib,
|
diskoLib,
|
||||||
rootMountPoint,
|
globals,
|
||||||
parent,
|
parent,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
@@ -131,8 +131,8 @@
|
|||||||
(config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off")
|
(config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off")
|
||||||
{
|
{
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if ! findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
if ! findmnt ${config._name} "${globals.rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
mount ${config._name} "${rootMountPoint}${config.mountpoint}" \
|
mount ${config._name} "${globals.rootMountPoint}${config.mountpoint}" \
|
||||||
-o X-mount.mkdir \
|
-o X-mount.mkdir \
|
||||||
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||||
${lib.optionalString ((config.options.mountpoint or "") != "legacy") "-o zfsutil"} \
|
${lib.optionalString ((config.options.mountpoint or "") != "legacy") "-o zfsutil"} \
|
||||||
@@ -157,8 +157,8 @@
|
|||||||
(config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off")
|
(config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off")
|
||||||
{
|
{
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
if findmnt ${config._name} "${globals.rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
umount "${rootMountPoint}${config.mountpoint}"
|
umount "${globals.rootMountPoint}${config.mountpoint}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -3,7 +3,7 @@
|
|||||||
options,
|
options,
|
||||||
lib,
|
lib,
|
||||||
diskoLib,
|
diskoLib,
|
||||||
rootMountPoint,
|
globals,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -364,7 +364,7 @@ in
|
|||||||
fi
|
fi
|
||||||
if [ $continue -eq 1 ]; then
|
if [ $continue -eq 1 ]; then
|
||||||
zpool create -f "${config.name}" \
|
zpool create -f "${config.name}" \
|
||||||
-R ${rootMountPoint} \
|
-R ${globals.rootMountPoint} \
|
||||||
${
|
${
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@@ -407,7 +407,7 @@ in
|
|||||||
{
|
{
|
||||||
dev = ''
|
dev = ''
|
||||||
zpool list "${config.name}" >/dev/null 2>/dev/null ||
|
zpool list "${config.name}" >/dev/null 2>/dev/null ||
|
||||||
zpool import -l -R ${rootMountPoint} "${config.name}"
|
zpool import -l -R ${globals.rootMountPoint} "${config.name}"
|
||||||
|
|
||||||
${lib.concatMapStrings (x: x._mount.dev or "") (lib.attrValues config.datasets)}
|
${lib.concatMapStrings (x: x._mount.dev or "") (lib.attrValues config.datasets)}
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
options,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
extendModules,
|
extendModules,
|
||||||
@@ -270,6 +271,7 @@ in
|
|||||||
makeTest = import "${modulesPath}/../tests/make-test-python.nix";
|
makeTest = import "${modulesPath}/../tests/make-test-python.nix";
|
||||||
eval-config = import "${modulesPath}/../lib/eval-config.nix";
|
eval-config = import "${modulesPath}/../lib/eval-config.nix";
|
||||||
qemu-common = import "${modulesPath}/../lib/qemu-common.nix";
|
qemu-common = import "${modulesPath}/../lib/qemu-common.nix";
|
||||||
|
canToggleSystemdInitrd = diskoLib.systemdInitrdToggleable options;
|
||||||
};
|
};
|
||||||
|
|
||||||
system.build =
|
system.build =
|
||||||
|
|||||||
Reference in new issue
Block a user