about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorLily Foster <lily@lily.flowers>2024-03-18 16:10:15 -0700
committerGitHub <noreply@github.com>2024-03-18 16:10:15 -0700
commite3c0bb42552a77f73ce6a74637b7e53b6d68ef30 (patch)
tree6cfe2f036782a9dd83dbf2a48e35531f7de700d8 /nixos/modules
parent83f77a1b3858caddca36c7e371d6d0b8cc1a75d5 (diff)
parent9ec0e31f79d676288278a92c105f11121f694d01 (diff)
downloadnixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.tar
nixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.tar.gz
nixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.tar.bz2
nixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.tar.lz
nixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.tar.xz
nixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.tar.zst
nixlib-e3c0bb42552a77f73ce6a74637b7e53b6d68ef30.zip
Merge pull request #294542 from Janik-Haag/garage
nixos/garage: add env-var wrapper for admin cli
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/web-servers/garage.nix14
1 files changed, 13 insertions, 1 deletions
diff --git a/nixos/modules/services/web-servers/garage.nix b/nixos/modules/services/web-servers/garage.nix
index 48dd5b34757c..616be978b6e5 100644
--- a/nixos/modules/services/web-servers/garage.nix
+++ b/nixos/modules/services/web-servers/garage.nix
@@ -75,7 +75,19 @@ in
       source = configFile;
     };
 
-    environment.systemPackages = [ cfg.package ]; # For administration
+    # For administration
+    environment.systemPackages = [
+      (pkgs.writeScriptBin "garage" ''
+        # make it so all future variables set are automatically exported as environment variables
+        set -a
+
+        # source the set environmentFile (since systemd EnvironmentFile is supposed to be a minor subset of posix sh parsing) (with shell arg escaping to avoid quoting issues)
+        [ -f ${lib.escapeShellArg cfg.environmentFile} ] && . ${lib.escapeShellArg cfg.environmentFile}
+
+        # exec the program with quoted args (also with shell arg escaping for the program path to avoid quoting issues there)
+        exec ${lib.escapeShellArg (lib.getExe cfg.package)} "$@"
+      '')
+    ];
 
     systemd.services.garage = {
       description = "Garage Object Storage (S3 compatible)";