summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2015-11-11 16:18:38 +0300
committerNikolay Amiantov <ab@fmap.me>2015-11-11 16:18:57 +0300
commit98008623976f676dc28f9aa1af424979312ed635 (patch)
tree9c0574b92f94dc5c4b1f16ae601ecb050b3b4df7
parent360e8008f20723846eca1d40b2236b0469414c97 (diff)
downloadnixpkgs-98008623976f676dc28f9aa1af424979312ed635.tar
nixpkgs-98008623976f676dc28f9aa1af424979312ed635.tar.gz
nixpkgs-98008623976f676dc28f9aa1af424979312ed635.tar.bz2
nixpkgs-98008623976f676dc28f9aa1af424979312ed635.tar.lz
nixpkgs-98008623976f676dc28f9aa1af424979312ed635.tar.xz
nixpkgs-98008623976f676dc28f9aa1af424979312ed635.tar.zst
nixpkgs-98008623976f676dc28f9aa1af424979312ed635.zip
nixos/autofs: revive and update to systemd
-rw-r--r--nixos/modules/module-list.nix2
-rw-r--r--nixos/modules/services/misc/autofs.nix45
2 files changed, 8 insertions, 39 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 0db7ee916ba..034ea933a7d 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -188,7 +188,7 @@
   ./services/mail/postfix.nix
   ./services/mail/spamassassin.nix
   ./services/misc/apache-kafka.nix
-  #./services/misc/autofs.nix
+  ./services/misc/autofs.nix
   ./services/misc/canto-daemon.nix
   ./services/misc/calibre-server.nix
   ./services/misc/cpuminer-cryptonight.nix
diff --git a/nixos/modules/services/misc/autofs.nix b/nixos/modules/services/misc/autofs.nix
index f4a1059d09f..b4dae79cf8a 100644
--- a/nixos/modules/services/misc/autofs.nix
+++ b/nixos/modules/services/misc/autofs.nix
@@ -71,48 +71,17 @@ in
 
   config = mkIf cfg.enable {
 
-    environment.etc = singleton
-      { target = "auto.master";
-        source = pkgs.writeText "auto.master" cfg.autoMaster;
-      };
-
     boot.kernelModules = [ "autofs4" ];
 
-    jobs.autofs =
+    systemd.services.autofs =
       { description = "Filesystem automounter";
+        wantedBy = [ "multi-user.target" ];
+        after = [ "network.target" ];
 
-        startOn = "started network-interfaces";
-        stopOn = "stopping network-interfaces";
-
-        path = [ pkgs.nfs-utils pkgs.sshfsFuse ];
-
-        preStop =
-          ''
-            set -e; while :; do pkill -TERM automount; sleep 1; done
-          '';
-
-        # automount doesn't clean up when receiving SIGKILL.
-        # umount -l should unmount the directories recursively when they are no longer used
-        # It does, but traces are left in /etc/mtab. So unmount recursively..
-        postStop =
-          ''
-          PATH=${pkgs.gnused}/bin:${pkgs.coreutils}/bin
-          exec &> /tmp/logss
-          # double quote for sed:
-          escapeSpaces(){ sed 's/ /\\\\040/g'; }
-          unescapeSpaces(){ sed 's/\\040/ /g'; }
-          sed -n 's@^\s*\(\([^\\ ]\|\\ \)*\)\s.*@\1@p' ${autoMaster} | sed 's/[\\]//' | while read mountPoint; do
-            sed -n "s@[^ ]\+\s\+\($(echo "$mountPoint"| escapeSpaces)[^ ]*\).*@\1@p" /proc/mounts | sort -r | unescapeSpaces| while read smountP; do
-              ${pkgs.utillinux}/bin/umount -l "$smountP" || true
-            done
-          done
-          '';
-
-        script =
-          ''
-            ${if cfg.debug then "exec &> /var/log/autofs" else ""}
-            exec ${pkgs.autofs5}/sbin/automount ${if cfg.debug then "-d" else ""} -f -t ${builtins.toString cfg.timeout} "${autoMaster}" ${if cfg.debug then "-l7" else ""}
-          '';
+        serviceConfig = {
+          ExecStart = "${pkgs.autofs5}/sbin/automount ${if cfg.debug then "-d" else ""} -f -t ${builtins.toString cfg.timeout} ${autoMaster} ${if cfg.debug then "-l7" else ""}";
+          ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+        };
       };
 
   };