From 85add7c531c5621bb82d89660c6df81e25b79e5b Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 30 Aug 2022 19:55:15 -0700 Subject: [PATCH] add a script to mount servo root --- modules/universal/fs.nix | 31 +++++++++++++++++---- pkgs/sane-scripts/src/sane-mount-servo-root | 18 ++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100755 pkgs/sane-scripts/src/sane-mount-servo-root diff --git a/modules/universal/fs.nix b/modules/universal/fs.nix index e27d9ca2..3b6739e1 100644 --- a/modules/universal/fs.nix +++ b/modules/universal/fs.nix @@ -1,8 +1,8 @@ { pkgs, ... }: -let sshOpts = { +let sshOpts = rec { fsType = "fuse.sshfs"; - options = [ + optionsBase = [ "x-systemd.automount" "_netdev" "user" @@ -11,23 +11,44 @@ let sshOpts = { "identityfile=/home/colin/.ssh/id_ed25519" "allow_other" "default_permissions" + ]; + optionsColin = optionsBase ++ [ "uid=1000" "gid=100" ]; + # optionsRoot = optionsBase ++ [ + # "uid=0" + # "gid=0" + # ]; }; in { fileSystems."/mnt/servo-media-wan" = { device = "colin@uninsane.org:/var/lib/uninsane/media"; - inherit (sshOpts) fsType options; + inherit (sshOpts) fsType; + options = sshOpts.optionsColin; }; fileSystems."/mnt/servo-media-lan" = { device = "colin@servo:/var/lib/uninsane/media"; - inherit (sshOpts) fsType options; + inherit (sshOpts) fsType; + options = sshOpts.optionsColin; + }; + fileSystems."/mnt/servo-root-wan" = { + device = "colin@uninsane.org:/"; + inherit (sshOpts) fsType; + # options = sshOpts.optionsRoot; + options = sshOpts.optionsColin; + }; + fileSystems."/mnt/servo-root-lan" = { + device = "colin@servo:/"; + inherit (sshOpts) fsType; + # options = sshOpts.optionsRoot; + options = sshOpts.optionsColin; }; fileSystems."/mnt/desko-home" = { device = "colin@desko:/home/colin"; - inherit (sshOpts) fsType options; + inherit (sshOpts) fsType; + options = sshOpts.optionsColin; }; environment.systemPackages = [ diff --git a/pkgs/sane-scripts/src/sane-mount-servo-root b/pkgs/sane-scripts/src/sane-mount-servo-root new file mode 100755 index 00000000..5015dfd5 --- /dev/null +++ b/pkgs/sane-scripts/src/sane-mount-servo-root @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -ex + +mnt=/mnt/servo-root-wan +# if lan not mounted, then try to mount it +if ! (test -d /mnt/servo-root-lan/nix) +then + sudo mount /mnt/servo-root-lan && mnt=/mnt/servo-root-lan +fi + +# if the needed mount isn't mounted, mount it +if ! (test -d $mnt/nix) +then + sudo mount $mnt +fi + +# symlink the fastest mount point into place +sudo ln -sf $mnt /mnt/servo-root