From 2785974eef89de5325517fb960cf41594317fc9a Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 9 Mar 2023 06:49:11 +0100 Subject: [PATCH] filesystem/nodev: mountpoint can be empty --- types/filesystem.nix | 9 +++++---- types/nodev.nix | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/types/filesystem.nix b/types/filesystem.nix index 93d0cac..cda58b8 100644 --- a/types/filesystem.nix +++ b/types/filesystem.nix @@ -17,7 +17,8 @@ description = "Options to pass to mount"; }; mountpoint = lib.mkOption { - type = optionTypes.absolute-pathname; + type = lib.types.nullOr optionTypes.absolute-pathname; + default = null; description = "Path to mount the filesystem to"; }; format = lib.mkOption { @@ -41,7 +42,7 @@ }; _mount = diskoLib.mkMountOption { inherit config options; - default = { dev }: { + default = { dev }: lib.optionalAttrs (config.mountpoint != null) { fs.${config.mountpoint} = '' if ! findmnt ${dev} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then mount ${dev} "${rootMountPoint}${config.mountpoint}" \ @@ -55,13 +56,13 @@ _config = lib.mkOption { internal = true; readOnly = true; - default = dev: [{ + default = dev: lib.optional (config.mountpoint != null) { fileSystems.${config.mountpoint} = { device = dev; fsType = config.format; options = config.mountOptions; }; - }]; + }; description = "NixOS configuration"; }; _pkgs = lib.mkOption { diff --git a/types/nodev.nix b/types/nodev.nix index 2700ab7..9fe7b86 100644 --- a/types/nodev.nix +++ b/types/nodev.nix @@ -17,7 +17,7 @@ description = "Device to use"; }; mountpoint = lib.mkOption { - type = optionTypes.absolute-pathname; + type = lib.types.nullOr optionTypes.absolute-pathname; default = config._module.args.name; description = "Location to mount the file system at"; }; @@ -39,7 +39,7 @@ }; _mount = diskoLib.mkMountOption { inherit config options; - default = _: { + default = _: lib.optionalAttrs (config.mountpoint != null) { fs.${config.mountpoint} = '' if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then mount -t ${config.fsType} ${config.device} "${rootMountPoint}${config.mountpoint}" \ @@ -52,13 +52,13 @@ _config = lib.mkOption { internal = true; readOnly = true; - default = [{ + default = lib.optional (config.mountpoint != null) { fileSystems.${config.mountpoint} = { device = config.device; fsType = config.fsType; options = config.mountOptions; }; - }]; + }; description = "NixOS configuration"; }; _pkgs = lib.mkOption {