flake.nix (4021B)
1 { 2 description = "tangle development shell"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 }; 7 8 outputs = 9 { self, nixpkgs }: 10 let 11 systems = [ 12 "aarch64-darwin" 13 "aarch64-linux" 14 "x86_64-darwin" 15 "x86_64-linux" 16 ]; 17 forAllSystems = nixpkgs.lib.genAttrs systems; 18 mkPkgs = system: import nixpkgs { inherit system; }; 19 mkScript = 20 pkgs: name: text: 21 pkgs.writeShellApplication { 22 inherit name text; 23 runtimeInputs = [ 24 pkgs.cargo-nextest 25 pkgs.cargo-llvm-cov 26 pkgs.llvmPackages.llvm 27 ]; 28 }; 29 in 30 { 31 devShells = forAllSystems ( 32 system: 33 let 34 pkgs = mkPkgs system; 35 in 36 { 37 default = pkgs.mkShell { 38 packages = [ 39 pkgs.cargo-nextest 40 pkgs.cargo-llvm-cov 41 pkgs.llvmPackages.llvm 42 ]; 43 }; 44 } 45 ); 46 47 apps = forAllSystems ( 48 system: 49 let 50 pkgs = mkPkgs system; 51 check = mkScript pkgs "tangle-check" '' 52 cargo fmt --all -- --check 53 cargo test -p tangle --test source_comments 54 cargo test -p tangle --test unsafe_code 55 cargo check --workspace --all-targets 56 cargo clippy --workspace --all-targets -- -D warnings 57 ''; 58 test = mkScript pkgs "tangle-test" '' 59 cargo test --workspace 60 cargo nextest run --workspace 61 ''; 62 coverage = mkScript pkgs "tangle-coverage" '' 63 if ! cargo llvm-cov --version >/dev/null 2>&1; then 64 printf '%s\n' 'cargo llvm-cov is required' 65 exit 1 66 fi 67 LLVM_COV="$(command -v llvm-cov)" 68 LLVM_PROFDATA="$(command -v llvm-profdata)" 69 export LLVM_COV 70 export LLVM_PROFDATA 71 cargo llvm-cov clean --workspace 72 cargo llvm-cov --workspace --all-targets --show-missing-lines --fail-under-lines 100 --fail-uncovered-lines 0 73 ''; 74 ci = mkScript pkgs "tangle-ci" '' 75 cargo fmt --all -- --check 76 cargo test -p tangle --test source_comments 77 cargo test -p tangle --test unsafe_code 78 cargo check --workspace --all-targets 79 cargo clippy --workspace --all-targets -- -D warnings 80 cargo test --workspace 81 ''; 82 releaseAcceptance = mkScript pkgs "tangle-release-acceptance" '' 83 cargo fmt --all -- --check 84 cargo test -p tangle --test source_comments 85 cargo test -p tangle --test unsafe_code 86 cargo check --workspace --all-targets 87 cargo clippy --workspace --all-targets -- -D warnings 88 cargo test --workspace 89 cargo test -p tangle_runtime --test base_relay_v2 90 cargo test -p tangle_runtime isolation 91 cargo test -p tangle_runtime server 92 cargo test -p tangle_runtime auth 93 cargo test -p tangle_runtime backup 94 cargo test -p tangle_runtime export 95 cargo test -p tangle_groups 96 cargo test -p tangle_store_pocket 97 cargo test -p tangle_bench 98 cargo run -p tangle_bench --bin tangle-benchmark-report -- --profile virtual-relay-tenancy 99 ''; 100 in 101 { 102 check = { 103 type = "app"; 104 program = "${check}/bin/tangle-check"; 105 }; 106 test = { 107 type = "app"; 108 program = "${test}/bin/tangle-test"; 109 }; 110 coverage = { 111 type = "app"; 112 program = "${coverage}/bin/tangle-coverage"; 113 }; 114 ci = { 115 type = "app"; 116 program = "${ci}/bin/tangle-ci"; 117 }; 118 "release-acceptance" = { 119 type = "app"; 120 program = "${releaseAcceptance}/bin/tangle-release-acceptance"; 121 }; 122 } 123 ); 124 }; 125 }