Skip to content

Commit c158227

Browse files
authored
Extract Nix package for better compatability with Nixpkgs (#16)
Fixes #14
1 parent 2214d1a commit c158227

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

bash-env-json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
# SOFTWARE.
2424

25-
VERSION="0.9.2"
25+
VERSION="0.10.0a1"
2626
USAGE="bash-env-json [--help] [--shellfns <comma-separated-function-names>] [path]"
2727

2828
shopt -s extglob

flake.nix

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,7 @@
1313
pkgs = import nixpkgs {
1414
inherit system;
1515
};
16-
bash-env-json =
17-
let
18-
inherit (pkgs) bash coreutils gnused jq makeWrapper writeShellScriptBin;
19-
inherit (pkgs.lib) makeBinPath;
20-
21-
substFullPaths = program_package:
22-
let replaceList = pkgs.lib.attrsets.mapAttrsToList (name: pkg: { from = " ${name} "; to = " ${pkg}/bin/${name} "; }) program_package; in
23-
builtins.replaceStrings (map (x: x.from) replaceList) (map (x: x.to) replaceList);
24-
25-
in
26-
(writeShellScriptBin "bash-env-json"
27-
(substFullPaths
28-
{
29-
env = pkgs.coreutils;
30-
jq = pkgs.jq;
31-
mktemp = pkgs.coreutils;
32-
rm = pkgs.coreutils;
33-
sed = pkgs.gnused;
34-
touch = pkgs.coreutils;
35-
}
36-
(builtins.readFile ./bash-env-json))).overrideAttrs (old: {
37-
buildInputs = [ bash ];
38-
buildCommand =
39-
''
40-
${old.buildCommand}
41-
patchShebangs $out
42-
'';
43-
});
16+
bash-env-json = import ./package.nix pkgs;
4417
in
4518
{
4619
devShells =

package.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ lib
2+
, bash
3+
, coreutils
4+
, gnused
5+
, jq
6+
, writeShellScriptBin
7+
, ...
8+
}:
9+
let
10+
substFullPaths = program_package:
11+
let replaceList = lib.attrsets.mapAttrsToList (name: pkg: { from = " ${name} "; to = " ${pkg}/bin/${name} "; }) program_package; in
12+
builtins.replaceStrings (map (x: x.from) replaceList) (map (x: x.to) replaceList);
13+
14+
in
15+
(writeShellScriptBin "bash-env-json"
16+
(substFullPaths
17+
{
18+
env = coreutils;
19+
jq = jq;
20+
mktemp = coreutils;
21+
rm = coreutils;
22+
sed = gnused;
23+
touch = coreutils;
24+
}
25+
(builtins.readFile ./bash-env-json))).overrideAttrs (old: {
26+
buildInputs = [ bash ];
27+
buildCommand =
28+
''
29+
${old.buildCommand}
30+
patchShebangs $out
31+
'';
32+
})

0 commit comments

Comments
 (0)