-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
268 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(use-modules (gnu packages) | ||
((gnu packages bash) #:select (bash-minimal)) | ||
((gnu packages certs) #:select (nss-certs)) | ||
(gnu packages compression) | ||
(gnu packages curl) | ||
(gnu packages moreutils) | ||
(gnu packages rust) | ||
((gnu packages tls) #:select (openssl)) | ||
((gnu packages web) #:select (jq)) | ||
(guix build-system trivial) | ||
(guix download) | ||
((guix licenses) #:prefix license:) | ||
(guix packages)) | ||
|
||
;; We don't use (list rust "rust-src") for two reasons: | ||
;; | ||
;; - Hashes in Cargo.lock are replaced, resulting in: | ||
;; error: checksum for `<package> <version>` changed between lock files | ||
;; | ||
;; - It drags in a bunch of unnecessary deps, including python. | ||
;; See: guix graph --type=references rust | xdot - | ||
|
||
;; Instead, we create a new package with the unaltered rust source | ||
;; and vendor the standard library in cargo.sh | ||
|
||
(define-public rust-std | ||
(package | ||
(name "rust-std") | ||
(version (package-version rust)) | ||
;; You'd expect (source (package-source (rust)) to work here, | ||
;; but it refers to the source store item and NOT the .tar.gz archive | ||
(source (origin | ||
(method url-fetch) | ||
(uri (origin-uri (package-source rust))) | ||
(sha256 | ||
(content-hash-value (origin-hash (package-source rust)))))) | ||
(build-system trivial-build-system) | ||
(native-inputs (list tar gzip)) | ||
(arguments | ||
`(#:modules ((guix build utils)) | ||
#:builder | ||
(begin | ||
(use-modules (guix build utils)) | ||
(let ((out (assoc-ref %outputs "out")) | ||
(source (assoc-ref %build-inputs "source")) | ||
(tar (search-input-file %build-inputs "/bin/tar")) | ||
(gzip (search-input-file %build-inputs "/bin/gzip")) | ||
(gzip-path (string-append (assoc-ref %build-inputs "gzip") "/bin"))) | ||
(setenv "PATH" gzip-path) | ||
(mkdir out) | ||
(invoke tar "xvf" source "-C" out "--strip-components=1"))))) | ||
(synopsis (package-synopsis rust)) | ||
(description (package-description rust)) | ||
(home-page (package-home-page rust)) | ||
(license (package-license rust)))) | ||
|
||
(packages->manifest | ||
(append | ||
(list | ||
bash-minimal | ||
coreutils-minimal | ||
curl | ||
findutils ;; find | ||
grep | ||
gzip | ||
jq | ||
moreutils | ||
nss-certs | ||
openssl | ||
sed | ||
tar | ||
(list rust "cargo") | ||
rust-std))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
set -e -o pipefail | ||
|
||
# Environment variables for determinism | ||
export LC_ALL=C | ||
export SOURCE_DATE_EPOCH=1397818193 | ||
export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name" | ||
export TZ="UTC" | ||
|
||
# Given a package name and an output name, return the path of that output in our | ||
# current guix environment | ||
store_path() { | ||
grep --extended-regexp "/[^-]{32}-${1}-[^-]+${2:+-${2}}" "${GUIX_ENVIRONMENT}/manifest" \ | ||
| head --lines=1 \ | ||
| sed --expression='s|\x29*$||' \ | ||
--expression='s|^[[:space:]]*"||' \ | ||
--expression='s|"[[:space:]]*$||' | ||
} | ||
|
||
echo "Fetching rust dependencies.." | ||
|
||
cd /monero/src/fcmp_pp/fcmp_pp_rust | ||
|
||
# error: the cargo feature `public-dependency` requires a nightly version of Cargo, but this is the `stable` channel | ||
# | ||
# https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency | ||
export RUSTC_BOOTSTRAP=1 | ||
|
||
# Assert that `Cargo.lock` will remain unchanged | ||
CARGO_OPTIONS="--locked" | ||
|
||
# https://github.com/rust-lang/wg-cargo-std-aware/issues/23#issuecomment-1445119470 | ||
# If we don't vendor std, we'll run into: 'error: no matching package named `compiler_builtins` found' during build. | ||
CARGO_OPTIONS+=" --sync $(store_path rust-std)/library/Cargo.toml" | ||
|
||
# Vendor fcmp_pp_rust + std library deps | ||
cargo vendor ${CARGO_OPTIONS} /rust/vendor | ||
|
||
cp -r "$(store_path rust-std)/library" /rust/library | ||
|
||
cd /rust/vendor | ||
|
||
# `cargo vendor` includes dozens of packages that aren't needed to build the standard library. | ||
# We can't simply remove these packages, because cargo expects them to be there. | ||
# Instead, we replace the packages with a stub, which is sufficient to pass cargo's checks. | ||
while IFS= read -r line; do | ||
cd "$line" | ||
find . -not -path "." -not -name "Cargo.toml" -not -name ".cargo-checksum.json" -delete | ||
mkdir src | ||
touch src/lib.rs | ||
|
||
# Cargo.toml must remain unaltered. | ||
# src/lib.rs must exist, but may be empty. | ||
# 'e3b0...b855' is equivalent to `echo -n "" | sha256sum -` | ||
# We can't set 'package' to the empty hash, as this might conflict with fcmp_pp_rust's Cargo.lock, resulting | ||
# in the same error. | ||
cat .cargo-checksum.json \ | ||
| jq '{files: {"Cargo.toml": .files["Cargo.toml"]}, package}' \ | ||
| jq '.files += {"src/lib.rs": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}' \ | ||
| sponge .cargo-checksum.json | ||
cd .. | ||
done < "/monero/contrib/guix/rust/stubs" | ||
|
||
cd /rust | ||
|
||
# Create deterministic archive | ||
find . -print0 \ | ||
| sort --zero-terminated \ | ||
| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \ | ||
| gzip -9n > "/sources/$RUST_DEPS_ARCHIVE" | ||
|
||
sha256sum "/sources/$RUST_DEPS_ARCHIVE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[source.crates-io] | ||
replace-with = "vendored-sources" | ||
|
||
[source."git+https://github.com/kayabaNerve/crypto-bigint?branch=c-repr"] | ||
git = "https://github.com/kayabaNerve/crypto-bigint" | ||
branch = "c-repr" | ||
replace-with = "vendored-sources" | ||
|
||
[source."git+https://github.com/kayabaNerve/fcmp-plus-plus"] | ||
git = "https://github.com/kayabaNerve/fcmp-plus-plus" | ||
replace-with = "vendored-sources" | ||
|
||
[source.vendored-sources] | ||
directory = "/rust/vendor" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
addr2line | ||
adler | ||
allocator-api2 | ||
cc | ||
dlmalloc | ||
fortanix-sgx-abi | ||
getopts | ||
gimli-0.28.1 | ||
gimli | ||
hermit-abi | ||
memchr | ||
miniz_oxide | ||
object | ||
r-efi | ||
r-efi-alloc | ||
rand | ||
rand_xorshift | ||
unicode-width | ||
unwinding | ||
wasi | ||
windows-sys | ||
windows-targets | ||
windows_aarch64_gnullvm | ||
windows_aarch64_msvc | ||
windows_i686_gnu | ||
windows_i686_gnullvm | ||
windows_i686_msvc | ||
windows_x86_64_gnu | ||
windows_x86_64_gnullvm | ||
windows_x86_64_msvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters