File tree Expand file tree Collapse file tree 3 files changed +34
-51
lines changed
Expand file tree Collapse file tree 3 files changed +34
-51
lines changed Original file line number Diff line number Diff line change 9999 '' ;
100100 } ;
101101
102- genFlakes =
103- let
104- flake = pkgs . substitute {
105- src = ./lib/devshell-flake.nix ;
106- substitutions = [
107- "--replace-fail"
108- ''inputs.source.url = "path:empty"''
109- ''inputs.source.url = "path:SOURCE_URL"''
110- "--replace-fail"
111- ''inputs.config.url = "path:empty"''
112- ''inputs.config.url = "path:CONFIG_URL"''
113- ] ;
114- } ;
115- in
116- pkgs . writeShellScriptBin "gen-flakes" ''
117- export PATH="${
118- with pkgs ;
119- lib . makeBinPath [
120- coreutils
121- gnused
122- nix
123- ]
124- } "
125-
102+ genFlakes = pkgs . writeShellApplication {
103+ name = "gen-flakes" ;
104+ runtimeInputs = with pkgs ; [
105+ coreutils
106+ gnused
107+ nix
108+ ] ;
109+ text = ''
126110 SOURCE_DIR="$1"
127- SOURCE_FLAKE ="$2"
111+ FLAKE_DEST ="$2"
128112
129- mkdir -p "$SOURCE_FLAKE/config"
113+ mkdir -p "$FLAKE_DEST/config"
114+ sed -e "s#path:./source#path:$SOURCE_DIR#" ${ ./lib/devshell-flake.nix } > "$FLAKE_DEST/flake.nix"
130115
131116 if test -e "$SOURCE_DIR/flake.toml"; then
132- nix eval --file ${ ./lib/make-config-flake.nix } --apply "f: f $SOURCE_DIR/flake.toml" --raw --impure --offline | \
133- sed -e "s#url = \"path:./#url = \"path:$SOURCE_DIR/#g" > "$SOURCE_FLAKE/config/flake.nix"
117+ nix eval \
118+ --file ${ ./lib/make-config-flake.nix } \
119+ --apply "f: f $SOURCE_DIR/flake.toml" \
120+ --extra-experimental-features "flakes nix-command" \
121+ --raw --impure --offline |\
122+ sed -e "s#url = \"path:./#url = \"path:$SOURCE_DIR/#g" > "$FLAKE_DEST/config/flake.nix"
134123 else
135- cp -f ${ ./lib/empty-config-flake.nix } "$SOURCE_FLAKE /config/flake.nix"
124+ cp -f ${ ./lib/empty-config-flake.nix } "$FLAKE_DEST /config/flake.nix"
136125 fi
137-
138- sed -e "s#SOURCE_URL#$SOURCE_DIR#; s#CONFIG_URL#$SOURCE_FLAKE/config#" ${ flake } > "$SOURCE_FLAKE/flake.nix"
139126 '' ;
127+ } ;
140128 } ;
141129
142130 apps = perSystem (
Original file line number Diff line number Diff line change 11{
22 inputs . devshell . url = "github:numtide/devshell" ;
3+ inputs . systems . url = "github:nix-systems/default" ;
34
4- inputs . source . url = "path:empty " ;
5+ inputs . source . url = "path:./source " ;
56 inputs . source . flake = false ;
67
7- inputs . config . url = "path:empty " ;
8+ inputs . config . url = "path:./config " ;
89
910 outputs =
10- inputs @{
11- # deadnix: skip
12- nixpkgs ,
13- ...
14- } :
11+ inputs :
1512 let
16- toml-file = "${ inputs . source . outPath } /devshell.toml" ;
17-
1813 ins = inputs // inputs . config . inputs ;
19- nixpkgs = ins . nixpkgs ;
14+ devshell_toml = ins . source + "/devshell.toml" ;
15+
16+ nixpkgs = ins . nixpkgs or ins . devshell . inputs . nixpkgs ;
17+ perSystem = nixpkgs . lib . genAttrs ( import ins . systems ) ;
2018
21- perSystem = nixpkgs . lib . genAttrs nixpkgs . lib . systems . flakeExposed ;
19+ nix-config = ins . config . lib . nix-config or { } ;
20+ overlays-config = ins . config . lib . overlays or [ ] ;
21+ attr-overlay = name : value : [ ins . ${ name } . overlays . ${ value } ] ;
22+ overlays = with nixpkgs . lib ; flatten ( map ( mapAttrsToList attr-overlay ) overlays-config ) ;
2223
2324 devShells = perSystem (
2425 system :
2526 let
26-
27- nix-config = ins . config . lib . nix-config or { } ;
28- overlays-config = ins . config . lib . overlays or [ ] ;
29- attr-overlay = name : value : [ ins . ${ name } . overlays . ${ value } ] ;
30- overlays = with nixpkgs . lib ; flatten ( map ( mapAttrsToList attr-overlay ) overlays-config ) ;
31-
3227 pkgs = import nixpkgs {
3328 inherit system ;
3429 config = nix-config ;
3934 _module . args = {
4035 inputs = ins ;
4136 } ;
42- imports = [ ( pkgs . devshell . importTOML toml-file ) ] ;
37+ imports = [ ( pkgs . devshell . importTOML devshell_toml ) ] ;
4338 } ;
4439 in
4540 {
Original file line number Diff line number Diff line change @@ -19,11 +19,11 @@ function test_template() {
1919
2020 cp -rf " $base /$template " /* " $out /"
2121
22- nix run " path:$base "
22+ nix run " path:$base " --show-trace
2323 test -e " $HOME /.config/direnv/lib/use_devshell_toml.sh"
2424
2525 # use bash strict inside .envrc
26- echo " set -euo pipefail; source $HOME /.config/direnv/lib/use_devshell_toml.sh; use devshell_toml" > " $out /.envrc"
26+ echo " set -euo pipefail; source $HOME /.config/direnv/lib/use_devshell_toml.sh; use devshell_toml --show-trace " > " $out /.envrc"
2727
2828 direnv allow " $out "
2929 direnv exec " $out " check
You can’t perform that action at this time.
0 commit comments