Files
system-config/home-manager/features/mounts/mcp-archive.nix

51 lines
1.3 KiB
Nix

{ pkgs, ... }:
{
home.packages = with pkgs; [ sshfs ];
systemd.user.services =
let
mountArchive = ''
${pkgs.sshfs}/bin/sshfs \
-f \
-o reconnect \
-o compression=yes \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o IdentityFile=%h/.ssh/id_ed25519 \
-o StrictHostKeyChecking=yes \
drew@mcp:/tank/archive/drew \
%h/archive
'';
# unmountArchive = "/run/wrappers/bin/fusermount -u %h/archive";
in
{
# Mounts the archive when the system is online.
mcp-archive = {
Unit = {
Description = "SSHFS mount for remote archive";
# Start only after the network is online
After = [ "network-online.target" ];
# Stop this service if the network stops
StopPropagatedFrom = [ "network-online.target" ];
};
Service = {
Type = "simple";
ExecStartPre = "/run/current-system/sw/bin/mkdir -p %h/archive";
ExecStart = mountArchive;
Restart = "on-failure";
RestartSec = "10s";
};
Install = {
# It doesn't like to disconnect on sleep, so not making it automount at all
# WantedBy = [ "default.target" ];
};
};
};
}