mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
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
9 changed files with 131 additions and 148 deletions
|
@ -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";
|
||||
fileSystems."/".device = "/dev/root";
|
||||
|
||||
fileSystems."/nix/store" =
|
||||
{ fsType = "squashfs";
|
||||
device = "/nix-store.squashfs";
|
||||
options = "loop";
|
||||
neededForBoot = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# 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
|
||||
# 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,47 +29,7 @@ let
|
|||
)}
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
fileSystems = mkOption {
|
||||
example = [
|
||||
{ mountPoint = "/";
|
||||
device = "/dev/hda1";
|
||||
}
|
||||
{ mountPoint = "/data";
|
||||
device = "/dev/hda2";
|
||||
fsType = "ext3";
|
||||
options = "data=journal";
|
||||
}
|
||||
{ mountPoint = "/bigdisk";
|
||||
label = "bigdisk";
|
||||
}
|
||||
];
|
||||
|
||||
description = ''
|
||||
The file systems to be mounted. It must include an entry for
|
||||
the root directory (<literal>mountPoint = \"/\"</literal>). Each
|
||||
entry in the list is an attribute set with the following fields:
|
||||
<literal>mountPoint</literal>, <literal>device</literal>,
|
||||
<literal>fsType</literal> (a file system type recognised by
|
||||
<command>mount</command>; defaults to
|
||||
<literal>\"auto\"</literal>), and <literal>options</literal>
|
||||
(the mount options passed to <command>mount</command> using the
|
||||
<option>-o</option> flag; defaults to <literal>\"defaults\"</literal>).
|
||||
|
||||
Instead of specifying <literal>device</literal>, you can also
|
||||
specify a volume label (<literal>label</literal>) for file
|
||||
systems that support it, such as ext2/ext3 (see <command>mke2fs
|
||||
-L</command>).
|
||||
'';
|
||||
|
||||
type = types.list types.optionSet;
|
||||
fileSystemOpts = { name, ... }: {
|
||||
|
||||
options = {
|
||||
|
||||
|
@ -122,7 +84,51 @@ in
|
|||
type = types.bool;
|
||||
description = "Disable running fsck on this filesystem.";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
mountPoint = mkDefault name;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
fileSystems = mkOption {
|
||||
example = {
|
||||
"/".device = "/dev/hda1";
|
||||
"/data" = {
|
||||
device = "/dev/hda2";
|
||||
fsType = "ext3";
|
||||
options = "data=journal";
|
||||
};
|
||||
"/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
|
||||
entry in the list is an attribute set with the following fields:
|
||||
<literal>mountPoint</literal>, <literal>device</literal>,
|
||||
<literal>fsType</literal> (a file system type recognised by
|
||||
<command>mount</command>; defaults to
|
||||
<literal>\"auto\"</literal>), and <literal>options</literal>
|
||||
(the mount options passed to <command>mount</command> using the
|
||||
<option>-o</option> flag; defaults to <literal>\"defaults\"</literal>).
|
||||
|
||||
Instead of specifying <literal>device</literal>, you can also
|
||||
specify a volume label (<literal>label</literal>) for file
|
||||
systems that support it, such as ext2/ext3 (see <command>mke2fs
|
||||
-L</command>).
|
||||
'';
|
||||
};
|
||||
|
||||
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";
|
||||
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;
|
||||
}
|
||||
{ mountPoint = "/tmp/xchg";
|
||||
device = "//10.0.2.4/xchg";
|
||||
};
|
||||
"/tmp/shared" =
|
||||
{ device = "//10.0.2.4/shared";
|
||||
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";
|
||||
};
|
||||
} // 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…
Add table
Add a link
Reference in a new issue