nix/container/Hdd.nix

80 lines
1.7 KiB
Nix
Raw Permalink Normal View History

2024-06-09 23:35:53 +03:00
# ISSUE: Broken, can't read/write sda device.
{
container,
pkgs,
config,
lib,
...
}:
with lib;
let
cfg = config.container.module.hdd;
in
{
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;
};
};
};
2024-06-25 04:04:39 +03:00
config = mkIf cfg.enable {
2024-10-14 04:51:19 +03:00
systemd.tmpfiles.rules = container.mkContainerDir cfg [ "data" ];
2024-06-09 23:35:53 +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
# allowedDevices = [
# {
# modifier = "rwm";
# node = "/dev/sda";
# }
# ];
2024-06-09 23:35:53 +03:00
# additionalCapabilities = [ "CAP_SYS_ADMIN" ];
2024-06-09 23:35:53 +03:00
config =
{ ... }:
container.mkContainerConfig cfg {
environment.systemPackages = with pkgs; [ smartmontools ];
2024-06-09 23:35:53 +03:00
services.scrutiny = {
enable = true;
settings.web = {
listen = {
host = cfg.address;
port = cfg.port;
};
};
};
};
};
};
2024-06-09 23:35:53 +03:00
}