mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
nix show-derivation
-> nix derivation show
This commit is contained in:
parent
4e9f32f993
commit
2b98af2e62
@ -15,7 +15,7 @@
|
||||
|
||||
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
|
||||
|
||||
|
25
src/nix/derivation.cc
Normal file
25
src/nix/derivation.cc
Normal 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");
|
@ -127,6 +127,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
||||
{"optimise-store", {"store", "optimise"}},
|
||||
{"ping-store", {"store", "ping"}},
|
||||
{"sign-paths", {"store", "sign"}},
|
||||
{"show-derivation", {"derivation", "show"}},
|
||||
{"to-base16", {"hash", "to-base16"}},
|
||||
{"to-base32", {"hash", "to-base32"}},
|
||||
{"to-base64", {"hash", "to-base64"}},
|
||||
|
@ -1,5 +1,5 @@
|
||||
// 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 "common-args.hh"
|
||||
@ -61,4 +61,4 @@ struct CmdShowDerivation : InstallablesCommand
|
||||
}
|
||||
};
|
||||
|
||||
static auto rCmdShowDerivation = registerCommand<CmdShowDerivation>("show-derivation");
|
||||
static auto rCmdShowDerivation = registerCommand2<CmdShowDerivation>({"derivation", "show"});
|
||||
|
@ -8,7 +8,7 @@ R""(
|
||||
[store derivation]: ../../glossary.md#gloss-store-derivation
|
||||
|
||||
```console
|
||||
# nix show-derivation nixpkgs#hello
|
||||
# nix derivation show nixpkgs#hello
|
||||
{
|
||||
"/nix/store/s6rn4jz1sin56rf4qj5b5v8jxjm32hlk-hello-2.10.drv": {
|
||||
…
|
||||
@ -20,14 +20,14 @@ R""(
|
||||
NixOS system:
|
||||
|
||||
```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
|
||||
graph:
|
||||
|
||||
```console
|
||||
# nix show-derivation -r nixpkgs#firefox \
|
||||
# nix derivation show -r nixpkgs#firefox \
|
||||
| jq -r '.[] | select(.outputs.out.hash and .env.urls) | .env.urls' \
|
||||
| uniq | sort
|
||||
```
|
||||
|
@ -3,7 +3,7 @@
|
||||
source common.sh
|
||||
|
||||
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 () {
|
||||
local derivationPath=$1
|
||||
|
@ -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'
|
||||
|
||||
drvPath=$(nix eval --json --file ./impure-derivations.nix impure.drvPath | jq -r .)
|
||||
[[ $(nix show-derivation $drvPath | jq ".[\"$drvPath\"].outputs.out.impure") = true ]]
|
||||
[[ $(nix show-derivation $drvPath | jq ".[\"$drvPath\"].outputs.stuff.impure") = true ]]
|
||||
[[ $(nix derivation show $drvPath | jq ".[\"$drvPath\"].outputs.out.impure") = true ]]
|
||||
[[ $(nix derivation show $drvPath | jq ".[\"$drvPath\"].outputs.stuff.impure") = true ]]
|
||||
|
||||
# Fixed-output derivations *can* depend on impure derivations.
|
||||
path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAddressed | jq -r .[].outputs.out)
|
||||
|
Loading…
Reference in New Issue
Block a user