mirror of
https://github.com/TECHNOFAB11/disko.git
synced 2025-12-12 08:00:05 +01:00
style: Apply nixpkgs-fmt and fix
Apply standard formatting and some statix conventions using; ```sh nixpkgs-fmt **.nix && statix fix . ``` With the intent of making contribution a bit easier and reducing mental load in hand formatting (in the same vein as [black]). [black]: https://github.com/psf/black#the-uncompromising-code-formatter
This commit is contained in:
parent
b1a4ecb8ca
commit
08435eec4b
23 changed files with 171 additions and 158 deletions
|
|
@ -48,7 +48,7 @@
|
|||
subvolMounts = diskoLib.deepMergeMap (subvol: subvol._mount { inherit dev; parent = config.mountpoint; }) (lib.attrValues config.subvolumes);
|
||||
in
|
||||
{
|
||||
fs = subvolMounts.fs // lib.optionalAttrs (!isNull config.mountpoint) {
|
||||
fs = subvolMounts.fs // lib.optionalAttrs (config.mountpoint != null) {
|
||||
${config.mountpoint} = ''
|
||||
if ! findmnt ${dev} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "${rootMountPoint}${config.mountpoint}" \
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
readOnly = true;
|
||||
default = dev: [
|
||||
(map (subvol: subvol._config dev config.mountpoint) (lib.attrValues config.subvolumes))
|
||||
(lib.optional (!isNull config.mountpoint) {
|
||||
(lib.optional (config.mountpoint != null) {
|
||||
fileSystems.${config.mountpoint} = {
|
||||
device = dev;
|
||||
fsType = "btrfs";
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@
|
|||
default = { dev, parent }:
|
||||
let
|
||||
mountpoint =
|
||||
if (!isNull config.mountpoint) then config.mountpoint
|
||||
else if (isNull parent) then config.name
|
||||
if (config.mountpoint != null) then config.mountpoint
|
||||
else if (parent == null) then config.name
|
||||
else null;
|
||||
in
|
||||
lib.optionalAttrs (!isNull mountpoint) {
|
||||
lib.optionalAttrs (mountpoint != null) {
|
||||
fs.${mountpoint} = ''
|
||||
if ! findmnt ${dev} "${rootMountPoint}${mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "${rootMountPoint}${mountpoint}" \
|
||||
|
|
@ -70,11 +70,11 @@
|
|||
default = dev: parent:
|
||||
let
|
||||
mountpoint =
|
||||
if (!isNull config.mountpoint) then config.mountpoint
|
||||
else if (isNull parent) then config.name
|
||||
if (config.mountpoint != null) then config.mountpoint
|
||||
else if (parent == null) then config.name
|
||||
else null;
|
||||
in
|
||||
lib.optional (!isNull mountpoint) {
|
||||
lib.optional (mountpoint != null) {
|
||||
fileSystems.${mountpoint} = {
|
||||
device = dev;
|
||||
fsType = "btrfs";
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ rec {
|
|||
name = "subType";
|
||||
description = "one of ${concatStringsSep "," (attrNames typeAttr)}";
|
||||
check = x: if x ? type then typeAttr.${x.type}.check x else throw "No type option set in:\n${generators.toPretty {} x}";
|
||||
merge = loc: defs:
|
||||
foldl' (res: def: typeAttr.${def.value.type}.merge loc [ def ]) { } defs;
|
||||
merge = loc: foldl' (res: def: typeAttr.${def.value.type}.merge loc [ def ]) { };
|
||||
nestedTypes = typeAttr;
|
||||
};
|
||||
|
||||
|
|
@ -38,8 +37,7 @@ rec {
|
|||
deepMergeMap (x: x.t = "test") [ { x = { y = 1; z = 3; }; } { x = { bla = 234; }; } ]
|
||||
=> { x = { y = 1; z = 3; bla = 234; t = "test"; }; }
|
||||
*/
|
||||
deepMergeMap = f: listOfAttrs:
|
||||
foldr (attr: acc: (recursiveUpdate acc (f attr))) { } listOfAttrs;
|
||||
deepMergeMap = f: foldr (attr: acc: (recursiveUpdate acc (f attr))) { };
|
||||
|
||||
/* get a device and an index to get the matching device name
|
||||
|
||||
|
|
@ -119,7 +117,7 @@ rec {
|
|||
maybeSTr "hello world"
|
||||
=> "hello world"
|
||||
*/
|
||||
maybeStr = x: optionalString (!isNull x) x;
|
||||
maybeStr = x: optionalString (x != null) x;
|
||||
|
||||
/* Takes a Submodules config and options argument and returns a serializable
|
||||
subset of config variables as a shell script snippet.
|
||||
|
|
@ -147,7 +145,7 @@ rec {
|
|||
default = "";
|
||||
};
|
||||
|
||||
mkSubType = module: lib.types.submodule ([
|
||||
mkSubType = module: lib.types.submodule [
|
||||
module
|
||||
|
||||
{
|
||||
|
|
@ -161,7 +159,7 @@ rec {
|
|||
inherit diskoLib optionTypes subTypes rootMountPoint;
|
||||
};
|
||||
}
|
||||
]);
|
||||
];
|
||||
|
||||
mkCreateOption = { config, options, default }@attrs:
|
||||
lib.mkOption {
|
||||
|
|
@ -189,7 +187,7 @@ rec {
|
|||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
default = args: attrs.default args;
|
||||
inherit (attrs) default;
|
||||
description = "Mount script";
|
||||
};
|
||||
|
||||
|
|
@ -215,7 +213,7 @@ rec {
|
|||
trap 'rm -rf "$disko_devices_dir"' EXIT
|
||||
mkdir -p "$disko_devices_dir"
|
||||
|
||||
${concatMapStrings (dev: (attrByPath (dev ++ [ "_create" ]) ({}: {}) devices) {}) sortedDeviceList}
|
||||
${concatMapStrings (dev: (attrByPath (dev ++ [ "_create" ]) (_: {}) devices) {}) sortedDeviceList}
|
||||
'';
|
||||
/* Takes a disko device specification and returns a string which mounts the disks
|
||||
|
||||
|
|
@ -326,7 +324,7 @@ rec {
|
|||
};
|
||||
};
|
||||
|
||||
subTypes = lib.mapAttrs (_: module: diskoLib.mkSubType module) {
|
||||
subTypes = lib.mapAttrs (_: diskoLib.mkSubType) {
|
||||
nodev = ./nodev.nix;
|
||||
btrfs = ./btrfs.nix;
|
||||
btrfs_subvol = ./btrfs_subvol.nix;
|
||||
|
|
|
|||
|
|
@ -22,30 +22,30 @@
|
|||
readOnly = true;
|
||||
type = diskoLib.jsonType;
|
||||
default =
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta [ "disk" config.device ]);
|
||||
lib.optionalAttrs (config.content != null) (config.content._meta [ "disk" config.device ]);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = {}: config.content._create { dev = config.device; };
|
||||
default = _: config.content._create { dev = config.device; };
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = {}:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._mount { dev = config.device; });
|
||||
default = _:
|
||||
lib.optionalAttrs (config.content != null) (config.content._mount { dev = config.device; });
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default =
|
||||
lib.optional (!isNull config.content) (config.content._config config.device);
|
||||
lib.optional (config.content != null) (config.content._config config.device);
|
||||
description = "NixOS configuration";
|
||||
};
|
||||
_pkgs = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: [ pkgs.jq ] ++ lib.optionals (!isNull config.content) (config.content._pkgs pkgs);
|
||||
default = pkgs: [ pkgs.jq ] ++ lib.optionals (config.content != null) (config.content._pkgs pkgs);
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@
|
|||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
default = dev:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta dev);
|
||||
lib.optionalAttrs (config.content != null) (config.content._meta dev);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = { dev }: ''
|
||||
cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraArgs}
|
||||
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (!isNull config.keyFile) "--key-file ${config.keyFile}"}
|
||||
${lib.optionalString (!isNull config.content) (config.content._create {dev = "/dev/mapper/${config.name}";})}
|
||||
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"}
|
||||
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/mapper/${config.name}";})}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
|
|
@ -46,10 +46,10 @@
|
|||
{
|
||||
dev = ''
|
||||
cryptsetup status ${config.name} >/dev/null 2>/dev/null ||
|
||||
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (!isNull config.keyFile) "--key-file ${config.keyFile}"}
|
||||
${lib.optionalString (!isNull config.content) contentMount.dev or ""}
|
||||
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"}
|
||||
${lib.optionalString (config.content != null) contentMount.dev or ""}
|
||||
'';
|
||||
fs = lib.optionalAttrs (!isNull config.content) contentMount.fs or { };
|
||||
fs = lib.optionalAttrs (config.content != null) contentMount.fs or { };
|
||||
};
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
|
|
@ -59,14 +59,14 @@
|
|||
[
|
||||
# TODO do we need this always in initrd and only there?
|
||||
{ boot.initrd.luks.devices.${config.name}.device = dev; }
|
||||
] ++ (lib.optional (!isNull config.content) (config.content._config "/dev/mapper/${config.name}"));
|
||||
] ++ (lib.optional (config.content != null) (config.content._config "/dev/mapper/${config.name}"));
|
||||
description = "NixOS configuration";
|
||||
};
|
||||
_pkgs = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: [ pkgs.cryptsetup ] ++ (lib.optionals (!isNull config.content) (config.content._pkgs pkgs));
|
||||
default = pkgs: [ pkgs.cryptsetup ] ++ (lib.optionals (config.content != null) (config.content._pkgs pkgs));
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
default = dev:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta dev);
|
||||
lib.optionalAttrs (config.content != null) (config.content._meta dev);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
|
|
@ -42,24 +42,24 @@
|
|||
--yes \
|
||||
${if lib.hasInfix "%" config.size then "-l" else "-L"} ${config.size} \
|
||||
-n ${config.name} \
|
||||
${lib.optionalString (!isNull config.lvm_type) "--type=${config.lvm_type}"} \
|
||||
${lib.optionalString (config.lvm_type != null) "--type=${config.lvm_type}"} \
|
||||
${config.extraArgs} \
|
||||
${vg}
|
||||
${lib.optionalString (!isNull config.content) (config.content._create {dev = "/dev/${vg}/${config.name}";})}
|
||||
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/${vg}/${config.name}";})}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = { vg }:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._mount { dev = "/dev/${vg}/${config.name}"; });
|
||||
lib.optionalAttrs (config.content != null) (config.content._mount { dev = "/dev/${vg}/${config.name}"; });
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default = vg:
|
||||
[
|
||||
(lib.optional (!isNull config.content) (config.content._config "/dev/${vg}/${config.name}"))
|
||||
(lib.optional (!isNull config.lvm_type) {
|
||||
(lib.optional (config.content != null) (config.content._config "/dev/${vg}/${config.name}"))
|
||||
(lib.optional (config.lvm_type != null) {
|
||||
boot.initrd.kernelModules = [ "dm-${config.lvm_type}" ];
|
||||
})
|
||||
];
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: lib.optionals (!isNull config.content) (config.content._pkgs pkgs);
|
||||
default = pkgs: lib.optionals (config.content != null) (config.content._pkgs pkgs);
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@
|
|||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = {}: ''
|
||||
default = _: ''
|
||||
vgcreate ${config.name} $(tr '\n' ' ' < $disko_devices_dir/lvm_${config.name})
|
||||
${lib.concatMapStrings (lv: lv._create {vg = config.name; }) (lib.attrValues config.lvs)}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = {}:
|
||||
default = _:
|
||||
let
|
||||
lvMounts = diskoLib.deepMergeMap (lv: lv._mount { vg = config.name; }) (lib.attrValues config.lvs);
|
||||
in
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
vgchange -a y
|
||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues lvMounts)}
|
||||
'';
|
||||
fs = lvMounts.fs;
|
||||
inherit (lvMounts) fs;
|
||||
};
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
readOnly = true;
|
||||
type = diskoLib.jsonType;
|
||||
default =
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta [ "mdadm" config.name ]);
|
||||
lib.optionalAttrs (config.content != null) (config.content._meta [ "mdadm" config.name ]);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = {}: ''
|
||||
default = _: ''
|
||||
echo 'y' | mdadm --create /dev/md/${config.name} \
|
||||
--level=${toString config.level} \
|
||||
--raid-devices=$(wc -l $disko_devices_dir/raid_${config.name} | cut -f 1 -d " ") \
|
||||
|
|
@ -42,27 +42,27 @@
|
|||
--homehost=any \
|
||||
$(tr '\n' ' ' < $disko_devices_dir/raid_${config.name})
|
||||
udevadm trigger --subsystem-match=block; udevadm settle
|
||||
${lib.optionalString (!isNull config.content) (config.content._create {dev = "/dev/md/${config.name}";})}
|
||||
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/md/${config.name}";})}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = {}:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._mount { dev = "/dev/md/${config.name}"; });
|
||||
default = _:
|
||||
lib.optionalAttrs (config.content != null) (config.content._mount { dev = "/dev/md/${config.name}"; });
|
||||
# TODO we probably need to assemble the mdadm somehow
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default =
|
||||
lib.optional (!isNull config.content) (config.content._config "/dev/md/${config.name}");
|
||||
lib.optional (config.content != null) (config.content._config "/dev/md/${config.name}");
|
||||
description = "NixOS configuration";
|
||||
};
|
||||
_pkgs = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: (lib.optionals (!isNull config.content) (config.content._pkgs pkgs));
|
||||
default = pkgs: (lib.optionals (config.content != null) (config.content._pkgs pkgs));
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@
|
|||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = {}: "";
|
||||
default = _: "";
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = {}: {
|
||||
default = _: {
|
||||
fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount -t ${config.fsType} ${config.device} "${rootMountPoint}${config.mountpoint}" \
|
||||
|
|
@ -54,8 +54,8 @@
|
|||
readOnly = true;
|
||||
default = [{
|
||||
fileSystems.${config.mountpoint} = {
|
||||
device = config.device;
|
||||
fsType = config.fsType;
|
||||
inherit (config) device;
|
||||
inherit (config) fsType;
|
||||
options = config.mountOptions;
|
||||
};
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
default = dev:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta dev);
|
||||
lib.optionalAttrs (config.content != null) (config.content._meta dev);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
''}
|
||||
# ensure /dev/disk/by-path/..-partN exists before continuing
|
||||
udevadm trigger --subsystem-match=block; udevadm settle
|
||||
${lib.optionalString (config.bootable) ''
|
||||
${lib.optionalString config.bootable ''
|
||||
parted -s ${dev} -- set ${toString config.index} boot on
|
||||
''}
|
||||
${lib.concatMapStringsSep "" (flag: ''
|
||||
|
|
@ -74,26 +74,26 @@
|
|||
'') config.flags}
|
||||
# ensure further operations can detect new partitions
|
||||
udevadm trigger --subsystem-match=block; udevadm settle
|
||||
${lib.optionalString (!isNull config.content) (config.content._create {dev = (diskoLib.deviceNumbering dev config.index);})}
|
||||
${lib.optionalString (config.content != null) (config.content._create {dev = diskoLib.deviceNumbering dev config.index;})}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = { dev }:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._mount { dev = (diskoLib.deviceNumbering dev config.index); });
|
||||
lib.optionalAttrs (config.content != null) (config.content._mount { dev = diskoLib.deviceNumbering dev config.index; });
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default = dev:
|
||||
lib.optional (!isNull config.content) (config.content._config (diskoLib.deviceNumbering dev config.index));
|
||||
lib.optional (config.content != null) (config.content._config (diskoLib.deviceNumbering dev config.index));
|
||||
description = "NixOS configuration";
|
||||
};
|
||||
_pkgs = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: lib.optionals (!isNull config.content) (config.content._pkgs pkgs);
|
||||
default = pkgs: lib.optionals (config.content != null) (config.content._pkgs pkgs);
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
default = dev: [{
|
||||
swapDevices = [{
|
||||
device = dev;
|
||||
randomEncryption = config.randomEncryption;
|
||||
inherit (config) randomEncryption;
|
||||
}];
|
||||
}];
|
||||
description = "NixOS configuration";
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
default = dev:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta dev);
|
||||
lib.optionalAttrs (config.content != null) (config.content._meta dev);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
|
|
@ -58,14 +58,14 @@
|
|||
${lib.optionalString (config.zfs_type == "volume") "-V ${config.size}"}
|
||||
${lib.optionalString (config.zfs_type == "volume") ''
|
||||
udevadm trigger --subsystem-match=block; udevadm settle
|
||||
${lib.optionalString (!isNull config.content) (config.content._create {dev = "/dev/zvol/${zpool}/${config.name}";})}
|
||||
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/zvol/${zpool}/${config.name}";})}
|
||||
''}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = { zpool }:
|
||||
lib.optionalAttrs (config.zfs_type == "volume" && !isNull config.content) (config.content._mount { dev = "/dev/zvol/${zpool}/${config.name}"; }) //
|
||||
lib.optionalAttrs (config.zfs_type == "volume" && config.content != null) (config.content._mount { dev = "/dev/zvol/${zpool}/${config.name}"; }) //
|
||||
lib.optionalAttrs (config.zfs_type == "filesystem" && config.options.mountpoint or "" != "none") {
|
||||
fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${zpool}/${config.name} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
internal = true;
|
||||
readOnly = true;
|
||||
default = zpool:
|
||||
(lib.optional (config.zfs_type == "volume" && !isNull config.content) (config.content._config "/dev/zvol/${zpool}/${config.name}")) ++
|
||||
(lib.optional (config.zfs_type == "volume" && config.content != null) (config.content._config "/dev/zvol/${zpool}/${config.name}")) ++
|
||||
(lib.optional (config.zfs_type == "filesystem" && config.options.mountpoint or "" != "none") {
|
||||
fileSystems.${config.mountpoint} = {
|
||||
device = "${zpool}/${config.name}";
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: [ pkgs.util-linux ] ++ lib.optionals (!isNull config.content) (config.content._pkgs pkgs);
|
||||
default = pkgs: [ pkgs.util-linux ] ++ lib.optionals (config.content != null) (config.content._pkgs pkgs);
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = {}: ''
|
||||
default = _: ''
|
||||
zpool create ${config.name} \
|
||||
${config.mode} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = {}:
|
||||
default = _:
|
||||
let
|
||||
datasetMounts = diskoLib.deepMergeMap (dataset: dataset._mount { zpool = config.name; }) (lib.attrValues config.datasets);
|
||||
in
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
zpool list '${config.name}' >/dev/null 2>/dev/null || zpool import '${config.name}'
|
||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
|
||||
'';
|
||||
fs = datasetMounts.fs // lib.optionalAttrs (!isNull config.mountpoint) {
|
||||
fs = datasetMounts.fs // lib.optionalAttrs (config.mountpoint != null) {
|
||||
${config.mountpoint} = ''
|
||||
if ! findmnt ${config.name} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${config.name} "${rootMountPoint}${config.mountpoint}" \
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
readOnly = true;
|
||||
default = [
|
||||
(map (dataset: dataset._config config.name) (lib.attrValues config.datasets))
|
||||
(lib.optional (!isNull config.mountpoint) {
|
||||
(lib.optional (config.mountpoint != null) {
|
||||
fileSystems.${config.mountpoint} = {
|
||||
device = config.name;
|
||||
fsType = "zfs";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue