mirror of
https://github.com/nix-community/naersk
synced 2024-11-10 06:04:17 +00:00
Document and format config.nix
This commit is contained in:
parent
92432c40d9
commit
6a33730b34
1 changed files with 95 additions and 88 deletions
183
config.nix
183
config.nix
|
@ -7,84 +7,89 @@ let
|
|||
else attrs0.${attrName}
|
||||
else default;
|
||||
mkAttrs = attrs0: rec
|
||||
{ # The name of the derivation.
|
||||
name = attrs0.name or null;
|
||||
# The version of the derivation.
|
||||
version = attrs0.version or null;
|
||||
# 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`.
|
||||
src = attrs0.src or null;
|
||||
# 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`.
|
||||
root = attrs0.root or null;
|
||||
{
|
||||
# The name of the derivation.
|
||||
name = attrs0.name or null;
|
||||
# The version of the derivation.
|
||||
version = attrs0.version or null;
|
||||
# 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`.
|
||||
src = attrs0.src or null;
|
||||
# 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`.
|
||||
root = attrs0.root or null;
|
||||
|
||||
# The command to use for the build.
|
||||
cargoBuild =
|
||||
allowFun attrs0 "cargoBuild"
|
||||
''cargo $cargo_options build $cargo_build_options'';
|
||||
# The command to use for the build.
|
||||
cargoBuild =
|
||||
allowFun attrs0 "cargoBuild"
|
||||
''cargo $cargo_options build $cargo_build_options'';
|
||||
|
||||
# foo
|
||||
# note: stuff depends on --out-dir
|
||||
# note: is added as cargo_build_options
|
||||
cargoBuildOptions =
|
||||
allowFun attrs0 "cargoBuildOptions" [ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' "--out-dir" "out" ];
|
||||
# Options passed to cargo build, i.e. `cargo build <OPTS>`. <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/>
|
||||
cargoBuildOptions =
|
||||
allowFun attrs0 "cargoBuildOptions" [ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' "--out-dir" "out" ];
|
||||
|
||||
# When true, `checkPhase` is run.
|
||||
doCheck = attrs0.doCheck or true;
|
||||
# When true, `checkPhase` is run.
|
||||
doCheck = attrs0.doCheck or true;
|
||||
|
||||
# The commands to run in the `checkPhase`.
|
||||
cargoTestCommands =
|
||||
allowFun attrs0 "cargoTestCommands" [ ''cargo $cargo_options test $cargo_test_options'' ];
|
||||
# The commands to run in the `checkPhase`.
|
||||
cargoTestCommands =
|
||||
allowFun attrs0 "cargoTestCommands" [ ''cargo $cargo_options test $cargo_test_options'' ];
|
||||
|
||||
# baaaar
|
||||
cargoTestOptions =
|
||||
allowFun attrs0 "cargoTestOptions" [ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' ];
|
||||
# Options passed to cargo test, i.e. `cargo test <OPTS>` <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/>
|
||||
cargoTestOptions =
|
||||
allowFun attrs0 "cargoTestOptions" [ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' ];
|
||||
|
||||
# Extra `buildInputs` to all derivations.
|
||||
buildInputs = attrs0.buildInputs or [];
|
||||
# Extra `buildInputs` to all derivations.
|
||||
buildInputs = attrs0.buildInputs or [];
|
||||
|
||||
# Options passed to cargo before the command (cargo OPTIONS <cmd>)
|
||||
# used by the default cargoBuild
|
||||
cargoOptions =
|
||||
allowFun attrs0 "cargoOptions" [ "-Z" "unstable-options" ];
|
||||
# Options passed to all cargo commands, i.e. `cargo <OPTS> ...` <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/>
|
||||
cargoOptions =
|
||||
allowFun attrs0 "cargoOptions" [ "-Z" "unstable-options" ];
|
||||
|
||||
# When true, `cargo doc` is run and a new output `doc` is generated.
|
||||
doDoc = attrs0.doDoc or false;
|
||||
# When true, all cargo builds are run with `--release`.
|
||||
# sets cargo_release
|
||||
release = attrs0.release or true;
|
||||
# An override for all derivations involved in the build.
|
||||
override = attrs0.override or (x: x);
|
||||
# When true, no intermediary (dependency-only) build is run. Enabling
|
||||
# `singleStep` greatly reduces the incrementality of the builds.
|
||||
singleStep = attrs0.singleStep or false;
|
||||
# The targets to build if the `Cargo.toml` is a virtual manifest.
|
||||
targets = attrs0.targets or null;
|
||||
# When true, the resulting binaries are copied to `$out/bin`.
|
||||
copyBins = attrs0.copyBins or true;
|
||||
# When true, the documentation is generated in a different output, `doc`.
|
||||
copyDocsToSeparateOutput = attrs0.copyDocsToSeparateOutput or true;
|
||||
# When true, the build fails if the documentation step fails; otherwise
|
||||
# the failure is ignored.
|
||||
doDocFail = attrs0.doDocFail or false;
|
||||
# When true, references to the nix store are removed from the generated
|
||||
# documentation.
|
||||
removeReferencesToSrcFromDocs = attrs0.removeReferencesToSrcFromDocs or true;
|
||||
# When true, the build output of intermediary builds is compressed with
|
||||
# [`Zstandard`](https://facebook.github.io/zstd/). This reduces the size
|
||||
# of closures.
|
||||
compressTarget = attrs0.compressTarget or true;
|
||||
# When true, the `target/` directory is copied to `$out`.
|
||||
copyTarget = attrs0.copyTarget or false;
|
||||
# Whether to use the `fromTOML` built-in or not. When set to `false` the
|
||||
# python package `remarshal` is used instead (in a derivation) and the
|
||||
# JSON output is read with `builtins.fromJSON`.
|
||||
# This is a workaround for old versions of Nix. May be used safely from
|
||||
# Nix 2.3 onwards where all bugs in `builtins.fromTOML` seem to have been
|
||||
# fixed.
|
||||
usePureFromTOML = attrs0.usePureFromTOML or true;
|
||||
};
|
||||
# When true, `cargo doc` is run and a new output `doc` is generated.
|
||||
doDoc = attrs0.doDoc or false;
|
||||
# When true, all cargo builds are run with `--release`.
|
||||
# sets cargo_release
|
||||
release = attrs0.release or true;
|
||||
# An override for all derivations involved in the build.
|
||||
override = attrs0.override or (x: x);
|
||||
# When true, no intermediary (dependency-only) build is run. Enabling
|
||||
# `singleStep` greatly reduces the incrementality of the builds.
|
||||
singleStep = attrs0.singleStep or false;
|
||||
# The targets to build if the `Cargo.toml` is a virtual manifest.
|
||||
targets = attrs0.targets or null;
|
||||
# When true, the resulting binaries are copied to `$out/bin`.
|
||||
copyBins = attrs0.copyBins or true;
|
||||
# When true, the documentation is generated in a different output, `doc`.
|
||||
copyDocsToSeparateOutput = attrs0.copyDocsToSeparateOutput or true;
|
||||
# When true, the build fails if the documentation step fails; otherwise
|
||||
# the failure is ignored.
|
||||
doDocFail = attrs0.doDocFail or false;
|
||||
# When true, references to the nix store are removed from the generated
|
||||
# documentation.
|
||||
removeReferencesToSrcFromDocs = attrs0.removeReferencesToSrcFromDocs or true;
|
||||
# When true, the build output of intermediary builds is compressed with
|
||||
# [`Zstandard`](https://facebook.github.io/zstd/). This reduces the size
|
||||
# of closures.
|
||||
compressTarget = attrs0.compressTarget or true;
|
||||
# When true, the `target/` directory is copied to `$out`.
|
||||
copyTarget = attrs0.copyTarget or false;
|
||||
# Whether to use the `fromTOML` built-in or not. When set to `false` the
|
||||
# python package `remarshal` is used instead (in a derivation) and the
|
||||
# JSON output is read with `builtins.fromJSON`.
|
||||
# This is a workaround for old versions of Nix. May be used safely from
|
||||
# Nix 2.3 onwards where all bugs in `builtins.fromTOML` seem to have been
|
||||
# fixed.
|
||||
usePureFromTOML = attrs0.usePureFromTOML or true;
|
||||
};
|
||||
|
||||
argIsAttrs =
|
||||
if lib.isDerivation arg then false
|
||||
|
@ -113,22 +118,22 @@ let
|
|||
root = attrs.root;
|
||||
src = attrs.src;
|
||||
in
|
||||
# src: yes, root: no
|
||||
if hasSrc && ! hasRoot then
|
||||
if isPath src then
|
||||
{ src = lib.cleanSource src; root = src; }
|
||||
else { inherit src; root = src; }
|
||||
# src: yes, root: yes
|
||||
else if hasRoot && hasSrc then
|
||||
{ inherit src root; }
|
||||
# src: no, root: yes
|
||||
else if hasRoot && ! hasSrc then
|
||||
if isPath root then
|
||||
{ inherit root; src = lib.cleanSource root; }
|
||||
else
|
||||
{ inherit root; src = root; }
|
||||
# src: no, root: yes
|
||||
else throw "please specify either 'src' or 'root'";
|
||||
# src: yes, root: no
|
||||
if hasSrc && ! hasRoot then
|
||||
if isPath src then
|
||||
{ src = lib.cleanSource src; root = src; }
|
||||
else { inherit src; root = src; }
|
||||
# src: yes, root: yes
|
||||
else if hasRoot && hasSrc then
|
||||
{ inherit src root; }
|
||||
# src: no, root: yes
|
||||
else if hasRoot && ! hasSrc then
|
||||
if isPath root then
|
||||
{ inherit root; src = lib.cleanSource root; }
|
||||
else
|
||||
{ inherit root; src = root; }
|
||||
# src: no, root: yes
|
||||
else throw "please specify either 'src' or 'root'";
|
||||
|
||||
usePureFromTOML = attrs.usePureFromTOML;
|
||||
readTOML = builtinz.readTOML usePureFromTOML;
|
||||
|
@ -225,10 +230,12 @@ let
|
|||
let
|
||||
rootDir = lib.removeSuffix "/*" member;
|
||||
subdirs = builtins.attrNames (builtins.readDir (root + "/${rootDir}"));
|
||||
in map (subdir: "${rootDir}/${subdir}") subdirs
|
||||
in
|
||||
map (subdir: "${rootDir}/${subdir}") subdirs
|
||||
else [ member ];
|
||||
|
||||
in lib.concatMap expandMember listedMembers;
|
||||
in
|
||||
lib.concatMap expandMember listedMembers;
|
||||
|
||||
patchedSources =
|
||||
let
|
||||
|
|
Loading…
Reference in a new issue