Skip to content

Commit b1478a7

Browse files
update nix
1 parent 7003259 commit b1478a7

File tree

3 files changed

+45
-59
lines changed

3 files changed

+45
-59
lines changed

flake.lock

Lines changed: 3 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
url = "github:ipetkov/crane";
1717
};
1818
nix2container = {
19-
# TODO(SchahinRohani): Use a specific commit hash until nix2container is stable.
20-
url = "github:nlewo/nix2container/cc96df7c3747c61c584d757cfc083922b4f4b33e";
19+
url = "github:nlewo/nix2container";
2120
inputs.nixpkgs.follows = "nixpkgs";
2221
};
2322
};
@@ -101,18 +100,27 @@
101100
# Map the nix system to the Rust target triple that we'd want to target
102101
# by default.
103102
targetArch =
104-
(
105-
nixSystem:
106-
{
107-
"x86_64-linux" = "x86_64-unknown-linux-musl";
108-
"aarch64-linux" = "aarch64-unknown-linux-musl";
109-
"x86_64-darwin" = "x86_64-apple-darwin";
110-
"aarch64-darwin" = "aarch64-apple-darwin";
111-
}.${
112-
nixSystem
113-
} or (throw "Unsupported Nix host platform: ${nixSystem}")
114-
)
115-
p.stdenv.targetPlatform.system;
103+
if p.stdenv.targetPlatform.isLinux
104+
then
105+
if p.stdenv.targetPlatform.isMusl
106+
then
107+
if p.stdenv.targetPlatform.isAarch64
108+
then "aarch64-unknown-linux-musl"
109+
else "x86_64-unknown-linux-musl"
110+
else if p.stdenv.targetPlatform.isAarch64
111+
then "aarch64-unknown-linux-gnu"
112+
else "x86_64-unknown-linux-gnu"
113+
else
114+
(
115+
nixSystem:
116+
{
117+
"x86_64-darwin" = "x86_64-apple-darwin";
118+
"aarch64-darwin" = "aarch64-apple-darwin";
119+
}.${
120+
nixSystem
121+
} or (throw "Unsupported Nix host platform: ${nixSystem}")
122+
)
123+
p.stdenv.targetPlatform.system;
116124

117125
# Full path to the linker for CARGO_TARGET_XXX_LINKER
118126
linkerPath =
@@ -125,7 +133,7 @@
125133
{
126134
inherit src;
127135
stdenv = q:
128-
if q.stdenv.targetPlatform.isLinux
136+
if q.stdenv.targetPlatform.isLinux && !q.stdenv.hostPlatform.isMusl
129137
then q.pkgsMusl.stdenv
130138
else q.stdenv;
131139
strictDeps = true;
@@ -168,14 +176,18 @@
168176
then pkgs.pkgsCross.musl64
169177
else if pkgs.system == "aarch64-linux"
170178
then pkgs.pkgsCross.aarch64-multiplatform-musl
179+
else if pkgs.system == "x86_64-darwin"
180+
then pkgs.pkgsCross.gnu64
181+
else if pkgs.system == "aarch64-darwin"
182+
then pkgs.pkgsCross.aarch64-multiplatform
171183
else pkgs;
172184

173185
nativelink = nativelinkFor nativeTargetPkgs;
174186

175187
# These two can be built by all build platforms. This is not true for
176188
# darwin targets which are only buildable via native compilation.
177-
nativelink-aarch64-linux = nativelinkFor pkgs.pkgsCross.aarch64-multiplatform-musl;
178-
nativelink-x86_64-linux = nativelinkFor pkgs.pkgsCross.musl64;
189+
nativelink-aarch64-linux = nativelinkFor pkgs.pkgsCross.aarch64-multiplatform;
190+
nativelink-x86_64-linux = nativelinkFor pkgs.pkgsCross.gnu64;
179191

180192
nativelink-is-executable-test = pkgs.callPackage ./tools/nativelink-is-executable-test.nix {inherit nativelink;};
181193

@@ -331,6 +343,7 @@
331343
(_final: prev: {
332344
cargo-llvm-cov = prev.cargo-llvm-cov.overrideAttrs (old: {
333345
meta = old.meta // {broken = false;};
346+
doCheck = false;
334347
});
335348
})
336349
];
@@ -374,6 +387,14 @@
374387

375388
generate-bazel-rc = pkgs.callPackage tools/generate-bazel-rc/build.nix {craneLib = craneLibFor pkgs;};
376389
generate-stores-config = pkgs.callPackage nativelink-config/generate-stores-config/build.nix {craneLib = craneLibFor pkgs;};
390+
391+
inherit
392+
nativelink-aarch64-linux
393+
nativelink-image
394+
nativelink-worker-init
395+
nativelink-x86_64-linux
396+
;
397+
image = nativelink-image;
377398
}
378399
// (pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec {
379400
inherit
@@ -382,6 +403,7 @@
382403
nativelink-worker-init
383404
nativelink-x86_64-linux
384405
;
406+
image = nativelink-image;
385407

386408
nativelink-worker-lre-cc = createWorker pkgs.lre.lre-cc.image;
387409
lre-java = pkgs.callPackage ./local-remote-execution/lre-java.nix {inherit buildImage;};
@@ -392,7 +414,6 @@
392414
nativelink-worker-toolchain-drake = createWorker toolchain-drake;
393415
nativelink-worker-toolchain-buck2 = createWorker toolchain-buck2;
394416
nativelink-worker-buck2-toolchain = buck2-toolchain;
395-
image = nativelink-image;
396417
})
397418
// (
398419
# It's not possible to crosscompile to darwin, not even between

tools/public/local-image-test.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ writeShellScriptBin "local-image-test" ''
1313
# nothing would still lead to a new hash. Instead we use the
1414
# derivation hash as the tag so that the tag is reused if the image
1515
# didn't change.
16-
IMAGE_TAG=$(nix eval .#$1.imageTag --raw)
17-
IMAGE_NAME=$(nix eval .#$1.imageName --raw)
16+
IMAGE_TAG=$(nix --extra-experimental-features 'nix-command flakes' eval .#$1.imageTag --raw)
17+
IMAGE_NAME=$(nix --extra-experimental-features 'nix-command flakes' eval .#$1.imageName --raw)
1818
19-
nix run .#$1.copyTo \
19+
nix --extra-experimental-features 'nix-command flakes' run .#$1.copyTo \
2020
docker-daemon:''${IMAGE_NAME}:''${IMAGE_TAG}
2121
2222
# Ensure that the image has minimal closure size.

0 commit comments

Comments
 (0)