feat: use mold linker through crane

nixos
Moritz Böhme 2024-01-20 16:24:08 +01:00
parent c37a55d570
commit b0951b6805
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
2 changed files with 17 additions and 11 deletions

View File

@ -1,2 +0,0 @@
[target.x86_64-unknown-linux-gnu]
linker = "clang"

View File

@ -23,28 +23,36 @@
}; };
toolchain = fenix.packages.${system}.stable; toolchain = fenix.packages.${system}.stable;
craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain; craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain;
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
in in
{ {
packages.default = packages =
let let
inherit (pkgs.lib) fileset; inherit (pkgs.lib) fileset;
in without = fs: fileset.difference ./. fs;
craneLib.buildPackage { nixFiles = fileset.unions [ ./flake.nix ./flake.lock ./.envrc ];
gitFiles = fileset.gitTracked ./.;
src = fileset.toSource { src = fileset.toSource {
root = ./.; root = ./.;
fileset = fileset.intersection fileset = fileset.intersection (without nixFiles) gitFiles;
(fileset.difference ./.
(fileset.unions [ ./.cargo ./flake.nix ./flake.lock ./.envrc ]))
(fileset.gitTracked ./.);
}; };
in
{
default =
craneLib.buildPackage {
inherit src stdenv;
};
}; };
devShell = pkgs.mkShell.override devShell = pkgs.mkShell.override
{ {
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; inherit stdenv;
} }
{ {
nativeBuildInputs = with toolchain; [ rustc cargo rust-analyzer clippy ]; nativeBuildInputs = with toolchain;
[ rustc cargo rust-analyzer clippy ] ++ (with pkgs;
[ ]
);
}; };
}); });
} }