Reorganize for zfs
This commit is contained in:
parent
2933964680
commit
cfb48de40c
57 changed files with 817 additions and 492 deletions
56
modules/zfs.nix
Normal file
56
modules/zfs.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
options.custom.zfs = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
encrypted = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
systemLinks = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
{ path = "/var/lib/docker"; type = "cache"; }
|
||||
{ path = "/var/lib/docker/volumes"; type = "data"; }
|
||||
];
|
||||
};
|
||||
homeLinks = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
{ path = ".config/syncthing"; type = "data"; }
|
||||
{ path = ".cache/nix-index"; type = "cache"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config.boot = lib.mkIf config.custom.zfs.enable {
|
||||
supportedFilesystems = [ "zfs" ];
|
||||
zfs.requestEncryptionCredentials = config.custom.zfs.encrypted;
|
||||
initrd.postDeviceCommands = lib.mkAfter ''
|
||||
zfs rollback -r rpool/local/root@blank
|
||||
'';
|
||||
};
|
||||
|
||||
config.services.zfs.autoScrub.enable = config.custom.zfs.enable;
|
||||
config.services.zfs.trim.enable = config.custom.zfs.enable;
|
||||
|
||||
config.environment.etc = lib.mkIf config.custom.zfs.enable {
|
||||
nixos = { source = "/data/etc/nixos/"; };
|
||||
};
|
||||
|
||||
config.systemd.tmpfiles.rules = lib.mkIf config.custom.zfs.enable (
|
||||
[ "d /home/charlotte 0700 charlotte users - -" ] ++
|
||||
(map (location: "L ${location.path} - - - - /${location.type}${location.path}") config.custom.zfs.systemLinks)
|
||||
);
|
||||
|
||||
config.home-manager.users.charlotte = { ... }: {
|
||||
systemd.user.tmpfiles.rules = lib.mkIf config.custom.zfs.enable (
|
||||
map
|
||||
(location: "L /home/charlotte/${location.path} - - - - /${location.type}/home/charlotte/${location.path}")
|
||||
config.custom.zfs.homeLinks
|
||||
);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue