-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
66 lines (57 loc) · 1.73 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
description = "nu_plugin_bash_env";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
bash-env-json = {
url = "github:tesujimath/bash-env-json/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, flake-utils, bash-env-json, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib stdenvNoCC;
flakePkgs = {
bash-env-json = bash-env-json.packages.${system}.default;
};
bash-env-module-with-bash-env-json = stdenvNoCC.mkDerivation
{
name = "bash-env.nu-with-bash-env-json";
src = ./bash-env.nu;
dontUnpack = true;
preferLocalBuild = true;
allowSubstitutes = false;
buildPhase = ''
runHook preBuild
mkdir -p "$out"
substitute "$src" "$out/bash-env.nu" --replace-fail ${lib.escapeShellArg "bash-env-json"} ${lib.escapeShellArg "${flakePkgs.bash-env-json}/bin/bash-env-json"}
runHook postBuild
'';
};
in
{
devShells.default =
let
inherit (pkgs)
mkShell
bashInteractive
jq;
in
mkShell {
nativeBuildInputs = [
bashInteractive
jq
];
};
packages = {
default = bash-env-module-with-bash-env-json;
module = bash-env-module-with-bash-env-json;
};
}
);
}