mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 17:14:33 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
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 "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 ];
|
|
|
|
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 - -"
|
|
];
|
|
};
|
|
}
|