From 618e4580240c71a7ac866649e01439e75ef4d6a6 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 23 Aug 2024 23:36:43 +0200 Subject: ... --- home-modules/lmu-hausschrift/default.nix | 37 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'home-modules') diff --git a/home-modules/lmu-hausschrift/default.nix b/home-modules/lmu-hausschrift/default.nix index c3344947..ceaf7252 100644 --- a/home-modules/lmu-hausschrift/default.nix +++ b/home-modules/lmu-hausschrift/default.nix @@ -24,24 +24,37 @@ with lib; ''; }; - systemd.user.services.sops-nix = { + systemd.user.services.unpack-lmu-hausschrift = { + Unit = { + ConditionPathExists = [ + "!%h/.local/share/lmu-hausschrift" + "!%t/lmu-hausschrift" + ]; + }; + Unit = { + After = ["sops-nix.service"]; + }; + Install = { + WantedBy = ["sops-nix.service"]; + }; Service = { - ExecStartPost = pkgs.writeShellScript "unpack-lmu-hausschrift.sh" '' + UMask = "07077"; + Environment = [ + "PATH=${lib.makeBinPath (with pkgs; [gnutar coreutils])}" + ]; + ExecStart = pkgs.writeShellScript "unpack-lmu-hausschrift.sh" '' set -xe out=''${XDG_RUNTIME_DIR:-/tmp}/lmu-hausschrift src="${config.sops.secrets."lmu-hausschrift.tar.zstd".path}" - src=''${src#"%r/"} - src=''${XDG_RUNTIME_DIR:-/tmp}/"''${src}" - - umask 07077 - - if [[ ! -d "''${out}" ]]; then - ${pkgs.coreutils}/bin/mkdir -p "''${out}" - ${pkgs.gnutar}/bin/tar -xaf "''${src}" -C "''${out}" - - ${pkgs.coreutils}/bin/ln -sfT "''${out}" "${config.home.homeDirectory}/.local/share/lmu-hausschrift" + if [[ "$src" =~ ^%r ]]; then + src=''${src#"%r/"} + src=''${XDG_RUNTIME_DIR:-/tmp}/"''${src}" fi + + mkdir -p "''${out}" + tar -xaf "''${src}" -C "''${out}" + ln -sfT "''${out}" "${config.home.homeDirectory}/.local/share/lmu-hausschrift" ''; }; }; -- cgit v1.2.3