Parameterise ssd module

This commit is contained in:
Simon Bruder 2020-12-05 15:33:36 +01:00
parent f718f79192
commit ab39c6035c
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
4 changed files with 33 additions and 4 deletions

View file

@ -6,7 +6,6 @@
./hardware-configuration.nix
../../modules/cpu/intel.nix
../../modules/gpu/intel.nix
../../modules/ssd.nix
../../modules/libvirt.nix
../../modules
../../profiles/dev.nix
@ -16,6 +15,7 @@
sbruder = {
gui = true;
restic.enable = true;
ssd.enable = true;
wireguard.home = {
enable = true;
address = "10.80.0.4";

View file

@ -7,7 +7,6 @@
../../modules/cpu/intel.nix
../../modules/gpu/amd.nix
../../modules/libvirt.nix
../../modules/ssd.nix
../../modules
../../profiles/dev.nix
../../users/simon
@ -16,6 +15,7 @@
sbruder = {
gui = true;
restic.enable = true;
ssd.enable = true;
wireguard.home = {
enable = true;
address = "10.80.0.5";

View file

@ -22,6 +22,7 @@
./prometheus/node_exporter.nix
./pulseaudio.nix
./restic.nix
./ssd.nix
./ssh.nix
./sway.nix
./tools.nix

View file

@ -1,4 +1,32 @@
{ config, lib, ... }:
let
cfg = config.sbruder.ssd;
in
{
fileSystems."/".options = [ "noatime" "nodiratime" "discard" ];
options.sbruder.ssd = {
enable = lib.mkEnableOption "ssd optimisations";
fileSystems = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "/" ];
description = "List of file systems to apply optimisations to";
};
};
config = lib.mkIf cfg.enable {
fileSystems = builtins.listToAttrs
(builtins.map
(fs: {
name = fs;
value = {
options = [
"discard"
"noatime"
"nodiratime"
];
};
})
cfg.fileSystems);
services.fstrim.enable = true;
};
}