mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab58501b23 | ||
|
|
3163b2724c | ||
|
|
bba79f6b5e | ||
|
|
89e458a3bb | ||
|
|
58cd832497 | ||
|
|
09a776702b | ||
|
|
4be2aadf13 | ||
|
|
ca47da60e5 | ||
|
|
78d685c123 | ||
|
|
a6a3179ddf |
No files matched your search
+7
-1
@@ -244,4 +244,10 @@ main() {
|
|||||||
nixos-install --no-channel-copy --no-root-password --system "$nixos_system" --root "$mountPoint"
|
nixos-install --no-channel-copy --no-root-password --system "$nixos_system" --root "$mountPoint"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
if main "$@"; then
|
||||||
|
echo "disko-install succeeded"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "disko-install failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
vdb = {
|
||||||
|
device = "/dev/disk/by-id/some-disk-id";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
ESP = {
|
||||||
|
type = "EF00";
|
||||||
|
size = "100M";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"name with spaces" = {
|
||||||
|
size = "100M";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/name with spaces";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"name^with\\some@special#chars" = {
|
||||||
|
size = "100M";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/name^with\\some@special#chars";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
vdb = {
|
||||||
|
device = "/dev/sda";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "table";
|
||||||
|
format = "gpt";
|
||||||
|
partitions = [
|
||||||
|
{
|
||||||
|
name = "ESP";
|
||||||
|
start = "1MiB";
|
||||||
|
end = "100MiB";
|
||||||
|
bootable = true;
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "name with spaces";
|
||||||
|
start = "100MiB";
|
||||||
|
end = "200MiB";
|
||||||
|
bootable = true;
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/name_with_spaces";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "root";
|
||||||
|
start = "200MiB";
|
||||||
|
end = "100%";
|
||||||
|
part-type = "primary";
|
||||||
|
bootable = true;
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
type = "lvm_vg";
|
type = "lvm_vg";
|
||||||
lvs = {
|
lvs = {
|
||||||
root = {
|
root = {
|
||||||
size = "100M";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "ext4";
|
format = "ext4";
|
||||||
|
|||||||
+54
-14
@@ -82,6 +82,37 @@ let
|
|||||||
${dev} seems not to be a supported disk format. Please add this to disko in https://github.com/nix-community/disko/blob/master/lib/default.nix
|
${dev} seems not to be a supported disk format. Please add this to disko in https://github.com/nix-community/disko/blob/master/lib/default.nix
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
/* Escape a string as required to be used in udev symlinks
|
||||||
|
|
||||||
|
The allowed characters are "0-9A-Za-z#+-.:=@_/", valid UTF-8 character sequences, and "\x00" hex encoding.
|
||||||
|
Everything else is escaped as "\xXX" where XX is the hex value of the character.
|
||||||
|
|
||||||
|
The source of truth for the list of allowed characters is the udev documentation:
|
||||||
|
https://www.freedesktop.org/software/systemd/man/latest/udev.html#SYMLINK1
|
||||||
|
|
||||||
|
This function is implemented as a best effort. It is not guaranteed to be 100% in line
|
||||||
|
with the udev implementation, and we hope that you're not crazy enough to try to break it.
|
||||||
|
|
||||||
|
hexEscapeUdevSymlink :: str -> str
|
||||||
|
|
||||||
|
Example:
|
||||||
|
hexEscapeUdevSymlink "Boot data partition"
|
||||||
|
=> "Boot\x20data\x20partition"
|
||||||
|
|
||||||
|
hexEscapeUdevSymlink "Even(crazier)par&titi^onName"
|
||||||
|
=> "Even\x28crazier\x29par\x26titi\x5EonName"
|
||||||
|
|
||||||
|
hexEscapeUdevSymlink "all0these@char#acters+_are-allow.ed"
|
||||||
|
=> "all0these@char#acters+_are-allow.ed"
|
||||||
|
*/
|
||||||
|
hexEscapeUdevSymlink =
|
||||||
|
let
|
||||||
|
allowedChars = "[0-9A-Za-z#+-.:=@_/]";
|
||||||
|
charToHex = c: lib.toHexString (lib.strings.charToInt c);
|
||||||
|
in
|
||||||
|
lib.stringAsChars
|
||||||
|
(c: if lib.match allowedChars c != null || c == "" then c else "\\x" + charToHex c);
|
||||||
|
|
||||||
/* get the index an item in a list
|
/* get the index an item in a list
|
||||||
|
|
||||||
indexOf :: (a -> bool) -> [a] -> int -> int
|
indexOf :: (a -> bool) -> [a] -> int -> int
|
||||||
@@ -92,7 +123,7 @@ let
|
|||||||
|
|
||||||
indexOf (x: x == "x") [ 1 2 3 ] 0
|
indexOf (x: x == "x") [ 1 2 3 ] 0
|
||||||
=> 0
|
=> 0
|
||||||
*/
|
*/
|
||||||
indexOf = f: list: fallback:
|
indexOf = f: list: fallback:
|
||||||
let
|
let
|
||||||
iter = index: list:
|
iter = index: list:
|
||||||
@@ -304,6 +335,14 @@ let
|
|||||||
*/
|
*/
|
||||||
packages = toplevel: toplevel._packages;
|
packages = toplevel: toplevel._packages;
|
||||||
|
|
||||||
|
/* Checks whether nixpkgs is recent enough for vmTools to support the customQemu argument.
|
||||||
|
|
||||||
|
Returns false, which is technically incorrect, for a few commits on 2024-07-08, but we can't be more accurate.
|
||||||
|
|
||||||
|
vmToolsSupportsCustomQemu :: pkgs -> bool
|
||||||
|
*/
|
||||||
|
vmToolsSupportsCustomQemu = pkgs: lib.versionAtLeast pkgs.lib.version "24.11.20240709";
|
||||||
|
|
||||||
optionTypes = rec {
|
optionTypes = rec {
|
||||||
filename = lib.mkOptionType {
|
filename = lib.mkOptionType {
|
||||||
name = "filename";
|
name = "filename";
|
||||||
@@ -391,21 +430,22 @@ let
|
|||||||
default = { pkgs, checked ? false }:
|
default = { pkgs, checked ? false }:
|
||||||
let
|
let
|
||||||
throwIfNoDisksDetected = _: v: if devices.disk == { } then throw "No disks defined, did you forget to import your disko config?" else v;
|
throwIfNoDisksDetected = _: v: if devices.disk == { } then throw "No disks defined, did you forget to import your disko config?" else v;
|
||||||
|
destroyDependencies = with pkgs; [
|
||||||
|
util-linux
|
||||||
|
e2fsprogs
|
||||||
|
mdadm
|
||||||
|
zfs
|
||||||
|
lvm2
|
||||||
|
bash
|
||||||
|
jq
|
||||||
|
gnused
|
||||||
|
gawk
|
||||||
|
coreutils-full
|
||||||
|
];
|
||||||
in
|
in
|
||||||
lib.mapAttrs throwIfNoDisksDetected {
|
lib.mapAttrs throwIfNoDisksDetected {
|
||||||
destroyScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-destroy" ''
|
destroyScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-destroy" ''
|
||||||
export PATH=${lib.makeBinPath (with pkgs; [
|
export PATH=${lib.makeBinPath destroyDependencies}:$PATH
|
||||||
util-linux
|
|
||||||
e2fsprogs
|
|
||||||
mdadm
|
|
||||||
zfs
|
|
||||||
lvm2
|
|
||||||
bash
|
|
||||||
jq
|
|
||||||
gnused
|
|
||||||
gawk
|
|
||||||
coreutils-full
|
|
||||||
])}:$PATH
|
|
||||||
${cfg.config._destroy}
|
${cfg.config._destroy}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@@ -420,7 +460,7 @@ let
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
diskoScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko" ''
|
diskoScript = (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko" ''
|
||||||
export PATH=${lib.makeBinPath ((cfg.config._packages pkgs) ++ [ pkgs.bash ])}:$PATH
|
export PATH=${lib.makeBinPath ((cfg.config._packages pkgs) ++ [ pkgs.bash ] ++ destroyDependencies)}:$PATH
|
||||||
${cfg.config._disko}
|
${cfg.config._disko}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ let
|
|||||||
disks = lib.attrValues cfg_.disko.devices.disk;
|
disks = lib.attrValues cfg_.disko.devices.disk;
|
||||||
rootDisk = {
|
rootDisk = {
|
||||||
name = "root";
|
name = "root";
|
||||||
file = ''"$tmp"/${(builtins.head disks).name}.qcow2'';
|
file = ''"$tmp"/${lib.escapeShellArg (builtins.head disks).name}.qcow2'';
|
||||||
driveExtraOpts.cache = "writeback";
|
driveExtraOpts.cache = "writeback";
|
||||||
driveExtraOpts.werror = "report";
|
driveExtraOpts.werror = "report";
|
||||||
deviceExtraOpts.bootindex = "1";
|
deviceExtraOpts.bootindex = "1";
|
||||||
@@ -29,7 +29,7 @@ let
|
|||||||
otherDisks = map
|
otherDisks = map
|
||||||
(disk: {
|
(disk: {
|
||||||
name = disk.name;
|
name = disk.name;
|
||||||
file = ''"$tmp"/${disk.name}.qcow2'';
|
file = ''"$tmp"/${lib.escapeShellArg disk.name}.qcow2'';
|
||||||
driveExtraOpts.werror = "report";
|
driveExtraOpts.werror = "report";
|
||||||
})
|
})
|
||||||
(builtins.tail disks);
|
(builtins.tail disks);
|
||||||
@@ -72,8 +72,8 @@ in
|
|||||||
trap 'rm -rf "$tmp"' EXIT
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
${lib.concatMapStringsSep "\n" (disk: ''
|
${lib.concatMapStringsSep "\n" (disk: ''
|
||||||
${hostPkgs.qemu}/bin/qemu-img create -f qcow2 \
|
${hostPkgs.qemu}/bin/qemu-img create -f qcow2 \
|
||||||
-b ${config.system.build.diskoImages}/${disk.name}.qcow2 \
|
-b ${config.system.build.diskoImages}/${lib.escapeShellArg disk.name}.qcow2 \
|
||||||
-F qcow2 "$tmp"/${disk.name}.qcow2
|
-F qcow2 "$tmp"/${lib.escapeShellArg disk.name}.qcow2
|
||||||
'') disks}
|
'') disks}
|
||||||
set +f
|
set +f
|
||||||
${config.system.build.vm}/bin/run-*-vm
|
${config.system.build.vm}/bin/run-*-vm
|
||||||
|
|||||||
+13
-9
@@ -12,15 +12,19 @@ let
|
|||||||
checked = diskoCfg.checkScripts;
|
checked = diskoCfg.checkScripts;
|
||||||
|
|
||||||
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
||||||
vmTools = pkgs.vmTools.override {
|
vmTools = pkgs.vmTools.override
|
||||||
rootModules = [ "9p" "9pnet_virtio" "virtio_pci" "virtio_blk" ]
|
{
|
||||||
++ (lib.optional configSupportsZfs "zfs")
|
rootModules = [ "9p" "9pnet_virtio" "virtio_pci" "virtio_blk" ]
|
||||||
++ cfg.extraRootModules;
|
++ (lib.optional configSupportsZfs "zfs")
|
||||||
customQemu = cfg.qemu;
|
++ cfg.extraRootModules;
|
||||||
kernel = pkgs.aggregateModules
|
kernel = pkgs.aggregateModules
|
||||||
(with cfg.kernelPackages; [ kernel ]
|
(with cfg.kernelPackages; [ kernel ]
|
||||||
++ lib.optional (lib.elem "zfs" cfg.extraRootModules || configSupportsZfs) zfs);
|
++ lib.optional (lib.elem "zfs" cfg.extraRootModules || configSupportsZfs) zfs);
|
||||||
};
|
}
|
||||||
|
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu pkgs)
|
||||||
|
{
|
||||||
|
customQemu = cfg.qemu;
|
||||||
|
};
|
||||||
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
|
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
|
||||||
systemToInstall = extendModules {
|
systemToInstall = extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
|
|||||||
+6
-6
@@ -135,7 +135,7 @@ in
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
# create the filesystem only if the device seems empty
|
# create the filesystem only if the device seems empty
|
||||||
if ! (blkid '${config.device}' -o export | grep -q '^TYPE='); then
|
if ! (blkid "${config.device}" -o export | grep -q '^TYPE='); then
|
||||||
mkfs.btrfs "${config.device}" ${toString config.extraArgs}
|
mkfs.btrfs "${config.device}" ${toString config.extraArgs}
|
||||||
fi
|
fi
|
||||||
${lib.optionalString (config.swap != {} || config.subvolumes != {}) ''
|
${lib.optionalString (config.swap != {} || config.subvolumes != {}) ''
|
||||||
@@ -151,7 +151,7 @@ in
|
|||||||
${lib.concatMapStrings (subvol: ''
|
${lib.concatMapStrings (subvol: ''
|
||||||
(
|
(
|
||||||
MNTPOINT=$(mktemp -d)
|
MNTPOINT=$(mktemp -d)
|
||||||
mount ${config.device} "$MNTPOINT" -o subvol=/
|
mount "${config.device}" "$MNTPOINT" -o subvol=/
|
||||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
||||||
SUBVOL_ABS_PATH="$MNTPOINT/${subvol.name}"
|
SUBVOL_ABS_PATH="$MNTPOINT/${subvol.name}"
|
||||||
mkdir -p "$(dirname "$SUBVOL_ABS_PATH")"
|
mkdir -p "$(dirname "$SUBVOL_ABS_PATH")"
|
||||||
@@ -177,8 +177,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}" "${rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then
|
||||||
mount ${config.device} "${rootMountPoint}${subvol.mountpoint}" \
|
mount "${config.device}" "${rootMountPoint}${subvol.mountpoint}" \
|
||||||
${lib.concatMapStringsSep " " (opt: "-o ${opt}") (subvol.mountOptions ++ [ "subvol=${subvol.name}" ])} \
|
${lib.concatMapStringsSep " " (opt: "-o ${opt}") (subvol.mountOptions ++ [ "subvol=${subvol.name}" ])} \
|
||||||
-o X-mount.mkdir
|
-o X-mount.mkdir
|
||||||
fi
|
fi
|
||||||
@@ -190,8 +190,8 @@ in
|
|||||||
{
|
{
|
||||||
fs = subvolMounts // lib.optionalAttrs (config.mountpoint != null) {
|
fs = subvolMounts // 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}" "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||||
mount ${config.device} "${rootMountPoint}${config.mountpoint}" \
|
mount "${config.device}" "${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
|
||||||
|
|||||||
@@ -44,10 +44,10 @@
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! (blkid '${config.device}' | grep -q 'TYPE='); then
|
if ! (blkid "${config.device}" | grep -q 'TYPE='); then
|
||||||
mkfs.${config.format} \
|
mkfs.${config.format} \
|
||||||
${lib.escapeShellArgs config.extraArgs} \
|
${lib.escapeShellArgs config.extraArgs} \
|
||||||
${config.device}
|
"${config.device}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -55,8 +55,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}" "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
mount ${config.device} "${rootMountPoint}${config.mountpoint}" \
|
mount "${config.device}" "${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
|
||||||
|
|||||||
+10
-10
@@ -41,7 +41,7 @@ in
|
|||||||
# workaround because mdadm partlabel do not appear in /dev/disk/by-partlabel
|
# workaround because mdadm partlabel do not appear in /dev/disk/by-partlabel
|
||||||
"/dev/disk/by-id/md-name-any:${config._parent.name}-part${toString partition.config._index}"
|
"/dev/disk/by-id/md-name-any:${config._parent.name}-part${toString partition.config._index}"
|
||||||
else
|
else
|
||||||
"/dev/disk/by-partlabel/${partition.config.label}";
|
"/dev/disk/by-partlabel/${diskoLib.hexEscapeUdevSymlink partition.config.label}";
|
||||||
description = "Device to use for the partition";
|
description = "Device to use for the partition";
|
||||||
};
|
};
|
||||||
priority = lib.mkOption {
|
priority = lib.mkOption {
|
||||||
@@ -127,12 +127,12 @@ in
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
${lib.optionalString (hp.config.mbrPartitionType != null) ''
|
${lib.optionalString (hp.config.mbrPartitionType != null) ''
|
||||||
sfdisk --label-nested dos --part-type ${parent.device} ${(toString partition.config._index)} ${hp.config.mbrPartitionType}
|
sfdisk --label-nested dos --part-type "${parent.device}" ${(toString partition.config._index)} ${hp.config.mbrPartitionType}
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle
|
||||||
''}
|
''}
|
||||||
${lib.optionalString hp.config.mbrBootableFlag ''
|
${lib.optionalString hp.config.mbrBootableFlag ''
|
||||||
sfdisk --label-nested dos --activate ${parent.device} ${(toString partition.config._index)}
|
sfdisk --label-nested dos --activate "${parent.device}" ${(toString partition.config._index)}
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -175,23 +175,23 @@ in
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! blkid "${config.device}" >&2; then
|
if ! blkid "${config.device}" >&2; then
|
||||||
sgdisk --clear ${config.device}
|
sgdisk --clear "${config.device}"
|
||||||
fi
|
fi
|
||||||
${lib.concatStrings (map (partition: ''
|
${lib.concatStrings (map (partition: ''
|
||||||
# try to create the partition, if it fails, try to change the type and name
|
# try to create the partition, if it fails, try to change the type and name
|
||||||
if ! sgdisk \
|
if ! sgdisk \
|
||||||
--align-end ${lib.optionalString (partition.alignment != 0) ''--set-alignment=${builtins.toString partition.alignment}''} \
|
--align-end ${lib.optionalString (partition.alignment != 0) ''--set-alignment=${builtins.toString partition.alignment}''} \
|
||||||
--new=${toString partition._index}:${partition.start}:${partition.end} \
|
--new=${toString partition._index}:${partition.start}:${partition.end} \
|
||||||
--change-name=${toString partition._index}:${partition.label} \
|
--change-name="${toString partition._index}:${partition.label}" \
|
||||||
--typecode=${toString partition._index}:${partition.type} \
|
--typecode=${toString partition._index}:${partition.type} \
|
||||||
${config.device}
|
"${config.device}"
|
||||||
then sgdisk \
|
then sgdisk \
|
||||||
--change-name=${toString partition._index}:${partition.label} \
|
--change-name="${toString partition._index}:${partition.label}" \
|
||||||
--typecode=${toString partition._index}:${partition.type} \
|
--typecode=${toString partition._index}:${partition.type} \
|
||||||
${config.device}
|
"${config.device}"
|
||||||
fi
|
fi
|
||||||
# ensure /dev/disk/by-path/..-partN exists before continuing
|
# ensure /dev/disk/by-path/..-partN exists before continuing
|
||||||
partprobe ${config.device} || : # sometimes partprobe fails, but the partitions are still up2date
|
partprobe "${config.device}" || : # sometimes partprobe fails, but the partitions are still up2date
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle
|
||||||
'') sortedPartitions)}
|
'') sortedPartitions)}
|
||||||
@@ -203,7 +203,7 @@ in
|
|||||||
+ (
|
+ (
|
||||||
lib.optionalString (!config.efiGptPartitionFirst) ":EE "
|
lib.optionalString (!config.efiGptPartitionFirst) ":EE "
|
||||||
)
|
)
|
||||||
+ parent.device)
|
+ ''"${parent.device}"'')
|
||||||
}
|
}
|
||||||
${lib.concatMapStrings (p:
|
${lib.concatMapStrings (p:
|
||||||
p.hybrid._create
|
p.hybrid._create
|
||||||
|
|||||||
+4
-4
@@ -21,7 +21,7 @@ let
|
|||||||
${lib.optionalString (lib.hasAttr "keyFileOffset" config.settings) "--keyfile-offset ${builtins.toString config.settings.keyFileOffset}"} \
|
${lib.optionalString (lib.hasAttr "keyFileOffset" config.settings) "--keyfile-offset ${builtins.toString config.settings.keyFileOffset}"} \
|
||||||
'';
|
'';
|
||||||
cryptsetupOpen = ''
|
cryptsetupOpen = ''
|
||||||
cryptsetup open ${config.device} ${config.name} \
|
cryptsetup open "${config.device}" "${config.name}" \
|
||||||
${lib.optionalString (config.settings.allowDiscards or false) "--allow-discards"} \
|
${lib.optionalString (config.settings.allowDiscards or false) "--allow-discards"} \
|
||||||
${lib.optionalString (config.settings.bypassWorkqueues or false) "--perf-no_read_workqueue --perf-no_write_workqueue"} \
|
${lib.optionalString (config.settings.bypassWorkqueues or false) "--perf-no_read_workqueue --perf-no_write_workqueue"} \
|
||||||
${toString config.extraOpenArgs} \
|
${toString config.extraOpenArgs} \
|
||||||
@@ -132,10 +132,10 @@ in
|
|||||||
echo "Passwords did not match, please try again."
|
echo "Passwords did not match, please try again."
|
||||||
done
|
done
|
||||||
''}
|
''}
|
||||||
cryptsetup -q luksFormat ${config.device} ${toString config.extraFormatArgs} ${keyFileArgs}
|
cryptsetup -q luksFormat "${config.device}" ${toString config.extraFormatArgs} ${keyFileArgs}
|
||||||
${cryptsetupOpen} --persistent
|
${cryptsetupOpen} --persistent
|
||||||
${toString (lib.forEach config.additionalKeyFiles (keyFile: ''
|
${toString (lib.forEach config.additionalKeyFiles (keyFile: ''
|
||||||
cryptsetup luksAddKey ${config.device} ${keyFile} ${keyFileArgs}
|
cryptsetup luksAddKey "${config.device}" ${keyFile} ${keyFileArgs}
|
||||||
''))}
|
''))}
|
||||||
fi
|
fi
|
||||||
${lib.optionalString (config.content != null) config.content._create}
|
${lib.optionalString (config.content != null) config.content._create}
|
||||||
@@ -149,7 +149,7 @@ in
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
dev = ''
|
dev = ''
|
||||||
if ! cryptsetup status ${config.name} >/dev/null 2>/dev/null; then
|
if ! cryptsetup status "${config.name}" >/dev/null 2>/dev/null; then
|
||||||
${lib.optionalString config.askPassword ''
|
${lib.optionalString config.askPassword ''
|
||||||
if [ -z ''${IN_DISKO_TEST+x} ]; then
|
if [ -z ''${IN_DISKO_TEST+x} ]; then
|
||||||
set +x
|
set +x
|
||||||
|
|||||||
@@ -31,10 +31,10 @@
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! (blkid '${config.device}' | grep -q 'TYPE='); then
|
if ! (blkid "${config.device}" | grep -q 'TYPE='); then
|
||||||
pvcreate ${config.device}
|
pvcreate "${config.device}"
|
||||||
fi
|
fi
|
||||||
echo "${config.device}" >>"$disko_devices_dir"/lvm_${config.vg}
|
echo "${config.device}" >>"$disko_devices_dir"/lvm_${lib.escapeShellArg config.vg}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|||||||
@@ -84,23 +84,23 @@ in
|
|||||||
in
|
in
|
||||||
''
|
''
|
||||||
${lib.concatMapStringsSep "\n" (k: ''modprobe "${k}"'') kernelModules}
|
${lib.concatMapStringsSep "\n" (k: ''modprobe "${k}"'') kernelModules}
|
||||||
readarray -t lvm_devices < <(cat "$disko_devices_dir"/lvm_${config.name})
|
readarray -t lvm_devices < <(cat "$disko_devices_dir"/lvm_${lib.escapeShellArg config.name})
|
||||||
if ! vgdisplay "${config.name}" >/dev/null; then
|
if ! vgdisplay "${config.name}" >/dev/null; then
|
||||||
vgcreate ${config.name} \
|
vgcreate "${config.name}" \
|
||||||
"''${lvm_devices[@]}"
|
"''${lvm_devices[@]}"
|
||||||
fi
|
fi
|
||||||
${lib.concatMapStrings (lv: ''
|
${lib.concatMapStrings (lv: ''
|
||||||
if ! lvdisplay '${config.name}/${lv.name}'; then
|
if ! lvdisplay "${config.name}/${lv.name}"; then
|
||||||
lvcreate \
|
lvcreate \
|
||||||
--yes \
|
--yes \
|
||||||
${if (lv.lvm_type == "thinlv") then "-V"
|
${if (lv.lvm_type == "thinlv") then "-V"
|
||||||
else if lib.hasInfix "%" lv.size then "-l" else "-L"} \
|
else if lib.hasInfix "%" lv.size then "-l" else "-L"} \
|
||||||
${lv.size} \
|
${if lib.hasSuffix "%" lv.size then "${lv.size}FREE" else lv.size} \
|
||||||
-n ${lv.name} \
|
-n "${lv.name}" \
|
||||||
${lib.optionalString (lv.lvm_type == "thinlv") "--thinpool=${lv.pool}"} \
|
${lib.optionalString (lv.lvm_type == "thinlv") "--thinpool=${lv.pool}"} \
|
||||||
${lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "--type=${lv.lvm_type}"} \
|
${lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "--type=${lv.lvm_type}"} \
|
||||||
${toString lv.extraArgs} \
|
${toString lv.extraArgs} \
|
||||||
${config.name}
|
"${config.name}"
|
||||||
fi
|
fi
|
||||||
'') sortedLvs}
|
'') sortedLvs}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -34,20 +34,20 @@
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! test -e /dev/md/${config.name}; then
|
if ! test -e "/dev/md/${config.name}"; then
|
||||||
readarray -t disk_devices < <(cat "$disko_devices_dir"/raid_${config.name})
|
readarray -t disk_devices < <(cat "$disko_devices_dir"/raid_${lib.escapeShellArg config.name})
|
||||||
echo 'y' | mdadm --create /dev/md/${config.name} \
|
echo 'y' | mdadm --create "/dev/md/${config.name}" \
|
||||||
--level=${toString config.level} \
|
--level=${toString config.level} \
|
||||||
--raid-devices="$(wc -l "$disko_devices_dir"/raid_${config.name} | cut -f 1 -d " ")" \
|
--raid-devices="$(wc -l "$disko_devices_dir"/raid_${lib.escapeShellArg config.name} | cut -f 1 -d " ")" \
|
||||||
--metadata=${config.metadata} \
|
--metadata=${config.metadata} \
|
||||||
--force \
|
--force \
|
||||||
--homehost=any \
|
--homehost=any \
|
||||||
"''${disk_devices[@]}"
|
"''${disk_devices[@]}"
|
||||||
partprobe /dev/md/${config.name}
|
partprobe "/dev/md/${config.name}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle
|
||||||
# for some reason mdadm devices spawn with an existing partition table, so we need to wipe it
|
# for some reason mdadm devices spawn with an existing partition table, so we need to wipe it
|
||||||
sgdisk --zap-all /dev/md/${config.name}
|
sgdisk --zap-all "/dev/md/${config.name}"
|
||||||
fi
|
fi
|
||||||
${lib.optionalString (config.content != null) config.content._create}
|
${lib.optionalString (config.content != null) config.content._create}
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
echo "${config.device}" >>"$disko_devices_dir"/raid_${config.name}
|
echo "${config.device}" >>"$disko_devices_dir"/raid_${lib.escapeShellArg config.name}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@
|
|||||||
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} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||||
mount -t ${config.fsType} ${config.device} "${rootMountPoint}${config.mountpoint}" \
|
mount -t ${config.fsType} "${config.device}" "${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
|
||||||
|
|||||||
+3
-3
@@ -71,7 +71,7 @@
|
|||||||
if ! blkid "${config.device}" -o export | grep -q '^TYPE='; then
|
if ! blkid "${config.device}" -o export | grep -q '^TYPE='; then
|
||||||
mkswap \
|
mkswap \
|
||||||
${toString config.extraArgs} \
|
${toString config.extraArgs} \
|
||||||
${config.device}
|
"${config.device}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
# TODO: we don't support encrypted swap yet
|
# TODO: we don't support encrypted swap yet
|
||||||
default = lib.optionalAttrs (!config.randomEncryption) {
|
default = lib.optionalAttrs (!config.randomEncryption) {
|
||||||
fs.${config.device} = ''
|
fs.${config.device} = ''
|
||||||
if ! swapon --show | grep -q "^$(readlink -f ${config.device}) "; then
|
if ! swapon --show | grep -q "^$(readlink -f "${config.device}") "; then
|
||||||
swapon ${
|
swapon ${
|
||||||
lib.optionalString (config.discardPolicy != null)
|
lib.optionalString (config.discardPolicy != null)
|
||||||
"--discard${lib.optionalString (config.discardPolicy != "both")
|
"--discard${lib.optionalString (config.discardPolicy != "both")
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
"--priority=${toString config.priority}"
|
"--priority=${toString config.priority}"
|
||||||
} \
|
} \
|
||||||
--options=${lib.concatStringsSep "," config.mountOptions} \
|
--options=${lib.concatStringsSep "," config.mountOptions} \
|
||||||
${config.device}
|
"${config.device}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-7
@@ -91,26 +91,26 @@
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! blkid "${config.device}" >/dev/null; then
|
if ! blkid "${config.device}" >/dev/null; then
|
||||||
parted -s ${config.device} -- mklabel ${config.format}
|
parted -s "${config.device}" -- mklabel ${config.format}
|
||||||
${lib.concatStrings (map (partition: ''
|
${lib.concatStrings (map (partition: ''
|
||||||
${lib.optionalString (config.format == "gpt") ''
|
${lib.optionalString (config.format == "gpt") ''
|
||||||
parted -s ${config.device} -- mkpart ${partition.name} ${diskoLib.maybeStr partition.fs-type} ${partition.start} ${partition.end}
|
parted -s "${config.device}" -- mkpart "${diskoLib.hexEscapeUdevSymlink partition.name}" ${diskoLib.maybeStr partition.fs-type} ${partition.start} ${partition.end}
|
||||||
''}
|
''}
|
||||||
${lib.optionalString (config.format == "msdos") ''
|
${lib.optionalString (config.format == "msdos") ''
|
||||||
parted -s ${config.device} -- mkpart ${partition.part-type} ${diskoLib.maybeStr partition.fs-type} ${partition.start} ${partition.end}
|
parted -s "${config.device}" -- mkpart ${partition.part-type} ${diskoLib.maybeStr partition.fs-type} ${partition.start} ${partition.end}
|
||||||
''}
|
''}
|
||||||
# ensure /dev/disk/by-path/..-partN exists before continuing
|
# ensure /dev/disk/by-path/..-partN exists before continuing
|
||||||
partprobe ${config.device}
|
partprobe "${config.device}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle
|
||||||
${lib.optionalString partition.bootable ''
|
${lib.optionalString partition.bootable ''
|
||||||
parted -s ${config.device} -- set ${toString partition._index} boot on
|
parted -s "${config.device}" -- set ${toString partition._index} boot on
|
||||||
''}
|
''}
|
||||||
${lib.concatMapStringsSep "" (flag: ''
|
${lib.concatMapStringsSep "" (flag: ''
|
||||||
parted -s ${config.device} -- set ${toString partition._index} ${flag} on
|
parted -s "${config.device}" -- set ${toString partition._index} ${flag} on
|
||||||
'') partition.flags}
|
'') partition.flags}
|
||||||
# ensure further operations can detect new partitions
|
# ensure further operations can detect new partitions
|
||||||
partprobe ${config.device}
|
partprobe "${config.device}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle
|
||||||
'') config.partitions)}
|
'') config.partitions)}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
echo "${config.device}" >>"$disko_devices_dir"/zfs_${config.pool}
|
echo "${config.device}" >>"$disko_devices_dir"/zfs_${lib.escapeShellArg config.pool}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|||||||
@@ -47,12 +47,12 @@
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! zfs get type ${config._parent.name}/${config.name} >/dev/null 2>&1; then
|
if ! zfs get type "${config._parent.name}/${config.name}" >/dev/null 2>&1; then
|
||||||
zfs create ${config._parent.name}/${config.name} \
|
zfs create "${config._parent.name}/${config.name}" \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
-V ${config.size}
|
-V ${config.size}
|
||||||
zvol_wait
|
zvol_wait
|
||||||
partprobe /dev/zvol/${config._parent.name}/${config.name}
|
partprobe "/dev/zvol/${config._parent.name}/${config.name}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle
|
||||||
fi
|
fi
|
||||||
|
|||||||
+8
-8
@@ -79,7 +79,7 @@ in
|
|||||||
};
|
};
|
||||||
cache = lib.mkOption {
|
cache = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
A dedicated zfs cache device (L2ARC). See
|
A dedicated zfs cache device (L2ARC). See
|
||||||
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Cache_Devices
|
https://openzfs.github.io/openzfs-docs/man/master/7/zpoolconcepts.7.html#Cache_Devices
|
||||||
@@ -146,14 +146,14 @@ in
|
|||||||
topology = lib.optionalAttrs hasTopology config.mode.topology;
|
topology = lib.optionalAttrs hasTopology config.mode.topology;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name})
|
readarray -t zfs_devices < <(cat "$disko_devices_dir/zfs_${config.name}")
|
||||||
if [ ''${#zfs_devices[@]} -eq 0 ]; then
|
if [ ''${#zfs_devices[@]} -eq 0 ]; then
|
||||||
echo "no devices found for zpool ${config.name}. Did you misspell the pool name?" >&2
|
echo "no devices found for zpool ${config.name}. Did you misspell the pool name?" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Try importing the pool without mounting anything if it exists.
|
# Try importing the pool without mounting anything if it exists.
|
||||||
# This allows us to set mounpoints.
|
# This allows us to set mounpoints.
|
||||||
if zpool import -N -f '${config.name}' || zpool list '${config.name}'; then
|
if zpool import -N -f "${config.name}" || zpool list "${config.name}"; then
|
||||||
echo "not creating zpool ${config.name} as a pool with that name already exists" >&2
|
echo "not creating zpool ${config.name} as a pool with that name already exists" >&2
|
||||||
else
|
else
|
||||||
continue=1
|
continue=1
|
||||||
@@ -206,13 +206,13 @@ in
|
|||||||
fi
|
fi
|
||||||
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 ${rootMountPoint} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
||||||
''${topology:+ $topology}
|
''${topology:+ $topology}
|
||||||
if [[ $(zfs get -H mounted ${config.name} | cut -f3) == "yes" ]]; then
|
if [[ $(zfs get -H mounted "${config.name}" | cut -f3) == "yes" ]]; then
|
||||||
zfs unmount ${config.name}
|
zfs unmount "${config.name}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -227,8 +227,8 @@ in
|
|||||||
in
|
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 ${rootMountPoint} "${config.name}"
|
||||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
|
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
|
||||||
'';
|
'';
|
||||||
fs = datasetMounts.fs or { };
|
fs = datasetMounts.fs or { };
|
||||||
|
|||||||
+17
-3
@@ -194,6 +194,17 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = config.disko.imageBuilder.qemu != null -> diskoLib.vmToolsSupportsCustomQemu pkgs;
|
||||||
|
message = ''
|
||||||
|
You have set config.disko.imageBuild.qemu, but vmTools in your nixpkgs version "${lib.version}"
|
||||||
|
does not support overriding the qemu package with the customQemu option yet.
|
||||||
|
Please upgrade nixpkgs so that `lib.version` is at least "24.11.20240709".
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
_module.args.diskoLib = import ./lib {
|
_module.args.diskoLib = import ./lib {
|
||||||
inherit lib;
|
inherit lib;
|
||||||
rootMountPoint = config.disko.rootMountPoint;
|
rootMountPoint = config.disko.rootMountPoint;
|
||||||
@@ -226,8 +237,11 @@ in
|
|||||||
|
|
||||||
# we need to specify the keys here, so we don't get an infinite recursion error
|
# we need to specify the keys here, so we don't get an infinite recursion error
|
||||||
# Remember to add config keys here if they are added to types
|
# Remember to add config keys here if they are added to types
|
||||||
fileSystems = lib.mkIf cfg.enableConfig cfg.devices._config.fileSystems or { };
|
fileSystems = lib.mkIf
|
||||||
boot = lib.mkIf cfg.enableConfig cfg.devices._config.boot or { };
|
cfg.enableConfig cfg.devices._config.fileSystems or { };
|
||||||
swapDevices = lib.mkIf cfg.enableConfig cfg.devices._config.swapDevices or [ ];
|
boot = lib.mkIf
|
||||||
|
cfg.enableConfig cfg.devices._config.boot or { };
|
||||||
|
swapDevices = lib.mkIf
|
||||||
|
cfg.enableConfig cfg.devices._config.swapDevices or [ ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { }
|
||||||
|
, diskoLib ? pkgs.callPackage ../lib { }
|
||||||
|
}:
|
||||||
|
diskoLib.testLib.makeDiskoTest {
|
||||||
|
inherit pkgs;
|
||||||
|
name = "gpt-name-with-whitespace";
|
||||||
|
disko-config = ../example/gpt-name-with-whitespace.nix;
|
||||||
|
extraTestScript = ''
|
||||||
|
machine.succeed("mountpoint /");
|
||||||
|
machine.succeed("mountpoint '/name with spaces'");
|
||||||
|
machine.succeed("mountpoint '/name^with\\some@special#chars'");
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { }
|
||||||
|
, diskoLib ? pkgs.callPackage ../lib { }
|
||||||
|
}:
|
||||||
|
diskoLib.testLib.makeDiskoTest {
|
||||||
|
inherit pkgs;
|
||||||
|
name = "legacy-table-with-whitespace";
|
||||||
|
disko-config = ../example/legacy-table-with-whitespace.nix;
|
||||||
|
extraTestScript = ''
|
||||||
|
machine.succeed("mountpoint /");
|
||||||
|
machine.succeed("mountpoint /name_with_spaces");
|
||||||
|
'';
|
||||||
|
}
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{ version = "1.8.2"; released = false; }
|
{ version = "1.9.0"; released = true; }
|
||||||
Reference in new issue
Block a user