nix: use mold on all Linux targets; fix source filters

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib5925097dd366505d01f9448e7e2ee926a6a6964
This commit is contained in:
raf 2026-03-27 23:48:19 +03:00
commit 5ce0f3b1e8
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -1,22 +1,13 @@
{
lib,
stdenv,
stdenvAdapters,
rustPlatform,
llvm,
useMold ? stdenv.isLinux,
}: let
toml = (lib.importTOML ../Cargo.toml).package;
pname = toml.name;
inherit (toml) version;
# Select stdenv based on useMold flag
stdenv =
if useMold
then stdenvAdapters.useMoldLinker llvm.stdenv
else llvm.stdenv;
in
rustPlatform.buildRustPackage.override {inherit stdenv;} {
rustPlatform.buildRustPackage.override {inherit (llvm) stdenv;} {
inherit pname version;
src = let
fs = lib.fileset;
@ -25,10 +16,11 @@ in
fs.toSource {
root = s;
fileset = fs.unions [
(fs.fileFilter (file: builtins.any file.hasExt ["rs"]) (s + /src))
(fs.fileFilter (file: builtins.any file.hasExt ["rs"]) (s + /crates))
(fs.fileFilter (file: builtins.any file.hasExt ["rs"]) (s + /microfetch))
(s + /.cargo)
(s + /Cargo.lock)
(s + /Cargo.toml)
(s + /benches)
];
};
@ -37,12 +29,6 @@ in
buildNoDefaultFeatures = true;
doCheck = false;
# Only set RUSTFLAGS for mold if useMold is enabled
env = lib.optionalAttrs useMold {
CARGO_LINKER = "clang";
RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
};
meta = {
description = "Microscopic fetch script in Rust, for NixOS systems";
homepage = "https://github.com/NotAShelf/microfetch";