1{
2 stdenvNoCC,
3 lib,
4 fetchFromGitHub,
5 coreutils,
6 gnused,
7 jq,
8 nix-update-script,
9}:
10
11stdenvNoCC.mkDerivation (finalAttrs: {
12 pname = "bash-env-json";
13 version = "0.10.1";
14
15 src = fetchFromGitHub {
16 owner = "tesujimath";
17 repo = "bash-env-json";
18 rev = finalAttrs.version;
19 hash = "sha256-gyqj5r11DOfXd23LT7qwRLEoWvpHUbxbd28QJnlWTaQ=";
20 };
21
22 installPhase = ''
23 runHook preInstall
24
25 install -Dm755 bash-env-json -t $out/bin
26
27 runHook postInstall
28 '';
29
30 postFixup = ''
31 substituteInPlace $out/bin/bash-env-json --replace-fail " env " " ${lib.getExe' coreutils "env"} "
32 substituteInPlace $out/bin/bash-env-json --replace-fail " jq " " ${lib.getExe jq} "
33 substituteInPlace $out/bin/bash-env-json --replace-fail " mktemp " " ${lib.getExe' coreutils "mktemp"} "
34 substituteInPlace $out/bin/bash-env-json --replace-fail " rm " " ${lib.getExe' coreutils "rm"} "
35 substituteInPlace $out/bin/bash-env-json --replace-fail " sed " " ${lib.getExe gnused} "
36 substituteInPlace $out/bin/bash-env-json --replace-fail " touch " " ${lib.getExe' coreutils "touch"} "
37 '';
38
39 passthru.updateScript = nix-update-script { };
40
41 meta = {
42 description = "Export Bash environment as JSON for import into modern shells like Elvish and Nushell";
43 homepage = "https://github.com/tesujimath/bash-env-json";
44 mainProgram = "bash-env-json";
45 license = lib.licenses.mit;
46 maintainers = with lib.maintainers; [ jaredmontoya ];
47 platforms = lib.platforms.all;
48 };
49})