Skip to content

Commit 2a6a9ba

Browse files
committed
desktops: nfs mount /services, /remote, ~/remote
- /services and /remote are mounted with nfs - ~/remote is bind mounted to the remote home directory in /remote on login with pam_mount
1 parent de2b5d1 commit 2a6a9ba

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

modules/nfs.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
let
99
cfg = config.ocf.nfs;
10+
11+
# nix lazy evals so it should be fine to put it here
12+
homePath = if cfg.mountHome.asRemote then "/remote" else "/home";
1013
in
1114
{
1215
options.ocf.nfs = {
@@ -18,6 +21,12 @@ in
1821
default = false;
1922
};
2023

24+
mountHome.asRemote = lib.mkOption {
25+
type = lib.types.bool;
26+
description = "Mount homes from NFS to /remote instead of /home (for desktops which create home directory in tmpfs on login).";
27+
default = false;
28+
};
29+
2130
mountServices = lib.mkOption {
2231
type = lib.types.bool;
2332
description = "Mount /services from NFS.";
@@ -28,7 +37,7 @@ in
2837
config = lib.mkIf cfg.enable {
2938
boot.supportedFilesystems = [ "nfs" ];
3039

31-
fileSystems."/home" = lib.mkIf cfg.mountHome {
40+
fileSystems."${homePath}" = lib.mkIf cfg.mountHome {
3241
device = "homes:/home";
3342
fsType = "nfs4";
3443
options = [

profiles/desktop.nix

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ in
3535
tmpfsHome.enable = true;
3636
network.wakeOnLan.enable = true;
3737
logged-in-users-exporter.enable = true;
38-
nfs.enable = true;
38+
39+
nfs = {
40+
enable = true;
41+
mountServices = true;
42+
43+
# we keep a single nfs mount and then bind mount to it instead of having
44+
# many nfs mounts (each logged in user would need a mount)
45+
mountHome = true;
46+
mountHome.asRemote = true;
47+
};
3948

4049
graphical.enable = true;
4150
graphical.extra = true;
@@ -63,7 +72,7 @@ in
6372
services.login.rules.session.mount.order =
6473
config.security.pam.services.login.rules.session.krb5.order + 50;
6574
mount.extraVolumes = [
66-
''<volume fstype="fuse" path="${lib.getExe sshfs}#%(USER)@tsunami:" mountpoint="~/remote/" options="follow_symlinks,UserKnownHostsFile=/dev/null,StrictHostKeyChecking=no" pgrp="ocf" />''
75+
''<volume fstype="bind" path="/remote/$(USER:0:1)/$(USER:0:2)/$(USER)" mountpoint="$(HOME)/remote/" />''
6776
];
6877

6978
# Trim spaces from username

0 commit comments

Comments
 (0)