Remove the --indirect flag
All GC roots are now indirect.
This commit is contained in:
parent
b07167be5a
commit
00d25e8457
|
@ -12,7 +12,6 @@ Title: nix-instantiate
|
|||
[`--arg` *name* *value*]
|
||||
[{`--attr`| `-A`} *attrPath*]
|
||||
[`--add-root` *path*]
|
||||
[`--indirect`]
|
||||
[`--expr` | `-E`]
|
||||
*files…*
|
||||
|
||||
|
@ -32,8 +31,8 @@ standard input.
|
|||
|
||||
# Options
|
||||
|
||||
- `--add-root` *path*; `--indirect`
|
||||
See the [corresponding options](nix-store.md) in `nix-store`.
|
||||
- `--add-root` *path*
|
||||
See the [corresponding option](nix-store.md) in `nix-store`.
|
||||
|
||||
- `--parse`
|
||||
Just parse the input files, and print their abstract syntax trees on
|
||||
|
|
|
@ -9,7 +9,6 @@ Title: nix-store
|
|||
`nix-store` *operation* [*options…*] [*arguments…*]
|
||||
[`--option` *name* *value*]
|
||||
[`--add-root` *path*]
|
||||
[`--indirect`]
|
||||
|
||||
# Description
|
||||
|
||||
|
@ -28,27 +27,12 @@ have an effect.
|
|||
- `--add-root` *path*
|
||||
Causes the result of a realisation (`--realise` and
|
||||
`--force-realise`) to be registered as a root of the garbage
|
||||
collector. The root is stored in *path*, which must be inside a
|
||||
directory that is scanned for roots by the garbage collector
|
||||
(i.e., typically in a subdirectory of `/nix/var/nix/gcroots/`)
|
||||
*unless* the `--indirect` flag is used.
|
||||
|
||||
If there are multiple results, then multiple symlinks will be
|
||||
created by sequentially numbering symlinks beyond the first one
|
||||
(e.g., `foo`, `foo-2`, `foo-3`, and so on).
|
||||
|
||||
- `--indirect`
|
||||
In conjunction with `--add-root`, this option allows roots to be
|
||||
stored *outside* of the GC roots directory. This is useful for
|
||||
commands such as `nix-build` that place a symlink to the build
|
||||
result in the current directory; such a build result should not be
|
||||
garbage-collected unless the symlink is removed.
|
||||
|
||||
The `--indirect` flag causes a uniquely named symlink to *path* to
|
||||
be stored in `/nix/var/nix/gcroots/auto/`. For instance,
|
||||
collector. *path* will be created as a symlink to the resulting
|
||||
store path. In addition, a uniquely named symlink to *path* will
|
||||
be created in `/nix/var/nix/gcroots/auto/`. For instance,
|
||||
|
||||
```console
|
||||
$ nix-store --add-root /home/eelco/bla/result --indirect -r ...
|
||||
$ nix-store --add-root /home/eelco/bla/result -r ...
|
||||
|
||||
$ ls -l /nix/var/nix/gcroots/auto
|
||||
lrwxrwxrwx 1 ... 2005-03-13 21:10 dn54lcypm8f8... -> /home/eelco/bla/result
|
||||
|
@ -63,11 +47,13 @@ have an effect.
|
|||
|
||||
> **Warning**
|
||||
>
|
||||
> Note that it is not possible to move or rename indirect GC roots,
|
||||
> since the symlink in the `auto` directory will still point to the
|
||||
> old location.
|
||||
> Note that it is not possible to move or rename GC roots, since
|
||||
> the symlink in the `auto` directory will still point to the old
|
||||
> location.
|
||||
|
||||
<!-- end list -->
|
||||
If there are multiple results, then multiple symlinks will be
|
||||
created by sequentially numbering symlinks beyond the first one
|
||||
(e.g., `foo`, `foo-2`, `foo-3`, and so on).
|
||||
|
||||
# Operation `--realise`
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ using namespace nix;
|
|||
|
||||
static Path gcRoot;
|
||||
static int rootNr = 0;
|
||||
static bool indirectRoot = false;
|
||||
|
||||
|
||||
enum OutputKind { okPlain, okXML, okJSON };
|
||||
|
@ -71,11 +70,11 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
if (gcRoot == "")
|
||||
printGCWarning();
|
||||
else {
|
||||
Path rootName = indirectRoot ? absPath(gcRoot) : gcRoot;
|
||||
Path rootName = absPath(gcRoot);
|
||||
if (++rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
if (store2)
|
||||
drvPath = store2->addPermRoot(store2->parseStorePath(drvPath), rootName, indirectRoot);
|
||||
drvPath = store2->addPermRoot(store2->parseStorePath(drvPath), rootName, true);
|
||||
}
|
||||
std::cout << fmt("%s%s\n", drvPath, (outputName != "out" ? "!" + outputName : ""));
|
||||
}
|
||||
|
@ -127,7 +126,7 @@ static int _main(int argc, char * * argv)
|
|||
else if (*arg == "--add-root")
|
||||
gcRoot = getArg(*arg, arg, end);
|
||||
else if (*arg == "--indirect")
|
||||
indirectRoot = true;
|
||||
;
|
||||
else if (*arg == "--xml")
|
||||
outputKind = okXML;
|
||||
else if (*arg == "--json")
|
||||
|
|
|
@ -34,7 +34,6 @@ typedef void (* Operation) (Strings opFlags, Strings opArgs);
|
|||
|
||||
static Path gcRoot;
|
||||
static int rootNr = 0;
|
||||
static bool indirectRoot = false;
|
||||
static bool noOutput = false;
|
||||
static std::shared_ptr<Store> store;
|
||||
|
||||
|
@ -85,7 +84,7 @@ static PathSet realisePath(StorePathWithOutputs path, bool build = true)
|
|||
Path rootName = gcRoot;
|
||||
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
if (i->first != "out") rootName += "-" + i->first;
|
||||
outPath = store2->addPermRoot(store->parseStorePath(outPath), rootName, indirectRoot);
|
||||
outPath = store2->addPermRoot(store->parseStorePath(outPath), rootName, true);
|
||||
}
|
||||
}
|
||||
outputs.insert(outPath);
|
||||
|
@ -104,7 +103,7 @@ static PathSet realisePath(StorePathWithOutputs path, bool build = true)
|
|||
Path rootName = gcRoot;
|
||||
rootNr++;
|
||||
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
return {store2->addPermRoot(path.path, rootName, indirectRoot)};
|
||||
return {store2->addPermRoot(path.path, rootName, true)};
|
||||
}
|
||||
}
|
||||
return {store->printStorePath(path.path)};
|
||||
|
@ -1085,7 +1084,7 @@ static int _main(int argc, char * * argv)
|
|||
else if (*arg == "--add-root")
|
||||
gcRoot = absPath(getArg(*arg, arg, end));
|
||||
else if (*arg == "--indirect")
|
||||
indirectRoot = true;
|
||||
;
|
||||
else if (*arg == "--no-output")
|
||||
noOutput = true;
|
||||
else if (*arg != "" && arg->at(0) == '-') {
|
||||
|
|
|
@ -24,5 +24,5 @@ outPath2=$(nix-build $(nix-instantiate dependencies.nix) --no-out-link)
|
|||
outPath2=$(nix-build $(nix-instantiate dependencies.nix)!out --no-out-link)
|
||||
[[ $outPath = $outPath2 ]]
|
||||
|
||||
outPath2=$(nix-store -r $(nix-instantiate --indirect --add-root $TEST_ROOT/indirect dependencies.nix)!out)
|
||||
outPath2=$(nix-store -r $(nix-instantiate --add-root $TEST_ROOT/indirect dependencies.nix)!out)
|
||||
[[ $outPath = $outPath2 ]]
|
||||
|
|
|
@ -27,12 +27,12 @@ output=$(nix-shell --pure --keep SELECTED_IMPURE_VAR shell.nix -A shellDrv --run
|
|||
# Test nix-shell on a .drv symlink
|
||||
|
||||
# Legacy: absolute path and .drv extension required
|
||||
nix-instantiate shell.nix -A shellDrv --indirect --add-root $TEST_ROOT/shell.drv
|
||||
nix-instantiate shell.nix -A shellDrv --add-root $TEST_ROOT/shell.drv
|
||||
[[ $(nix-shell --pure $TEST_ROOT/shell.drv --run \
|
||||
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX"') = " - foo - bar" ]]
|
||||
|
||||
# New behaviour: just needs to resolve to a derivation in the store
|
||||
nix-instantiate shell.nix -A shellDrv --indirect --add-root $TEST_ROOT/shell
|
||||
nix-instantiate shell.nix -A shellDrv --add-root $TEST_ROOT/shell
|
||||
[[ $(nix-shell --pure $TEST_ROOT/shell --run \
|
||||
'echo "$IMPURE_VAR - $VAR_FROM_STDENV_SETUP - $VAR_FROM_NIX"') = " - foo - bar" ]]
|
||||
|
||||
|
|
Loading…
Reference in a new issue