Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, runCommand
3, rustPlatform
4, fetchFromGitHub
5, stdenv
6, coreutils
7}:
8
9let
10 # copied from flake.nix
11 # tests require extra setup with nix
12 custom = runCommand "custom" { } ''
13 mkdir -p $out/bin
14 touch $out/bin/{'foo$','foo"`'}
15 chmod +x $out/bin/{'foo$','foo"`'}
16 '';
17in
18
19rustPlatform.buildRustPackage rec {
20 pname = "patsh";
21 version = "0.2.0";
22
23 src = fetchFromGitHub {
24 owner = "nix-community";
25 repo = pname;
26 rev = "v${version}";
27 sha256 = "sha256-7HXJspebluQeejKYmVA7sy/F3dtU1gc4eAbKiPexMMA=";
28 };
29
30 cargoLock = {
31 lockFile = ./Cargo.lock;
32 outputHashes = {
33 "tree-sitter-bash-0.19.0" = "sha256-gTsA874qpCI/N5tmBI5eT8KDaM25gXM4VbcCbUU2EeI=";
34 };
35 };
36
37 nativeCheckInputs = [ custom ];
38
39 # see comment on `custom`
40 postPatch = ''
41 for file in tests/fixtures/*-expected.sh; do
42 substituteInPlace $file \
43 --subst-var-by cc ${stdenv.cc} \
44 --subst-var-by coreutils ${coreutils} \
45 --subst-var-by custom ${custom}
46 done
47 '';
48
49 meta = with lib; {
50 description = "A command-line tool for patching shell scripts inspired by resholve";
51 homepage = "https://github.com/nix-community/patsh";
52 changelog = "https://github.com/nix-community/patsh/blob/v${version}/CHANGELOG.md";
53 license = licenses.mpl20;
54 maintainers = with maintainers; [ figsoda ];
55 };
56}