just playing with tangled
0
fork

Configure Feed

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

at fileedittodo 196 lines 6.4 kB view raw
1{ 2 description = "Jujutsu VCS, a Git-compatible DVCS that is both simple and powerful"; 3 4 inputs = { 5 # For listing and iterating nix systems 6 flake-utils.url = "github:numtide/flake-utils"; 7 8 # For installing non-standard rustc versions 9 rust-overlay.url = "github:oxalica/rust-overlay"; 10 rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; 11 }; 12 13 outputs = { self, nixpkgs, flake-utils, rust-overlay }: { 14 overlays.default = (final: prev: { 15 jujutsu = self.packages.${final.system}.jujutsu; 16 }); 17 } // 18 (flake-utils.lib.eachDefaultSystem (system: 19 let 20 pkgs = import nixpkgs { 21 inherit system; 22 overlays = [ 23 rust-overlay.overlays.default 24 ]; 25 }; 26 27 filterSrc = src: regexes: 28 pkgs.lib.cleanSourceWith { 29 inherit src; 30 filter = path: type: 31 let 32 relPath = pkgs.lib.removePrefix (toString src + "/") (toString path); 33 in 34 pkgs.lib.all (re: builtins.match re relPath == null) regexes; 35 }; 36 37 ourRustVersion = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default); 38 39 ourRustPlatform = pkgs.makeRustPlatform { 40 rustc = ourRustVersion; 41 cargo = ourRustVersion; 42 }; 43 44 # these are needed in both devShell and buildInputs 45 darwinDeps = with pkgs; lib.optionals stdenv.isDarwin [ 46 darwin.apple_sdk.frameworks.Security 47 darwin.apple_sdk.frameworks.SystemConfiguration 48 libiconv 49 ]; 50 51 # these are needed in both devShell and buildInputs 52 linuxNativeDeps = with pkgs; lib.optionals stdenv.isLinux [ 53 mold-wrapped 54 ]; 55 56 # on macOS and Linux, use faster parallel linkers that are much more 57 # efficient than the defaults. these noticeably improve link time even for 58 # medium sized rust projects like jj 59 rustLinkerFlags = 60 if pkgs.stdenv.isLinux then 61 [ "-fuse-ld=mold" "-Wl,--compress-debug-sections=zstd" ] 62 else if pkgs.stdenv.isDarwin then 63 [ "-fuse-ld=/usr/bin/ld" "-ld_new" ] 64 else 65 [ ]; 66 67 rustLinkFlagsString = pkgs.lib.concatStringsSep " " (pkgs.lib.concatMap (x: 68 [ "-C" "link-arg=${x}" ] 69 ) rustLinkerFlags); 70 in 71 { 72 packages = { 73 jujutsu = ourRustPlatform.buildRustPackage { 74 pname = "jujutsu"; 75 version = "unstable-${self.shortRev or "dirty"}"; 76 77 buildFeatures = [ "packaging" ]; 78 cargoBuildFlags = [ "--bin" "jj" ]; # don't build and install the fake editors 79 useNextest = true; 80 src = filterSrc ./. [ 81 ".*\\.nix$" 82 "^.jj/" 83 "^flake\\.lock$" 84 "^target/" 85 ]; 86 87 cargoLock.lockFile = ./Cargo.lock; 88 nativeBuildInputs = with pkgs; [ 89 gzip 90 installShellFiles 91 makeWrapper 92 pkg-config 93 94 # for signing tests 95 gnupg 96 openssh 97 ] ++ linuxNativeDeps; 98 buildInputs = with pkgs; [ 99 openssl zstd libgit2 libssh2 100 ] ++ darwinDeps; 101 102 ZSTD_SYS_USE_PKG_CONFIG = "1"; 103 LIBSSH2_SYS_USE_PKG_CONFIG = "1"; 104 RUSTFLAGS = pkgs.lib.optionalString pkgs.stdenv.isLinux "-C link-arg=-fuse-ld=mold"; 105 NIX_JJ_GIT_HASH = self.rev or ""; 106 CARGO_INCREMENTAL = "0"; 107 108 preCheck = '' 109 export RUST_BACKTRACE=1 110 ''; 111 112 postInstall = '' 113 $out/bin/jj util mangen > ./jj.1 114 installManPage ./jj.1 115 116 installShellCompletion --cmd jj \ 117 --bash <($out/bin/jj util completion bash) \ 118 --fish <($out/bin/jj util completion fish) \ 119 --zsh <($out/bin/jj util completion zsh) 120 ''; 121 122 meta = { 123 description = "Git-compatible DVCS that is both simple and powerful"; 124 homepage = "https://github.com/martinvonz/jj"; 125 license = pkgs.lib.licenses.asl20; 126 mainProgram = "jj"; 127 }; 128 }; 129 default = self.packages.${system}.jujutsu; 130 }; 131 132 formatter = pkgs.nixpkgs-fmt; 133 134 checks.jujutsu = self.packages.${system}.jujutsu.overrideAttrs ({ ... }: { 135 # FIXME (aseipp): when running `nix flake check`, this will override the 136 # main package, and nerf the build and installation phases. this is 137 # because for some inexplicable reason, the cargo cache gets invalidated 138 # in between buildPhase and checkPhase, causing every nix CI build to be 139 # 2x as long. 140 # 141 # upstream issue: https://github.com/NixOS/nixpkgs/issues/291222 142 buildPhase = "true"; 143 installPhase = "touch $out"; 144 # NOTE (aseipp): buildRustPackage also, by default, runs `cargo check` 145 # in `--release` mode, which is far slower; the existing CI builds all 146 # use the default `test` profile, so we should too. 147 cargoCheckType = "test"; 148 }); 149 150 devShells.default = pkgs.mkShell { 151 packages = with pkgs; [ 152 # NOTE (aseipp): explicitly add rust-src to the rustc compiler only in 153 # devShell. this in turn causes a dependency on the rust compiler src, 154 # which bloats the closure size by several GiB. but doing this here 155 # and not by default avoids the default flake install from including 156 # that dependency, so it's worth it 157 # 158 # relevant PR: https://github.com/rust-lang/rust/pull/129687 159 (ourRustVersion.override { 160 extensions = [ "rust-src" "rust-analyzer" ]; 161 }) 162 163 # Foreign dependencies 164 openssl zstd libgit2 libssh2 165 pkg-config 166 167 # Additional tools recommended by contributing.md 168 cargo-deny 169 cargo-insta 170 cargo-nextest 171 cargo-watch 172 173 # Miscellaneous tools 174 watchman 175 176 # In case you need to run `cargo run --bin gen-protos` 177 protobuf 178 179 # To run the signing tests 180 gnupg 181 openssh 182 183 # For building the documentation website 184 uv 185 ] ++ darwinDeps ++ linuxNativeDeps; 186 187 shellHook = '' 188 export RUST_BACKTRACE=1 189 export ZSTD_SYS_USE_PKG_CONFIG=1 190 export LIBSSH2_SYS_USE_PKG_CONFIG=1 191 192 export RUSTFLAGS="-Zthreads=0 ${rustLinkFlagsString}" 193 ''; 194 }; 195 })); 196}