How setup iscsi

I couldn’t find satisfying documentation about how to get a iscsi drive running on nixos.

I tried to install open-iscsi and run iscsiadm but this does not work since nixos does not allow changes in /etc/iscsi/ it seems. I am new to nixos.

I have found some mentions about using the configuration.nix file but not how to do that exactly.

thanks in advance.

Ok I figured it out.

you need to enable iscsid in the conf and then you can also add the file system.


  services.openiscsi.enable = true;

# probably not needed 
  services.openiscsi.discoverPortal = "ip:3260";
# probably not needed = "";

  environment.systemPackages = with pkgs; [

  fileSystems."/run/media/user/SteamLibrary" = {
    device = "/dev/disk/by-uuid/uuidasdfasdfasdfasdf";
    fsType = "btrfs";
    options = ["nofail"

you probably can setup the auto login in the configuration.nix too but I was happy to be able to use the iscsiadm after enableing openiscsi.