mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 16:43:58 +00:00
ef176dcf7e
conversions were done using https://github.com/pennae/nix-doc-munge using (probably) rev f34e145 running nix-doc-munge nixos/**/*.nix nix-doc-munge --import nixos/**/*.nix the tool ensures that only changes that could affect the generated manual *but don't* are committed, other changes require manual review and are discarded.
54 lines
1.3 KiB
Nix
54 lines
1.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.target;
|
|
in
|
|
{
|
|
###### interface
|
|
options = {
|
|
services.target = with types; {
|
|
enable = mkEnableOption (lib.mdDoc "the kernel's LIO iscsi target");
|
|
|
|
config = mkOption {
|
|
type = attrs;
|
|
default = {};
|
|
description = lib.mdDoc ''
|
|
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 ];
|
|
|
|
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 = "${pkgs.python3.pkgs.rtslib}/bin/targetctl restore";
|
|
ExecStop = "${pkgs.python3.pkgs.rtslib}/bin/targetctl clear";
|
|
RemainAfterExit = "yes";
|
|
};
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d /etc/target 0700 root root - -"
|
|
];
|
|
};
|
|
}
|