11 cfg = config.services.target;
16 services.target = with types; {
17 enable = mkEnableOption "the kernel's LIO iscsi target";
23 Content of /etc/target/saveconfig.json
24 This file is normally read and written by targetcli
31 config = mkIf cfg.enable {
32 environment.etc."target/saveconfig.json" = {
33 text = builtins.toJSON cfg.config;
37 environment.systemPackages = with pkgs; [ targetcli ];
39 boot.kernelModules = [
45 systemd.services.iscsi-target = {
51 requires = [ "sys-kernel-config.mount" ];
52 wantedBy = [ "multi-user.target" ];
55 ExecStart = "${pkgs.python3.pkgs.rtslib}/bin/targetctl restore";
56 ExecStop = "${pkgs.python3.pkgs.rtslib}/bin/targetctl clear";
57 RemainAfterExit = "yes";
61 systemd.tmpfiles.rules = [
62 "d /etc/target 0700 root root - -"