Skip to content

buildRustpackage: failed to load source for a dependency on $x #44465

@erictapen

Description

@erictapen

Issue description

I'm trying to package sequoia-pgp. Building it with Cargo works fine, but I fail to build it with Nix.

Sequoia is a multi-crate project, which pulls some dependencies directly from GitLab. For some reason, cargo doesn't find the nettle-rs sources, but they are in /nix/store/1ypg6q4rxaw0v5w4wysmslsgaklwrq9l-sequoia-pgp-2018-06-24-vendor.

Steps to reproduce

This is what I have so far. Upstream doesn't provide a Cargo.lock, so I generated a working one with cargo build.

commit a39cd2dd5467fd1cffcb48d7b98e3bb1d6c58827 (HEAD -> sequoia-pgp-init)
Author: Justin Humm <[email protected]>
Date:   Thu Apr 12 19:29:55 2018 +0200

    sequoia-pgp: init

diff --git a/pkgs/tools/security/sequoia-pgp/default.nix b/pkgs/tools/security/sequoia-pgp/default.nix
new file mode 100644
index 00000000000..1d9a5bd4681
--- /dev/null
+++ b/pkgs/tools/security/sequoia-pgp/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchFromGitLab, fetchurl, runCommand, rustPlatform
+, pkgconfig
+, gcc
+, openssl
+, capnproto
+, nettle
+, clang
+, llvmPackages
+, sqlite
+}:
+
+
+rustPlatform.buildRustPackage rec {
+  name = "sequoia-pgp-${version}";
+  version = "2018-06-24";
+
+  src =
+    let
+      source = fetchFromGitLab {
+        owner = "sequoia-pgp";
+        repo = "sequoia";
+        rev = "2897cfc02ad67c920cf82898bdba27eb296f12ef";
+        sha256 = "0yb37lka2ddbykc4gsc5f30ycq59ss2wygdmnvq00idxylwcddql";
+      };
+      cargo-lock = fetchurl {
+        url = "https://gist.githubusercontent.com/erictapen/d5486b923efdbe933d633b0826749914/raw/049c08893b039e33c2086b36779631c0bab01c63/Cargo.lock";
+        sha256 = "0m8xhysrp55qh560a69yylbcrz9gz8ja9svjs3qw58vglszchgbw";
+      };
+    in
+    runCommand "cargo-sequoia-src" {} ''
+      cp -R ${source} $out
+      chmod +w $out
+      cp ${cargo-lock} $out/Cargo.lock
+    '';
+
+  buildInputs = [
+    pkgconfig
+    gcc
+    openssl
+    capnproto
+    nettle
+    clang
+    llvmPackages.libclang
+    sqlite
+  ];
+
+  cargoSha256 = "0i128q53p01glk6aij9lpxmcadz0fr941yqdk295k8fz7jrvmyh4";
+
+  meta = with stdenv.lib; {
+    description = "PGP implementation in Rust";
+    homepage = https://gitlab.com/sequoia-pgp/sequoia;
+    license = with licenses; [ gpl3 ];
+    maintainers = [ maintainers.erictapen ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 5474ef98e58..d7c1b2c02a2 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -5078,6 +5078,8 @@ with pkgs;

   seqdiag = with python3Packages; toPythonApplication seqdiag;

+  sequoia-pgp = callPackage ../tools/security/sequoia-pgp { };
+
   screenfetch = callPackage ../tools/misc/screenfetch { };

   sg3_utils = callPackage ../tools/system/sg3_utils { };

When trying to build this on master, I get the following:

$ nix-build -A sequoia-pgp
these derivations will be built:
  /nix/store/2f9ins0yj462dwvfhkb7h3xjf1dng379-sequoia-pgp-2018-06-24.drv
building '/nix/store/2f9ins0yj462dwvfhkb7h3xjf1dng379-sequoia-pgp-2018-06-24.drv'...
unpacking sources
unpacking source archive /nix/store/r9ji1rqz17zyf62zbn7jpd2lc67fqkql-cargo-sequoia-src
source root is cargo-sequoia-src
unpacking source archive /nix/store/1ypg6q4rxaw0v5w4wysmslsgaklwrq9l-sequoia-pgp-2018-06-24-vendor
patching sources
configuring
building
Running cargo build --release
error: failed to load source for a dependency on `nettle`

Caused by:
  Unable to update https://gitlab.com/sequoia-pgp/nettle-rs.git#28f92f80

Caused by:
  failed to open: /homeless-shelter/.cargo/git/.cargo-lock-git

Caused by:
  Permission denied (os error 13)
builder for '/nix/store/2f9ins0yj462dwvfhkb7h3xjf1dng379-sequoia-pgp-2018-06-24.drv' failed with exit code 101
error: build of '/nix/store/2f9ins0yj462dwvfhkb7h3xjf1dng379-sequoia-pgp-2018-06-24.drv' failed

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.59, NixOS, 18.03 (Impala)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.0.4
  • channels(justin): "nixos-18.03-18.03.132915.d6c6c7fcec6"
  • nixpkgs: /home/justin/nixpkgs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions