diff --git a/Cargo.lock b/Cargo.lock index e2397ab..3a23f75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -557,9 +557,9 @@ checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hotpath" -version = "0.8.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0a2c66c081fe3684a54a7e5d059c9d9ad6b3ee5ccea14f6e4f056dbd77becf" +checksum = "08382b985a19a79d95d35e2e201b02cc4b99efe2f47d82f3fd4301bb0005bb68" dependencies = [ "arc-swap", "base64", @@ -586,9 +586,9 @@ dependencies = [ [[package]] name = "hotpath-macros" -version = "0.8.0" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38fa43ca80cf906cd05127e490d740a51abb38316db7bce9d95e89724a81761" +checksum = "7d618063f89423ebe079a69f5435a13d4909219d4e359757118b75fd05ae65d0" dependencies = [ "proc-macro2", "quote", @@ -786,9 +786,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.178" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libredox" diff --git a/Cargo.toml b/Cargo.toml index 9f6cc4a..c245c00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,8 @@ name = "microfetch" path = "src/main.rs" [dependencies] -hotpath = { optional = true, version = "0.8.0" } -libc = "0.2.178" +hotpath = { optional = true, version = "0.7.5" } +libc = "0.2.177" [dev-dependencies] criterion = "0.8.0" diff --git a/README.md b/README.md index 8f59640..f148a61 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,15 @@
-

Microfetch

-

Microscopic fetch tool in Rust, for NixOS systems, with special emphasis on speed

+

+ Microfetch +

+

+ Microscopic fetch tool in Rust, for NixOS systems, with special emphasis on speed +


Synopsis
- Features | Motivation
| Benchmarks
+ Features | Motivation
Installation
@@ -61,42 +65,34 @@ on your system: it is pretty _[fast](#benchmarks)_... ## Motivation -[Rube-Goldmark Machine]: https://en.wikipedia.org/wiki/Rube_Goldberg_machine +Fastfetch, as its name probably hinted, is a very fast fetch tool written in C. +However, I am not interested in _any_ of its additional features, and I'm not +interested in its configuration options. Sure I can _configure_ it when I +dislike the defaults, but how often would I really change the configuration... -Fastfetch, as its name _probably_ already hinted, is a very fast fetch tool -written in C. I used to use Fastfetch on my systems, but I eventually came to -the realization that I am _not interested in any of its additional features_. I -don't use Sixel, I don't change my configuration more than maybe once a year and -I don't even display most of the fields that it does. Sure the configurability -is nice and I can configure the defaults that I do not like but how often do I -really do that? +Microfetch is my response to this problem. It is an _even faster_ fetch tool +that I would've written in Bash and put in my `~/.bashrc` but is _actually_ +incredibly fast because it opts out of all the customization options provided by +tools such as Fastfetch. Ultimately, it's a small, opinionated binary with a +nice size that doesn't bother me, and incredible speed. Customization? No thank +you. I cannot re-iterate it enough, Microfetch is _annoyingly fast_. -Since I already enjoy programming challenges, and don't use a fetch program that -often, I eventually came to try and answer the question _how fast can I make my -fetch script?_ It is an _even faster_ fetch tool that I would've written in Bash -and put in my `~/.bashrc` but is _actually_ incredibly fast because it opts out -of all the customization options provided by tools such as Fastfetch. Since -Fetch scripts are kind of a coming-of-age ritual for most Linux users, I've -decided to use it on my system. You also might be interested if you like the -defaults and like speed. +The project is written in Rust, which comes at the cost of "bloated" dependency +trees and the increased build times, but we make an extended effort to keep the +dependencies minimal and build times managable. The latter is also very easily +mitigated with Nix's binary cache systems. Since Microfetch is already in +Nixpkgs, you are recommended to use it to utilize the binary cache properly. The +usage of Rust _is_ nice, however, since it provides us with incredible tooling +and a very powerful language that allows for Microfetch to be as fast as +possible. Sure C could've been used here as well, but do you think I hate +myself? -Ultimately, it's a small, opinionated binary with a nice size that doesn't -bother me, and incredible speed. Customization? No thank you. I cannot -re-iterate it enough, Microfetch is _annoyingly fast_. It does not, however, -solve a technical problem. The "problem" Microfetch solves is entirely -self-imposed. On the matter of _size_, the project is written in Rust, which -comes at the cost of "bloated" dependency trees and the increased build times, -but we make an extended effort to keep the dependencies minimal and build times -managable. The latter is also very easily mitigated with Nix's binary cache -systems. Since Microfetch is already in Nixpkgs, you are recommended to use it -to utilize the binary cache properly. The usage of Rust _is_ nice, however, -since it provides us with incredible tooling and a very powerful language that -allows for Microfetch to be as fast as possible. ~~Sure C could've been used -here as well, but do you think I hate myself?~~ Microfetch now features -handwritten assembly to unsafely optimize some areas. In hindsight you all -should have seen this coming. Is it faster? Yes. - -Also see: [Rube-Goldmark Machine] +> [!IMPORTANT] +> **Update as of November 30th, 2025**: +> +> Microfetch now inlines handwritten assembly for even better performance. I +> know I previously said I do not hate myself but I'm beginning to suspect this +> is no longer the case. Enjoy the performance benefits! ## Benchmarks @@ -204,31 +200,17 @@ You can't. ### Why? -Customization, of most kinds, are expensive: I could try reading environment -variables, parse command-line arguments or read a configuration file to allow -configuring various fields but those inflate execution time and the resource -consumption by a lot. Since Microfetch is closer to a code golf challenge than a -program that attempts to fill a gap, I have elected not to make this trade. +Customization, of any kind, is expensive: I could try reading environment +variables, parse command-line arguments or read a configuration file but all of +those increment execution time and resource consumption by a lot. ### Really? -[main module]: ./src/main.rs -[discussions tab]: https://github.com/NotAShelf/microfetch/discussions - -To be fair, you _can_ customize Microfetch by, well, patching it. It is -certainly not the easiest way of doing so but if you are planning to change -something in Microfetch, patching is the best way to go. It will also the only -way that does not compromise on speed, unless you patch in bad code. Various -users have adapted Microfetch to their distribution by patching the -[main module] and inserting the logo of their choice. This is also the best way -to go if you plan to make small changes. If your changes are not small, you -might want to look for a program that is designed to be customizable; Microfetch -is built for maximum performance. +To be fair, you _can_ customize Microfetch by, well, patching it. It's not the +best way per se, but it will be the only way that does not compromise on speed. The Nix package allows passing patches in a streamlined manner by passing -`.overrideAttrs` to the derivation. You can apply your patches in `patches` and -share your derivations with people. Feel free to use the [discussions tab] to -share your own variants of Microfetch! +`.overrideAttrs` to the derivation. ## Contributing @@ -240,22 +222,13 @@ Contributions that help improve performance in specific areas of Microfetch are welcome. Though, prepare to be bombarded with questions if your changes are large. -### Hacking +## Hacking -A Nix flake is provided. You may use `nix develop` to get started. Direnv users -may instead run `direnv allow` to get a complete environment with shell -integration. +A Nix flake is provided. `nix develop` to get started. Direnv users may simply +run `direnv allow` to get started. -Non-Nix user will need `cargo`, `clang` and `mold` installed on their system to -build Microfetch. As Mold seems to yield _slightly_ better results than the -default linker, it has been set as the default in `.cargo/config.toml` for -x86-64 Linux. You may override those defaults using the `RUSTFLAGS` environment -variable. For example: - -```sh -# Use ld instead of Mold -$ RUSTFLAGS="-C linker=/path/to/ld.lld" cargo build -``` +Non-nix users will need `cargo` and `gcc` installed on their system, see +`Cargo.toml` for available release profiles. ## Thanks @@ -272,7 +245,6 @@ person about current issues. To list a few, special thanks to: - [@sioodmy](https://github.com/sioodmy) - Being cute - [@mewoocat](https://github.com/mewoocat) - The awesome NixOS logo ASCII used in Microfetch -- [@uzaaft](https://github.com/uzaaft) - Helping me going faster Additionally a big thank you to everyone who used, talked about or criticized Microfetch. I might have missed your name here, but you have my thanks. diff --git a/src/main.rs b/src/main.rs index e29d6d1..c3e7c69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,7 @@ fn print_system_info( {blue} ▟█▛ {blue}▝█▘{cyan}▟█▛ {cyan} {blue}Shell{reset}  {shell} {blue}▟█████▛ {cyan}▟█████▛ {cyan} {blue}Uptime{reset}  {uptime} {blue} ▟█▛{cyan}▗█▖ {cyan}▟█▛ {cyan} {blue}Desktop{reset}  {desktop} - {blue} ▝█▛ {cyan}██▖{blue}▗▄▄▄▄▄▄▄▄▄▄▄ {cyan}󰍛 {blue}Memory{reset}  {memory_usage} + {blue} ▝█▛ {cyan}██▖{blue}▗▄▄▄▄▄▄▄▄▄▄▄ {cyan} {blue}Memory{reset}  {memory_usage} {blue} ▝ {cyan}▟█▜█▖{blue}▀▀▀▀▀██▛▀▀▘ {cyan}󱥎 {blue}Storage (/){reset}  {storage} {cyan} ▟█▘ ▜█▖ {blue}▝█▛ {cyan} {blue}Colors{reset}  {colors}\n\n" )?;