File tree Expand file tree Collapse file tree 5 files changed +33
-40
lines changed
nix/process-compose/settings Expand file tree Collapse file tree 5 files changed +33
-40
lines changed Original file line number Diff line number Diff line change 3333 '' ;
3434
3535 # Create .sqlite database from chinook database.
36- sqlite-init . command = pkgs . writeShellApplication {
37- name = "sqlite-init" ;
38- text = ''
39- echo "$(date): Importing Chinook database ($DATAFILE) ..."
40- ${ lib . getExe pkgs . sqlite } "$DATAFILE" < ${ inputs . chinookDb } /ChinookDatabase/DataSources/Chinook_Sqlite.sql
41- echo "$(date): Done."
42- '' ;
43- } ;
36+ sqlite-init . command = ''
37+ echo "$(date): Importing Chinook database ($DATAFILE) ..."
38+ ${ lib . getExe pkgs . sqlite } "$DATAFILE" < ${ inputs . chinookDb } /ChinookDatabase/DataSources/Chinook_Sqlite.sql
39+ echo "$(date): Done."
40+ '' ;
4441
4542 # Run sqlite-web on the local chinook database.
4643 sqlite-web = {
47- command = pkgs . writeShellApplication {
48- name = "sqlite-web" ;
49- text = ''
50- ${ pkgs . sqlite-web } /bin/sqlite_web "$DATAFILE"
51- '' ;
52- } ;
44+ command = ''
45+ ${ pkgs . sqlite-web } /bin/sqlite_web "$DATAFILE"
46+ '' ;
5347 # The 'depends_on' will have this process wait until the above one is completed.
5448 depends_on . "sqlite-init" . condition = "process_completed_successfully" ;
5549 } ;
Original file line number Diff line number Diff line change 1- { lib , ... } :
1+ { name , pkgs , lib , ... } :
22
33args :
44lib . mkOption ( args // {
55 type = lib . types . either lib . types . package lib . types . str ;
66 apply = pkg :
7- if builtins . isString pkg then pkg else
8- lib . getExe pkg ;
7+ if builtins . isString pkg
8+ # process-compose is unreliable in handling environment variable, so let's
9+ # wrap it in a bash script.
10+ then lib . getExe ( pkgs . writeShellApplication { inherit name ; text = pkg ; } )
11+ else lib . getExe pkg ;
912} )
Original file line number Diff line number Diff line change 5252 default = "-c" ;
5353 example = "-c" ;
5454 } ;
55- shell_command = import ./command.nix { inherit lib ; } {
55+ shell_command = mkOption {
56+ type = types . str ;
5657 description = ''
5758 The shell to use to run the process `command`s.
5859
5960 For reproducibility across systems, by default this uses
6061 `pkgs.bash`.
6162 '' ;
62- default = pkgs . bash ;
63+ default = lib . getExe pkgs . bash ;
6364 } ;
6465 } ;
6566
Original file line number Diff line number Diff line change 1- { lib , ... } :
1+ { name , pkgs , lib , ... } :
22
33let
44 inherit ( lib ) types mkOption ;
99in
1010{
1111 options = {
12- command = import ./command.nix { inherit lib ; } {
12+ command = import ./command.nix { inherit name pkgs lib ; } {
1313 description = ''
14- The command that runs this process
14+ The command or script or package that runs this process
1515
16- If a package is given, its executable is used as the command. This is
17- useful to pass in a `writeShellApplication.`
16+ If a package is given, its executable is used as the command. Otherwise,
17+ the command string is wrapped in a `pkgs.writeShellApplication` which
18+ uses ShellCheck and runs the command in bash.
1819 '' ;
1920 } ;
2021
Original file line number Diff line number Diff line change 3333 '' ;
3434 } ;
3535 in
36- pkgs . writeShellApplication {
37- name = "sqlite-init" ;
38- text = ''
39- echo "$(date): Creating database ($DATAFILE) ..."
40- ${ lib . getExe pkgs . sqlite } "$DATAFILE" < ${ sqlFile }
41- echo "$(date): Done."
42- '' ;
43- } ;
36+ ''
37+ echo "$(date): Creating database ($DATAFILE) ..."
38+ ${ lib . getExe pkgs . sqlite } "$DATAFILE" < ${ sqlFile }
39+ echo "$(date): Done."
40+ '' ;
4441
4542 # Query something, write to result.txt
4643 sqlite-query = {
47- command = pkgs . writeShellApplication {
48- name = "sqlite-query" ;
49- text = ''
50- ${ lib . getExe pkgs . sqlite } "$DATAFILE" \
51- 'select val from demo where val = "Hello"' \
52- > result.txt
53- '' ;
54- } ;
44+ command = ''
45+ ${ lib . getExe pkgs . sqlite } "$DATAFILE" \
46+ 'select val from demo where val = "Hello"' \
47+ > result.txt
48+ '' ;
5549 # The 'depends_on' will have this process wait until the above one is completed.
5650 depends_on . "sqlite-init" . condition = "process_completed_successfully" ;
5751 availability . restart = "no" ;
You can’t perform that action at this time.
0 commit comments