pkgs: use comments uniformly
This commit is contained in:
102
pkgs/default.nix
102
pkgs/default.nix
@@ -1,23 +1,23 @@
|
|||||||
with import ../lib;
|
# Collection of nix-writers.
|
||||||
|
#
|
||||||
|
# Purpose: Use your favourite language to generate
|
||||||
|
# an executable and package it in nix.
|
||||||
|
#
|
||||||
|
# How to use it: Every nix-writer has the form:
|
||||||
|
# writeLang "Name-of-exec" ''
|
||||||
|
# source code in <Lang>
|
||||||
|
# ''
|
||||||
|
#
|
||||||
|
# If the source code compiles in <Lang>,
|
||||||
|
# nix will generate an executable /nix/store/<SHA>-<Name-of-exec>
|
||||||
|
#
|
||||||
|
# Getting started:
|
||||||
|
#
|
||||||
|
# Switch into the example directory and call
|
||||||
|
# nix-build hello_world.nix.
|
||||||
|
#
|
||||||
|
|
||||||
/* Collection of nix-writers.
|
with import ../lib;
|
||||||
*
|
|
||||||
* Purpose: Use your favourite language to generate
|
|
||||||
* an executable and package it in nix.
|
|
||||||
*
|
|
||||||
* How to use it: Every nix-writer has the form:
|
|
||||||
* writeLang "Name-of-exec" ''
|
|
||||||
* source code in <Lang>
|
|
||||||
* ''
|
|
||||||
*
|
|
||||||
* If the source code compiles in <Lang>,
|
|
||||||
* nix will generate an executable /nix/store/<SHA>-<Name-of-exec>
|
|
||||||
*
|
|
||||||
* Getting started:
|
|
||||||
*
|
|
||||||
* Switch into the example directory and call
|
|
||||||
* nix-build hello_world.nix.
|
|
||||||
*/
|
|
||||||
|
|
||||||
pkgs: oldpkgs: {
|
pkgs: oldpkgs: {
|
||||||
exec = name: { filename, argv ? null, envp ? null, destination ? "" }:
|
exec = name: { filename, argv ? null, envp ? null, destination ? "" }:
|
||||||
@@ -54,14 +54,13 @@ pkgs: oldpkgs: {
|
|||||||
execBin = name: cfg:
|
execBin = name: cfg:
|
||||||
pkgs.exec name (cfg // { destination = "/bin/${name}"; });
|
pkgs.exec name (cfg // { destination = "/bin/${name}"; });
|
||||||
|
|
||||||
/* Base implementation for non-compiled executables.
|
# Base implementation for non-compiled executables.
|
||||||
Takes an interpreter, for example `${pkgs.bash}/bin/bash`
|
# Takes an interpreter, for example `${pkgs.bash}/bin/bash`
|
||||||
|
#
|
||||||
Examples:
|
# Examples:
|
||||||
writebash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; }
|
# writebash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; }
|
||||||
makeScriptWriter { interpreter = "${pkgs.dash}/bin/dash"; } "hello" "echo hello world"
|
# makeScriptWriter { interpreter = "${pkgs.dash}/bin/dash"; } "hello" "echo hello world"
|
||||||
*/
|
#
|
||||||
|
|
||||||
makeScriptWriter = { interpreter, check ? null }: name: text:
|
makeScriptWriter = { interpreter, check ? null }: name: text:
|
||||||
assert (with types; either absolute-pathname filename).check name;
|
assert (with types; either absolute-pathname filename).check name;
|
||||||
pkgs.write (baseNameOf name) {
|
pkgs.write (baseNameOf name) {
|
||||||
@@ -72,22 +71,25 @@ pkgs: oldpkgs: {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Take a name and specification and build a derivation out of it
|
# Take a name and specification and build a derivation out of it
|
||||||
Examples:
|
# Examples:
|
||||||
write "name" { "/etc/test" = { text = "hello world"; }; }
|
# write "name" { "/etc/test" = { text = "hello world"; }; }
|
||||||
|
#
|
||||||
write "name" { "" = { executable = true; text = "echo hello world"; }; }
|
# write "name" { "" = { executable = true; text = "echo hello world"; }; }
|
||||||
|
#
|
||||||
write "name" { "/bin/test" = { executable = true; text = "echo hello world"; }; }
|
# write "name" { "/bin/test" = { executable = true; text = "echo hello world"; }; }
|
||||||
|
#
|
||||||
write "name" { "" = { executable = true;
|
# write "name" {
|
||||||
check = "${pkgs.shellcheck}/bin/shellcheck";
|
# "" = {
|
||||||
text = ''
|
# executable = true;
|
||||||
#!/bin/sh
|
# check = "${pkgs.shellcheck}/bin/shellcheck";
|
||||||
echo hello world
|
# text = ''
|
||||||
'';
|
# #!/bin/sh
|
||||||
}; }
|
# echo hello world
|
||||||
*/
|
# '';
|
||||||
|
# };
|
||||||
|
# }
|
||||||
|
#
|
||||||
write = name: specs0:
|
write = name: specs0:
|
||||||
let
|
let
|
||||||
env = filevars // { passAsFile = attrNames filevars; };
|
env = filevars // { passAsFile = attrNames filevars; };
|
||||||
@@ -157,13 +159,13 @@ pkgs: oldpkgs: {
|
|||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
/* Like writeScript but the first line is a shebang to bash
|
# Like writeScript but the first line is a shebang to bash
|
||||||
|
#
|
||||||
Example:
|
# Example:
|
||||||
writeBash "example" ''
|
# writeBash "example" ''
|
||||||
echo hello world
|
# echo hello world
|
||||||
''
|
# ''
|
||||||
*/
|
#
|
||||||
writeBash = pkgs.makeScriptWriter {
|
writeBash = pkgs.makeScriptWriter {
|
||||||
interpreter = "${pkgs.bash}/bin/bash";
|
interpreter = "${pkgs.bash}/bin/bash";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user