diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-09-03 11:22:00 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-09-03 11:22:00 +0200 |
commit | 00d25e84577659ccf0bc360c61c47b6cd25d1c26 (patch) | |
tree | 9e25d4a65da3b33023e7d4ddb3ee480f12573205 | |
parent | b07167be5aeb91c06ca3487b3d18f6c8f59942a0 (diff) |
Remove the --indirect flag
All GC roots are now indirect.
-rw-r--r-- | doc/manual/src/command-ref/nix-instantiate.md | 5 | ||||
-rw-r--r-- | doc/manual/src/command-ref/nix-store.md | 34 | ||||
-rw-r--r-- | src/nix-instantiate/nix-instantiate.cc | 7 | ||||
-rw-r--r-- | src/nix-store/nix-store.cc | 7 | ||||
-rw-r--r-- | tests/nix-build.sh | 2 | ||||
-rw-r--r-- | tests/nix-shell.sh | 4 |
6 files changed, 21 insertions, 38 deletions
diff --git a/doc/manual/src/command-ref/nix-instantiate.md b/doc/manual/src/command-ref/nix-instantiate.md index 5b5ee0439..d09f5ed6a 100644 --- a/doc/manual/src/command-ref/nix-instantiate.md +++ b/doc/manual/src/command-ref/nix-instantiate.md @@ -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 diff --git a/doc/manual/src/command-ref/nix-store.md b/doc/manual/src/command-ref/nix-store.md index 193d670c2..4680339e4 100644 --- a/doc/manual/src/command-ref/nix-store.md +++ b/doc/manual/src/command-ref/nix-store.md @@ -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` diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index bf353677a..d4996b93b 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -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") diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index a58edff57..4382b1460 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -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) == '-') { diff --git a/tests/nix-build.sh b/tests/nix-build.sh index 0eb599608..3123c6da3 100644 --- a/tests/nix-build.sh +++ b/tests/nix-build.sh @@ -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 ]] diff --git a/tests/nix-shell.sh b/tests/nix-shell.sh index 650904057..1228bb04f 100644 --- a/tests/nix-shell.sh +++ b/tests/nix-shell.sh @@ -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" ]] |