Skip to content

Commit

Permalink
Merge pull request #117165 from drewrisinger/dr-pr-fix-pass-import
Browse files Browse the repository at this point in the history
passExtensions.pass-import: fix, convert to buildPythonApplication
  • Loading branch information
SuperSandro2000 committed Apr 12, 2021
2 parents 4646cba + 40b9f4e commit 2868749
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 73 deletions.

This file was deleted.

4 changes: 1 addition & 3 deletions pkgs/tools/security/pass/extensions/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ with pkgs;
pythonPackages = python3Packages;
};
pass-checkup = callPackage ./checkup.nix {};
pass-import = callPackage ./import.nix {
pythonPackages = python3Packages;
};
pass-import = callPackage ./import.nix {};
pass-otp = callPackage ./otp.nix {};
pass-tomb = callPackage ./tomb.nix {};
pass-update = callPackage ./update.nix {};
Expand Down
70 changes: 41 additions & 29 deletions pkgs/tools/security/pass/extensions/import.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{ lib, stdenv, fetchFromGitHub, pythonPackages, makeWrapper, fetchpatch }:

let
pythonEnv = pythonPackages.python.withPackages (p: [
p.defusedxml
p.setuptools
p.pyaml
p.pykeepass
p.filemagic
p.cryptography
p.secretstorage
]);

in stdenv.mkDerivation rec {
{ lib
, fetchFromGitHub
, fetchpatch
, python3Packages
, gnupg
, pass
}:

python3Packages.buildPythonApplication rec {
pname = "pass-import";
version = "3.1";

Expand All @@ -22,26 +17,43 @@ in stdenv.mkDerivation rec {
sha256 = "sha256-nH2xAqWfMT+Brv3z9Aw6nbvYqArEZjpM28rKsRPihqA=";
};

patches = [ ./0001-Fix-installation-with-Nix.patch ];

nativeBuildInputs = [ makeWrapper ];

buildInputs = [ pythonEnv ];

makeFlags = [ "DESTDIR=${placeholder "out"}" ];

postInstall = ''
wrapProgram $out/bin/pimport \
--prefix PATH : "${pythonEnv}/bin" \
--prefix PYTHONPATH : "$out/${pythonPackages.python.sitePackages}"
wrapProgram $out/lib/password-store/extensions/import.bash \
--prefix PATH : "${pythonEnv}/bin" \
--prefix PYTHONPATH : "$out/${pythonPackages.python.sitePackages}"
# by default, tries to install scripts/pimport, which is a bash wrapper around "python -m pass_import ..."
# This is a better way to do the same, and takes advantage of the existing Nix python environments
patches = [
# from https://github.com/roddhjav/pass-import/pull/138
(fetchpatch {
name = "pass-import-pr-138-pimport-entrypoint.patch";
url = "https://github.com/roddhjav/pass-import/commit/ccdb6995bee6436992dd80d7b3101f0eb94c59bb.patch";
sha256 = "sha256-CO8PyWxa4eLuTQBB+jKTImFPlPn+1yt6NBsIp+SPk94=";
})
];

propagatedBuildInputs = with python3Packages; [
cryptography
defusedxml
pyaml
pykeepass
python_magic # similar API to "file-magic", but already in nixpkgs.
secretstorage
];

checkInputs = [
gnupg
pass
python3Packages.pytestCheckHook
];

disabledTests = [
"test_import_gnome_keyring" # requires dbus, which pytest doesn't support
];
postCheck = ''
$out/bin/pimport --list-exporters --list-importers
'';

meta = with lib; {
description = "Pass extension for importing data from existing password managers";
homepage = "https://github.com/roddhjav/pass-import";
changelog = "https://github.com/roddhjav/pass-import/blob/v${version}/CHANGELOG.rst";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ lovek323 fpletz tadfisher ];
platforms = platforms.unix;
Expand Down

0 comments on commit 2868749

Please sign in to comment.