From 36592c44eb7ab068088c771c6fc011734daf0a4a Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 20 Sep 2024 11:19:30 +0200 Subject: [PATCH] Create paste directories in /ceph/p MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that all hut users have a paste directory in /ceph/p owned by themselves. We need to wait for the ceph mount point to create them, so we use a systemd service that waits for the remote-fs.target. Reviewed-by: Aleix Boné --- m/hut/p.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/m/hut/p.nix b/m/hut/p.nix index f53472d..30bfc0b 100644 --- a/m/hut/p.nix +++ b/m/hut/p.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, config, ... }: let p = pkgs.writeShellScriptBin "p" '' set -e @@ -21,4 +21,23 @@ let in { environment.systemPackages = with pkgs; [ p ]; + + # Make sure we have a directory per user. We cannot use the nice + # systemd-tmpfiles-setup.service service because this is a remote FS, and it + # may not be mounted when it runs. + systemd.services.create-paste-dirs = let + # Take only normal users in hut + users = lib.filterAttrs (_: v: v.isNormalUser) config.users.users; + commands = lib.concatLists (lib.mapAttrsToList + (_: user: [ + "install -d -o ${user.name} -g ${user.group} -m 0755 /ceph/p/${user.name}" + ]) users); + script = pkgs.writeShellScript "create-paste-dirs.sh" (lib.concatLines commands); + in { + enable = true; + wants = [ "remote-fs.target" ]; + after = [ "remote-fs.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig.ExecStart = script; + }; }