apply treefmt

This commit is contained in:
Jörg Thalheim authored and mergify[bot] committed 2023-08-11 08:45:46 +00:00
1 parent 049d1bd952
commit b32f0e2876
8 files changed
+47 -25

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
{ ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
+15 -8
View File
@@ -23,10 +23,12 @@ let
name = "subType"; name = "subType";
description = "one of ${concatStringsSep "," (attrNames types)}"; description = "one of ${concatStringsSep "," (attrNames types)}";
check = x: if x ? type then types.${x.type}.check x else throw "No type option set in:\n${generators.toPretty {} x}"; check = x: if x ? type then types.${x.type}.check x else throw "No type option set in:\n${generators.toPretty {} x}";
merge = loc: foldl' (res: def: types.${def.value.type}.merge loc [ merge = loc: foldl'
(res: def: types.${def.value.type}.merge loc [
# we add a dummy root parent node to render documentation # we add a dummy root parent node to render documentation
(lib.recursiveUpdate { value._module.args = extraArgs; } def) (lib.recursiveUpdate { value._module.args = extraArgs; } def)
]) { }; ])
{ };
nestedTypes = types; nestedTypes = types;
}; };
@@ -328,9 +330,11 @@ let
/* topLevel type of the disko config, takes attrsets of disks, mdadms, zpools, nodevs, and lvm vgs. /* topLevel type of the disko config, takes attrsets of disks, mdadms, zpools, nodevs, and lvm vgs.
*/ */
toplevel = lib.types.submodule (cfg: let toplevel = lib.types.submodule (cfg:
let
devices = { inherit (cfg.config) disk mdadm zpool lvm_vg nodev; }; devices = { inherit (cfg.config) disk mdadm zpool lvm_vg nodev; };
in { in
{
options = { options = {
disk = lib.mkOption { disk = lib.mkOption {
type = lib.types.attrsOf diskoLib.types.disk; type = lib.types.attrsOf diskoLib.types.disk;
@@ -445,7 +449,8 @@ let
description = '' description = ''
The script to create all devices defined by disko.devices The script to create all devices defined by disko.devices
''; '';
default = let default =
let
sortedDeviceList = diskoLib.sortDevicesByDependencies (cfg.config._meta.deviceDependencies or { }) devices; sortedDeviceList = diskoLib.sortDevicesByDependencies (cfg.config._meta.deviceDependencies or { }) devices;
in in
'' ''
@@ -464,13 +469,15 @@ let
description = '' description = ''
The script to mount all devices defined by disko.devices The script to mount all devices defined by disko.devices
''; '';
default = let default =
let
fsMounts = diskoLib.deepMergeMap (dev: dev._mount.fs or { }) (flatten (map attrValues (attrValues devices))); fsMounts = diskoLib.deepMergeMap (dev: dev._mount.fs or { }) (flatten (map attrValues (attrValues devices)));
sortedDeviceList = diskoLib.sortDevicesByDependencies (cfg.config._meta.deviceDependencies or { }) devices; sortedDeviceList = diskoLib.sortDevicesByDependencies (cfg.config._meta.deviceDependencies or { }) devices;
in '' in
''
set -efux set -efux
# first create the necessary devices # first create the necessary devices
${concatMapStrings (dev: ((attrByPath (dev ++ [ "_mount" ]) {} devices)).dev or "") sortedDeviceList} ${concatMapStrings (dev: (attrByPath (dev ++ [ "_mount" ]) {} devices).dev or "") sortedDeviceList}
# and then mount the filesystems in alphabetical order # and then mount the filesystems in alphabetical order
${concatStrings (attrValues fsMounts)} ${concatStrings (attrValues fsMounts)}
+6 -3
View File
@@ -55,12 +55,15 @@ let
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches "" ${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
''; '';
QEMU_OPTS = lib.concatMapStringsSep " " (disk: "-drive file=${disk.name}.raw,if=virtio,cache=unsafe,werror=report") (lib.attrValues nixosConfig.config.disko.devices.disk); QEMU_OPTS = lib.concatMapStringsSep " " (disk: "-drive file=${disk.name}.raw,if=virtio,cache=unsafe,werror=report") (lib.attrValues nixosConfig.config.disko.devices.disk);
in { in
pure = pkgs.vmTools.runInLinuxVM (pkgs.runCommand name { {
pure = pkgs.vmTools.runInLinuxVM (pkgs.runCommand name
{
buildInputs = dependencies; buildInputs = dependencies;
inherit preVM QEMU_OPTS; inherit preVM QEMU_OPTS;
memSize = 1024; memSize = 1024;
} builder); }
builder);
impure = diskoLib.writeCheckedBash { inherit checked pkgs; } name '' impure = diskoLib.writeCheckedBash { inherit checked pkgs; } name ''
set -efu set -efu
export PATH=${lib.makeBinPath dependencies} export PATH=${lib.makeBinPath dependencies}
+16 -8
View File
@@ -12,7 +12,8 @@ let
let let
cleanedTopLevel = lib.filterAttrsRecursive (n: _: !lib.hasPrefix "_" n) cfg; cleanedTopLevel = lib.filterAttrsRecursive (n: _: !lib.hasPrefix "_" n) cfg;
preparedDisks = lib.foldlAttrs (acc: n: v: { preparedDisks = lib.foldlAttrs
(acc: n: v: {
devices = lib.tail acc.devices; devices = lib.tail acc.devices;
grub-devices = acc.grub-devices ++ (lib.optional (lib.any (part: (part.type or "") == "EF02") (lib.attrValues (v.content.partitions or { }))) (lib.head acc.devices)); grub-devices = acc.grub-devices ++ (lib.optional (lib.any (part: (part.type or "") == "EF02") (lib.attrValues (v.content.partitions or { }))) (lib.head acc.devices));
disks = acc.disks // { disks = acc.disks // {
@@ -21,11 +22,13 @@ let
content = v.content // { device = lib.head acc.devices; }; content = v.content // { device = lib.head acc.devices; };
}; };
}; };
}) { })
{
inherit devices; inherit devices;
grub-devices = [ ]; grub-devices = [ ];
disks = { }; disks = { };
} cleanedTopLevel.disko.devices.disk; }
cleanedTopLevel.disko.devices.disk;
in in
cleanedTopLevel // { cleanedTopLevel // {
boot.loader.grub.devices = if (preparedDisks.grub-devices != [ ]) then preparedDisks.grub-devices else [ "nodev" ]; boot.loader.grub.devices = if (preparedDisks.grub-devices != [ ]) then preparedDisks.grub-devices else [ "nodev" ];
@@ -60,12 +63,14 @@ let
}; };
# for installation we skip /dev/vda because it is the test runner disk # for installation we skip /dev/vda because it is the test runner disk
importedDiskoConfig = if builtins.isPath disko-config then importedDiskoConfig =
if builtins.isPath disko-config then
import disko-config import disko-config
else else
disko-config; disko-config;
diskoConfigWithArgs = if builtins.isFunction importedDiskoConfig then diskoConfigWithArgs =
if builtins.isFunction importedDiskoConfig then
importedDiskoConfig { inherit lib; } importedDiskoConfig { inherit lib; }
else else
importedDiskoConfig; importedDiskoConfig;
@@ -184,9 +189,11 @@ let
connect-timeout = 1; connect-timeout = 1;
}; };
networking.hostId = lib.mkIf ( networking.hostId = lib.mkIf
(
(testConfigInstall ? networking.hostId) && (testConfigInstall.networking.hostId != null) (testConfigInstall ? networking.hostId) && (testConfigInstall.networking.hostId != null)
) testConfigInstall.networking.hostId; )
testConfigInstall.networking.hostId;
virtualisation.emptyDiskImages = builtins.genList (_: 4096) num-disks; virtualisation.emptyDiskImages = builtins.genList (_: 4096) num-disks;
@@ -256,5 +263,6 @@ let
''; '';
}; };
}; };
in testLib in
testLib
+3 -1
View File
@@ -93,7 +93,9 @@
(_: subvol: (_: subvol:
lib.warnIf (subvol.mountOptions != (options.subvolumes.type.getSubOptions [ ]).mountOptions.default && subvol.mountpoint == null) lib.warnIf (subvol.mountOptions != (options.subvolumes.type.getSubOptions [ ]).mountOptions.default && subvol.mountpoint == null)
"Subvolume ${subvol.name} has mountOptions but no mountpoint. See upgrade guide (2023-07-09 121df48)." "Subvolume ${subvol.name} has mountOptions but no mountpoint. See upgrade guide (2023-07-09 121df48)."
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} "${rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then
mount ${config.device} "${rootMountPoint}${subvol.mountpoint}" \ mount ${config.device} "${rootMountPoint}${subvol.mountpoint}" \
+2 -2
View File
@@ -39,13 +39,13 @@
}; };
_mount = diskoLib.mkMountOption { _mount = diskoLib.mkMountOption {
inherit config options; inherit config options;
default = lib.optionalAttrs (config.content != null) (config.content._mount); default = lib.optionalAttrs (config.content != null) config.content._mount;
}; };
_config = lib.mkOption { _config = lib.mkOption {
internal = true; internal = true;
readOnly = true; readOnly = true;
default = default =
lib.optional (config.content != null) (config.content._config); lib.optional (config.content != null) config.content._config;
description = "NixOS configuration"; description = "NixOS configuration";
}; };
_pkgs = lib.mkOption { _pkgs = lib.mkOption {
+2 -1
View File
@@ -24,7 +24,8 @@ in
}; };
device = lib.mkOption { device = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = if config._parent.type == "mdadm" then default =
if config._parent.type == "mdadm" then
# 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
+2 -1
View File
@@ -1,6 +1,7 @@
{ config, options, lib, diskoLib, parent, device, ... }: { config, options, lib, diskoLib, parent, device, ... }:
let let
keyFile = if lib.hasAttr "keyFile" config.settings keyFile =
if lib.hasAttr "keyFile" config.settings
then config.settings.keyFile then config.settings.keyFile
else if config.keyFile != null else if config.keyFile != null
then lib.warn "The option `keyFile` is deprecated. See the `settings` option." config.keyFile then lib.warn "The option `keyFile` is deprecated. See the `settings` option." config.keyFile