nix: update inputs
[sourcephile-nix.git] / shell / modules / development / libraries / nix-plugins.nix
index 938056c329ae1fd7eb1a55f4f291b797097ef3d3..0975ac8052acc1ec391ab47db633063c2cb333bf 100644 (file)
@@ -2,10 +2,11 @@
 # which provides an unsafe exec.
 # Useful to get secrets from a local password-store.
 { config, lib, pkgs, ... }:
-let cfg = config.nix-plugins;
-    inherit (lib) types;
+let
+  cfg = config.nix-plugins;
+  inherit (lib) types;
 
-    /*
+  /*
     # Wrapper around nix to load extra-builtins.nix with nix-plugins.
     nix-with-extra-builtins = pkgs.writeShellScriptBin "nix-with-extra-builtins" ''
       ${pkgs.nix}/bin/nix \
@@ -15,50 +16,45 @@ let cfg = config.nix-plugins;
     '';
     */
 
-    # Wrapper around pass to call it with exec in extra-builtins.nix.
-    # Unfortunately it can only load secrets which can be represented as a Nix string,
-    # hence without null-byte and such special characters.
-    # FIXME: make a nix-pass-chomp
-    nix-pass = pkgs.writeShellScript "nix-pass" ''
-      set -e
-      f=$(mktemp)
-      trap "shred -u $f" EXIT
-      ${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"
-      nix-instantiate --eval -E "builtins.readFile $f"
-    '';
+  # Wrapper around pass to call it with exec in extra-builtins.nix.
+  # Unfortunately it can only load secrets which can be represented as a Nix string,
+  # hence without null-byte and such special characters.
+  # FIXME: make a nix-pass-chomp
+  nix-pass = pkgs.writeShellScript "nix-pass" ''
+    set -e
+    f=$(mktemp)
+    trap "shred -u $f" EXIT
+    ${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"
+    nix-instantiate --eval -E "builtins.readFile $f"
+  '';
 
-    # 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
-      ${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-file = pkgs.writeShellScript "nix-pass-to-file" ''
+    set -e
+    set -o pipefail
+    ${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 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.
 
-    # Wrapper around git to call it with exec in extra-builtins.nix.
-    nix-git = pkgs.writeShellScript "nix-git" ''
-      cd "$1"; shift
-      ${pkgs.git}/bin/git "$@"
-    '';
+  # Wrapper around git to call it with exec in extra-builtins.nix.
+  nix-git = pkgs.writeShellScript "nix-git" ''
+    cd "$1"; shift
+    ${pkgs.git}/bin/git "$@"
+  '';
 in
 {
   options.nix-plugins = {
@@ -69,8 +65,9 @@ in
         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.
@@ -78,7 +75,7 @@ in
       apply = lines: pkgs.writeText "extra-builtins.nix" (''
         { exec, ... }:
         {
-        '' + lines + ''
+      '' + lines + ''
         }
       '');
     };