dev-nis
December 18, 2024, 4:18pm
1
Hi, I’m trying to package HopToDesk for Nix which is written in Rust. However, when running nix-build -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'
,
I always get this error which I don’t really understand:
ln: failed to create symbolic link '/nix/store/qs3mfgd9m6lm8wmh3zlfwa6kgz9sm796-cargo-vendor-dir/core-foundation-sys-0.8.6/g6jsg92jj9hyg3gjpad3wpchsh1sj3aj-core-foundation-sys-0.8.6': Permission denied
error: builder for '/nix/store/w8zf45pcf2qlbhir2a9jrnwwjp39lmd3-cargo-vendor-dir.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/fw3c7kicdd79q0wk3h3kmivibvjv13k7-hoptodesk-1.42.1.drv' failed to build
I don’t really understand, what has no permission here?
This is not my first Nix package (I already successfully submitted a package once) but my first one with Rust
This is my package:
lib,
fetchFromGitLab,
rustPlatform,
fetchurl
}:
rustPlatform.buildRustPackage rec {
pname = "hoptodesk";
version = "1.42.1";
src = fetchFromGitLab {
owner = "hoptodesk";
repo = "hoptodesk";
rev = "1.42.1";
hash = "sha256-F+gA+Z4gZoNJYdy28uIjqiJcwcNsyUzl6BXsiIZO0gE=";
};
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};
#postPatch = ''
# ln -s ${./Cargo.lock} Cargo.lock
#'';
cargoHash = lib.fakeHash;
meta = with lib; {
description = "Free Remote Desktop Software. Easily access remote devices securely with end-to-end encryption.";
homepage = "https://www.hoptodesk.com/";
license = licenses.agpl3Only;
maintainers = with maintainers; [ NIS ];
};
}
You ran into this bug basically
opened 02:37PM - 28 Jul 22 UTC
0.kind: bug
6.topic: rust
### Describe the bug
`rustPlatform.importCargoLock`, which is used by `rustPl… atform.buildRustPackage` when `cargoLock.lockFile` is set, requires explicit hashes for all git dependencies in `outputHashes.<package>`, because their integrity can’t be verified otherwise. They are keyed by the package name and the version, which works fine for published crates, but can fail for git dependencies, where it is possible to have two packages with the same version but a different source URL (and therefore different contents and hashes).
### Steps To Reproduce
Try to import the cargo lock file for any rust project that depends on different git revisions of one package that share the same (Cargo.toml metadata) version.
I found this when trying to build the [firmware for Nitrokey 3](https://github.com/Nitrokey/nitrokey-3-firmware) with Nix, but I also created a minimal example to isolate this: https://github.com/sbruder/nix-cargo-two-unpinned-dependencies
In case of the latter, the build fails with the following message, even though there is a hash specified for `libc-0.2.126`:
error: No hash was found while vendoring the git dependency libc-0.2.126. You can add
a hash through the `outputHashes` argument of `importCargoLock`:
outputHashes = {
"libc-0.2.126" = "<hash>";
};
If you use `buildRustPackage`, you can add this attribute to the `cargoLock`
attribute set.
### Expected behavior
One should be able to specify the output hash for each git version of the package that is used separately.
### Notify maintainers
@danieldk
### Metadata
- system: `"x86_64-linux"`
- host os: `Linux 5.18.12, NixOS, 22.05 (Quokka), 22.05.20220722.e3583ad`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.8.1`
- channels(root): `""`
- nixpkgs: `/nix/store/v039w5dpnfqy2qvqq04a489s8zqvr4di-source`
which would be fixed by the below, potentially
NixOS:staging
← junjihashimoto:feature/rust-dup
opened 05:54AM - 22 Jan 24 UTC
## Description of changes
<!--
For package updates please link to a changelo… g or describe changes, this helps your fellow maintainers discover breaking updates.
For new packages please briefly describe the package or provide a link to its homepage.
-->
Fix these issues(https://github.com/NixOS/nixpkgs/issues/183344 and https://github.com/NixOS/nixpkgs/issues/30742).
This patch does the same thing of `cargo-vendor --no-merge-sources`.
It puts git sources to 'git-\<sha\>' directory.
## Things done
- Built on platform(s)
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [x] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [x] `sandbox = true`
- [x] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [x] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.05 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) (or backporting [23.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2305.section.md) and [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
-->
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
3 Likes
dev-nis
December 19, 2024, 2:14pm
3
Ah thank’s for the reply!
So should I just wait until that gets merged or is there a workaround you can suggest in the meantime?
1 Like