Merge pull request #125 from emilazy/push-qppkqwrwsowk

Fix build with Darwin and Nix 2.26 after updates
This commit is contained in:
Cole Helbling 2025-02-24 11:27:00 -08:00 committed by GitHub
commit 1eeaf990c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 68 additions and 177 deletions

View file

@ -1,3 +0,0 @@
# For -Zbuild-std
[target.aarch64-unknown-linux-musl]
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc"]

View file

@ -21,10 +21,8 @@ jobs:
- name: Check health of flake.lock - name: Check health of flake.lock
uses: DeterminateSystems/flake-checker-action@main uses: DeterminateSystems/flake-checker-action@main
# TODO: re-enable fail mode when we find a way to bump Nixpkgs to 24.05 with:
# without breaking the static Rust build fail-mode: true
#with:
# fail-mode: true
- name: Check Rust formatting - name: Check Rust formatting
run: nix develop --command cargo fmt --check run: nix develop --command cargo fmt --check

45
Cargo.lock generated
View file

@ -239,7 +239,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "attic" name = "attic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#0a8d39427498b33c6fac4610faa2406ba83653aa" source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#f789ed4a186e136ea938c28551eaaf8081cc4496"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"base64 0.22.1", "base64 0.22.1",
@ -254,12 +254,12 @@ dependencies = [
"lazy_static", "lazy_static",
"log", "log",
"nix-base32", "nix-base32",
"pkg-config",
"regex", "regex",
"serde", "serde",
"serde_with", "serde_with",
"serde_yaml", "serde_yaml",
"sha2", "sha2",
"system-deps",
"tempfile", "tempfile",
"tokio", "tokio",
"tracing", "tracing",
@ -270,7 +270,7 @@ dependencies = [
[[package]] [[package]]
name = "attic-client" name = "attic-client"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#0a8d39427498b33c6fac4610faa2406ba83653aa" source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#f789ed4a186e136ea938c28551eaaf8081cc4496"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-channel", "async-channel",
@ -301,7 +301,7 @@ dependencies = [
[[package]] [[package]]
name = "attic-server" name = "attic-server"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#0a8d39427498b33c6fac4610faa2406ba83653aa" source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#f789ed4a186e136ea938c28551eaaf8081cc4496"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-compression", "async-compression",
@ -353,7 +353,7 @@ dependencies = [
[[package]] [[package]]
name = "attic-token" name = "attic-token"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#0a8d39427498b33c6fac4610faa2406ba83653aa" source = "git+https://github.com/DeterminateSystems/attic?branch=fixups-for-magic-nix-cache#f789ed4a186e136ea938c28551eaaf8081cc4496"
dependencies = [ dependencies = [
"attic", "attic",
"base64 0.22.1", "base64 0.22.1",
@ -1074,6 +1074,16 @@ dependencies = [
"shlex", "shlex",
] ]
[[package]]
name = "cfg-expr"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d4ba6e40bd1184518716a6e1a781bf9160e286d219ccdb8ab2612e74cfe4789"
dependencies = [
"smallvec",
"target-lexicon",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -4775,12 +4785,31 @@ dependencies = [
"syn 2.0.98", "syn 2.0.98",
] ]
[[package]]
name = "system-deps"
version = "7.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66d23aaf9f331227789a99e8de4c91bf46703add012bdfd45fdecdfb2975a005"
dependencies = [
"cfg-expr",
"heck 0.5.0",
"pkg-config",
"toml",
"version-compare",
]
[[package]] [[package]]
name = "tap" name = "tap"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "target-lexicon"
version = "0.12.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.17.1" version = "3.17.1"
@ -5374,6 +5403,12 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version-compare"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.5" version = "0.9.5"

View file

@ -91,8 +91,8 @@ For local development, see `gha-cache/README.md` for more details on how to obta
```shell ```shell
cargo run -- -c creds.json --upstream https://cache.nixos.org cargo run -- -c creds.json --upstream https://cache.nixos.org
cargo build --release --target x86_64-unknown-linux-musl cargo build --release --target x86_64-unknown-linux-gnu
cargo build --release --target aarch64-unknown-linux-musl cargo build --release --target aarch64-unknown-linux-gnu
nix copy --to 'http://127.0.0.1:3000' $(which bash) nix copy --to 'http://127.0.0.1:3000' $(which bash)
nix-store --store $PWD/test-root --extra-substituters 'http://localhost:3000' --option require-sigs false -r $(which bash) nix-store --store $PWD/test-root --extra-substituters 'http://localhost:3000' --option require-sigs false -r $(which bash)
``` ```

View file

@ -1,59 +1,21 @@
{ {
"nodes": { "nodes": {
"crane": { "crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1714842444, "lastModified": 1739936662,
"narHash": "sha256-z4HeSYtEdYxKurrbxCMb8v/I1LYDHR/aFrZtGtgUgHw=", "narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
"rev": "c5ee4371eea1728ef04bb09c79577c84d5e67a48", "owner": "ipetkov",
"revCount": 557, "repo": "crane",
"type": "tarball", "rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
"url": "https://api.flakehub.com/f/pinned/ipetkov/crane/0.16.6/018f4495-627e-7385-b537-81f1c1d4003b/source.tar.gz" "type": "github"
}, },
"original": { "original": {
"type": "tarball", "owner": "ipetkov",
"url": "https://flakehub.com/f/ipetkov/crane/0.16.3.tar.gz" "repo": "crane",
} "type": "github"
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1738391509,
"narHash": "sha256-TC3xA++KgprECm/WPsLUd+a77MObZPElCW6eAsjVW1k=",
"rev": "de3ea31eb651b663449361f77d9c1e8835290470",
"revCount": 2156,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.2156%2Brev-de3ea31eb651b663449361f77d9c1e8835290470/0194c095-0041-7b9c-b19e-cf1c4a2adaad/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/nix-community/fenix/0.1.1727.tar.gz"
} }
}, },
"flake-compat": { "flake-compat": {
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"revCount": 69,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.0.1.tar.gz"
}
},
"flake-compat_2": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1733328505, "lastModified": 1733328505,
@ -123,7 +85,7 @@
}, },
"nix": { "nix": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"git-hooks-nix": "git-hooks-nix", "git-hooks-nix": "git-hooks-nix",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
@ -208,28 +170,9 @@
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"fenix": "fenix",
"flake-compat": "flake-compat",
"nix": "nix", "nix": "nix",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
} }
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1738224931,
"narHash": "sha256-1zhfA5NBqin0Z79Se85juvqQteq7uClJMEb7l2pdDUY=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "3c2aca1e5e9fbabb4e05fc4baa62e807aadc476a",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -4,22 +4,14 @@
inputs = { inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.tar.gz"; nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.tar.gz";
fenix = { # Pinned to `master` until a release containing
url = "https://flakehub.com/f/nix-community/fenix/0.1.1727.tar.gz"; # <https://github.com/ipetkov/crane/pull/792> is cut.
inputs.nixpkgs.follows = "nixpkgs"; crane.url = "github:ipetkov/crane";
};
crane = {
url = "https://flakehub.com/f/ipetkov/crane/0.16.3.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.0.1.tar.gz";
nix.url = "https://flakehub.com/f/NixOS/nix/2.tar.gz"; nix.url = "https://flakehub.com/f/NixOS/nix/2.tar.gz";
}; };
outputs = { self, nixpkgs, fenix, crane, ... }@inputs: outputs = { self, nixpkgs, crane, ... }@inputs:
let let
supportedSystems = [ supportedSystems = [
"aarch64-linux" "aarch64-linux"
@ -38,27 +30,12 @@
inherit (pkgs) lib; inherit (pkgs) lib;
inherit system; inherit system;
}); });
fenixToolchain = system: with fenix.packages.${system};
combine ([
stable.clippy
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-src
stable.rust-analyzer
] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
] ++ nixpkgs.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]);
in in
{ {
overlays.default = final: prev: overlays.default = final: prev:
let let
toolchain = fenixToolchain final.hostPlatform.system; craneLib = crane.mkLib final;
craneLib = (crane.mkLib final).overrideToolchain toolchain;
crateName = craneLib.crateNameFromCargoToml { crateName = craneLib.crateNameFromCargoToml {
cargoToml = ./magic-nix-cache/Cargo.toml; cargoToml = ./magic-nix-cache/Cargo.toml;
}; };
@ -74,22 +51,15 @@
buildInputs = [ buildInputs = [
inputs.nix.packages.${final.stdenv.system}.default inputs.nix.packages.${final.stdenv.system}.default
final.boost final.boost
] ++ final.lib.optionals final.stdenv.isDarwin [
final.darwin.apple_sdk.frameworks.SystemConfiguration
(final.libiconv.override { enableStatic = true; enableShared = false; })
]; ];
NIX_CFLAGS_LINK = final.lib.optionalString final.stdenv.isDarwin "-lc++abi";
}; };
cargoArtifacts = craneLib.buildDepsOnly commonArgs; cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in in
rec { {
magic-nix-cache = craneLib.buildPackage (commonArgs // { magic-nix-cache = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts; inherit cargoArtifacts;
}); });
default = magic-nix-cache;
}; };
packages = forEachSupportedSystem ({ pkgs, ... }: rec { packages = forEachSupportedSystem ({ pkgs, ... }: rec {
@ -127,16 +97,16 @@
createChain 200 startFile; createChain 200 startFile;
}); });
devShells = forEachSupportedSystem ({ system, pkgs, lib }: devShells = forEachSupportedSystem ({ system, pkgs, lib }: {
let
toolchain = fenixToolchain system;
in
{
default = pkgs.mkShell { default = pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
toolchain rustc
cargo
clippy
rustfmt
rust-analyzer
nix # for linking attic inputs.nix.packages.${stdenv.system}.default # for linking attic
boost # for linking attic boost # for linking attic
bashInteractive bashInteractive
pkg-config pkg-config
@ -148,13 +118,9 @@
bacon bacon
age age
] ++ lib.optionals pkgs.stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.SystemConfiguration
]; ];
NIX_CFLAGS_LINK = lib.optionalString pkgs.stdenv.isDarwin "-lc++abi"; RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
}; };
}); });
}; };

View file

@ -1,48 +0,0 @@
diff --git a/mk/libraries.mk b/mk/libraries.mk
index 6541775f329..5118b957608 100644
--- a/mk/libraries.mk
+++ b/mk/libraries.mk
@@ -130,7 +130,15 @@ define build-library
$(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)
- $(1)_INSTALL_PATH := $$(libdir)/$$($(1)_NAME).a
+ $(1)_INSTALL_PATH := $(DESTDIR)$$($(1)_INSTALL_DIR)/$$($(1)_NAME).a
+
+ $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
+
+ $$($(1)_INSTALL_PATH): $$($(1)_OBJS) | $(DESTDIR)$$($(1)_INSTALL_DIR)/
+ +$$(trace-ld) $(LD) -Ur -o $$(_d)/$$($(1)_NAME).o $$^
+ $$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o
+
+ install: $$($(1)_INSTALL_PATH)
endif
diff --git a/src/libstore/local.mk b/src/libstore/local.mk
index 8f28bec6c1d..0d41e3c2cac 100644
--- a/src/libstore/local.mk
+++ b/src/libstore/local.mk
@@ -69,6 +69,13 @@ $(d)/build.cc:
clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh
+$(d)/nix-store.pc: $(d)/nix-store.pc.in
+ $(trace-gen) rm -f $@ && ./config.status --quiet --file=$@
+ifeq ($(BUILD_SHARED_LIBS), 1)
+ sed -i 's|@LIBS_PRIVATE@||' $@
+else
+ sed -i 's|@LIBS_PRIVATE@|Libs.private: $(libstore_LDFLAGS) $(libstore_LDFLAGS_PROPAGATED) $(foreach lib, $(libstore_LIBS), $($(lib)_LDFLAGS))|' $@
+endif
$(eval $(call install-file-in, $(d)/nix-store.pc, $(libdir)/pkgconfig, 0644))
$(foreach i, $(wildcard src/libstore/builtins/*.hh), \
diff --git a/src/libstore/nix-store.pc.in b/src/libstore/nix-store.pc.in
index 6d67b1e0380..738991d307b 100644
--- a/src/libstore/nix-store.pc.in
+++ b/src/libstore/nix-store.pc.in
@@ -7,3 +7,4 @@ Description: Nix Package Manager
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lnixstore -lnixutil
Cflags: -I${includedir}/nix -std=c++2a
+@LIBS_PRIVATE@