chore(nix): setup mold linker (#6009)

Also includes some minor tidy-up of the nix flake. `mold` is a much
faster linker and a drop-in replacement for GNU's `ld`.
This commit is contained in:
Thomas Eizinger
2024-07-24 14:03:17 +10:00
committed by GitHub
parent 7c8bbd550b
commit d95c1719aa
2 changed files with 8 additions and 46 deletions

37
scripts/nix/flake.lock generated
View File

@@ -36,37 +36,7 @@
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1717067539,
"narHash": "sha256-oIs5EF+6VpHJRvvpVWuqCYJMMVW/6h59aYUv9lABLtY=",
"owner": "nix-community",
"repo": "naersk",
"rev": "fa19d8c135e776dc97f4dcca08656a0eeb28d5c0",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 0,
"narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=",
"path": "/nix/store/qgbn0imyridkb9527v6gnv6z3jzzprb9-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1718229064,
"narHash": "sha256-ZFav8A9zPNfjZg/wrxh1uZeMJHELRfRgFP+meq01XYk=",
@@ -81,7 +51,7 @@
"type": "indirect"
}
},
"nixpkgs_3": {
"nixpkgs_2": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
@@ -100,15 +70,14 @@
"root": {
"inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1718331519,

View File

@@ -1,7 +1,6 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11";
naersk.url = "github:nix-community/naersk";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
@@ -15,7 +14,6 @@
inherit system;
overlays = [ (import rust-overlay) ];
};
naersk = pkgs.callPackage inputs.naersk { };
rust-nightly = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
# Wrap `cargo-udeps` to ensure it uses a nightly Rust version.
@@ -58,19 +56,14 @@
buildInputs = rustVersion ++ packages;
name = "rust-env";
src = ../../rust;
shellHook =
''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
'';
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH";
XDG_DATA_DIRS = "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS";
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages.clangUseLLVM}/bin/clang";
CARGO_ENCODED_RUSTFLAGS = "-Clink-arg=-fuse-ld=${pkgs.mold}/bin/mold";
};
in
{
packages.firezone-headless-client = naersk.buildPackage {
name = "foo";
src = ../../rust/headless-client;
};
devShells.default = mkShellWithRustVersion [
(pkgs.rust-bin.fromRustupToolchainFile ../../rust/rust-toolchain.toml)
];