Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 77 lines 2.0 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPackages, 5 fetchFromGitHub, 6 rustPlatform, 7 installShellFiles, 8 pkg-config, 9 withPCRE2 ? true, 10 pcre2, 11 writableTmpDirAsHomeHook, 12}: 13 14let 15 canRunRg = stdenv.hostPlatform.emulatorAvailable buildPackages; 16 rg = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/rg${stdenv.hostPlatform.extensions.executable}"; 17in 18rustPlatform.buildRustPackage rec { 19 pname = "ripgrep"; 20 version = "14.1.1"; 21 22 src = fetchFromGitHub { 23 owner = "BurntSushi"; 24 repo = "ripgrep"; 25 rev = version; 26 hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; 27 }; 28 29 cargoHash = "sha256-9atn5qyBDy4P6iUoHFhg+TV6Ur71fiah4oTJbBMeEy4="; 30 31 nativeBuildInputs = [ 32 installShellFiles 33 writableTmpDirAsHomeHook # required for wine when cross-compiling to Windows 34 ] 35 ++ lib.optional withPCRE2 pkg-config; 36 buildInputs = lib.optional withPCRE2 pcre2; 37 38 buildFeatures = lib.optional withPCRE2 "pcre2"; 39 40 postFixup = lib.optionalString canRunRg '' 41 ${rg} --generate man > rg.1 42 installManPage rg.1 43 44 installShellCompletion --cmd rg \ 45 --bash <(${rg} --generate complete-bash) \ 46 --fish <(${rg} --generate complete-fish) \ 47 --zsh <(${rg} --generate complete-zsh) 48 ''; 49 50 doInstallCheck = true; 51 installCheckPhase = '' 52 file="$(mktemp)" 53 echo "abc\nbcd\ncde" > "$file" 54 ${rg} -N 'bcd' "$file" 55 ${rg} -N 'cd' "$file" 56 '' 57 + lib.optionalString withPCRE2 '' 58 echo '(a(aa)aa)' | ${rg} -P '\((a*|(?R))*\)' 59 ''; 60 61 meta = { 62 description = "Utility that combines the usability of The Silver Searcher with the raw speed of grep"; 63 homepage = "https://github.com/BurntSushi/ripgrep"; 64 changelog = "https://github.com/BurntSushi/ripgrep/releases/tag/${version}"; 65 license = with lib.licenses; [ 66 unlicense # or 67 mit 68 ]; 69 maintainers = with lib.maintainers; [ 70 globin 71 ma27 72 zowoq 73 ]; 74 mainProgram = "rg"; 75 platforms = lib.platforms.all; 76 }; 77}