Files
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

66 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.target;
in
{
###### interface
options = {
services.target = with types; {
enable = mkEnableOption "the kernel's LIO iscsi target";
config = mkOption {
type = attrs;
default = { };
description = ''
Content of /etc/target/saveconfig.json
This file is normally read and written by targetcli
'';
};
};
};
###### implementation
config = mkIf cfg.enable {
environment.etc."target/saveconfig.json" = {
text = builtins.toJSON cfg.config;
mode = "0600";
};
environment.systemPackages = with pkgs; [ targetcli-fb ];
boot.kernelModules = [
"configfs"
"target_core_mod"
"iscsi_target_mod"
];
systemd.services.iscsi-target = {
enable = true;
after = [
"network.target"
"local-fs.target"
];
requires = [ "sys-kernel-config.mount" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${lib.getExe pkgs.python3Packages.rtslib-fb} restore";
ExecStop = "${lib.getExe pkgs.python3Packages.rtslib-fb} clear";
RemainAfterExit = "yes";
};
};
systemd.tmpfiles.rules = [
"d /etc/target 0700 root root - -"
];
};
}