this repo has no description
0
fork

Configure Feed

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

at 2c4eddb8606eb7af5908146d2b84a3818a6dfd4e 161 lines 5.0 kB view raw
1{ 2 description = "cmprss: a compression client for the CLI"; 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 # inherit (self.checks.${system}.pre-commit-check) shellHook; 127 shellHook = '' 128 ${self.checks.${system}.pre-commit-check.shellHook} 129 echo --------------------- 130 just list 131 echo --------------------- 132 ''; 133 134 # Include the packages from the defined checks and packages 135 inputsFrom = 136 (builtins.attrValues self.checks.${system}) 137 ++ (builtins.attrValues self.packages.${system}); 138 139 # Extra inputs can be added here 140 nativeBuildInputs = with pkgs; [ 141 act # For running Github Actions locally 142 alejandra 143 deadnix 144 just 145 nodePackages.prettier 146 statix 147 148 # Code coverage 149 cargo-tarpaulin 150 ]; 151 152 # Many tools read this to find the sources for rust stdlib 153 RUST_SRC_PATH = "${rustSrc}/lib/rustlib/src/rust/library"; 154 }; 155 }) 156 // { 157 overlays.default = final: prev: { 158 cmprss = self.packages.${final.system}.cmprss; 159 }; 160 }; 161}