2022-12-02 08:20:57 +00:00
|
|
|
{ lib
|
2022-12-17 10:02:37 +00:00
|
|
|
, runCommand
|
2022-12-02 08:20:57 +00:00
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, stdenv
|
2022-12-17 10:02:37 +00:00
|
|
|
, coreutils
|
2022-12-02 08:20:57 +00:00
|
|
|
}:
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
let
|
|
|
|
# copied from flake.nix
|
|
|
|
# tests require extra setup with nix
|
|
|
|
custom = runCommand "custom" { } ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
touch $out/bin/{'foo$','foo"`'}
|
|
|
|
chmod +x $out/bin/{'foo$','foo"`'}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
2022-12-02 08:20:57 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "patsh";
|
2022-12-17 10:02:37 +00:00
|
|
|
version = "0.2.0";
|
2022-12-02 08:20:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nix-community";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-12-17 10:02:37 +00:00
|
|
|
sha256 = "sha256-7HXJspebluQeejKYmVA7sy/F3dtU1gc4eAbKiPexMMA=";
|
2022-12-02 08:20:57 +00:00
|
|
|
};
|
|
|
|
|
2023-03-27 19:17:25 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
|
|
|
"tree-sitter-bash-0.19.0" = "sha256-gTsA874qpCI/N5tmBI5eT8KDaM25gXM4VbcCbUU2EeI=";
|
|
|
|
};
|
|
|
|
};
|
2022-12-02 08:20:57 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ custom ];
|
2022-12-02 08:20:57 +00:00
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
# see comment on `custom`
|
|
|
|
postPatch = ''
|
|
|
|
for file in tests/fixtures/*-expected.sh; do
|
|
|
|
substituteInPlace $file \
|
|
|
|
--subst-var-by cc ${stdenv.cc} \
|
|
|
|
--subst-var-by coreutils ${coreutils} \
|
|
|
|
--subst-var-by custom ${custom}
|
|
|
|
done
|
2022-12-02 08:20:57 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A command-line tool for patching shell scripts inspired by resholve";
|
|
|
|
homepage = "https://github.com/nix-community/patsh";
|
|
|
|
changelog = "https://github.com/nix-community/patsh/blob/v${version}/CHANGELOG.md";
|
|
|
|
license = licenses.mpl20;
|
|
|
|
maintainers = with maintainers; [ figsoda ];
|
|
|
|
};
|
|
|
|
}
|