File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed
Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ on your system: it is pretty _[fast](#benchmarks)_...
4343- Fast
4444- Really fast
4545- Minimal dependencies
46- - Tiny binary (~ 370kb)
46+ - Tiny binary (~ 370kb [ ^ 1 ] )
4747- Actually really fast
4848- Cool NixOS logo (other, inferior, distros are not supported)
4949- Reliable detection of following info:
@@ -60,6 +60,9 @@ on your system: it is pretty _[fast](#benchmarks)_...
6060- Did I mention fast?
6161- Respects [ ` NO_COLOR ` spec] ( https://no-color.org/ )
6262
63+ [ ^ 1 ] : With the Mold linker, which is enabled by default in the Flake package,
64+ the binary size is roughly 350kb. That's nearly 20kb reduction in size :)
65+
6366## Motivation
6467
6568Fastfetch, as its name probably hinted, is a very fast fetch tool written in C.
Original file line number Diff line number Diff line change 1010 forEachSystem = nixpkgs . lib . genAttrs systems ;
1111 pkgsForEach = nixpkgs . legacyPackages ;
1212 in {
13- packages = forEachSystem ( system : {
13+ packages = forEachSystem ( system : let
14+ pkgs = pkgsForEach . ${ system } ;
15+ in {
1416 default = self . packages . ${ system } . microfetch ;
15- microfetch = pkgsForEach . ${ system } . callPackage ./nix/package.nix { } ;
17+ microfetch = pkgs . callPackage ./nix/package.nix { } ;
18+ microfetch-mold = pkgs . callPackage ./nix/package.nix { useMold = true ; } ;
1619 } ) ;
1720
1821 devShells = forEachSystem ( system : {
Original file line number Diff line number Diff line change 11{
22 lib ,
3- rustPlatform ,
3+ stdenv ,
44 stdenvAdapters ,
5+ rustPlatform ,
56 llvm ,
7+ useMold ? stdenv . isLinux && ! stdenv . hostPlatform . isAarch ,
68} : let
79 toml = ( lib . importTOML ../Cargo.toml ) . package ;
810 pname = toml . name ;
911 inherit ( toml ) version ;
12+
13+ # Select stdenv based on useMold flag
14+ stdenv =
15+ if useMold
16+ then stdenvAdapters . useMoldLinker llvm . stdenv
17+ else llvm . stdenv ;
1018in
11- rustPlatform . buildRustPackage . override { stdenv = stdenvAdapters . useMoldLinker llvm . stdenv ; } {
19+ rustPlatform . buildRustPackage . override { inherit stdenv ; } {
1220 inherit pname version ;
1321 src = let
1422 fs = lib . fileset ;
2634
2735 cargoLock . lockFile = ../Cargo.lock ;
2836 enableParallelBuilding = true ;
29- env . RUSTFLAGS = "-C link-arg=-fuse-ld=mold" ;
37+ buildNoDefaultFeatures = true ;
38+ doCheck = false ;
39+
40+ # Only set RUSTFLAGS for mold if useMold is enabled
41+ env = lib . optionalAttrs useMold {
42+ CARGO_LINKER = "clang" ;
43+ RUSTFLAGS = "-C link-arg=-fuse-ld=mold" ;
44+ } ;
3045
3146 meta = {
3247 description = "Microscopic fetch script in Rust, for NixOS systems" ;
You can’t perform that action at this time.
0 commit comments