Turn fileSystems into an attribute set
So now you can write fileSystems = [ { mountPoint = "/"; device = "/dev/sda1"; } ]; as fileSystems."/".device = "/dev/sda1";
This commit is contained in:
parent
97f087cd44
commit
458f36f5f1
|
@ -230,11 +230,7 @@ $ reboot</screen>
|
|||
{
|
||||
boot.loader.grub.device = "/dev/sda";
|
||||
|
||||
fileSystems =
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
}
|
||||
];
|
||||
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||
|
||||
swapDevices =
|
||||
[ { device = "/dev/disk/by-label/swap"; } ];
|
||||
|
|
|
@ -184,17 +184,13 @@ in
|
|||
# Note that /dev/root is a symlink to the actual root device
|
||||
# specified on the kernel command line, created in the stage 1 init
|
||||
# script.
|
||||
fileSystems =
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/root";
|
||||
}
|
||||
{ mountPoint = "/nix/store";
|
||||
fsType = "squashfs";
|
||||
device = "/nix-store.squashfs";
|
||||
options = "loop";
|
||||
neededForBoot = true;
|
||||
}
|
||||
];
|
||||
fileSystems."/".device = "/dev/root";
|
||||
|
||||
fileSystems."/nix/store" =
|
||||
{ fsType = "squashfs";
|
||||
device = "/nix-store.squashfs";
|
||||
options = "loop";
|
||||
};
|
||||
|
||||
# We need squashfs in the initrd to mount the compressed Nix store,
|
||||
# and aufs to make the root filesystem appear writable.
|
||||
|
|
|
@ -239,17 +239,14 @@ if $generate; then
|
|||
# Add filesystem entries for each partition that you want to see
|
||||
# mounted at boot time. This should include at least the root
|
||||
# filesystem.
|
||||
fileSystems =
|
||||
[ # { mountPoint = "/";
|
||||
# device = "/dev/disk/by-label/nixos";
|
||||
# }
|
||||
|
||||
# { mountPoint = "/data"; # where you want to mount the device
|
||||
# device = "/dev/sdb"; # the device
|
||||
# fsType = "ext3"; # the type of the partition
|
||||
# options = "data=journal";
|
||||
# }
|
||||
];
|
||||
# fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||
|
||||
# fileSystems."/data" = # where you want to mount the device
|
||||
# { device = "/dev/sdb"; # the device
|
||||
# fsType = "ext3"; # the type of the partition
|
||||
# options = "data=journal";
|
||||
# };
|
||||
|
||||
# List swap partitions activated at boot time.
|
||||
swapDevices =
|
||||
|
|
|
@ -99,9 +99,12 @@ let
|
|||
options.neededForBoot = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "
|
||||
Mount this file system to boot on NixOS.
|
||||
";
|
||||
description = ''
|
||||
If set, this file system will be mounted in the initial
|
||||
ramdisk. By default, this applies to the root file system
|
||||
and to the file system containing
|
||||
<filename>/nix/store</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -236,8 +239,8 @@ let
|
|||
# booting (such as the FS containing /nix/store, or an FS needed for
|
||||
# mounting /, like / on a loopback).
|
||||
fileSystems = filter
|
||||
(fs: fs.mountPoint == "/" || fs.neededForBoot)
|
||||
config.fileSystems;
|
||||
(fs: fs.mountPoint == "/" || fs.mountPoint == "/nix" || fs.mountPoint == "/nix/store" || fs.neededForBoot)
|
||||
(attrValues config.fileSystems);
|
||||
|
||||
|
||||
udevRules = pkgs.stdenv.mkDerivation {
|
||||
|
|
|
@ -5,12 +5,14 @@ with utils;
|
|||
|
||||
let
|
||||
|
||||
fileSystems = attrValues config.fileSystems;
|
||||
|
||||
fstab = pkgs.writeText "fstab"
|
||||
''
|
||||
# This is a generated file. Do not edit!
|
||||
|
||||
# Filesystems.
|
||||
${flip concatMapStrings config.fileSystems (fs:
|
||||
${flip concatMapStrings fileSystems (fs:
|
||||
(if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}")
|
||||
+ " " + fs.mountPoint
|
||||
+ " " + fs.fsType
|
||||
|
@ -27,6 +29,70 @@ let
|
|||
)}
|
||||
'';
|
||||
|
||||
fileSystemOpts = { name, ... }: {
|
||||
|
||||
options = {
|
||||
|
||||
mountPoint = mkOption {
|
||||
example = "/mnt/usb";
|
||||
type = types.uniq types.string;
|
||||
description = "Location of the mounted the file system.";
|
||||
};
|
||||
|
||||
device = mkOption {
|
||||
default = null;
|
||||
example = "/dev/sda";
|
||||
type = types.uniq (types.nullOr types.string);
|
||||
description = "Location of the device.";
|
||||
};
|
||||
|
||||
label = mkOption {
|
||||
default = null;
|
||||
example = "root-partition";
|
||||
type = types.uniq (types.nullOr types.string);
|
||||
description = "Label of the device (if any).";
|
||||
};
|
||||
|
||||
fsType = mkOption {
|
||||
default = "auto";
|
||||
example = "ext3";
|
||||
type = types.uniq types.string;
|
||||
description = "Type of the file system.";
|
||||
};
|
||||
|
||||
options = mkOption {
|
||||
default = "defaults,relatime";
|
||||
example = "data=journal";
|
||||
type = types.string;
|
||||
merge = pkgs.lib.concatStringsSep ",";
|
||||
description = "Options used to mount the file system.";
|
||||
};
|
||||
|
||||
autoFormat = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
If the device does not currently contain a filesystem (as
|
||||
determined by <command>blkid</command>, then automatically
|
||||
format it with the filesystem type specified in
|
||||
<option>fsType</option>. Use with caution.
|
||||
'';
|
||||
};
|
||||
|
||||
noCheck = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Disable running fsck on this filesystem.";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
mountPoint = mkDefault name;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -36,20 +102,17 @@ in
|
|||
options = {
|
||||
|
||||
fileSystems = mkOption {
|
||||
example = [
|
||||
{ mountPoint = "/";
|
||||
device = "/dev/hda1";
|
||||
}
|
||||
{ mountPoint = "/data";
|
||||
example = {
|
||||
"/".device = "/dev/hda1";
|
||||
"/data" = {
|
||||
device = "/dev/hda2";
|
||||
fsType = "ext3";
|
||||
options = "data=journal";
|
||||
}
|
||||
{ mountPoint = "/bigdisk";
|
||||
label = "bigdisk";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
"/bigdisk".label = "bigdisk";
|
||||
};
|
||||
type = types.loaOf types.optionSet;
|
||||
options = [ fileSystemOpts ];
|
||||
description = ''
|
||||
The file systems to be mounted. It must include an entry for
|
||||
the root directory (<literal>mountPoint = \"/\"</literal>). Each
|
||||
|
@ -66,63 +129,6 @@ in
|
|||
systems that support it, such as ext2/ext3 (see <command>mke2fs
|
||||
-L</command>).
|
||||
'';
|
||||
|
||||
type = types.list types.optionSet;
|
||||
|
||||
options = {
|
||||
|
||||
mountPoint = mkOption {
|
||||
example = "/mnt/usb";
|
||||
type = types.uniq types.string;
|
||||
description = "Location of the mounted the file system.";
|
||||
};
|
||||
|
||||
device = mkOption {
|
||||
default = null;
|
||||
example = "/dev/sda";
|
||||
type = types.uniq (types.nullOr types.string);
|
||||
description = "Location of the device.";
|
||||
};
|
||||
|
||||
label = mkOption {
|
||||
default = null;
|
||||
example = "root-partition";
|
||||
type = types.uniq (types.nullOr types.string);
|
||||
description = "Label of the device (if any).";
|
||||
};
|
||||
|
||||
fsType = mkOption {
|
||||
default = "auto";
|
||||
example = "ext3";
|
||||
type = types.uniq types.string;
|
||||
description = "Type of the file system.";
|
||||
};
|
||||
|
||||
options = mkOption {
|
||||
default = "defaults,relatime";
|
||||
example = "data=journal";
|
||||
type = types.string;
|
||||
merge = pkgs.lib.concatStringsSep ",";
|
||||
description = "Options used to mount the file system.";
|
||||
};
|
||||
|
||||
autoFormat = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
If the device does not currently contain a filesystem (as
|
||||
determined by <command>blkid</command>, then automatically
|
||||
format it with the filesystem type specified in
|
||||
<option>fsType</option>. Use with caution.
|
||||
'';
|
||||
};
|
||||
|
||||
noCheck = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Disable running fsck on this filesystem.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
system.fsPackages = mkOption {
|
||||
|
@ -152,12 +158,11 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
boot.supportedFilesystems =
|
||||
map (fs: fs.fsType) config.fileSystems;
|
||||
boot.supportedFilesystems = map (fs: fs.fsType) fileSystems;
|
||||
|
||||
boot.initrd.supportedFilesystems =
|
||||
map (fs: fs.fsType)
|
||||
(filter (fs: fs.mountPoint == "/" || fs.neededForBoot) config.fileSystems);
|
||||
(filter (fs: fs.mountPoint == "/" || fs.neededForBoot) fileSystems);
|
||||
|
||||
# Add the mount helpers to the system path so that `mount' can find them.
|
||||
system.fsPackages = [ pkgs.dosfstools ];
|
||||
|
@ -207,7 +212,7 @@ in
|
|||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
|
||||
in listToAttrs (map formatDevice (filter (fs: fs.autoFormat) config.fileSystems));
|
||||
in listToAttrs (map formatDevice (filter (fs: fs.autoFormat) fileSystems));
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -62,11 +62,7 @@ with pkgs.lib;
|
|||
''
|
||||
);
|
||||
|
||||
fileSystems =
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
}
|
||||
];
|
||||
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||
|
||||
boot.initrd.kernelModules = [ "xen-blkfront" "aufs" ];
|
||||
boot.kernelModules = [ "xen-netfront" ];
|
||||
|
|
|
@ -68,11 +68,7 @@ with pkgs.lib;
|
|||
''
|
||||
);
|
||||
|
||||
fileSystems =
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
}
|
||||
];
|
||||
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||
|
||||
boot.kernelParams = [ "console=ttyS0" ];
|
||||
|
||||
|
|
|
@ -320,35 +320,33 @@ in
|
|||
# where the regular value for the `fileSystems' attribute should be
|
||||
# disregarded for the purpose of building a VM test image (since
|
||||
# those filesystems don't exist in the VM).
|
||||
fileSystems = mkOverride 50 (
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/vda";
|
||||
}
|
||||
{ mountPoint = "/nix/store";
|
||||
device = "//10.0.2.4/store";
|
||||
fsType = "cifs";
|
||||
options = "guest,sec=none,noperm,noacl";
|
||||
neededForBoot = true;
|
||||
}
|
||||
{ mountPoint = "/tmp/xchg";
|
||||
device = "//10.0.2.4/xchg";
|
||||
fsType = "cifs";
|
||||
options = "guest,sec=none,noperm,noacl";
|
||||
neededForBoot = true;
|
||||
}
|
||||
{ mountPoint = "/tmp/shared";
|
||||
device = "//10.0.2.4/shared";
|
||||
fsType = "cifs";
|
||||
options = "guest,sec=none,noperm,noacl";
|
||||
neededForBoot = true;
|
||||
}
|
||||
] ++ optional cfg.useBootLoader
|
||||
{ mountPoint = "/boot";
|
||||
device = "/dev/disk/by-label/boot";
|
||||
fsType = "ext4";
|
||||
options = "ro";
|
||||
noCheck = true; # fsck fails on a r/o filesystem
|
||||
});
|
||||
fileSystems =
|
||||
{ "/".device = "/dev/vda";
|
||||
"/nix/store" =
|
||||
{ device = "//10.0.2.4/store";
|
||||
fsType = "cifs";
|
||||
options = "guest,sec=none,noperm,noacl";
|
||||
};
|
||||
"/tmp/xchg" =
|
||||
{ device = "//10.0.2.4/xchg";
|
||||
fsType = "cifs";
|
||||
options = "guest,sec=none,noperm,noacl";
|
||||
neededForBoot = true;
|
||||
};
|
||||
"/tmp/shared" =
|
||||
{ device = "//10.0.2.4/shared";
|
||||
fsType = "cifs";
|
||||
options = "guest,sec=none,noperm,noacl";
|
||||
neededForBoot = true;
|
||||
};
|
||||
} // optionalAttrs cfg.useBootLoader
|
||||
{ "/boot" =
|
||||
{ device = "/dev/disk/by-label/boot";
|
||||
fsType = "ext4";
|
||||
options = "ro";
|
||||
noCheck = true; # fsck fails on a r/o filesystem
|
||||
};
|
||||
};
|
||||
|
||||
swapDevices = mkOverride 50 [ ];
|
||||
|
||||
|
|
|
@ -71,11 +71,7 @@ with pkgs.lib;
|
|||
''
|
||||
);
|
||||
|
||||
fileSystems =
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
}
|
||||
];
|
||||
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||
|
||||
boot.loader.grub.version = 2;
|
||||
boot.loader.grub.device = "/dev/sda";
|
||||
|
|
Loading…
Reference in a new issue