Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trezor GPG agent #47891

Closed
wants to merge 2 commits into from
Closed

Trezor GPG agent #47891

wants to merge 2 commits into from

Conversation

jb55
Copy link
Contributor

@jb55 jb55 commented Oct 5, 2018

Motivation for this change

This is a continuation of #32773 /cc @fpletz @FRidh

See the commits for why I've moved it out of python modules.

This patchset adds a systemd user service that provides a Trezor GPG agent. This allows you to use your Trezor for signing and encrypting things.

range-diff: v1 -> v2

 1:  1e63ead03d5 < -:  ----------- trezor-agent: 0.9.0 -> 0.9.2
 2:  939215154c6 < -:  ----------- trezor-agent: support qt pinentry on non-ttys
 -:  ----------- > 1:  09558b61be6 trezor-agent: 0.9.0 -> 0.12.0
 3:  971112bd12d ! 2:  c35222cbb30 trezor-agent: system service for trezor-gpg-agent
@@ -4,6 +4,8 @@
 
     Allows you to use your Trezor as a GnuPG agent
 
+    Signed-off-by: William Casarin <jb55@jb55.com>
+
 diff --git a/nixos/modules/programs/gnupg.nix b/nixos/modules/programs/gnupg.nix
 --- a/nixos/modules/programs/gnupg.nix
 +++ b/nixos/modules/programs/gnupg.nix
@@ -27,8 +29,8 @@
 +      example = "/home/alice/.gnupg/trezor";
 +      description = ''
 +        The GNUPGHOME path for your Trezor GnuPG config. See
-+        https://github.com/romanz/trezor-agent/blob/master/README-GPG.md on how
-+        to set this up.
++        https://github.com/romanz/trezor-agent/blob/master/doc/README-GPG.md on
++        how to set this up.
 +      '';
 +    };
 +
@@ -51,7 +53,7 @@
 +        GNUPGHOME=cfg.trezor-agent.configPath;
 +      };
 +
-+      serviceConfig.ExecStart = "${pkgs.python27Packages.trezor_agent}/bin/trezor-gpg-agent";
++      serviceConfig.ExecStart = "${pkgs.trezor-agent}/bin/trezor-gpg-agent";
 +    };
 +  });
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: trezor-agent

Partial log (click to expand)

writing top-level names to trezor_agent.egg-info/top_level.txt
reading manifest file 'trezor_agent.egg-info/SOURCES.txt'
writing manifest file 'trezor_agent.egg-info/SOURCES.txt'
running build_ext

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
/nix/store/gwx3azs5dqqy56i506gdh2appzh45cy7-python3.6-trezor_agent-0.12.0

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: trezor-agent

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: trezor-agent

Partial log (click to expand)

writing top-level names to trezor_agent.egg-info/top_level.txt
reading manifest file 'trezor_agent.egg-info/SOURCES.txt'
writing manifest file 'trezor_agent.egg-info/SOURCES.txt'
running build_ext

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
/nix/store/dxg9xxb2bmnfbzdvc55zwgwmp90qlkn7-python3.6-trezor_agent-0.12.0

@mmahut
Copy link
Member

mmahut commented May 20, 2019

@jb55 any update?

trezor-agent now splits agents into different packages.

We move trezor-agent out of python modules into the main package tree,
simply because the "python module" part of trezor-agent is now libagent.
trezor-agent is now simply a few command line binaries for libagent.

ledger-agent, etc. should now be packaged separately.

Signed-off-by: William Casarin <jb55@jb55.com>
@jb55
Copy link
Contributor Author

jb55 commented May 20, 2019

@mmahut rebased. I use this daily, works great!

Allows you to use your Trezor as a GnuPG agent

Signed-off-by: William Casarin <jb55@jb55.com>
Copy link
Member

@mmahut mmahut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent built from this pull request don't run for me:

# ./trezor-gpg
Traceback (most recent call last):
  File "/nix/store/24nxjvrrga6py9l564j5i2z8hnl9qcms-python3.7-trezor_agent-0.12.0/bin/.trezor-gpg-wrapped", line 11, in <module>
    sys.exit(gpg_tool())
  File "/nix/store/24nxjvrrga6py9l564j5i2z8hnl9qcms-python3.7-trezor_agent-0.12.0/bin/trezor_agent.py", line 6, in <lambda>
    gpg_tool = lambda: libagent.gpg.main(DeviceType)
  File "/nix/store/xl421r94zlhp2skqk37rlnm7s9xwygks-python3.7-libagent-0.13.1/lib/python3.7/site-packages/libagent/gpg/__init__.py", line 286, in main
    resources_map = {r.key: r for r in pkg_resources.require(agent_package)}
  File "/nix/store/yf4i32dx953p2dv2agfdyxdwg6ba0l61-python3.7-setuptools-41.0.1/lib/python3.7/site-packages/setuptools-41.0.1-py3.7.egg/pkg_resources/__init__.py", line 900, in require
  File "/nix/store/yf4i32dx953p2dv2agfdyxdwg6ba0l61-python3.7-setuptools-41.0.1/lib/python3.7/site-packages/setuptools-41.0.1-py3.7.egg/pkg_resources/__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'wheel>=0.32.3' distribution was not found and is required by libagent

@jb55
Copy link
Contributor Author

jb55 commented May 20, 2019 via email

@mmahut
Copy link
Member

mmahut commented Aug 19, 2019

Any updates?

@ivan
Copy link
Member

ivan commented Sep 6, 2019

For the author, reviewers, and committers: this PR was scanned and appears to add a use of the deprecated types.string, which emits a warning as of #66346. Before merging, please change this to another type, possibly:

  • types.str for a single string where merging does not make sense, or cannot work
  • types.lines for multi-line configuration or scripts where merging is possible
  • types.listOf types.str for a mergeable list of strings

@jb55
Copy link
Contributor Author

jb55 commented Sep 6, 2019

@mmahut I can't seem to figure out how to fix the wheel issue. I think I forgot about this because I originally ran that command from repo itself.

This is sufficiently old now so I think I'll close this PR until I get around to a fix.

@jb55 jb55 closed this Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants