freeciv: reload is not supported
[sourcephile-nix.git] / shell / modules / development / libraries / nix-plugins.nix
index 8a832ede527ff06479ef28456f2e7bb6f9d795f7..ee3d69bc47471be3bf5e7bdb472a697e6b56d06b 100644 (file)
@@ -23,32 +23,37 @@ let cfg = config.nix-plugins;
       set -e
       f=$(mktemp)
       trap "shred -u $f" EXIT
-      # NOTE: using an envvar removes the trailing newline added by pass generate
+      ${pkgs.pass}/bin/pass show "$1" >"$f"
+      nix-instantiate --eval -E "builtins.readFile $f"
+    '';
+    # Like nix-pass but remove the trailing spaces and newlines at the end of the content.
+    nix-pass-chomp = pkgs.writeShellScript "nix-pass-chomp" ''
+      set -e
+      f=$(mktemp)
+      trap "shred -u $f" EXIT
       pass="$(${pkgs.pass}/bin/pass show "$1")"
-      printf %s "$pass" >$f
+      printf %s "$pass" >"$f"
       nix-instantiate --eval -E "builtins.readFile $f"
     '';
-    /*
-      nix-store --add $f
-    */
-    /*
-      set -o pipefail
-      ${pkgs.pass}/bin/pass show "$1" |
-      ${pkgs.gnused}/bin/sed \
-       -e 's:\n:\\n:g;s:\r:\\r:g;s:\t:\\t:g;s:":\\":g;1s:^:":;$s:$:":;'
-    */
 
     # Wrapper around pass to call it with exec in extra-builtins.nix and put the output in a file.
     # Needed for boot.initrd.network.ssh.host*Key.
     nix-pass-to-file = pkgs.writeShellScript "nix-pass-to-file" ''
       set -e
       set -o pipefail
-      cd "$PWD"
       ${pkgs.pass}/bin/pass show "$1" |
       install -D -m 400 /dev/stdin "$2"
       printf '%s\n' "$2"
     '';
 
+    # Wrapper around pass to call it with exec in extra-builtins.nix and put the output in a file.
+    # Needed for boot.initrd.network.ssh.host*Key.
+    nix-pass-to-store = pkgs.writeShellScript "nix-pass-to-store" ''
+      set -e
+      ${pkgs.pass}/bin/pass show "$1" >"$f"
+      nix-store --add "$f"
+    '';
+
     # Wrapper around git to call it with exec in extra-builtins.nix.
     nix-git = pkgs.writeShellScript "nix-git" ''
       cd "$1"; shift
@@ -62,9 +67,11 @@ in
       type = types.lines;
       default = ''
         pass         = path: exec [ "${nix-pass}" path ];
+        pass-chomp   = path: exec [ "${nix-pass-chomp}" path ];
         pass-to-file = path: name: exec [ "${nix-pass-to-file}" path name ];
-        git          = dir: args: exec ([ "${nix-git}" (builtins.toPath dir) ] ++ args);
-        git-time     = dir: path: exec [ "${nix-git}" (builtins.toPath dir) "log" "-1" "--format=%ct" "--" path ];
+        git          = dir: args: exec ([ "${nix-git}" dir ] ++ args);
+        git-time     = dir: path: exec [ "${nix-git}" dir "log" "-1" "--format=%ct" "--" path ];
+        gpg          = args: exec ([ "${pkgs.gnupg}/bin/gpg" ] ++ args);
       '';
       description = ''
         Content put in extra-builtins.nix for nix-plugins.