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>

authored by

Aneesh Agrawal and committed by
Robin Gloster
3c5fca96 f7aa9217

+46 -25
+1 -1
nixos/doc/manual/configuration/config-file.xml
··· 157 157 fileSystems."/boot" = 158 158 { device = "/dev/sda1"; 159 159 fsType = "ext4"; 160 - options = "rw,data=ordered,relatime"; 160 + options = [ "rw" "data=ordered" "relatime" ]; 161 161 }; 162 162 </programlisting> 163 163 </para>
+2 -2
nixos/doc/manual/man-nixos-generate-config.xml
··· 165 165 fileSystems."/" = 166 166 { device = "/dev/disk/by-label/nixos"; 167 167 fsType = "ext3"; 168 - options = "rw,data=ordered,relatime"; 168 + options = [ "rw" "data=ordered" "relatime" ]; 169 169 }; 170 170 171 171 fileSystems."/boot" = 172 172 { device = "/dev/sda1"; 173 173 fsType = "ext3"; 174 - options = "rw,errors=continue,user_xattr,acl,barrier=1,data=writeback,relatime"; 174 + options = [ "rw" "errors=continue" "user_xattr" "acl" "barrier=1" "data=writeback" "relatime" ]; 175 175 }; 176 176 177 177 swapDevices =
+17
nixos/doc/manual/release-notes/rl-unstable.xml
··· 155 155 rights, new <literal>aliasFiles</literal> and <literal>mapFiles</literal> 156 156 options and more.</para> 157 157 </listitem> 158 + 159 + <listitem> 160 + <para>Filesystem options should now be configured as a list of strings, not 161 + a comma-separated string. The old style will continue to work, but print a 162 + warning, until the 16.09 release. An example of the new style: 163 + 164 + <programlisting> 165 + fileSystems."/example" = { 166 + device = "/dev/sdc"; 167 + fsType = "btrfs"; 168 + options = [ "noatime" "compress=lzo" "space_cache" "autodefrag" ]; 169 + }; 170 + </programlisting> 171 + 172 + </para> 173 + </listitem> 174 + 158 175 </itemizedlist> 159 176 160 177
+4 -4
nixos/modules/installer/cd-dvd/iso-image.nix
··· 249 249 250 250 fileSystems."/" = 251 251 { fsType = "tmpfs"; 252 - options = "mode=0755"; 252 + options = [ "mode=0755" ]; 253 253 }; 254 254 255 255 # Note that /dev/root is a symlink to the actual root device ··· 266 266 fileSystems."/nix/.ro-store" = 267 267 { fsType = "squashfs"; 268 268 device = "/iso/nix-store.squashfs"; 269 - options = "loop"; 269 + options = [ "loop" ]; 270 270 neededForBoot = true; 271 271 }; 272 272 273 273 fileSystems."/nix/.rw-store" = 274 274 { fsType = "tmpfs"; 275 - options = "mode=0755"; 275 + options = [ "mode=0755" ]; 276 276 neededForBoot = true; 277 277 }; 278 278 279 279 fileSystems."/nix/store" = 280 280 { fsType = "unionfs-fuse"; 281 281 device = "unionfs"; 282 - options = "allow_other,cow,nonempty,chroot=/mnt-root,max_files=32768,hide_meta_files,dirs=/nix/.rw-store=rw:/nix/.ro-store=ro"; 282 + options = [ "allow_other" "cow" "nonempty" "chroot=/mnt-root" "max_files=32768" "hide_meta_files" "dirs=/nix/.rw-store=rw:/nix/.ro-store=ro" ]; 283 283 }; 284 284 285 285 boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "usb-storage" ];
+2 -2
nixos/modules/installer/tools/nixos-generate-config.pl
··· 349 349 fileSystems.\"$mountPoint\" = 350 350 { device = \"$base$path\"; 351 351 fsType = \"none\"; 352 - options = \"bind\"; 352 + options = \[ \"bind\" \]; 353 353 }; 354 354 355 355 EOF ··· 409 409 410 410 if (scalar @extraOptions > 0) { 411 411 $fileSystems .= <<EOF; 412 - options = \"${\join ",", uniq(@extraOptions)}\"; 412 + options = \[ ${\join " ", map { "\"" . $_ . "\"" } uniq(@extraOptions)} \]; 413 413 EOF 414 414 } 415 415
+1 -1
nixos/modules/system/boot/stage-1.nix
··· 207 207 (filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices); 208 208 209 209 fsInfo = 210 - let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ]; 210 + 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) ]; 211 211 in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems)); 212 212 213 213 setHostId = optionalString (config.networking.hostId != null) ''
+11 -7
nixos/modules/tasks/filesystems.nix
··· 41 41 }; 42 42 43 43 options = mkOption { 44 - default = "defaults"; 45 - example = "data=journal"; 46 - type = types.commas; # FIXME: should be a list 44 + default = [ "defaults" ]; 45 + example = [ "data=journal" ]; 47 46 description = "Options used to mount the file system."; 48 - }; 47 + } // (if versionAtLeast lib.nixpkgsVersion "16.09" then { 48 + type = types.listOf types.str; 49 + } else { 50 + type = types.either types.commas (types.listOf types.str); 51 + 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); 52 + }); 49 53 50 54 autoFormat = mkOption { 51 55 default = false; ··· 112 116 "/data" = { 113 117 device = "/dev/hda2"; 114 118 fsType = "ext3"; 115 - options = "data=journal"; 119 + options = [ "data=journal" ]; 116 120 }; 117 121 "/bigdisk".label = "bigdisk"; 118 122 }; ··· 127 131 <command>mount</command>; defaults to 128 132 <literal>"auto"</literal>), and <literal>options</literal> 129 133 (the mount options passed to <command>mount</command> using the 130 - <option>-o</option> flag; defaults to <literal>"defaults"</literal>). 134 + <option>-o</option> flag; defaults to <literal>[ "defaults" ]</literal>). 131 135 132 136 Instead of specifying <literal>device</literal>, you can also 133 137 specify a volume label (<literal>label</literal>) for file ··· 177 181 else throw "No device specified for mount point ‘${fs.mountPoint}’.") 178 182 + " " + fs.mountPoint 179 183 + " " + fs.fsType 180 - + " " + fs.options 184 + + " " + builtins.concatStringsSep "," fs.options 181 185 + " 0" 182 186 + " " + (if skipCheck fs then "0" else 183 187 if fs.mountPoint == "/" then "1" else "2")
+6 -6
nixos/modules/virtualisation/qemu-vm.nix
··· 427 427 ${if cfg.writableStore then "/nix/.ro-store" else "/nix/store"} = 428 428 { device = "store"; 429 429 fsType = "9p"; 430 - options = "trans=virtio,version=9p2000.L,cache=loose"; 430 + options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ]; 431 431 neededForBoot = true; 432 432 }; 433 433 "/tmp/xchg" = 434 434 { device = "xchg"; 435 435 fsType = "9p"; 436 - options = "trans=virtio,version=9p2000.L,cache=loose"; 436 + options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ]; 437 437 neededForBoot = true; 438 438 }; 439 439 "/tmp/shared" = 440 440 { device = "shared"; 441 441 fsType = "9p"; 442 - options = "trans=virtio,version=9p2000.L"; 442 + options = [ "trans=virtio" "version=9p2000.L" ]; 443 443 neededForBoot = true; 444 444 }; 445 445 } // optionalAttrs cfg.writableStore 446 446 { "/nix/store" = 447 447 { fsType = "unionfs-fuse"; 448 448 device = "unionfs"; 449 - options = "allow_other,cow,nonempty,chroot=/mnt-root,max_files=32768,hide_meta_files,dirs=/nix/.rw-store=rw:/nix/.ro-store=ro"; 449 + options = [ "allow_other" "cow" "nonempty" "chroot=/mnt-root" "max_files=32768" "hide_meta_files" "dirs=/nix/.rw-store=rw:/nix/.ro-store=ro" ]; 450 450 }; 451 451 } // optionalAttrs (cfg.writableStore && cfg.writableStoreUseTmpfs) 452 452 { "/nix/.rw-store" = 453 453 { fsType = "tmpfs"; 454 - options = "mode=0755"; 454 + options = [ "mode=0755" ]; 455 455 neededForBoot = true; 456 456 }; 457 457 } // optionalAttrs cfg.useBootLoader 458 458 { "/boot" = 459 459 { device = "/dev/vdb2"; 460 460 fsType = "vfat"; 461 - options = "ro"; 461 + options = [ "ro" ]; 462 462 noCheck = true; # fsck fails on a r/o filesystem 463 463 }; 464 464 });
+1 -1
nixos/tests/misc.nix
··· 16 16 systemd.tmpfiles.rules = [ "d /tmp 1777 root root 10d" ]; 17 17 fileSystems = mkVMOverride { "/tmp2" = 18 18 { fsType = "tmpfs"; 19 - options = "mode=1777,noauto"; 19 + options = [ "mode=1777" "noauto" ]; 20 20 }; 21 21 }; 22 22 systemd.automounts = singleton
+1 -1
nixos/tests/nfs.nix
··· 8 8 [ { mountPoint = "/data"; 9 9 device = "server:/data"; 10 10 fsType = "nfs"; 11 - options = "vers=${toString version}"; 11 + options = [ "vers=${toString version}" ]; 12 12 } 13 13 ]; 14 14 networking.firewall.enable = false; # FIXME: only open statd