{ description = "A configurable fetch tool written in Rust."; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; advisory-db = { url = "github:rustsec/advisory-db"; flake = false; }; }; outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; }; inherit (pkgs) lib; craneLib = crane.mkLib pkgs; src = craneLib.cleanCargoSource (craneLib.path ./.); commonArgs = { inherit src; buildInputs = [ ]; }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; nxfetch = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); nxfetch-benchmark = pkgs.writeShellScriptBin "benchmark" ( lib.strings.concatStringsSep " " [ "${pkgs.hyperfine}/bin/hyperfine" "--warmup 10" "--shell=none" "${nxfetch}/bin/nxfetch" "${pkgs.afetch}/bin/afetch" "${pkgs.bunnyfetch}/bin/bunnyfetch" "${pkgs.fastfetch}/bin/fastfetch" "${pkgs.inxi}/bin/inxi" "${pkgs.neofetch}/bin/neofetch" "${pkgs.pfetch}/bin/pfetch" "${pkgs.profetch}/bin/profetch" "${pkgs.yafetch}/bin/yafetch" ] ); nxfetch-benchmark-single = pkgs.writeShellScriptBin "benchmark-single" ( lib.strings.concatStringsSep " " [ "${pkgs.hyperfine}/bin/hyperfine" "--warmup 10" "--shell=none" "${nxfetch}/bin/nxfetch" ] ); in { checks = { inherit nxfetch; nxfetch-clippy = craneLib.cargoClippy ( commonArgs // { inherit cargoArtifacts; cargoClippyExtraArgs = "--all-targets -- --deny warnings"; } ); nxfetch-doc = craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; }); nxfetch-fmt = craneLib.cargoFmt { inherit src; }; nxfetch-audit = craneLib.cargoAudit { inherit src advisory-db; }; }; packages = { default = nxfetch; benchmark = nxfetch-benchmark; benchmark-single = nxfetch-benchmark-single; }; apps.default = flake-utils.lib.mkApp { name = "nxfetch"; drv = nxfetch; }; formatter = pkgs.nixfmt-rfc-style; devShells.default = pkgs.mkShell { inputsFrom = builtins.attrValues self.checks.${system}; RUST_BACKTRACE = "full"; CARGO_PROFILE_RELEASE_DEBUG = true; nativeBuildInputs = with pkgs; [ cargo-flamegraph # profiler cargo # rust package manager clippy # opinionated rust formatter marksman # md language server nixfmt-rfc-style # nix code formatter rust-analyzer # rust analyzer taplo-lsp # toml language server ]; LD_LIBRARY_PATH = lib.makeLibraryPath commonArgs.buildInputs; }; } ); nixConfig = { extra-substituters = [ "https://nxfetch.cachix.org" ]; extra-trusted-public-keys = [ "nxfetch.cachix.org-1:DqGz4BdO5hI+4fqS27EEtnYZzinSurUdeQn2PsvzyvA=" ]; }; }