From 70cea4f7dac579cd836249aa23d2e96c3efdb0b3 Mon Sep 17 00:00:00 2001 From: Jonas Hahn Date: Sun, 31 Aug 2025 16:52:24 +0200 Subject: [PATCH] Test automount --- modules/services/webdav.nix | 72 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/modules/services/webdav.nix b/modules/services/webdav.nix index 61b7fb6..bbd7d5a 100644 --- a/modules/services/webdav.nix +++ b/modules/services/webdav.nix @@ -1,46 +1,42 @@ { inputs, config, ... }: { - imports = [ - inputs.sops-nix.nixosModules.sops - ]; + imports = [ inputs.sops-nix.nixosModules.sops ]; - services.davfs2.enable = true; + services.davfs2.enable = true; - sops = { - defaultSopsFile = ./../../secrets.yaml; - defaultSopsFormat = "yaml"; - age.keyFile = "/home/jonas/.config/sops/age/keys.txt"; - templates = { - "davtemp" = { - owner = "root"; - content = ''${config.sops.placeholder.webdav_secret}''; - mode = "0600"; - path = "/etc/davfs2/secrets"; - }; - }; - secrets = { - webdav_secret = { - owner = "jonas"; - }; - }; - }; + sops = { + defaultSopsFile = ./../../secrets.yaml; + defaultSopsFormat = "yaml"; + age.keyFile = "/home/jonas/.config/sops/age/keys.txt"; + templates = { + "davtemp" = { + owner = "root"; + content = "${config.sops.placeholder.webdav_secret}"; + mode = "0600"; + path = "/etc/davfs2/secrets"; + }; + }; + secrets = { webdav_secret = { owner = "jonas"; }; }; + }; - # Ensure the mountpoint directory exists - systemd.tmpfiles.rules = [ - "d /mnt/webdav 0755 jonas users -" - ]; + # Ensure the mountpoint directory exists + systemd.tmpfiles.rules = [ "d /mnt/webdav 0755 jonas users -" ]; - # Just works - systemd.mounts = [ - { - description = "Webdav mount point"; - wants = [ "network-online.target" ]; - what = "https://dav.hahn1.one"; - where = "/mnt/webdav"; - type = "davfs"; - options = "uid=1000,gid=1000,file_mode=0664,dir_mode=2775,_netdev"; - mountConfig.TimeoutSec = "5s"; - } - ]; + # Just works + systemd.mounts = [{ + description = "Webdav mount point"; + wants = [ "network-online.target" ]; + what = "https://dav.hahn1.one"; + where = "/mnt/webdav"; + type = "davfs"; + options = "uid=1000,gid=1000,file_mode=0664,dir_mode=2775,_netdev"; + mountConfig.TimeoutSec = "5s"; + }]; + + systemd.automounts = [{ + where = "/mnt/webdav"; + wantedBy = [ "multi-user.target" ]; + automountConfig = { TimeoutIdleSec = "20m"; }; + }]; }