Skip to content

Commit

Permalink
Update NAS profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
yousiki committed Mar 16, 2024
1 parent 7793185 commit 365a3b7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/configurations/nixos/hakase/_hardware-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,6 @@
};
};

# Mount NAS satoshi.
fileSystems."/mnt/nas-mck-home" = {
device = "//nas-changping.ybh1998.space/home";
fsType = "cifs";
options = let
# this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in ["${automount_opts},noperm,credentials=${config.sops.secrets.nas-credentials.path}"];
};

fileSystems."/mnt/nas-mck-share" = {
device = "//nas-changping.ybh1998.space/share";
fsType = "cifs";
options = let
# this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in ["${automount_opts},noperm,credentials=${config.sops.secrets.nas-credentials.path}"];
};

fileSystems."/mnt/nas-yyp-home" = {
device = "//nas.ybh1998.space/home";
fsType = "cifs";
options = let
# this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in ["${automount_opts},noperm,credentials=${config.sops.secrets.nas-credentials.path}"];
};

fileSystems."/mnt/nas-yyp-share" = {
device = "//nas.ybh1998.space/share";
fsType = "cifs";
options = let
# this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in ["${automount_opts},noperm,credentials=${config.sops.secrets.nas-credentials.path}"];
};

# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
Expand Down
1 change: 1 addition & 0 deletions src/configurations/nixos/hakase/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
nixosProfiles.nvidia-gpu
nixosProfiles.sops
nixosProfiles.vscode-server
nixosProfiles.nas

# Home-manager module
globals.inputs.home-manager.nixosModules.home-manager
Expand Down
38 changes: 38 additions & 0 deletions src/profiles/nixos/nas.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Mount NAS servers on NixOS.
{globals, ...}: {
config,
lib,
pkgs,
...
}: let
cfg = config.services.nas;
in {
options.services.nas = {
mountRoot = lib.mkOption {
type = lib.types.str;
default = "/mnt";
description = "The root directory to mount NAS servers.";
};
};

config = let
mkCifs = device: {
device = device;
fsType = "cifs";
options = [
"noauto"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=5s"
"x-systemd.mount-timeout=5s"
"noperm"
"credentials=${config.sops.secrets.nas-credentials.path}"
];
};
in {
fileSystems."${cfg.mountRoot}/nas-yyp-home" = mkCifs "//nas.ybh1998.space/home";
fileSystems."${cfg.mountRoot}/nas-yyp-share" = mkCifs "//nas.ybh1998.space/share";
fileSystems."${cfg.mountRoot}/nas-mck-home" = mkCifs "//nas-changping.ybh1998.space/home";
fileSystems."${cfg.mountRoot}/nas-mck-share" = mkCifs "//nas-changping.ybh1998.space/share";
};
}

0 comments on commit 365a3b7

Please sign in to comment.