This commit is contained in:
Motiejus Jakštys 2024-12-02 19:48:26 +02:00
parent 4253e78b07
commit abb7513d57
4 changed files with 0 additions and 67 deletions

View File

@ -10,11 +10,9 @@ let
in
{
imports = [
./snapshot
./sshd
./unitstatus
./users
./zfs
];
options.mj = with lib.types; {

View File

@ -1,41 +0,0 @@
{ config, lib, ... }:
{
options.mj.base.snapshot = {
enable = lib.mkEnableOption "Enable zfs snapshots";
mountpoints = lib.mkOption {
default = { };
type = with lib.types; listOf str;
};
};
config = lib.mkIf config.mj.base.snapshot.enable {
services.sanoid = {
enable = true;
templates.prod = {
hourly = 24;
daily = 7;
autosnap = true;
autoprune = true;
};
extraArgs = [ "--verbose" ];
datasets =
let
fs_zfs = lib.filterAttrs (_: v: v.fsType == "zfs") config.fileSystems;
mountpoint2fs = builtins.listToAttrs (
map (mountpoint: {
name = mountpoint;
value = builtins.getAttr mountpoint fs_zfs;
}) config.mj.base.snapshot.mountpoints
);
s_datasets = lib.mapAttrs' (_mountpoint: fs: {
name = fs.device;
value = {
use_template = [ "prod" ];
};
}) mountpoint2fs;
in
s_datasets;
};
};
}

View File

@ -1,18 +0,0 @@
{ config, lib, ... }:
{
options.mj.base.zfs = with lib.types; {
enable = lib.mkEnableOption "Enable common zfs options";
};
config = lib.mkIf config.mj.base.zfs.enable {
# TODO
#services.zfs = assert lib.assertMsg (config.mj.base.unitstatus.enable "mj.base.unitstatus must be enabled"; {
services.zfs = {
autoScrub.enable = true;
trim.enable = true;
expandOnBoot = "all";
};
mj.base.unitstatus.units = [ "zfs-scrub" ];
};
}

View File

@ -61,18 +61,12 @@ in
};
public = defaults // {
#"path" = cfg.dataDir;
"path" = "/var/run/samba/dataDir";
"writeable" = "yes";
"read only" = "no";
"create mask" = "0664";
"directory mask" = "0775";
};
#snapshots = defaults // {
# "path" = cfg.dataDir + "/.zfs/snapshot";
# "writeable" = "no";
# "read only" = "yes";
#};
};
};