File tree Expand file tree Collapse file tree 3 files changed +61
-3
lines changed Expand file tree Collapse file tree 3 files changed +61
-3
lines changed Original file line number Diff line number Diff line change @@ -57,3 +57,42 @@ Entering shell ...
57
57
"foo": "1"
58
58
}
59
59
```
60
+
61
+ Scripts can also have an optional description, which can be useful in your ` enterShell ` .
62
+
63
+ ``` nix title="devenv.nix"
64
+ { pkgs, config, lib, ... }:
65
+
66
+ {
67
+ packages = [ pkgs.curl pkgs.jq ];
68
+
69
+ scripts.silly-example.exec = ''curl "https://httpbin.org/get?$1" | jq .args'';
70
+ scripts.silly-example.description = "curls httpbin with provided arg";
71
+
72
+ scripts.serious-example.exec = ''${pkgs.cowsay}/bin/cowsay "$*"'';
73
+ scripts.serious-example.description = ''echoes args in a very serious manner'';
74
+
75
+ enterShell = ''
76
+ echo
77
+ echo 🦾 Helper scripts you can run to make your development richer:
78
+ echo 🦾
79
+ ${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | ${pkgs.util-linuxMinimal}/bin/column -t | ${pkgs.gnused}/bin/sed -e 's|^|🦾 |' -e 's|••| |g'
80
+ ${lib.generators.toKeyValue {} (lib.mapAttrs (name: value: value.description) config.scripts)}
81
+ EOF
82
+ echo
83
+ '';
84
+ }
85
+ ```
86
+
87
+ ``` shell-session
88
+ $ devenv shell
89
+ Building shell ...
90
+ Entering shell ...
91
+
92
+ 🦾 Helper scripts you can run to make your development richer:
93
+ 🦾
94
+ 🦾 serious-example echoes args in a very serious manner
95
+ 🦾 silly-example curls httpbin with provided arg
96
+
97
+ (devenv) $
98
+ ```
Original file line number Diff line number Diff line change 1
- { pkgs , ... } :
1
+ { config , lib , pkgs , ... } :
2
2
3
3
{
4
- scripts . "gitversion" . exec = ''
5
- echo hello $(${ pkgs . git } /bin/git --version)
4
+ packages = [ pkgs . curl pkgs . jq ] ;
5
+
6
+ scripts . silly-example . exec = ''curl "https://httpbin.org/get?$1" | jq .args'' ;
7
+ scripts . silly-example . description = "curls httpbin with provided arg" ;
8
+
9
+ scripts . serious-example . exec = ''${ pkgs . cowsay } /bin/cowsay "$*"'' ;
10
+ scripts . serious-example . description = ''echoes args in a very serious manner'' ;
11
+
12
+ enterShell = ''
13
+ echo
14
+ echo 🦾 Helper scripts you can run to make your development richer:
15
+ echo 🦾
16
+ ${ pkgs . gnused } /bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | ${ pkgs . util-linuxMinimal } /bin/column -t | ${ pkgs . gnused } /bin/sed -e 's|^|🦾 |' -e 's|••| |g'
17
+ ${ lib . generators . toKeyValue { } ( lib . mapAttrs ( name : value : value . description ) config . scripts ) }
18
+ EOF
19
+ echo
6
20
'' ;
7
21
}
Original file line number Diff line number Diff line change 8
8
type = types . str ;
9
9
description = "Bash code to execute when the script is run." ;
10
10
} ;
11
+ description = lib . mkOption {
12
+ type = types . str ;
13
+ description = "Description of the script." ;
14
+ default = "" ;
15
+ } ;
11
16
} ;
12
17
} ) ;
13
18
# lib.hiPrioSet: prioritize scripts over plain packages
You can’t perform that action at this time.
0 commit comments