nix show-derivation -> nix derivation show

This commit is contained in:
John Ericson 2023-04-02 13:59:19 -04:00
parent 4e9f32f993
commit 2b98af2e62
7 changed files with 35 additions and 9 deletions

View file

@ -15,7 +15,7 @@
Example: `/nix/store/g946hcz4c8mdvq2g8vxx42z51qb71rvp-git-2.38.1.drv` Example: `/nix/store/g946hcz4c8mdvq2g8vxx42z51qb71rvp-git-2.38.1.drv`
See [`nix show-derivation`](./command-ref/new-cli/nix3-show-derivation.md) (experimental) for displaying the contents of store derivations. See [`nix derivation show`](./command-ref/new-cli/nix3-derivation-show.md) (experimental) for displaying the contents of store derivations.
[store derivation]: #gloss-store-derivation [store derivation]: #gloss-store-derivation

25
src/nix/derivation.cc Normal file
View file

@ -0,0 +1,25 @@
#include "command.hh"
using namespace nix;
struct CmdDerivation : virtual NixMultiCommand
{
CmdDerivation() : MultiCommand(RegisterCommand::getCommandsFor({"derivation"}))
{ }
std::string description() override
{
return "Work with derivations, Nix's notion of a build plan.";
}
Category category() override { return catUtility; }
void run() override
{
if (!command)
throw UsageError("'nix derivation' requires a sub-command.");
command->second->run();
}
};
static auto rCmdDerivation = registerCommand<CmdDerivation>("derivation");

View file

@ -127,6 +127,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
{"optimise-store", {"store", "optimise"}}, {"optimise-store", {"store", "optimise"}},
{"ping-store", {"store", "ping"}}, {"ping-store", {"store", "ping"}},
{"sign-paths", {"store", "sign"}}, {"sign-paths", {"store", "sign"}},
{"show-derivation", {"derivation", "show"}},
{"to-base16", {"hash", "to-base16"}}, {"to-base16", {"hash", "to-base16"}},
{"to-base32", {"hash", "to-base32"}}, {"to-base32", {"hash", "to-base32"}},
{"to-base64", {"hash", "to-base64"}}, {"to-base64", {"hash", "to-base64"}},

View file

@ -1,5 +1,5 @@
// FIXME: integrate this with nix path-info? // FIXME: integrate this with nix path-info?
// FIXME: rename to 'nix store show-derivation' or 'nix debug show-derivation'? // FIXME: rename to 'nix store derivation show' or 'nix debug derivation show'?
#include "command.hh" #include "command.hh"
#include "common-args.hh" #include "common-args.hh"
@ -61,4 +61,4 @@ struct CmdShowDerivation : InstallablesCommand
} }
}; };
static auto rCmdShowDerivation = registerCommand<CmdShowDerivation>("show-derivation"); static auto rCmdShowDerivation = registerCommand2<CmdShowDerivation>({"derivation", "show"});

View file

@ -8,7 +8,7 @@ R""(
[store derivation]: ../../glossary.md#gloss-store-derivation [store derivation]: ../../glossary.md#gloss-store-derivation
```console ```console
# nix show-derivation nixpkgs#hello # nix derivation show nixpkgs#hello
{ {
"/nix/store/s6rn4jz1sin56rf4qj5b5v8jxjm32hlk-hello-2.10.drv": { "/nix/store/s6rn4jz1sin56rf4qj5b5v8jxjm32hlk-hello-2.10.drv": {
@ -20,14 +20,14 @@ R""(
NixOS system: NixOS system:
```console ```console
# nix show-derivation -r /run/current-system # nix derivation show -r /run/current-system
``` ```
* Print all files fetched using `fetchurl` by Firefox's dependency * Print all files fetched using `fetchurl` by Firefox's dependency
graph: graph:
```console ```console
# nix show-derivation -r nixpkgs#firefox \ # nix derivation show -r nixpkgs#firefox \
| jq -r '.[] | select(.outputs.out.hash and .env.urls) | .env.urls' \ | jq -r '.[] | select(.outputs.out.hash and .env.urls) | .env.urls' \
| uniq | sort | uniq | sort
``` ```

View file

@ -3,7 +3,7 @@
source common.sh source common.sh
drv=$(nix-instantiate ./content-addressed.nix -A rootCA --arg seed 1) drv=$(nix-instantiate ./content-addressed.nix -A rootCA --arg seed 1)
nix show-derivation "$drv" --arg seed 1 nix derivation show "$drv" --arg seed 1
buildAttr () { buildAttr () {
local derivationPath=$1 local derivationPath=$1

View file

@ -37,8 +37,8 @@ path4=$(nix build -L --no-link --json --file ./impure-derivations.nix impureOnIm
(! nix build -L --no-link --json --file ./impure-derivations.nix inputAddressed 2>&1) | grep 'depends on impure derivation' (! nix build -L --no-link --json --file ./impure-derivations.nix inputAddressed 2>&1) | grep 'depends on impure derivation'
drvPath=$(nix eval --json --file ./impure-derivations.nix impure.drvPath | jq -r .) drvPath=$(nix eval --json --file ./impure-derivations.nix impure.drvPath | jq -r .)
[[ $(nix show-derivation $drvPath | jq ".[\"$drvPath\"].outputs.out.impure") = true ]] [[ $(nix derivation show $drvPath | jq ".[\"$drvPath\"].outputs.out.impure") = true ]]
[[ $(nix show-derivation $drvPath | jq ".[\"$drvPath\"].outputs.stuff.impure") = true ]] [[ $(nix derivation show $drvPath | jq ".[\"$drvPath\"].outputs.stuff.impure") = true ]]
# Fixed-output derivations *can* depend on impure derivations. # Fixed-output derivations *can* depend on impure derivations.
path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAddressed | jq -r .[].outputs.out) path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAddressed | jq -r .[].outputs.out)