storage-refactor #9
1 changed files with 63 additions and 7 deletions
|
|
@ -1,9 +1,13 @@
|
|||
args @ {lib, ...}: let
|
||||
args @ {
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
datasetSubmodule = (import ./submodules/dataset.nix) args;
|
||||
in {
|
||||
options.storage = {
|
||||
zfs = {
|
||||
# TODO: enable option implementation
|
||||
enable = lib.mkEnableOption "Should zfs be enabled on this system.";
|
||||
|
||||
notifications = {
|
||||
|
|
@ -30,10 +34,6 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
# TODO: we need options to configure zfs pools
|
||||
# we should have warnings when the configured pool is missing drives after activation
|
||||
# TODO: implementation of this
|
||||
# TODO: validations that we have at least one boot drive
|
||||
pool = let
|
||||
deviceType =
|
||||
lib.types.coercedTo lib.types.str (device: {
|
||||
|
|
@ -64,4 +64,60 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.storage.zfs.enable (lib.mkMerge [
|
||||
{
|
||||
services.zfs = {
|
||||
autoScrub.enable = true;
|
||||
autoSnapshot.enable = true;
|
||||
};
|
||||
|
||||
# TODO: post activation script that makes sure that our configured pool match the pool that exist on the system
|
||||
# TODO: validation that we have a boot drive
|
||||
# TODO: disko config mapping
|
||||
}
|
||||
(lib.mkIf config.storage.zfs.notifications.enable {
|
||||
programs.msmtp = {
|
||||
enable = true;
|
||||
setSendmail = true;
|
||||
defaults = {
|
||||
aliases = "/etc/aliases";
|
||||
port = config.storage.zfs.notifications.port;
|
||||
tls_trust_file = "/etc/ssl/certs/ca-certificates.crt";
|
||||
tls = "on";
|
||||
auth = "login";
|
||||
tls_starttls = "off";
|
||||
};
|
||||
accounts = {
|
||||
zfs_notifications = {
|
||||
auth = true;
|
||||
tls = true;
|
||||
host = config.storage.zfs.notifications.host;
|
||||
passwordeval = "cat ${config.storage.zfs.notifications.tokenFile}";
|
||||
user = config.storage.zfs.notifications.user;
|
||||
from = config.storage.zfs.notifications.user;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.zfs = {
|
||||
zed = {
|
||||
enableMail = true;
|
||||
|
||||
settings = {
|
||||
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
|
||||
ZED_EMAIL_ADDR = [config.storage.zfs.notifications.to];
|
||||
ZED_EMAIL_PROG = "${pkgs.msmtp}/bin/msmtp";
|
||||
ZED_EMAIL_OPTS = "-a zfs_notifications @ADDRESS@";
|
||||
|
||||
ZED_NOTIFY_INTERVAL_SECS = 3600;
|
||||
ZED_NOTIFY_VERBOSE = true;
|
||||
|
||||
ZED_USE_ENCLOSURE_LEDS = true;
|
||||
ZED_SCRUB_AFTER_RESILVER = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue