nixos-config/modules/common/filesystem.nix

68 lines
1.3 KiB
Nix
Raw Normal View History

{ lib, config, ... }:
with lib;
let
fsModule = types.submodule {
options = {
mountpoint = mkOption {
type = types.str;
description = ''
The filesystem mountpoint.
'';
};
deviceUUID = mkOption {
type = types.str;
description = ''
The volume UUID.
'';
};
fsType = mkOption {
type = types.str;
description = ''
The volume filesystem.
'';
};
};
};
in
{
options.filesystems = mkOption {
type = types.listOf fsModule;
default = [ ];
example = [
{
mountpoint = "/";
deviceUUID = "XXXXX-YYYYYY-AJDKKSKSJ";
fsType = "ext4";
}
];
description = ''
The machine filesystem tree description.
'';
};
options.swapDeviceUUID = mkOption {
type = types.nullOr types.str;
default = null;
};
config = {
fileSystems = builtins.listToAttrs (map
(fs: {
name = fs.mountpoint;
value = {
device = "/dev/disk/by-uuid/${fs.deviceUUID}";
fsType = fs.fsType;
};
})
config.filesystems);
swapDevices = mkIf (config.swapDeviceUUID != null) [
{ device = "/dev/disk/by-uuid/${config.swapDeviceUUID}"; }
];
};
}