From 519ddf2b0a0896af3ad80b96bab1540a1b9356a6 Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Wed, 22 Apr 2026 21:07:25 +0200 Subject: [PATCH] nixos/iscsi-initiator: add option discoverType --- .../services/networking/iscsi/initiator.nix | 20 ++++++++++++++++++- .../networking/iscsi/root-initiator.nix | 19 +++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/iscsi/initiator.nix b/nixos/modules/services/networking/iscsi/initiator.nix index 7a4ca5d58254..d7ebe927aea6 100644 --- a/nixos/modules/services/networking/iscsi/initiator.nix +++ b/nixos/modules/services/networking/iscsi/initiator.nix @@ -20,6 +20,24 @@ in default = null; description = "Portal to discover targets on"; }; + + discoverType = mkOption { + description = '' + Target discovery type. + Change this if you want to discover your targes via an iSNS server + or use the targets provided via firmware settings. + See {manpage}`iscsiadm(8)`. + ''; + default = "sendtargets"; + example = "sendtargets"; + type = enum [ + "st" + "sendtargets" + "isns" + "fw" + ]; + }; + name = mkOption { type = str; description = "Name of this iscsi initiator"; @@ -81,7 +99,7 @@ in wantedBy = [ "remote-fs.target" ]; serviceConfig.ExecStartPre = mkIf (cfg.discoverPortal != null) - "${cfg.package}/bin/iscsiadm --mode discoverydb --type sendtargets --portal ${escapeShellArg cfg.discoverPortal} --discover"; + "${cfg.package}/bin/iscsiadm --mode discoverydb --type ${cfg.discoverType} --portal ${escapeShellArg cfg.discoverPortal} --discover"; }; environment.systemPackages = [ cfg.package ]; diff --git a/nixos/modules/services/networking/iscsi/root-initiator.nix b/nixos/modules/services/networking/iscsi/root-initiator.nix index 86396ae1e24f..9a93bfc0ed4f 100644 --- a/nixos/modules/services/networking/iscsi/root-initiator.nix +++ b/nixos/modules/services/networking/iscsi/root-initiator.nix @@ -43,6 +43,23 @@ in type = nullOr str; }; + discoverType = mkOption { + description = '' + Target discovery type. + Change this if you want to discover your targes via an iSNS server + or use the targets provided via firmware settings. + See {manpage}`iscsiadm(8)`. + ''; + default = "sendtargets"; + example = "sendtargets"; + type = enum [ + "st" + "sendtargets" + "isns" + "fw" + ]; + }; + target = mkOption { description = '' Name of the iSCSI target to boot from. @@ -168,7 +185,7 @@ in iscsid --foreground --no-pid-file --debug ${toString cfg.logLevel} & iscsiadm --mode discoverydb \ - --type sendtargets \ + --type ${cfg.discoverType} \ --discover \ --portal ${escapeShellArg cfg.discoverPortal} \ --debug ${toString cfg.logLevel}