]> git.scottworley.com Git - auto-upgrade-with-pinch/commitdiff
Trust the specified key
authorScott Worley <scottworley@scottworley.com>
Tue, 14 Apr 2020 23:14:28 +0000 (16:14 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 18 May 2020 18:35:06 +0000 (11:35 -0700)
overlays/keyedgit.nix

index bbc156bd2079d08d91f769cc95697f479b58e64e..bf260e7d9abf34f8dedc1142eb6cf28312522f0a 100644 (file)
@@ -3,26 +3,27 @@
 self: super: {
   keyedgit = key:
     let
 self: super: {
   keyedgit = key:
     let
-      keyring = super.runCommand "keyedkeyring.gpg" {} ''
+      homelessGPG = super.writeShellScript "homeless-gpg" ''
         export GNUPGHOME=$(mktemp -d)
         export GNUPGHOME=$(mktemp -d)
-        ${self.gnupg}/bin/gpg --no-default-keyring --keyring=$out --import ${key}
+        trap 'rm -r "$GNUPGHOME"' EXIT
+        ${self.gnupg}/bin/gpg "$@"
+      '';
+      keyring = super.runCommand "keyedkeyring.gpg" {} ''
+        ${homelessGPG} --no-default-keyring --keyring=$out --import ${key}
+      '';
+      keyid = super.runCommand "keyid" {} ''
+        ${homelessGPG} --with-colons --show-keys ${key} | awk -F: '{ print $5; exit }' > $out
+      '';
+      keyedGPG = super.writeShellScript "keyed-gpg" ''
+        ${homelessGPG} --no-default-keyring --keyring=${keyring} --trusted-key "$(< ${keyid} )" "$@"
       '';
       '';
-      keyedgpg = super.symlinkJoin {
-        name = "keyedgpg";
-        buildInputs = [ super.makeWrapper ];
-        paths = [ self.gnupg ];
-        postBuild = ''
-          wrapProgram "$out/bin/gpg" \
-            --add-flags '--no-default-keyring --keyring=${keyring}'
-        '';
-      };
     in super.symlinkJoin {
       name = "keyedgit";
       paths = [ self.git ];
       buildInputs = [ super.makeWrapper ];
       postBuild = ''
         wrapProgram "$out/bin/git" \
     in super.symlinkJoin {
       name = "keyedgit";
       paths = [ self.git ];
       buildInputs = [ super.makeWrapper ];
       postBuild = ''
         wrapProgram "$out/bin/git" \
-          --add-flags '-c gpg.program=${keyedgpg}/bin/gpg'
+          --add-flags '-c gpg.program=${keyedGPG}'
       '';
     };
 }
       '';
     };
 }