diff --git a/lib/default.nix b/lib/default.nix index d4ba865..bcab0ff 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -39,22 +39,21 @@ let loc: defs: let evaled = lib.evalModules { - modules = - [ - { - freeformType = lib.types.lazyAttrsOf lib.types.raw; - options.type = lib.mkOption { - type = lib.types.str; - }; - } - ] - ++ map ( - { value, file }: - { - _file = file; - config = value; - } - ) defs; + modules = [ + { + freeformType = lib.types.lazyAttrsOf lib.types.raw; + options.type = lib.mkOption { + type = lib.types.str; + }; + } + ] + ++ map ( + { value, file }: + { + _file = file; + config = value; + } + ) defs; }; inherit (evaled.config) type; in @@ -1195,6 +1194,7 @@ let }; binfmt = import ./binfmt.nix; - } // outputs; + } + // outputs; in diskoLib diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index 2e1b55f..8ca4098 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -29,19 +29,18 @@ let vmTools = pkgs.vmTools.override ( { - rootModules = - [ - "9p" - "9pnet_virtio" # we can drop those in future if we stop supporting 24.11 + rootModules = [ + "9p" + "9pnet_virtio" # we can drop those in future if we stop supporting 24.11 - "virtiofs" - "virtio_pci" - "virtio_blk" - "virtio_balloon" - "virtio_rng" - ] - ++ (lib.optional configSupportsZfs "zfs") - ++ cfg.extraRootModules; + "virtiofs" + "virtio_pci" + "virtio_blk" + "virtio_balloon" + "virtio_rng" + ] + ++ (lib.optional configSupportsZfs "zfs") + ++ cfg.extraRootModules; kernel = pkgs.aggregateModules ( [ cfg.kernelPackages.kernel diff --git a/lib/tests.nix b/lib/tests.nix index 1cfe536..9edd8d3 100644 --- a/lib/tests.nix +++ b/lib/tests.nix @@ -237,21 +237,20 @@ let ( { config, ... }: { - boot.supportedFilesystems = - [ - "btrfs" - "cifs" - "f2fs" - "jfs" - "ntfs" - "reiserfs" - "vfat" - "xfs" - ] - ++ lib.optional ( - config.networking.hostId != null - && lib.meta.availableOn pkgs.stdenv.hostPlatform config.boot.zfs.package - ) "zfs"; + boot.supportedFilesystems = [ + "btrfs" + "cifs" + "f2fs" + "jfs" + "ntfs" + "reiserfs" + "vfat" + "xfs" + ] + ++ lib.optional ( + config.networking.hostId != null + && lib.meta.availableOn pkgs.stdenv.hostPlatform config.boot.zfs.package + ) "zfs"; } ) diff --git a/lib/types/luks.nix b/lib/types/luks.nix index 1875696..9404711 100644 --- a/lib/types/luks.nix +++ b/lib/types/luks.nix @@ -227,7 +227,8 @@ in { boot.initrd.luks.devices.${config.name} = { inherit (config) device; - } // config.settings; + } + // config.settings; } ]) ++ (lib.optional (config.content != null) config.content._config); diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index f40d0ed..f44041f 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -7,16 +7,15 @@ }: let # Load kernel modules to ensure device mapper types are available - kernelModules = - [ - # Prevent unbootable systems if LVM snapshots are present at boot time. - "dm-snapshot" - ] - ++ lib.filter (x: x != "") ( - map (lv: lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "dm-${lv.lvm_type}") ( - lib.attrValues config.lvs - ) - ); + kernelModules = [ + # Prevent unbootable systems if LVM snapshots are present at boot time. + "dm-snapshot" + ] + ++ lib.filter (x: x != "") ( + map (lv: lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "dm-${lv.lvm_type}") ( + lib.attrValues config.lvs + ) + ); in { options = { @@ -182,24 +181,24 @@ in _config = lib.mkOption { internal = true; readOnly = true; - default = - [ { boot.initrd.kernelModules = kernelModules; } ] - ++ map (lv: [ - (lib.optional (lv.content != null) lv.content._config) - (lib.optional (lv.lvm_type != null) { - boot.initrd.kernelModules = - [ - (if lv.lvm_type == "mirror" then "dm-mirror" else "dm-raid") - ] - ++ lib.optional (lv.lvm_type == "raid0") "raid0" - ++ lib.optional (lv.lvm_type == "raid1") "raid1" - # ++ lib.optional (lv.lvm_type == "raid10") "raid10" - ++ lib.optional ( - lv.lvm_type == "raid4" || lv.lvm_type == "raid5" || lv.lvm_type == "raid6" - ) "raid456"; + default = [ + { boot.initrd.kernelModules = kernelModules; } + ] + ++ map (lv: [ + (lib.optional (lv.content != null) lv.content._config) + (lib.optional (lv.lvm_type != null) { + boot.initrd.kernelModules = [ + (if lv.lvm_type == "mirror" then "dm-mirror" else "dm-raid") + ] + ++ lib.optional (lv.lvm_type == "raid0") "raid0" + ++ lib.optional (lv.lvm_type == "raid1") "raid1" + # ++ lib.optional (lv.lvm_type == "raid10") "raid10" + ++ lib.optional ( + lv.lvm_type == "raid4" || lv.lvm_type == "raid5" || lv.lvm_type == "raid6" + ) "raid456"; - }) - ]) (lib.attrValues config.lvs); + }) + ]) (lib.attrValues config.lvs); description = "NixOS configuration"; }; _pkgs = lib.mkOption { diff --git a/lib/types/mdadm.nix b/lib/types/mdadm.nix index d8939e1..277d9bc 100644 --- a/lib/types/mdadm.nix +++ b/lib/types/mdadm.nix @@ -115,7 +115,8 @@ boot.initrd.services.swraid.enable = true; } ) - ] ++ lib.optional (config.content != null) config.content._config; + ] + ++ lib.optional (config.content != null) config.content._config; description = "NixOS configuration"; }; _pkgs = lib.mkOption { diff --git a/lib/types/zfs_fs.nix b/lib/types/zfs_fs.nix index 37e1c6f..e006432 100644 --- a/lib/types/zfs_fs.nix +++ b/lib/types/zfs_fs.nix @@ -124,19 +124,20 @@ fi ''; }) - // lib.optionalAttrs - (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") - { - fs.${config.mountpoint} = '' - if ! findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then - mount ${config._name} "${rootMountPoint}${config.mountpoint}" \ - -o X-mount.mkdir \ - ${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \ - ${lib.optionalString ((config.options.mountpoint or "") != "legacy") "-o zfsutil"} \ - -t zfs - fi - ''; - }; + // + lib.optionalAttrs + (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") + { + fs.${config.mountpoint} = '' + if ! findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then + mount ${config._name} "${rootMountPoint}${config.mountpoint}" \ + -o X-mount.mkdir \ + ${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \ + ${lib.optionalString ((config.options.mountpoint or "") != "legacy") "-o zfsutil"} \ + -t zfs + fi + ''; + }; }; _unmount = diskoLib.mkUnmountOption { @@ -149,15 +150,16 @@ fi ''; }) - // lib.optionalAttrs - (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") - { - fs.${config.mountpoint} = '' - if findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then - umount "${rootMountPoint}${config.mountpoint}" - fi - ''; - }; + // + lib.optionalAttrs + (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") + { + fs.${config.mountpoint} = '' + if findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then + umount "${rootMountPoint}${config.mountpoint}" + fi + ''; + }; }; _config = lib.mkOption { @@ -170,8 +172,7 @@ device = "${config._name}"; fsType = "zfs"; options = - config.mountOptions - ++ lib.optional ((config.options.mountpoint or "") != "legacy") "zfsutil"; + config.mountOptions ++ lib.optional ((config.options.mountpoint or "") != "legacy") "zfsutil"; }; }; description = "NixOS configuration"; diff --git a/tests/disko-install/configuration.nix b/tests/disko-install/configuration.nix index 7eaf12c..5baf751 100644 --- a/tests/disko-install/configuration.nix +++ b/tests/disko-install/configuration.nix @@ -25,11 +25,12 @@ ]; }; services.openssh.enable = true; - boot.kernelParams = - [ "console=tty0" ] - ++ (lib.optional (pkgs.stdenv.hostPlatform.isAarch) "ttyAMA0,115200") - ++ (lib.optional (pkgs.stdenv.hostPlatform.isRiscV64) "ttySIF0,115200") - ++ [ "console=ttyS0,115200" ]; + boot.kernelParams = [ + "console=tty0" + ] + ++ (lib.optional (pkgs.stdenv.hostPlatform.isAarch) "ttyAMA0,115200") + ++ (lib.optional (pkgs.stdenv.hostPlatform.isRiscV64) "ttySIF0,115200") + ++ [ "console=ttyS0,115200" ]; # reduce closure size nixpkgs.flake.setFlakeRegistry = false; diff --git a/tests/disko-install/default.nix b/tests/disko-install/default.nix index c3af9dd..90dfe17 100644 --- a/tests/disko-install/default.nix +++ b/tests/disko-install/default.nix @@ -16,7 +16,8 @@ let self.nixosConfigurations.testmachine.config.system.build.toplevel self.nixosConfigurations.testmachine.config.system.build.diskoScript - ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); + ] + ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in