Modularize hardware config and remove specific nix folder
This commit is contained in:
parent
a5042bb645
commit
9ac5b25036
72 changed files with 322 additions and 100 deletions
69
modules/programs/drives.nix
Normal file
69
modules/programs/drives.nix
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
{ lib, config, options, ... }:
|
||||
let
|
||||
|
||||
driveModule = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The path of the drive.
|
||||
Note that a / is already added at the beginning.
|
||||
'';
|
||||
default = "";
|
||||
example = "drive2";
|
||||
};
|
||||
drive = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.anything;
|
||||
description = "The attrs of the drive";
|
||||
default = { };
|
||||
example = {
|
||||
device = "/dev/disk/by-label/DRIVE2";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"nodiratime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.mods = {
|
||||
extraDrives =
|
||||
lib.mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
{
|
||||
name = "drive2";
|
||||
drive = {
|
||||
device = "/dev/disk/by-label/DRIVE2";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"nodiratime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
}
|
||||
];
|
||||
# TODO: how to make this work
|
||||
# type = with lib.types; listOf (attrsOf driveModule);
|
||||
type = with lib.types; listOf (attrsOf anything);
|
||||
description = ''
|
||||
Extra drives to add.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = (lib.optionalAttrs (options?fileSystems) {
|
||||
fileSystems = builtins.listToAttrs
|
||||
(map
|
||||
({ name, drive }: {
|
||||
name = "/" + name;
|
||||
value = drive;
|
||||
})
|
||||
config.mods.extraDrives);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue