2022-11-27 15:20:00 +00:00
|
|
|
{ lib
|
2022-12-04 00:40:26 +00:00
|
|
|
, runCommand
|
2022-11-27 15:20:00 +00:00
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, stdenv
|
2022-12-04 00:40:26 +00:00
|
|
|
, coreutils
|
2022-11-27 15:20:00 +00:00
|
|
|
}:
|
|
|
|
|
2022-12-04 00:40:26 +00:00
|
|
|
let
|
2022-12-05 20:01:35 +00:00
|
|
|
# copied from flake.nix
|
|
|
|
# tests require extra setup with nix
|
2022-12-04 00:40:26 +00:00
|
|
|
custom = runCommand "custom" { } ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
touch $out/bin/{'foo$','foo"`'}
|
|
|
|
chmod +x $out/bin/{'foo$','foo"`'}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
2022-11-27 15:20:00 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "patsh";
|
2023-08-18 15:01:22 +00:00
|
|
|
version = "0.2.1";
|
2022-11-27 15:20:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nix-community";
|
2023-08-18 15:01:22 +00:00
|
|
|
repo = "patsh";
|
2022-11-27 15:20:00 +00:00
|
|
|
rev = "v${version}";
|
2023-08-18 15:01:22 +00:00
|
|
|
sha256 = "sha256-d2Br4RAlKO7Bpse8sFbIDCIYd2fYvby0ar9oIbQS2jc=";
|
2022-11-27 15:20:00 +00:00
|
|
|
};
|
|
|
|
|
2023-08-18 15:01:22 +00:00
|
|
|
cargoHash = "sha256-hAWMm3YjwTB8ajn3QeXEOJYmPzbbitdwyO4k/IyhlOI=";
|
2022-11-27 15:20:00 +00:00
|
|
|
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [ custom ];
|
2022-11-27 15:20:00 +00:00
|
|
|
|
2022-12-05 20:01:35 +00:00
|
|
|
# see comment on `custom`
|
2022-12-04 00:40:26 +00:00
|
|
|
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-11-27 15:20:00 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Command-line tool for patching shell scripts inspired by resholve";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "patsh";
|
2022-11-27 15:20:00 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|