|
| 1 | +{ |
| 2 | + stdenv, |
| 3 | + fetchFromGitHub, |
| 4 | + lib, |
| 5 | + nettle, |
| 6 | + nix-update-script, |
| 7 | + rustPlatform, |
| 8 | + pkg-config, |
| 9 | + runCommand, |
| 10 | +}: |
| 11 | + |
| 12 | +rustPlatform.buildRustPackage rec { |
| 13 | + pname = "rpm-sequoia"; |
| 14 | + version = "1.7.0"; |
| 15 | + |
| 16 | + src = fetchFromGitHub { |
| 17 | + owner = "rpm-software-management"; |
| 18 | + repo = "rpm-sequoia"; |
| 19 | + rev = "v${version}"; |
| 20 | + hash = "sha256-AZCsboUv4muKOw5El2Hw5O1cvAgD3JhBppacrQCJT2k="; |
| 21 | + }; |
| 22 | + |
| 23 | + cargoHash = "sha256-0yO1+OAkXje/ir8i8URVhIcW8gwXleYx+XL1U4bjtXk="; |
| 24 | + |
| 25 | + patches = [ |
| 26 | + ./objdump.patch |
| 27 | + ]; |
| 28 | + |
| 29 | + nativeBuildInputs = [ |
| 30 | + pkg-config |
| 31 | + rustPlatform.bindgenHook |
| 32 | + ]; |
| 33 | + |
| 34 | + propagatedBuildInputs = [ nettle ]; |
| 35 | + |
| 36 | + # Tests will parse the symbols, on darwin we have two issues: |
| 37 | + # - library name is hardcoded to librpm_sequoia.so |
| 38 | + # - The output of the objdump differs and the parsing logic needs to be adapted |
| 39 | + doCheck = !stdenv.hostPlatform.isDarwin; |
| 40 | + |
| 41 | + outputs = [ |
| 42 | + "out" |
| 43 | + "dev" |
| 44 | + ]; |
| 45 | + |
| 46 | + # Ensure the generated .pc file gets the correct prefix |
| 47 | + env.PREFIX = placeholder "out"; |
| 48 | + |
| 49 | + # Install extra files, the same as this is done on fedora: |
| 50 | + # https://src.fedoraproject.org/rpms/rust-rpm-sequoia/blob/f41/f/rust-rpm-sequoia.spec#_81 |
| 51 | + preInstall = |
| 52 | + # Install the generated pc file for consumption by the dependents |
| 53 | + '' |
| 54 | + install -Dm644 target/release/rpm-sequoia.pc -t $dev/lib/pkgconfig |
| 55 | + '' |
| 56 | + + |
| 57 | + # Dependents will rely on the versioned symlinks |
| 58 | + '' |
| 59 | + install -d $out/lib |
| 60 | + find target/release/ \ |
| 61 | + -maxdepth 1 \ |
| 62 | + -type l -name 'librpm_sequoia.*' \ |
| 63 | + -exec cp --no-dereference {} $out/lib/ \; |
| 64 | + ''; |
| 65 | + |
| 66 | + passthru.updateScript = nix-update-script { }; |
| 67 | + |
| 68 | + meta = { |
| 69 | + description = "An OpenPGP backend for rpm using Sequoia PGP"; |
| 70 | + homepage = "https://sequoia-pgp.org/"; |
| 71 | + license = lib.licenses.gpl2Plus; |
| 72 | + maintainers = with lib.maintainers; [ baloo ]; |
| 73 | + }; |
| 74 | +} |
0 commit comments