mirror of
https://github.com/nix-community/naersk
synced 2024-11-12 23:17:07 +00:00
Improve documentation on 'allowFun' parameters
This commit is contained in:
parent
362405f643
commit
222cac5b0d
2 changed files with 15 additions and 19 deletions
10
README.md
10
README.md
|
@ -45,13 +45,13 @@ it is converted to an attribute set equivalent to `{ root = theArg; }`.
|
|||
| `version` | The version of the derivation. |
|
||||
| `src` | Used by `naersk` as source input to the derivation. When `root` is not set, `src` is also used to discover the `Cargo.toml` and `Cargo.lock`. |
|
||||
| `root` | Used by `naersk` to read the `Cargo.toml` and `Cargo.lock` files. May be different from `src`. When `src` is not set, `root` is (indirectly) used as `src`. |
|
||||
| `cargoBuild` | The command to use for the build. Default: `''cargo $cargo_options build $cargo_build_options''` |
|
||||
| `cargoBuildOptions` | Options passed to cargo build, i.e. `cargo build <OPTS>`. These options can be accessed during the build through the environment variable `cargo_build_options`. <br/> Note: naersk relies on the `--out-dir out` option. <br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> Default: `[ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' "--out-dir" "out" ]` |
|
||||
| `cargoBuild` | The command to use for the build. When set to a function, the function is applied to the default value. <br/> Default: `''cargo $cargo_options build $cargo_build_options''` |
|
||||
| `cargoBuildOptions` | Options passed to cargo build, i.e. `cargo build <OPTS>`. These options can be accessed during the build through the environment variable `cargo_build_options`. <br/> Note: naersk relies on the `--out-dir out` option. <br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> When set to a function, the function is applied to the default value. <br/> Default: `[ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' "--out-dir" "out" ]` |
|
||||
| `doCheck` | When true, `checkPhase` is run. Default: `true` |
|
||||
| `cargoTestCommands` | The commands to run in the `checkPhase`. Default: `[ ''cargo $cargo_options test $cargo_test_options'' ]` |
|
||||
| `cargoTestOptions` | Options passed to cargo test, i.e. `cargo test <OPTS>`. These options can be accessed during the build through the environment variable `cargo_test_options`. <br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> Default: `[ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' ]` |
|
||||
| `cargoTestCommands` | The commands to run in the `checkPhase`. When set to a function, the function is applied to the default value. <br/> Default: `[ ''cargo $cargo_options test $cargo_test_options'' ]` |
|
||||
| `cargoTestOptions` | Options passed to cargo test, i.e. `cargo test <OPTS>`. These options can be accessed during the build through the environment variable `cargo_test_options`. <br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> When set to a function, the function is applied to the default value. <br/> Default: `[ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' ]` |
|
||||
| `buildInputs` | Extra `buildInputs` to all derivations. Default: `[]` |
|
||||
| `cargoOptions` | Options passed to all cargo commands, i.e. `cargo <OPTS> ...`. These options can be accessed during the build through the environment variable `cargo_options`. <br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> Default: `[ "-Z" "unstable-options" ]` |
|
||||
| `cargoOptions` | Options passed to all cargo commands, i.e. `cargo <OPTS> ...`. These options can be accessed during the build through the environment variable `cargo_options`. <br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> When set to a function, the function is applied to the default value. <br/> Default: `[ "-Z" "unstable-options" ]` |
|
||||
| `doDoc` | When true, `cargo doc` is run and a new output `doc` is generated. Default: `false` |
|
||||
| `release` | When true, all cargo builds are run with `--release`. The environment variable `cargo_release` is set to `--release` iff this option is set. Default: `true` |
|
||||
| `override` | An override for all derivations involved in the build. Default: `(x: x)` |
|
||||
|
|
|
@ -43,11 +43,10 @@ fn print_mk_attrs(mk_attrs: SyntaxNode) {
|
|||
for e in body.entries() {
|
||||
let k = e.key().expect("No key").path().next().unwrap();
|
||||
let v = e.value();
|
||||
let mshown = if let Some(x) = v.clone().and_then(OrDefault::cast) {
|
||||
let mextra_note = if let Some(x) = v.clone().and_then(OrDefault::cast) {
|
||||
x.default().and_then(|def| {
|
||||
let shown = format!("{}", def);
|
||||
if shown != "null" {
|
||||
Some(shown)
|
||||
if def.to_string() != "null" {
|
||||
Some(format!("Default: `{}`", def))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -63,12 +62,10 @@ fn print_mk_attrs(mk_attrs: SyntaxNode) {
|
|||
.lambda()
|
||||
.expect("No inner lambda");
|
||||
if inner2.to_string() == "allowFun" {
|
||||
Some(format!("{}", x.value().unwrap()))
|
||||
Some(format!("When set to a function, the function is applied to the default value. <br/> Default: `{}`", x.value().unwrap()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else if let Some(x) = v.clone().and_then(Lambda::cast) {
|
||||
Some("lambda".to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -79,14 +76,13 @@ fn print_mk_attrs(mk_attrs: SyntaxNode) {
|
|||
lines.push(l);
|
||||
}
|
||||
|
||||
let sss;
|
||||
if let Some(shown) = mshown {
|
||||
lines.push("Default:");
|
||||
sss = format!("`{}`", shown);
|
||||
lines.push(&sss);
|
||||
}
|
||||
let descr = lines.join(" ");
|
||||
println!("| `{}` | {} |", k, descr);
|
||||
if let Some(extra_note) = mextra_note {
|
||||
println!("| `{}` | {} {} |", k, descr, extra_note);
|
||||
lines.push(extra_note.clone().as_ref());
|
||||
} else {
|
||||
println!("| `{}` | {} |", k, descr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue