Skip to content

Commit

Permalink
Slightly clean up flake (#1515)
Browse files Browse the repository at this point in the history
- Remove obsolete {stable|nightly}-rust-native toolchains
- Inline maybeDarwinDeps for host
- Simplify unnecessarily complicated if-else statement
  • Loading branch information
aaronmondal authored Dec 3, 2024
1 parent 56dcd10 commit 2b18b90
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@
stable-rust-version = "1.82.0";
nightly-rust-version = "2024-11-23";

# TODO(aaronmondal): Tools like rustdoc don't work with the `pkgsMusl`
# package set because of missing libgcc_s. Fix this upstream and use the
# `stable-rust` toolchain in the devShell as well.
# See: https://github.com/oxalica/rust-overlay/issues/161
stable-rust-native = pkgs.rust-bin.stable.${stable-rust-version};
nightly-rust-native = pkgs.rust-bin.nightly.${nightly-rust-version};

maybeDarwinDeps = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.libiconv
];

llvmPackages = pkgs.llvmPackages_19;

customStdenv = pkgs.callPackage ./tools/llvmStdenv.nix {inherit llvmPackages;};
Expand Down Expand Up @@ -141,6 +128,8 @@
if isLinuxBuild && isLinuxTarget
then "${pkgs.mold}/bin/ld.mold"
else "${llvmPackages.lld}/bin/ld.lld";

linkerEnvVar = "CARGO_TARGET_${pkgs.lib.toUpper (pkgs.lib.replaceStrings ["-"] ["_"] targetArch)}_LINKER";
in
{
inherit src;
Expand All @@ -167,21 +156,10 @@
];
CARGO_BUILD_TARGET = targetArch;
}
// (
if isLinuxTarget
then
{
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
}
// (
if linkerPath != null
then {
"CARGO_TARGET_${pkgs.lib.toUpper (pkgs.lib.replaceStrings ["-"] ["_"] targetArch)}_LINKER" = linkerPath;
}
else {}
)
else {}
);
// (pkgs.lib.optionalAttrs isLinuxTarget {
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
${linkerEnvVar} = linkerPath;
});

# Additional target for external dependencies to simplify caching.
cargoArtifactsFor = p: (craneLibFor p).buildDepsOnly (commonArgsFor p);
Expand Down Expand Up @@ -232,7 +210,7 @@
"build-chromium-tests"
./deploy/chromium-example/build_chromium_tests.sh;

docs = pkgs.callPackage ./tools/docs.nix {rust = stable-rust-native.default;};
docs = pkgs.callPackage ./tools/docs.nix {rust = stableRustFor pkgs;};

inherit (nix2container.packages.${system}.nix2container) pullImage;
inherit (nix2container.packages.${system}.nix2container) buildImage;
Expand Down Expand Up @@ -459,7 +437,7 @@
pre-commit.settings = {
hooks = import ./tools/pre-commit-hooks.nix {
inherit pkgs;
nightly-rust = nightly-rust-native;
nightly-rust = pkgs.rust-bin.nightly.${nightly-rust-version};
};
};
local-remote-execution.settings = {
Expand Down Expand Up @@ -492,7 +470,7 @@
pkgs.pre-commit

# Rust
stable-rust-native.default
(stableRustFor pkgs)
bazel

## Infrastructure
Expand All @@ -515,8 +493,8 @@
pkgs.kustomize
pkgs.kubectx

## Web
pkgs.bun # got patched to the newest version (v.1.1.25)
# Web
pkgs.bun
pkgs.lychee
pkgs.nodejs_22 # For pagefind search
pkgs.playwright-driver
Expand All @@ -530,7 +508,11 @@
docs
build-chromium-tests
]
++ maybeDarwinDeps
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.libiconv
]
++ pkgs.lib.optionals (pkgs.stdenv.system != "x86_64-darwin") [
# Old darwin systems are incompatible with deno.
pkgs.deno
Expand Down

0 comments on commit 2b18b90

Please sign in to comment.