dotfiles/modules/os/core/fs/btrfs.nix
eriedaberrie e1fbf03dff Initial commit
Note: not the actual initial commit.

I swear I will stop repeatedly force pushing to this single commit eventually
ok.
2024-09-08 09:58:54 -07:00

34 lines
954 B
Nix

{ config, lib, ... }:
let
cfg = config.my.fs;
in {
config = lib.mkIf (cfg.type == "btrfs") {
fileSystems = builtins.mapAttrs (_: options: {
inherit (cfg) device;
fsType = "btrfs";
options = [ "noatime" "space_cache=v2" "compress=zstd:9" ]
++ options
++ lib.optional config.services.fstrim.enable "nodiscard";
}) ({
"/" = [ "subvol=root" ];
"/nix" = [ "subvol=nix" ];
"/home" = [ "subvol=home" ];
} // lib.optionalAttrs cfg.snapshots {
"/home/${config.my.user.username}/.cache" = [ "subvol=misc/cache" ];
"/home/${config.my.user.username}/no-snapshot" = [ "subvol=misc/other" ];
});
services = {
snapper = lib.mkIf cfg.snapshots {
configs.home = {
SUBVOLUME = "/home";
ALLOW_USERS = [ config.my.user.username ];
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
};
};
};
};
}