From a43f856b53bfc1107e2eca65f59e09f5671e2465 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Tue, 3 Jun 2025 19:07:43 +0200 Subject: [PATCH] Create directories in /vault/home for tent users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Aleix Boné --- m/tent/configuration.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/m/tent/configuration.nix b/m/tent/configuration.nix index 9e6a6a2..f31552a 100644 --- a/m/tent/configuration.nix +++ b/m/tent/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { imports = [ @@ -50,4 +50,21 @@ device = "/dev/disk/by-label/vault"; fsType = "ext4"; }; + + # Make a /vault/$USER directory for each user. + systemd.services.create-vault-dirs = let + # Take only normal users in tent + users = lib.filterAttrs (_: v: v.isNormalUser) config.users.users; + commands = lib.concatLists (lib.mapAttrsToList + (_: user: [ + "install -d -o ${user.name} -g ${user.group} -m 0711 /vault/home/${user.name}" + ]) users); + script = pkgs.writeShellScript "create-vault-dirs.sh" (lib.concatLines commands); + in { + enable = true; + wants = [ "local-fs.target" ]; + after = [ "local-fs.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig.ExecStart = script; + }; }