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;
craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain;
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
in
{
packages.default =
packages =
let
inherit (pkgs.lib) fileset;
in
craneLib.buildPackage {
without = fs: fileset.difference ./. fs;
nixFiles = fileset.unions [ ./flake.nix ./flake.lock ./.envrc ];
gitFiles = fileset.gitTracked ./.;
src = fileset.toSource {
root = ./.;
fileset = fileset.intersection
(fileset.difference ./.
(fileset.unions [ ./.cargo ./flake.nix ./flake.lock ./.envrc ]))
(fileset.gitTracked ./.);
fileset = fileset.intersection (without nixFiles) gitFiles;
};
in
{
default =
craneLib.buildPackage {
inherit src stdenv;
};
};
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;
[ ]
);
};
});
}