mirror of
https://github.com/NotAShelf/microfetch.git
synced 2025-12-07 21:43:51 +00:00
nix: build with Mold linker on x86_64-linux
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I771c36297577aba189058a2183ec2b4a6a6a6964
This commit is contained in:
parent
3ad14a95a6
commit
8c32f5f408
3 changed files with 27 additions and 6 deletions
|
|
@ -43,7 +43,7 @@ on your system: it is pretty _[fast](#benchmarks)_...
|
||||||
- Fast
|
- Fast
|
||||||
- Really fast
|
- Really fast
|
||||||
- Minimal dependencies
|
- Minimal dependencies
|
||||||
- Tiny binary (~370kb)
|
- Tiny binary (~370kb [^1])
|
||||||
- Actually really fast
|
- Actually really fast
|
||||||
- Cool NixOS logo (other, inferior, distros are not supported)
|
- Cool NixOS logo (other, inferior, distros are not supported)
|
||||||
- Reliable detection of following info:
|
- Reliable detection of following info:
|
||||||
|
|
@ -60,6 +60,9 @@ on your system: it is pretty _[fast](#benchmarks)_...
|
||||||
- Did I mention fast?
|
- Did I mention fast?
|
||||||
- Respects [`NO_COLOR` spec](https://no-color.org/)
|
- Respects [`NO_COLOR` spec](https://no-color.org/)
|
||||||
|
|
||||||
|
[^1]: With the Mold linker, which is enabled by default in the Flake package,
|
||||||
|
the binary size is roughly 350kb. That's nearly 20kb reduction in size :)
|
||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
|
||||||
Fastfetch, as its name probably hinted, is a very fast fetch tool written in C.
|
Fastfetch, as its name probably hinted, is a very fast fetch tool written in C.
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,12 @@
|
||||||
forEachSystem = nixpkgs.lib.genAttrs systems;
|
forEachSystem = nixpkgs.lib.genAttrs systems;
|
||||||
pkgsForEach = nixpkgs.legacyPackages;
|
pkgsForEach = nixpkgs.legacyPackages;
|
||||||
in {
|
in {
|
||||||
packages = forEachSystem (system: {
|
packages = forEachSystem (system: let
|
||||||
|
pkgs = pkgsForEach.${system};
|
||||||
|
in {
|
||||||
default = self.packages.${system}.microfetch;
|
default = self.packages.${system}.microfetch;
|
||||||
microfetch = pkgsForEach.${system}.callPackage ./nix/package.nix {};
|
microfetch = pkgs.callPackage ./nix/package.nix {};
|
||||||
|
microfetch-mold = pkgs.callPackage ./nix/package.nix {useMold = true;};
|
||||||
});
|
});
|
||||||
|
|
||||||
devShells = forEachSystem (system: {
|
devShells = forEachSystem (system: {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,22 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
rustPlatform,
|
stdenv,
|
||||||
stdenvAdapters,
|
stdenvAdapters,
|
||||||
|
rustPlatform,
|
||||||
llvm,
|
llvm,
|
||||||
|
useMold ? stdenv.isLinux && !stdenv.hostPlatform.isAarch,
|
||||||
}: let
|
}: let
|
||||||
toml = (lib.importTOML ../Cargo.toml).package;
|
toml = (lib.importTOML ../Cargo.toml).package;
|
||||||
pname = toml.name;
|
pname = toml.name;
|
||||||
inherit (toml) version;
|
inherit (toml) version;
|
||||||
|
|
||||||
|
# Select stdenv based on useMold flag
|
||||||
|
stdenv =
|
||||||
|
if useMold
|
||||||
|
then stdenvAdapters.useMoldLinker llvm.stdenv
|
||||||
|
else llvm.stdenv;
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage.override {stdenv = stdenvAdapters.useMoldLinker llvm.stdenv;} {
|
rustPlatform.buildRustPackage.override {inherit stdenv;} {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
src = let
|
src = let
|
||||||
fs = lib.fileset;
|
fs = lib.fileset;
|
||||||
|
|
@ -26,7 +34,14 @@ in
|
||||||
|
|
||||||
cargoLock.lockFile = ../Cargo.lock;
|
cargoLock.lockFile = ../Cargo.lock;
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
env.RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
|
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 = {
|
meta = {
|
||||||
description = "Microscopic fetch script in Rust, for NixOS systems";
|
description = "Microscopic fetch script in Rust, for NixOS systems";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue