{ config, lib, pkgs, ... }: let username = "brian"; uid = 1000; gid = 100; secrets = import ./secrets.nix; networkShares = [ { name = "seagate8tb"; device = "//10.0.0.128/PublicShare"; mountPoint = "/mnt/smb-seagate8tb"; } { name = "wd4tb"; device = "//10.0.0.65/wd4tb"; mountPoint = "/mnt/smb-wd4tb"; } { name = "stashapp"; device = "//10.0.0.65/stashapp"; mountPoint = "/mnt/smb-app"; } ]; networkFileSystems = builtins.listToAttrs (map (share: { name = share.mountPoint; value = { device = share.device; fsType = "cifs"; options = [ "username=${secrets."${share.name}Username"}" "password=${secrets."${share.name}Password"}" "uid=1000" "gid=1000" "file_mode=0775" "dir_mode=0775" ]; }; }) networkShares); in { # Only add network shares and NVMe # Root and boot are already in hardware-configuration.nix fileSystems = networkFileSystems // { # Your new NVMe drive ONLY "/mnt/nvme" = { device = "/dev/disk/by-label/nvmedrive"; fsType = "ext4"; options = [ "defaults" "noatime" "discard" "uid=${toString uid}" "gid=${toString gid}" "fmask=022" "dmask=022" ]; }; }; systemd.services.fix-nvme-permissions = { description = "Fix NVMe drive permissions"; wantedBy = [ "multi-user.target" ]; after = [ "local-fs.target" ]; script = '' # Set ownership chown -R ${username}:users /mnt/nvme 2>/dev/null || true # Create game directories mkdir -p /mnt/nvme/games/steam chown -R ${username}:users /mnt/nvme/games # Set permissions chmod -R 775 /mnt/nvme 2>/dev/null || true ''; serviceConfig.Type = "oneshot"; }; # Create symlinks in home directory for easy access systemd.tmpfiles.rules = (map (share: "L+ /home/${username}/${share.name} - - - - ${share.mountPoint}" ) networkShares) ++ [ "L+ /home/${username}/nvme - - - - /mnt/nvme" "d /mnt/nvme/games 0775 ${username} users -" "d /mnt/nvme/games/steam 0775 ${username} users -" ]; }