nix/container/Hdd.nix

71 lines
1.4 KiB
Nix
Raw Normal View History

2024-06-09 23:35:53 +03:00
# ISSUE: Broken, can't read/write sda device.
2024-06-25 04:04:39 +03:00
{ container, pkgs, config, lib, ... }: with lib; let
cfg = config.container.module.hdd;
2024-06-09 23:35:53 +03:00
in {
2024-06-25 04:04:39 +03:00
options = {
container.module.hdd = {
enable = mkEnableOption "Hdd health monitor.";
address = mkOption {
default = "10.1.0.10";
type = types.str;
};
port = mkOption {
default = 8080;
type = types.int;
};
domain = mkOption {
default = "hdd.${config.container.domain}";
type = types.str;
};
storage = mkOption {
default = "${config.container.storage}/hdd";
type = types.str;
};
};
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = container.mkContainerDir cfg [
"data"
];
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
containers.hdd = container.mkContainer cfg {
# bindMounts = let
# attachDrive = hostPath: {
# inherit hostPath;
# isReadOnly = false;
# };
# in {
# "/opt/scrutiny" = {
# hostPath = "${cfg.storage}/data";
# isReadOnly = false;
# };
# "/dev/sda" = attachDrive "/dev/sda";
# };
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
# allowedDevices = [
# {
# modifier = "rwm";
# node = "/dev/sda";
# }
# ];
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
# additionalCapabilities = [ "CAP_SYS_ADMIN" ];
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
config = { ... }: container.mkContainerConfig cfg {
environment.systemPackages = with pkgs; [ smartmontools ];
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
services.scrutiny = {
enable = true;
settings.web = {
listen = {
host = cfg.address;
port = cfg.port;
};
2024-06-09 23:35:53 +03:00
};
};
};
};
};
}