summaryrefslogtreecommitdiffstats
path: root/nixos/modules/tasks/filesystems.nix
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-08-31 16:45:19 +0300
committerNikolay Amiantov <ab@fmap.me>2016-08-31 16:50:13 +0300
commit7fa8c424bd1b1192d4a5653074f7c8ae271cfa68 (patch)
treed2bec6dca962225ea88d8997e308f8f7f2c9204f /nixos/modules/tasks/filesystems.nix
parent459d46dc5a3f47287431750cadc102244f370ac6 (diff)
nixos filesystems: move special filesystems to a dedicated option
Fixes #18159.
Diffstat (limited to 'nixos/modules/tasks/filesystems.nix')
-rw-r--r--nixos/modules/tasks/filesystems.nix62
1 files changed, 34 insertions, 28 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index d69284a75323..dd632437a78a 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -20,7 +20,7 @@ let
specialFSTypes = [ "proc" "sysfs" "tmpfs" "devtmpfs" "devpts" ];
- fileSystemOpts = { name, config, ... }: {
+ coreFileSystemOpts = { name, config, ... }: {
options = {
@@ -37,13 +37,6 @@ let
description = "Location of the device.";
};
- label = mkOption {
- default = null;
- example = "root-partition";
- type = types.nullOr types.str;
- description = "Label of the device (if any).";
- };
-
fsType = mkOption {
default = "auto";
example = "ext3";
@@ -62,6 +55,26 @@ let
apply = x: if isList x then x else lib.strings.splitString "," (builtins.trace "warning: passing a comma-separated string for filesystem options is deprecated; use a list of strings instead. This will become a hard error in 16.09." x);
});
+ };
+
+ config = {
+ mountPoint = mkDefault name;
+ device = mkIf (elem config.fsType specialFSTypes) (mkDefault config.fsType);
+ };
+
+ };
+
+ fileSystemOpts = { config, ... }: {
+
+ options = {
+
+ label = mkOption {
+ default = null;
+ example = "root-partition";
+ type = types.nullOr types.str;
+ description = "Label of the device (if any).";
+ };
+
autoFormat = mkOption {
default = false;
type = types.bool;
@@ -99,22 +112,9 @@ let
description = "Disable running fsck on this filesystem.";
};
- early = mkOption {
- default = false;
- type = types.bool;
- internal = true;
- description = ''
- Mount this filesystem very early during boot. At the moment of
- mounting no disks are exposed, so this option is primarily for
- special file systems.
- '';
- };
-
};
config = {
- mountPoint = mkDefault name;
- device = mkIf (elem config.fsType specialFSTypes) (mkDefault config.fsType);
options = mkIf config.autoResize [ "x-nixos.autoresize" ];
# -F needed to allow bare block device without partitions
@@ -151,7 +151,7 @@ in
"/bigdisk".label = "bigdisk";
}
'';
- type = types.loaOf (types.submodule fileSystemOpts);
+ type = types.loaOf (types.submodule [coreFileSystemOpts fileSystemOpts]);
description = ''
The file systems to be mounted. It must include an entry for
the root directory (<literal>mountPoint = "/"</literal>). Each
@@ -183,6 +183,15 @@ in
description = "Names of supported filesystem types.";
};
+ boot.specialFileSystems = mkOption {
+ default = {};
+ type = types.loaOf (types.submodule coreFileSystemOpts);
+ internal = true;
+ description = ''
+ Special filesystems that are mounted very early during boot.
+ '';
+ };
+
};
@@ -196,14 +205,11 @@ in
{ assertion = ! (fileSystems' ? "cycle");
message = "The ‘fileSystems’ option can't be topologically sorted: mountpoint dependency path ${ls " -> " fileSystems'.cycle} loops to ${ls ", " fileSystems'.loops}";
}
- { assertion = all (x: !x.early || (x.label == null && !x.autoFormat && !x.autoResize)) fileSystems;
- message = "Early filesystems don't support mounting by label, auto formatting and resizing";
- }
];
# Export for use in other modules
system.build.fileSystems = fileSystems;
- system.build.earlyMountScript = makeSpecialMounts (filter (fs: fs.early) fileSystems);
+ system.build.earlyMountScript = makeSpecialMounts (toposort fsBefore (attrValues config.boot.specialFileSystems)).result;
boot.supportedFilesystems = map (fs: fs.fsType) fileSystems;
@@ -234,7 +240,7 @@ in
+ " " + (if skipCheck fs then "0" else
if fs.mountPoint == "/" then "1" else "2")
+ "\n"
- ) (filter (fs: !fs.early) fileSystems)}
+ ) fileSystems}
# Swap devices.
${flip concatMapStrings config.swapDevices (sw:
@@ -282,7 +288,7 @@ in
in listToAttrs (map formatDevice (filter (fs: fs.autoFormat) fileSystems));
# Sync mount options with systemd's src/core/mount-setup.c: mount_table.
- fileSystems = mapAttrs (n: fs: fs // { early = true; }) {
+ boot.specialFileSystems = {
"/proc" = { fsType = "proc"; options = [ "nosuid" "noexec" "nodev" ]; };
"/sys" = { fsType = "sysfs"; options = [ "nosuid" "noexec" "nodev" ]; };
"/run" = { fsType = "tmpfs"; options = [ "nosuid" "nodev" "strictatime" "mode=755" "size=${config.boot.runSize}" ]; };