filesystems: use list of strings for fs options
Allow usage of list of strings instead of a comma-separated string for filesystem options. Deprecate the comma-separated string style with a warning message; convert this to a hard error after 16.09. 15.09 was just released, so this provides a deprecation period during the 16.03 release. closes #10518 Signed-off-by: Robin Gloster <mail@glob.in>
This commit is contained in:
parent
f7aa921773
commit
3c5fca9618
|
@ -157,7 +157,7 @@ boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 60;
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{ device = "/dev/sda1";
|
{ device = "/dev/sda1";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
options = "rw,data=ordered,relatime";
|
options = [ "rw" "data=ordered" "relatime" ];
|
||||||
};
|
};
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
|
@ -165,13 +165,13 @@ look like this:
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{ device = "/dev/disk/by-label/nixos";
|
{ device = "/dev/disk/by-label/nixos";
|
||||||
fsType = "ext3";
|
fsType = "ext3";
|
||||||
options = "rw,data=ordered,relatime";
|
options = [ "rw" "data=ordered" "relatime" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{ device = "/dev/sda1";
|
{ device = "/dev/sda1";
|
||||||
fsType = "ext3";
|
fsType = "ext3";
|
||||||
options = "rw,errors=continue,user_xattr,acl,barrier=1,data=writeback,relatime";
|
options = [ "rw" "errors=continue" "user_xattr" "acl" "barrier=1" "data=writeback" "relatime" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
swapDevices =
|
swapDevices =
|
||||||
|
|
|
@ -155,6 +155,23 @@ nginx.override {
|
||||||
rights, new <literal>aliasFiles</literal> and <literal>mapFiles</literal>
|
rights, new <literal>aliasFiles</literal> and <literal>mapFiles</literal>
|
||||||
options and more.</para>
|
options and more.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Filesystem options should now be configured as a list of strings, not
|
||||||
|
a comma-separated string. The old style will continue to work, but print a
|
||||||
|
warning, until the 16.09 release. An example of the new style:
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
fileSystems."/example" = {
|
||||||
|
device = "/dev/sdc";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [ "noatime" "compress=lzo" "space_cache" "autodefrag" ];
|
||||||
|
};
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ in
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{ fsType = "tmpfs";
|
{ fsType = "tmpfs";
|
||||||
options = "mode=0755";
|
options = [ "mode=0755" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Note that /dev/root is a symlink to the actual root device
|
# Note that /dev/root is a symlink to the actual root device
|
||||||
|
@ -266,20 +266,20 @@ in
|
||||||
fileSystems."/nix/.ro-store" =
|
fileSystems."/nix/.ro-store" =
|
||||||
{ fsType = "squashfs";
|
{ fsType = "squashfs";
|
||||||
device = "/iso/nix-store.squashfs";
|
device = "/iso/nix-store.squashfs";
|
||||||
options = "loop";
|
options = [ "loop" ];
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/nix/.rw-store" =
|
fileSystems."/nix/.rw-store" =
|
||||||
{ fsType = "tmpfs";
|
{ fsType = "tmpfs";
|
||||||
options = "mode=0755";
|
options = [ "mode=0755" ];
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/nix/store" =
|
fileSystems."/nix/store" =
|
||||||
{ fsType = "unionfs-fuse";
|
{ fsType = "unionfs-fuse";
|
||||||
device = "unionfs";
|
device = "unionfs";
|
||||||
options = "allow_other,cow,nonempty,chroot=/mnt-root,max_files=32768,hide_meta_files,dirs=/nix/.rw-store=rw:/nix/.ro-store=ro";
|
options = [ "allow_other" "cow" "nonempty" "chroot=/mnt-root" "max_files=32768" "hide_meta_files" "dirs=/nix/.rw-store=rw:/nix/.ro-store=ro" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "usb-storage" ];
|
boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "usb-storage" ];
|
||||||
|
|
|
@ -349,7 +349,7 @@ foreach my $fs (read_file("/proc/self/mountinfo")) {
|
||||||
fileSystems.\"$mountPoint\" =
|
fileSystems.\"$mountPoint\" =
|
||||||
{ device = \"$base$path\";
|
{ device = \"$base$path\";
|
||||||
fsType = \"none\";
|
fsType = \"none\";
|
||||||
options = \"bind\";
|
options = \[ \"bind\" \];
|
||||||
};
|
};
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
@ -409,7 +409,7 @@ EOF
|
||||||
|
|
||||||
if (scalar @extraOptions > 0) {
|
if (scalar @extraOptions > 0) {
|
||||||
$fileSystems .= <<EOF;
|
$fileSystems .= <<EOF;
|
||||||
options = \"${\join ",", uniq(@extraOptions)}\";
|
options = \[ ${\join " ", map { "\"" . $_ . "\"" } uniq(@extraOptions)} \];
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ let
|
||||||
(filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
|
(filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
|
||||||
|
|
||||||
fsInfo =
|
fsInfo =
|
||||||
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ];
|
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType (builtins.concatStringsSep "," fs.options) ];
|
||||||
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
|
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
|
||||||
|
|
||||||
setHostId = optionalString (config.networking.hostId != null) ''
|
setHostId = optionalString (config.networking.hostId != null) ''
|
||||||
|
|
|
@ -41,11 +41,15 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
options = mkOption {
|
options = mkOption {
|
||||||
default = "defaults";
|
default = [ "defaults" ];
|
||||||
example = "data=journal";
|
example = [ "data=journal" ];
|
||||||
type = types.commas; # FIXME: should be a list
|
|
||||||
description = "Options used to mount the file system.";
|
description = "Options used to mount the file system.";
|
||||||
};
|
} // (if versionAtLeast lib.nixpkgsVersion "16.09" then {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
} else {
|
||||||
|
type = types.either types.commas (types.listOf types.str);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
autoFormat = mkOption {
|
autoFormat = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -112,7 +116,7 @@ in
|
||||||
"/data" = {
|
"/data" = {
|
||||||
device = "/dev/hda2";
|
device = "/dev/hda2";
|
||||||
fsType = "ext3";
|
fsType = "ext3";
|
||||||
options = "data=journal";
|
options = [ "data=journal" ];
|
||||||
};
|
};
|
||||||
"/bigdisk".label = "bigdisk";
|
"/bigdisk".label = "bigdisk";
|
||||||
};
|
};
|
||||||
|
@ -127,7 +131,7 @@ in
|
||||||
<command>mount</command>; defaults to
|
<command>mount</command>; defaults to
|
||||||
<literal>"auto"</literal>), and <literal>options</literal>
|
<literal>"auto"</literal>), and <literal>options</literal>
|
||||||
(the mount options passed to <command>mount</command> using the
|
(the mount options passed to <command>mount</command> using the
|
||||||
<option>-o</option> flag; defaults to <literal>"defaults"</literal>).
|
<option>-o</option> flag; defaults to <literal>[ "defaults" ]</literal>).
|
||||||
|
|
||||||
Instead of specifying <literal>device</literal>, you can also
|
Instead of specifying <literal>device</literal>, you can also
|
||||||
specify a volume label (<literal>label</literal>) for file
|
specify a volume label (<literal>label</literal>) for file
|
||||||
|
@ -177,7 +181,7 @@ in
|
||||||
else throw "No device specified for mount point ‘${fs.mountPoint}’.")
|
else throw "No device specified for mount point ‘${fs.mountPoint}’.")
|
||||||
+ " " + fs.mountPoint
|
+ " " + fs.mountPoint
|
||||||
+ " " + fs.fsType
|
+ " " + fs.fsType
|
||||||
+ " " + fs.options
|
+ " " + builtins.concatStringsSep "," fs.options
|
||||||
+ " 0"
|
+ " 0"
|
||||||
+ " " + (if skipCheck fs then "0" else
|
+ " " + (if skipCheck fs then "0" else
|
||||||
if fs.mountPoint == "/" then "1" else "2")
|
if fs.mountPoint == "/" then "1" else "2")
|
||||||
|
|
|
@ -427,38 +427,38 @@ in
|
||||||
${if cfg.writableStore then "/nix/.ro-store" else "/nix/store"} =
|
${if cfg.writableStore then "/nix/.ro-store" else "/nix/store"} =
|
||||||
{ device = "store";
|
{ device = "store";
|
||||||
fsType = "9p";
|
fsType = "9p";
|
||||||
options = "trans=virtio,version=9p2000.L,cache=loose";
|
options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ];
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
"/tmp/xchg" =
|
"/tmp/xchg" =
|
||||||
{ device = "xchg";
|
{ device = "xchg";
|
||||||
fsType = "9p";
|
fsType = "9p";
|
||||||
options = "trans=virtio,version=9p2000.L,cache=loose";
|
options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ];
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
"/tmp/shared" =
|
"/tmp/shared" =
|
||||||
{ device = "shared";
|
{ device = "shared";
|
||||||
fsType = "9p";
|
fsType = "9p";
|
||||||
options = "trans=virtio,version=9p2000.L";
|
options = [ "trans=virtio" "version=9p2000.L" ];
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
} // optionalAttrs cfg.writableStore
|
} // optionalAttrs cfg.writableStore
|
||||||
{ "/nix/store" =
|
{ "/nix/store" =
|
||||||
{ fsType = "unionfs-fuse";
|
{ fsType = "unionfs-fuse";
|
||||||
device = "unionfs";
|
device = "unionfs";
|
||||||
options = "allow_other,cow,nonempty,chroot=/mnt-root,max_files=32768,hide_meta_files,dirs=/nix/.rw-store=rw:/nix/.ro-store=ro";
|
options = [ "allow_other" "cow" "nonempty" "chroot=/mnt-root" "max_files=32768" "hide_meta_files" "dirs=/nix/.rw-store=rw:/nix/.ro-store=ro" ];
|
||||||
};
|
};
|
||||||
} // optionalAttrs (cfg.writableStore && cfg.writableStoreUseTmpfs)
|
} // optionalAttrs (cfg.writableStore && cfg.writableStoreUseTmpfs)
|
||||||
{ "/nix/.rw-store" =
|
{ "/nix/.rw-store" =
|
||||||
{ fsType = "tmpfs";
|
{ fsType = "tmpfs";
|
||||||
options = "mode=0755";
|
options = [ "mode=0755" ];
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
} // optionalAttrs cfg.useBootLoader
|
} // optionalAttrs cfg.useBootLoader
|
||||||
{ "/boot" =
|
{ "/boot" =
|
||||||
{ device = "/dev/vdb2";
|
{ device = "/dev/vdb2";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
options = "ro";
|
options = [ "ro" ];
|
||||||
noCheck = true; # fsck fails on a r/o filesystem
|
noCheck = true; # fsck fails on a r/o filesystem
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ import ./make-test.nix ({ pkgs, ...} : {
|
||||||
systemd.tmpfiles.rules = [ "d /tmp 1777 root root 10d" ];
|
systemd.tmpfiles.rules = [ "d /tmp 1777 root root 10d" ];
|
||||||
fileSystems = mkVMOverride { "/tmp2" =
|
fileSystems = mkVMOverride { "/tmp2" =
|
||||||
{ fsType = "tmpfs";
|
{ fsType = "tmpfs";
|
||||||
options = "mode=1777,noauto";
|
options = [ "mode=1777" "noauto" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.automounts = singleton
|
systemd.automounts = singleton
|
||||||
|
|
|
@ -8,7 +8,7 @@ let
|
||||||
[ { mountPoint = "/data";
|
[ { mountPoint = "/data";
|
||||||
device = "server:/data";
|
device = "server:/data";
|
||||||
fsType = "nfs";
|
fsType = "nfs";
|
||||||
options = "vers=${toString version}";
|
options = [ "vers=${toString version}" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
networking.firewall.enable = false; # FIXME: only open statd
|
networking.firewall.enable = false; # FIXME: only open statd
|
||||||
|
|
Loading…
Reference in a new issue