this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at d3807962cbbaf22fd7cefbdbbdc9f641519931df 162 lines 5.0 kB view raw
1{ 2 description = "A compression multi-tool for the command line."; 3 4 inputs = { 5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 6 pre-commit-hooks = { 7 url = "github:cachix/pre-commit-hooks.nix"; 8 inputs = { 9 nixpkgs.follows = "nixpkgs"; 10 nixpkgs-stable.follows = "nixpkgs"; 11 }; 12 }; 13 14 crane = { 15 url = "github:ipetkov/crane"; 16 inputs.nixpkgs.follows = "nixpkgs"; 17 }; 18 19 flake-utils.url = "github:numtide/flake-utils"; 20 21 fenix = { 22 # Needed because rust-overlay, normally used by crane, doesn't have llvm-tools for coverage 23 url = "github:nix-community/fenix"; 24 inputs.nixpkgs.follows = "nixpkgs"; 25 inputs.rust-analyzer-src.follows = ""; 26 }; 27 28 advisory-db = { 29 # Rust dependency security advisories 30 url = "github:rustsec/advisory-db"; 31 flake = false; 32 }; 33 }; 34 35 outputs = {self, ...} @ inputs: 36 inputs.flake-utils.lib.eachDefaultSystem (system: let 37 pkgs = import inputs.nixpkgs { 38 inherit system; 39 }; 40 41 inherit (pkgs) lib; 42 43 # Use the stable rust tools from fenix 44 fenixStable = inputs.fenix.packages.${system}.stable; 45 rustSrc = fenixStable.rust-src; 46 toolChain = fenixStable.completeToolchain; 47 48 # Use the toolchain with the crane helper functions 49 craneLib = inputs.crane.lib.${system}.overrideToolchain toolChain; 50 51 # Clean the src to only have the Rust-relevant files 52 src = craneLib.cleanCargoSource (craneLib.path ./.); 53 54 # Common arguments for mkCargoDerivation, a helper for the crane functions 55 # Arguments can be included here even if they aren't used, but we only 56 # place them here if they would otherwise show up in multiple places 57 commonArgs = { 58 inherit src cargoArtifacts; 59 }; 60 61 # Build only the cargo dependencies so we can cache them all when running in CI 62 cargoArtifacts = craneLib.buildDepsOnly commonArgs; 63 64 # Build the actual crate itself, reusing the cargoArtifacts 65 cmprss = craneLib.buildPackage commonArgs; 66 in { 67 checks = 68 { 69 # Build the crate as part of `nix flake check` for convenience 70 inherit cmprss; 71 72 # Run clippy (and deny all warnings) on the crate source 73 cmprss-clippy = craneLib.cargoClippy (commonArgs 74 // { 75 cargoClippyExtraArgs = "--all-targets -- --deny warnings"; 76 }); 77 78 # Check docs build successfully 79 cmprss-doc = craneLib.cargoDoc commonArgs; 80 81 # Check formatting 82 cmprss-fmt = craneLib.cargoFmt commonArgs; 83 84 # Run tests with cargo-nextest 85 # Note: This provides limited value, as tests are already run in the build 86 cmprss-nextest = craneLib.cargoNextest commonArgs; 87 88 # Audit dependencies 89 crate-audit = craneLib.cargoAudit (commonArgs 90 // { 91 inherit (inputs) advisory-db; 92 }); 93 } 94 // lib.optionalAttrs (system == "x86_64-linux") { 95 # Check code coverage with tarpaulin runs 96 cmprss-tarpaulin = craneLib.cargoTarpaulin commonArgs; 97 } 98 // { 99 # Run formatting checks before commit 100 # Can be run manually with `pre-commit run -a` 101 pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { 102 src = ./.; 103 tools.rustfmt = toolChain; 104 hooks = { 105 alejandra.enable = true; # Nix formatting 106 prettier.enable = true; # Markdown formatting 107 rustfmt.enable = true; # Rust formatting 108 }; 109 }; 110 }; 111 112 packages = { 113 default = cmprss; 114 cmprss = cmprss; 115 }; 116 117 apps = rec { 118 default = cmprss; 119 cmprss = inputs.flake-utils.lib.mkApp { 120 drv = self.packages.${system}.cmprss; 121 }; 122 }; 123 124 devShells.default = pkgs.mkShell { 125 name = "cmprss"; 126 shellHook = '' 127 ${self.checks.${system}.pre-commit-check.shellHook} 128 echo --------------------- 129 task --list 130 echo --------------------- 131 ''; 132 133 # Include the packages from the defined checks and packages 134 inputsFrom = 135 (builtins.attrValues self.checks.${system}) 136 ++ (builtins.attrValues self.packages.${system}); 137 138 # Extra inputs can be added here 139 nativeBuildInputs = with pkgs; [ 140 act # For running Github Actions locally 141 alejandra 142 deadnix 143 git-cliff 144 go-task 145 gum # Pretty printing in scripts 146 nodePackages.prettier 147 statix 148 149 # Code coverage 150 cargo-tarpaulin 151 ]; 152 153 # Many tools read this to find the sources for rust stdlib 154 RUST_SRC_PATH = "${rustSrc}/lib/rustlib/src/rust/library"; 155 }; 156 }) 157 // { 158 overlays.default = final: prev: { 159 cmprss = self.packages.${final.system}.cmprss; 160 }; 161 }; 162}