Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nfs mounts and use home-manager instead of .desktopc #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions modules/ocf/graphical.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@

let
cfg = config.ocf.graphical;

# Default openssh doesn't include GSSAPI support, so we need to override sshfs
# to use the openssh_gssapi package instead. This is annoying because the
# sshfs package's openssh argument is nested in another layer of callPackage,
# so we override callPackage instead to override openssh.
sshfs = pkgs.sshfs.override {
callPackage = fn: args: (pkgs.callPackage fn args).override {
openssh = pkgs.openssh_gssapi;
};
};
in
{
options.ocf.graphical = {
Expand All @@ -23,11 +13,6 @@ in

config = lib.mkIf cfg.enable {
security.pam = {
# Mount ~/remote
services.login.pamMount = true;
services.login.rules.session.mount.order = config.security.pam.services.login.rules.session.krb5.order + 50;
mount.extraVolumes = [ ''<volume fstype="fuse" path="${lib.getExe sshfs}#%(USER)@tsunami:" mountpoint="~/remote/" options="follow_symlinks,UserKnownHostsFile=/dev/null,StrictHostKeyChecking=no" pgrp="ocf" />'' ];

# Trim spaces from username
services.login.rules.auth.trimspaces = {
control = "requisite";
Expand All @@ -42,6 +27,8 @@ in
boot = {
loader.timeout = 0;
initrd.systemd.enable = true;
initrd.supportedFilesystems = [ "nfs" ];
kernelModules = [ "nfs" ];
};

environment.etc = {
Expand Down Expand Up @@ -195,6 +182,14 @@ in
};
};
};
# NOTE: This will need you to export the desktops on dataloss for it to work.
# Will need to have a discussion to see if it's worth it.
fileSystems."/remote" = {
device = "homes:/opt/homes";
fsType = "nfs";
# Don't automatically mount, mount when accessed, umount after 10min idle
options = [ "noauto" "x-systemd.automount" "x-systemd.idle-timeout=600" ];
};

# KDE 6.0.3 has a bug that breaks logging out within the first 60 seconds.
# This is caused by the DrKonqi service's ExecStartPre command, which sleeps
Expand All @@ -214,13 +209,27 @@ in
};
};

systemd.user.services.desktoprc = {
description = "Source custom rc shared across desktops";
after = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];

systemd.user.services.link-user-remote = {
description = "SymLink ~/remote from NFS mount";
script = ''
if [[ ! -h "$HOME/remote" ]]; then
ln -s "/remote$HOME" "$HOME/remote"
fi
'';
};

systemd.user.services.home-manager = {
description = "load custom home manager config if present";
requires = [ "link-user-remote.service" ];
after = [ "link-user-remote.service" ];
wantedBy = [ "default.target" ];
path = [ pkgs.nix pkgs.git ];
script = ''
[ -f ~/remote/.desktoprc ] && . ~/remote/.desktoprc
# Will create a template directory if it doesn't exist. Maybe look into creating
# our own template repo as currently users will need to edit nix files to get
# custom packages etc...
nix run home-manager -- init --switch ~/remote/.home-manager
'';
};

Expand Down