Joey Hafner fff1d2c480
Enhancement (WIP): Consolidate system configurations into modules.
- system: Module describes core Linux system configuration parameters, and NixOS system parameters.
  - networking: Basic networking config for metal hosts.
  - sops: Configures sops-nix to decrypt secrets as appropriate, and provides a useful shell helper.
  - smb: Reusable module that returns one smb mount.
  - iscsi: Autoconnect and auto-mount iscsi target.
  - git: Basic Git config.
  - docker: Configure Docker.
  - hardware: Set of modules for physical hardware devices and their related configurations.
2025-02-16 00:13:27 -08:00

32 lines
1.0 KiB
Nix

{ iscsi, pkgs ? import <nixpkgs>, ... }: {
services.openiscsi = {
enable = true;
name = iscsi.iqn;
discoverPortal = "${iscsi.portalIP}";
};
systemd.services = {
iscsi-autoconnect = {
description = "Log into iSCSI target ${iscsi.iqn}";
after = [ "network.target" "iscsid.service" ];
wants = [ "iscsid.service" ];
serviceConfig = {
ExecStartPre = "${pkgs.openiscsi}/bin/iscsiadm -m discovery -t sendtargets -p ${iscsi.portalIP}";
ExecStart = "${pkgs.openiscsi}/bin/iscsiadm -m node -T ${iscsi.iqn} -p ${iscsi.portalIP} --login";
ExecStop = "${pkgs.openiscsi}/bin/iscsiadm -m node -T ${iscsi.iqn} -p ${iscsi.portalIP} --logout";
Restart = "on-failure";
RemainAfterExit = true;
};
};
};
fileSystems."${iscsi.mountPath}" = {
device = "/dev/disk/by-path/ip-${iscsi.portalIP}-iscsi-${iscsi.iqn}-lun-0-part1";
fsType = "${iscsi.fsType}";
options = [
"x-systemd.requires=iscsi.service"
"_netdev"
"users"
];
};
}