diff options
author | lassulus <lassulus@lassul.us> | 2018-10-27 13:14:56 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2018-10-27 13:17:34 +0200 |
commit | 1cfb083a20ffdc5d961357af944aafb129a6e638 (patch) | |
tree | 053c3e08392ac66676de2698184405e595480500 /pkgs | |
parent | 5a7233196186aa4fd62943f5fac31adce606e2df (diff) |
pkgs: document makeScriptwriter, write & writeBash
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/default.nix | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix index a56042c..084702d 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -54,6 +54,14 @@ pkgs: oldpkgs: { execBin = name: cfg: pkgs.exec name (cfg // { destination = "/bin/${name}"; }); + /* Base implementation for non-compiled executables. + Takes an interpreter, for example `${pkgs.bash}/bin/bash` + + Examples: + writebash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; } + makeScriptWriter { interpreter = "${pkgs.dash}/bin/dash"; } "hello" "echo hello world" + */ + makeScriptWriter = { interpreter, check ? null }: name: text: assert (with types; either absolute-pathname filename).check name; pkgs.write (baseNameOf name) { @@ -64,6 +72,22 @@ pkgs: oldpkgs: { }; }; + /* Take a name and specification and build a derivation out of it + Examples: + write "name" { "/etc/test" = { text = "hello world"; }; } + + write "name" { "" = { executable = true; text = "echo hello world"; }; } + + write "name" { "/bin/test" = { executable = true; text = "echo hello world"; }; } + + write "name" { "" = { executable = true; + check = "${pkgs.shellcheck}/bin/shellcheck"; + text = '' + #!/bin/sh + echo hello world + ''; + }; } + */ write = name: specs0: let env = filevars // { passAsFile = attrNames filevars; }; @@ -133,6 +157,13 @@ pkgs: oldpkgs: { ) ''; + /* Like writeScript but the first line is a shebang to bash + + Example: + writeBash "example" '' + echo hello world + '' + */ writeBash = name: text: assert (with types; either absolute-pathname filename).check name; pkgs.write (baseNameOf name) { |