mirror of
https://github.com/NixOS/nix
synced 2024-10-18 00:16:11 -04:00
Compare commits
20 commits
c2aa1d9780
...
6045b9154d
Author | SHA1 | Date | |
---|---|---|---|
6045b9154d | |||
694c378d14 | |||
e65510da56 | |||
1cd48008f0 | |||
2e2c7f3b14 | |||
c196011d23 | |||
7bd0c70b37 | |||
f51974d698 | |||
ed184f0b61 | |||
facc502bc8 | |||
fd8a4a86d9 | |||
16320f6d24 | |||
3f9ff10786 | |||
de41e46175 | |||
0e5a5303ad | |||
781ff7672e | |||
5d35424445 | |||
35599b8f86 | |||
a3aaa573c4 | |||
d68b2a7c1b |
2
.github/labeler.yml
vendored
2
.github/labeler.yml
vendored
|
@ -1,7 +1,7 @@
|
|||
"c api":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "src/lib*-c/**/*"
|
||||
- any-glob-to-any-file: "test/unit/**/nix_api_*"
|
||||
- any-glob-to-any-file: "src/*test*/**/nix_api_*"
|
||||
- any-glob-to-any-file: "doc/external-api/**/*"
|
||||
|
||||
"contributor-experience":
|
||||
|
|
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -49,22 +49,22 @@ perl/Makefile.config
|
|||
/src/libexpr/parser-tab.output
|
||||
/src/libexpr/nix.tbl
|
||||
/src/libexpr/tests
|
||||
/tests/unit/libexpr/libnixexpr-tests
|
||||
/src/libexpr-tests/libnixexpr-tests
|
||||
|
||||
# /src/libfetchers
|
||||
/tests/unit/libfetchers/libnixfetchers-tests
|
||||
/src/libfetchers-tests/libnixfetchers-tests
|
||||
|
||||
# /src/libflake
|
||||
/tests/unit/libflake/libnixflake-tests
|
||||
/src/libflake-tests/libnixflake-tests
|
||||
|
||||
# /src/libstore/
|
||||
*.gen.*
|
||||
/src/libstore/tests
|
||||
/tests/unit/libstore/libnixstore-tests
|
||||
/src/libstore-tests/libnixstore-tests
|
||||
|
||||
# /src/libutil/
|
||||
/src/libutil/tests
|
||||
/tests/unit/libutil/libnixutil-tests
|
||||
/src/libutil-tests/libnixutil-tests
|
||||
|
||||
/src/nix/nix
|
||||
|
||||
|
|
16
Makefile
16
Makefile
|
@ -40,14 +40,14 @@ endif
|
|||
|
||||
ifeq ($(ENABLE_UNIT_TESTS), yes)
|
||||
makefiles += \
|
||||
tests/unit/libutil/local.mk \
|
||||
tests/unit/libutil-support/local.mk \
|
||||
tests/unit/libstore/local.mk \
|
||||
tests/unit/libstore-support/local.mk \
|
||||
tests/unit/libfetchers/local.mk \
|
||||
tests/unit/libexpr/local.mk \
|
||||
tests/unit/libexpr-support/local.mk \
|
||||
tests/unit/libflake/local.mk
|
||||
src/libutil-tests/local.mk \
|
||||
src/libutil-test-support/local.mk \
|
||||
src/libstore-tests/local.mk \
|
||||
src/libstore-test-support/local.mk \
|
||||
src/libfetchers-tests/local.mk \
|
||||
src/libexpr-tests/local.mk \
|
||||
src/libexpr-test-support/local.mk \
|
||||
src/libflake-tests/local.mk
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_FUNCTIONAL_TESTS), yes)
|
||||
|
|
|
@ -60,10 +60,10 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
|
|||
> ```
|
||||
|
||||
The tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `src/${library_name_without-nix}-test`.
|
||||
Given an interface (header) and implementation pair in the original library, say, `src/libexpr/value/context.{hh,cc}`, we write tests for it in `src/nix-expr-tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `src/nix-expr-test-support/tests/value/context.{hh,cc}`.
|
||||
Given an interface (header) and implementation pair in the original library, say, `src/libexpr/value/context.{hh,cc}`, we write tests for it in `src/libexpr-tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `src/libexpr-test-support/tests/value/context.{hh,cc}`.
|
||||
|
||||
Data for unit tests is stored in a `data` subdir of the directory for each unit test executable.
|
||||
For example, `libnixstore` code is in `src/libstore`, and its test data is in `src/nix-store-tests/data`.
|
||||
For example, `libnixstore` code is in `src/libstore`, and its test data is in `src/libstore-tests/data`.
|
||||
The path to the `src/${library_name_without-nix}-test/data` directory is passed to the unit test executable with the environment variable `_NIX_TEST_UNIT_DATA`.
|
||||
Note that each executable only gets the data for its tests.
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@ We aim to achieve this by improving the contributor experience and attracting mo
|
|||
|
||||
## Members
|
||||
|
||||
- Eelco Dolstra (@edolstra) – Team lead
|
||||
- Valentin Gagarin (@fricklerhandwerk)
|
||||
- Thomas Bereknyei (@tomberek)
|
||||
- Robert Hensing (@roberth)
|
||||
- John Ericson (@Ericson2314)
|
||||
See https://nixos.org/community/teams/nix/ for the current team membership.
|
||||
|
||||
The team is on Github as [@NixOS/nix-team](https://github.com/orgs/NixOS/teams/nix-team).
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
excludes = [
|
||||
# We don't want to format test data
|
||||
# ''tests/(?!nixos/).*\.nix''
|
||||
''^tests/unit/[^/]*/data/.*$''
|
||||
''^src/[^/]*-tests/data/.*$''
|
||||
|
||||
# Don't format vendored code
|
||||
''^doc/manual/redirects\.js$''
|
||||
|
@ -28,8 +28,6 @@
|
|||
''^src/build-remote/build-remote\.cc$''
|
||||
''^src/libcmd/built-path\.cc$''
|
||||
''^src/libcmd/built-path\.hh$''
|
||||
''^src/libcmd/command\.cc$''
|
||||
''^src/libcmd/command\.hh$''
|
||||
''^src/libcmd/common-eval-args\.cc$''
|
||||
''^src/libcmd/common-eval-args\.hh$''
|
||||
''^src/libcmd/editor-for\.cc$''
|
||||
|
@ -427,64 +425,64 @@
|
|||
''^tests/nixos/ca-fd-leak/sender\.c''
|
||||
''^tests/nixos/ca-fd-leak/smuggler\.c''
|
||||
''^tests/nixos/user-sandboxing/attacker\.c''
|
||||
''^tests/unit/libexpr-support/tests/libexpr\.hh''
|
||||
''^tests/unit/libexpr-support/tests/value/context\.cc''
|
||||
''^tests/unit/libexpr-support/tests/value/context\.hh''
|
||||
''^tests/unit/libexpr/derived-path\.cc''
|
||||
''^tests/unit/libexpr/error_traces\.cc''
|
||||
''^tests/unit/libexpr/eval\.cc''
|
||||
''^tests/unit/libexpr/json\.cc''
|
||||
''^tests/unit/libexpr/main\.cc''
|
||||
''^tests/unit/libexpr/primops\.cc''
|
||||
''^tests/unit/libexpr/search-path\.cc''
|
||||
''^tests/unit/libexpr/trivial\.cc''
|
||||
''^tests/unit/libexpr/value/context\.cc''
|
||||
''^tests/unit/libexpr/value/print\.cc''
|
||||
''^tests/unit/libfetchers/public-key\.cc''
|
||||
''^tests/unit/libflake/flakeref\.cc''
|
||||
''^tests/unit/libflake/url-name\.cc''
|
||||
''^tests/unit/libstore-support/tests/derived-path\.cc''
|
||||
''^tests/unit/libstore-support/tests/derived-path\.hh''
|
||||
''^tests/unit/libstore-support/tests/nix_api_store\.hh''
|
||||
''^tests/unit/libstore-support/tests/outputs-spec\.cc''
|
||||
''^tests/unit/libstore-support/tests/outputs-spec\.hh''
|
||||
''^tests/unit/libstore-support/tests/path\.cc''
|
||||
''^tests/unit/libstore-support/tests/path\.hh''
|
||||
''^tests/unit/libstore-support/tests/protocol\.hh''
|
||||
''^tests/unit/libstore/common-protocol\.cc''
|
||||
''^tests/unit/libstore/content-address\.cc''
|
||||
''^tests/unit/libstore/derivation\.cc''
|
||||
''^tests/unit/libstore/derived-path\.cc''
|
||||
''^tests/unit/libstore/downstream-placeholder\.cc''
|
||||
''^tests/unit/libstore/machines\.cc''
|
||||
''^tests/unit/libstore/nar-info-disk-cache\.cc''
|
||||
''^tests/unit/libstore/nar-info\.cc''
|
||||
''^tests/unit/libstore/outputs-spec\.cc''
|
||||
''^tests/unit/libstore/path-info\.cc''
|
||||
''^tests/unit/libstore/path\.cc''
|
||||
''^tests/unit/libstore/serve-protocol\.cc''
|
||||
''^tests/unit/libstore/worker-protocol\.cc''
|
||||
''^tests/unit/libutil-support/tests/characterization\.hh''
|
||||
''^tests/unit/libutil-support/tests/hash\.cc''
|
||||
''^tests/unit/libutil-support/tests/hash\.hh''
|
||||
''^tests/unit/libutil/args\.cc''
|
||||
''^tests/unit/libutil/canon-path\.cc''
|
||||
''^tests/unit/libutil/chunked-vector\.cc''
|
||||
''^tests/unit/libutil/closure\.cc''
|
||||
''^tests/unit/libutil/compression\.cc''
|
||||
''^tests/unit/libutil/config\.cc''
|
||||
''^tests/unit/libutil/file-content-address\.cc''
|
||||
''^tests/unit/libutil/git\.cc''
|
||||
''^tests/unit/libutil/hash\.cc''
|
||||
''^tests/unit/libutil/hilite\.cc''
|
||||
''^tests/unit/libutil/json-utils\.cc''
|
||||
''^tests/unit/libutil/logging\.cc''
|
||||
''^tests/unit/libutil/lru-cache\.cc''
|
||||
''^tests/unit/libutil/pool\.cc''
|
||||
''^tests/unit/libutil/references\.cc''
|
||||
''^tests/unit/libutil/suggestions\.cc''
|
||||
''^tests/unit/libutil/url\.cc''
|
||||
''^tests/unit/libutil/xml-writer\.cc''
|
||||
''^src/libexpr-test-support/tests/libexpr\.hh''
|
||||
''^src/libexpr-test-support/tests/value/context\.cc''
|
||||
''^src/libexpr-test-support/tests/value/context\.hh''
|
||||
''^src/libexpr-tests/derived-path\.cc''
|
||||
''^src/libexpr-tests/error_traces\.cc''
|
||||
''^src/libexpr-tests/eval\.cc''
|
||||
''^src/libexpr-tests/json\.cc''
|
||||
''^src/libexpr-tests/main\.cc''
|
||||
''^src/libexpr-tests/primops\.cc''
|
||||
''^src/libexpr-tests/search-path\.cc''
|
||||
''^src/libexpr-tests/trivial\.cc''
|
||||
''^src/libexpr-tests/value/context\.cc''
|
||||
''^src/libexpr-tests/value/print\.cc''
|
||||
''^src/libfetchers-tests/public-key\.cc''
|
||||
''^src/libflake-tests/flakeref\.cc''
|
||||
''^src/libflake-tests/url-name\.cc''
|
||||
''^src/libstore-test-support/tests/derived-path\.cc''
|
||||
''^src/libstore-test-support/tests/derived-path\.hh''
|
||||
''^src/libstore-test-support/tests/nix_api_store\.hh''
|
||||
''^src/libstore-test-support/tests/outputs-spec\.cc''
|
||||
''^src/libstore-test-support/tests/outputs-spec\.hh''
|
||||
''^src/libstore-test-support/tests/path\.cc''
|
||||
''^src/libstore-test-support/tests/path\.hh''
|
||||
''^src/libstore-test-support/tests/protocol\.hh''
|
||||
''^src/libstore-tests/common-protocol\.cc''
|
||||
''^src/libstore-tests/content-address\.cc''
|
||||
''^src/libstore-tests/derivation\.cc''
|
||||
''^src/libstore-tests/derived-path\.cc''
|
||||
''^src/libstore-tests/downstream-placeholder\.cc''
|
||||
''^src/libstore-tests/machines\.cc''
|
||||
''^src/libstore-tests/nar-info-disk-cache\.cc''
|
||||
''^src/libstore-tests/nar-info\.cc''
|
||||
''^src/libstore-tests/outputs-spec\.cc''
|
||||
''^src/libstore-tests/path-info\.cc''
|
||||
''^src/libstore-tests/path\.cc''
|
||||
''^src/libstore-tests/serve-protocol\.cc''
|
||||
''^src/libstore-tests/worker-protocol\.cc''
|
||||
''^src/libutil-test-support/tests/characterization\.hh''
|
||||
''^src/libutil-test-support/tests/hash\.cc''
|
||||
''^src/libutil-test-support/tests/hash\.hh''
|
||||
''^src/libutil-tests/args\.cc''
|
||||
''^src/libutil-tests/canon-path\.cc''
|
||||
''^src/libutil-tests/chunked-vector\.cc''
|
||||
''^src/libutil-tests/closure\.cc''
|
||||
''^src/libutil-tests/compression\.cc''
|
||||
''^src/libutil-tests/config\.cc''
|
||||
''^src/libutil-tests/file-content-address\.cc''
|
||||
''^src/libutil-tests/git\.cc''
|
||||
''^src/libutil-tests/hash\.cc''
|
||||
''^src/libutil-tests/hilite\.cc''
|
||||
''^src/libutil-tests/json-utils\.cc''
|
||||
''^src/libutil-tests/logging\.cc''
|
||||
''^src/libutil-tests/lru-cache\.cc''
|
||||
''^src/libutil-tests/pool\.cc''
|
||||
''^src/libutil-tests/references\.cc''
|
||||
''^src/libutil-tests/suggestions\.cc''
|
||||
''^src/libutil-tests/url\.cc''
|
||||
''^src/libutil-tests/xml-writer\.cc''
|
||||
];
|
||||
};
|
||||
shellcheck = {
|
||||
|
@ -552,7 +550,6 @@
|
|||
''^tests/functional/flakes/check\.sh$''
|
||||
''^tests/functional/flakes/common\.sh$''
|
||||
''^tests/functional/flakes/config\.sh$''
|
||||
''^tests/functional/flakes/develop\.sh$''
|
||||
''^tests/functional/flakes/flakes\.sh$''
|
||||
''^tests/functional/flakes/follow-paths\.sh$''
|
||||
''^tests/functional/flakes/prefetch\.sh$''
|
||||
|
@ -650,7 +647,7 @@
|
|||
''^tests/functional/user-envs\.sh$''
|
||||
''^tests/functional/why-depends\.sh$''
|
||||
''^tests/functional/zstd\.sh$''
|
||||
''^tests/unit/libutil/data/git/check-data\.sh$''
|
||||
''^src/libutil-tests/data/git/check-data\.sh$''
|
||||
];
|
||||
};
|
||||
# TODO: nixfmt, https://github.com/NixOS/nixfmt/issues/153
|
||||
|
|
6
maintainers/onboarding.md
Normal file
6
maintainers/onboarding.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
# Onboarding a new team member
|
||||
|
||||
- https://github.com/NixOS/nixos-homepage/
|
||||
- https://github.com/orgs/NixOS/teams/nix-team
|
||||
- Matrix room
|
16
meson.build
16
meson.build
|
@ -40,12 +40,12 @@ if not meson.is_cross_build()
|
|||
endif
|
||||
|
||||
# Testing
|
||||
subproject('nix-util-test-support')
|
||||
subproject('nix-util-tests')
|
||||
subproject('nix-store-test-support')
|
||||
subproject('nix-store-tests')
|
||||
subproject('nix-fetchers-tests')
|
||||
subproject('nix-expr-test-support')
|
||||
subproject('nix-expr-tests')
|
||||
subproject('nix-flake-tests')
|
||||
subproject('libutil-test-support')
|
||||
subproject('libutil-tests')
|
||||
subproject('libstore-test-support')
|
||||
subproject('libstore-tests')
|
||||
subproject('libfetchers-tests')
|
||||
subproject('libexpr-test-support')
|
||||
subproject('libexpr-tests')
|
||||
subproject('libflake-tests')
|
||||
subproject('nix-functional-tests')
|
||||
|
|
|
@ -176,8 +176,6 @@ in {
|
|||
./scripts/local.mk
|
||||
] ++ lib.optionals enableManual [
|
||||
./doc/manual
|
||||
] ++ lib.optionals buildUnitTests [
|
||||
./tests/unit
|
||||
] ++ lib.optionals doInstallCheck [
|
||||
./tests/functional
|
||||
]));
|
||||
|
|
|
@ -32,24 +32,24 @@ in
|
|||
|
||||
nix-util = callPackage ../src/libutil/package.nix { };
|
||||
nix-util-c = callPackage ../src/libutil-c/package.nix { };
|
||||
nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { };
|
||||
nix-util-tests = callPackage ../tests/unit/libutil/package.nix { };
|
||||
nix-util-test-support = callPackage ../src/libutil-test-support/package.nix { };
|
||||
nix-util-tests = callPackage ../src/libutil-tests/package.nix { };
|
||||
|
||||
nix-store = callPackage ../src/libstore/package.nix { };
|
||||
nix-store-c = callPackage ../src/libstore-c/package.nix { };
|
||||
nix-store-test-support = callPackage ../tests/unit/libstore-support/package.nix { };
|
||||
nix-store-tests = callPackage ../tests/unit/libstore/package.nix { };
|
||||
nix-store-test-support = callPackage ../src/libstore-test-support/package.nix { };
|
||||
nix-store-tests = callPackage ../src/libstore-tests/package.nix { };
|
||||
|
||||
nix-fetchers = callPackage ../src/libfetchers/package.nix { };
|
||||
nix-fetchers-tests = callPackage ../tests/unit/libfetchers/package.nix { };
|
||||
nix-fetchers-tests = callPackage ../src/libfetchers-tests/package.nix { };
|
||||
|
||||
nix-expr = callPackage ../src/libexpr/package.nix { };
|
||||
nix-expr-c = callPackage ../src/libexpr-c/package.nix { };
|
||||
nix-expr-test-support = callPackage ../tests/unit/libexpr-support/package.nix { };
|
||||
nix-expr-tests = callPackage ../tests/unit/libexpr/package.nix { };
|
||||
nix-expr-test-support = callPackage ../src/libexpr-test-support/package.nix { };
|
||||
nix-expr-tests = callPackage ../src/libexpr-tests/package.nix { };
|
||||
|
||||
nix-flake = callPackage ../src/libflake/package.nix { };
|
||||
nix-flake-tests = callPackage ../tests/unit/libflake/package.nix { };
|
||||
nix-flake-tests = callPackage ../src/libflake-tests/package.nix { };
|
||||
|
||||
nix-main = callPackage ../src/libmain/package.nix { };
|
||||
nix-main-c = callPackage ../src/libmain-c/package.nix { };
|
||||
|
|
|
@ -41,21 +41,21 @@ INPUT = \
|
|||
@src@/libcmd \
|
||||
@src@/libexpr \
|
||||
@src@/libexpr/flake \
|
||||
@src@/nix-expr-tests \
|
||||
@src@/nix-expr-tests/value \
|
||||
@src@/nix-expr-test-support/test \
|
||||
@src@/nix-expr-test-support/test/value \
|
||||
@src@/libexpr-tests \
|
||||
@src@/libexpr-tests/value \
|
||||
@src@/libexpr-test-support/test \
|
||||
@src@/libexpr-test-support/test/value \
|
||||
@src@/libexpr/value \
|
||||
@src@/libfetchers \
|
||||
@src@/libmain \
|
||||
@src@/libstore \
|
||||
@src@/libstore/build \
|
||||
@src@/libstore/builtins \
|
||||
@src@/nix-store-tests \
|
||||
@src@/nix-store-test-support/test \
|
||||
@src@/libstore-tests \
|
||||
@src@/libstore-test-support/test \
|
||||
@src@/libutil \
|
||||
@src@/nix-util-tests \
|
||||
@src@/nix-util-test-support/test \
|
||||
@src@/libutil-tests \
|
||||
@src@/libutil-test-support/test \
|
||||
@src@/nix \
|
||||
@src@/nix-env \
|
||||
@src@/nix-store
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <algorithm>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "command.hh"
|
||||
|
@ -9,8 +10,7 @@
|
|||
#include "profiles.hh"
|
||||
#include "repl.hh"
|
||||
#include "strings.hh"
|
||||
|
||||
extern char * * environ __attribute__((weak));
|
||||
#include "environment-variables.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -23,7 +23,8 @@ nix::Commands RegisterCommand::getCommandsFor(const std::vector<std::string> & p
|
|||
if (name.size() == prefix.size() + 1) {
|
||||
bool equal = true;
|
||||
for (size_t i = 0; i < prefix.size(); ++i)
|
||||
if (name[i] != prefix[i]) equal = false;
|
||||
if (name[i] != prefix[i])
|
||||
equal = false;
|
||||
if (equal)
|
||||
res.insert_or_assign(name[prefix.size()], command);
|
||||
}
|
||||
|
@ -42,16 +43,16 @@ void NixMultiCommand::run()
|
|||
std::set<std::string> subCommandTextLines;
|
||||
for (auto & [name, _] : commands)
|
||||
subCommandTextLines.insert(fmt("- `%s`", name));
|
||||
std::string markdownError = fmt("`nix %s` requires a sub-command. Available sub-commands:\n\n%s\n",
|
||||
commandName, concatStringsSep("\n", subCommandTextLines));
|
||||
std::string markdownError =
|
||||
fmt("`nix %s` requires a sub-command. Available sub-commands:\n\n%s\n",
|
||||
commandName,
|
||||
concatStringsSep("\n", subCommandTextLines));
|
||||
throw UsageError(renderMarkdownToTerminal(markdownError));
|
||||
}
|
||||
command->second->run();
|
||||
}
|
||||
|
||||
StoreCommand::StoreCommand()
|
||||
{
|
||||
}
|
||||
StoreCommand::StoreCommand() {}
|
||||
|
||||
ref<Store> StoreCommand::getStore()
|
||||
{
|
||||
|
@ -126,10 +127,8 @@ ref<Store> EvalCommand::getEvalStore()
|
|||
ref<EvalState> EvalCommand::getEvalState()
|
||||
{
|
||||
if (!evalState) {
|
||||
evalState =
|
||||
std::allocate_shared<EvalState>(
|
||||
traceable_allocator<EvalState>(),
|
||||
lookupPath, getEvalStore(), fetchSettings, evalSettings, getStore());
|
||||
evalState = std::allocate_shared<EvalState>(
|
||||
traceable_allocator<EvalState>(), lookupPath, getEvalStore(), fetchSettings, evalSettings, getStore());
|
||||
|
||||
evalState->repair = repair;
|
||||
|
||||
|
@ -144,7 +143,8 @@ MixOperateOnOptions::MixOperateOnOptions()
|
|||
{
|
||||
addFlag({
|
||||
.longName = "derivation",
|
||||
.description = "Operate on the [store derivation](@docroot@/glossary.md#gloss-store-derivation) rather than its outputs.",
|
||||
.description =
|
||||
"Operate on the [store derivation](@docroot@/glossary.md#gloss-store-derivation) rather than its outputs.",
|
||||
.category = installablesCategory,
|
||||
.handler = {&operateOn, OperateOn::Derivation},
|
||||
});
|
||||
|
@ -233,46 +233,48 @@ void StorePathCommand::run(ref<Store> store, StorePaths && storePaths)
|
|||
|
||||
MixProfile::MixProfile()
|
||||
{
|
||||
addFlag({
|
||||
.longName = "profile",
|
||||
.description = "The profile to operate on.",
|
||||
.labels = {"path"},
|
||||
.handler = {&profile},
|
||||
.completer = completePath
|
||||
});
|
||||
addFlag(
|
||||
{.longName = "profile",
|
||||
.description = "The profile to operate on.",
|
||||
.labels = {"path"},
|
||||
.handler = {&profile},
|
||||
.completer = completePath});
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(const StorePath & storePath)
|
||||
{
|
||||
if (!profile) return;
|
||||
if (!profile)
|
||||
return;
|
||||
auto store = getStore().dynamic_pointer_cast<LocalFSStore>();
|
||||
if (!store) throw Error("'--profile' is not supported for this Nix store");
|
||||
if (!store)
|
||||
throw Error("'--profile' is not supported for this Nix store");
|
||||
auto profile2 = absPath(*profile);
|
||||
switchLink(profile2,
|
||||
createGeneration(*store, profile2, storePath));
|
||||
switchLink(profile2, createGeneration(*store, profile2, storePath));
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(const BuiltPaths & buildables)
|
||||
{
|
||||
if (!profile) return;
|
||||
if (!profile)
|
||||
return;
|
||||
|
||||
StorePaths result;
|
||||
|
||||
for (auto & buildable : buildables) {
|
||||
std::visit(overloaded {
|
||||
[&](const BuiltPath::Opaque & bo) {
|
||||
result.push_back(bo.path);
|
||||
std::visit(
|
||||
overloaded{
|
||||
[&](const BuiltPath::Opaque & bo) { result.push_back(bo.path); },
|
||||
[&](const BuiltPath::Built & bfd) {
|
||||
for (auto & output : bfd.outputs) {
|
||||
result.push_back(output.second);
|
||||
}
|
||||
},
|
||||
},
|
||||
[&](const BuiltPath::Built & bfd) {
|
||||
for (auto & output : bfd.outputs) {
|
||||
result.push_back(output.second);
|
||||
}
|
||||
},
|
||||
}, buildable.raw());
|
||||
buildable.raw());
|
||||
}
|
||||
|
||||
if (result.size() != 1)
|
||||
throw UsageError("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
||||
throw UsageError(
|
||||
"'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
||||
|
||||
updateProfile(result[0]);
|
||||
}
|
||||
|
@ -282,51 +284,78 @@ MixDefaultProfile::MixDefaultProfile()
|
|||
profile = getDefaultProfile();
|
||||
}
|
||||
|
||||
MixEnvironment::MixEnvironment() : ignoreEnvironment(false)
|
||||
MixEnvironment::MixEnvironment()
|
||||
: ignoreEnvironment(false)
|
||||
{
|
||||
addFlag({
|
||||
.longName = "ignore-environment",
|
||||
.longName = "ignore-env",
|
||||
.aliases = {"ignore-environment"},
|
||||
.shortName = 'i',
|
||||
.description = "Clear the entire environment (except those specified with `--keep`).",
|
||||
.description = "Clear the entire environment, except for those specified with `--keep-env-var`. "
|
||||
"Alias for `--ignore-environment`.",
|
||||
.category = environmentVariablesCategory,
|
||||
.handler = {&ignoreEnvironment, true},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "keep",
|
||||
.longName = "keep-env-var",
|
||||
.aliases = {"keep"},
|
||||
.shortName = 'k',
|
||||
.description = "Keep the environment variable *name*.",
|
||||
.description = "Keep the environment variable *name*, when using `--ignore-env`. "
|
||||
"Alias for `--keep`.",
|
||||
.category = environmentVariablesCategory,
|
||||
.labels = {"name"},
|
||||
.handler = {[&](std::string s) { keep.insert(s); }},
|
||||
.handler = {[&](std::string s) { keepVars.insert(s); }},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "unset",
|
||||
.longName = "unset-env-var",
|
||||
.aliases = {"unset"},
|
||||
.shortName = 'u',
|
||||
.description = "Unset the environment variable *name*.",
|
||||
.description = "Unset the environment variable *name*. "
|
||||
"Alias for `--unset`.",
|
||||
.category = environmentVariablesCategory,
|
||||
.labels = {"name"},
|
||||
.handler = {[&](std::string s) { unset.insert(s); }},
|
||||
.handler = {[&](std::string s) { unsetVars.insert(s); }},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "set-env-var",
|
||||
.shortName = 's',
|
||||
.description = "Add/override an environment variable *name* with *value*.\n\n"
|
||||
"> **Notes**\n"
|
||||
">\n"
|
||||
"> Duplicate definitions will be overwritten, last one wins.\n\n"
|
||||
"> Cancles out with `--unset-env-var`.\n\n",
|
||||
.category = environmentVariablesCategory,
|
||||
.labels = {"name", "value"},
|
||||
.handler = {[&](std::string name, std::string value) { setVars.insert_or_assign(name, value); }},
|
||||
});
|
||||
}
|
||||
|
||||
void MixEnvironment::setEnviron() {
|
||||
if (ignoreEnvironment) {
|
||||
if (!unset.empty())
|
||||
throw UsageError("--unset does not make sense with --ignore-environment");
|
||||
void MixEnvironment::setEnviron()
|
||||
{
|
||||
if (ignoreEnvironment && !unsetVars.empty())
|
||||
throw UsageError("--unset-env-var does not make sense with --ignore-env");
|
||||
|
||||
for (const auto & var : keep) {
|
||||
auto val = getenv(var.c_str());
|
||||
if (val) stringsEnv.emplace_back(fmt("%s=%s", var.c_str(), val));
|
||||
}
|
||||
if (!ignoreEnvironment && !keepVars.empty())
|
||||
throw UsageError("--keep-env-var does not make sense without --ignore-env");
|
||||
|
||||
vectorEnv = stringsToCharPtrs(stringsEnv);
|
||||
environ = vectorEnv.data();
|
||||
} else {
|
||||
if (!keep.empty())
|
||||
throw UsageError("--keep does not make sense without --ignore-environment");
|
||||
auto env = getEnv();
|
||||
|
||||
for (const auto & var : unset)
|
||||
unsetenv(var.c_str());
|
||||
}
|
||||
if (ignoreEnvironment)
|
||||
std::erase_if(env, [&](const auto & var) { return !keepVars.contains(var.first); });
|
||||
|
||||
if (!setVars.empty())
|
||||
for (const auto & [name, value] : setVars)
|
||||
env[name] = value;
|
||||
|
||||
if (!unsetVars.empty())
|
||||
std::erase_if(env, [&](const auto & var) { return unsetVars.contains(var.first); });
|
||||
|
||||
replaceEnv(env);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace nix {
|
|||
|
||||
extern std::string programPath;
|
||||
|
||||
extern char * * savedArgv;
|
||||
extern char ** savedArgv;
|
||||
|
||||
class EvalState;
|
||||
struct Pos;
|
||||
|
@ -24,7 +24,8 @@ static constexpr Command::Category catSecondary = 100;
|
|||
static constexpr Command::Category catUtility = 101;
|
||||
static constexpr Command::Category catNixInstallation = 102;
|
||||
|
||||
static constexpr auto installablesCategory = "Options that change the interpretation of [installables](@docroot@/command-ref/new-cli/nix.md#installables)";
|
||||
static constexpr auto installablesCategory =
|
||||
"Options that change the interpretation of [installables](@docroot@/command-ref/new-cli/nix.md#installables)";
|
||||
|
||||
struct NixMultiCommand : MultiCommand, virtual Command
|
||||
{
|
||||
|
@ -112,7 +113,9 @@ struct MixFlakeOptions : virtual Args, EvalCommand
|
|||
* arguments) so that the completions for these flags can use them.
|
||||
*/
|
||||
virtual std::vector<FlakeRef> getFlakeRefsForCompletion()
|
||||
{ return {}; }
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
struct SourceExprCommand : virtual Args, MixFlakeOptions
|
||||
|
@ -122,11 +125,9 @@ struct SourceExprCommand : virtual Args, MixFlakeOptions
|
|||
|
||||
SourceExprCommand();
|
||||
|
||||
Installables parseInstallables(
|
||||
ref<Store> store, std::vector<std::string> ss);
|
||||
Installables parseInstallables(ref<Store> store, std::vector<std::string> ss);
|
||||
|
||||
ref<Installable> parseInstallable(
|
||||
ref<Store> store, const std::string & installable);
|
||||
ref<Installable> parseInstallable(ref<Store> store, const std::string & installable);
|
||||
|
||||
virtual Strings getDefaultFlakeAttrPaths();
|
||||
|
||||
|
@ -272,10 +273,10 @@ struct RegisterCommand
|
|||
typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
|
||||
static Commands * commands;
|
||||
|
||||
RegisterCommand(std::vector<std::string> && name,
|
||||
std::function<ref<Command>()> command)
|
||||
RegisterCommand(std::vector<std::string> && name, std::function<ref<Command>()> command)
|
||||
{
|
||||
if (!commands) commands = new Commands;
|
||||
if (!commands)
|
||||
commands = new Commands;
|
||||
commands->emplace(name, command);
|
||||
}
|
||||
|
||||
|
@ -285,13 +286,13 @@ struct RegisterCommand
|
|||
template<class T>
|
||||
static RegisterCommand registerCommand(const std::string & name)
|
||||
{
|
||||
return RegisterCommand({name}, [](){ return make_ref<T>(); });
|
||||
return RegisterCommand({name}, []() { return make_ref<T>(); });
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
||||
{
|
||||
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
||||
return RegisterCommand(std::move(name), []() { return make_ref<T>(); });
|
||||
}
|
||||
|
||||
struct MixProfile : virtual StoreCommand
|
||||
|
@ -313,19 +314,21 @@ struct MixDefaultProfile : MixProfile
|
|||
MixDefaultProfile();
|
||||
};
|
||||
|
||||
struct MixEnvironment : virtual Args {
|
||||
struct MixEnvironment : virtual Args
|
||||
{
|
||||
|
||||
StringSet keep, unset;
|
||||
Strings stringsEnv;
|
||||
std::vector<char*> vectorEnv;
|
||||
StringSet keepVars;
|
||||
StringSet unsetVars;
|
||||
std::map<std::string, std::string> setVars;
|
||||
bool ignoreEnvironment;
|
||||
|
||||
MixEnvironment();
|
||||
|
||||
/***
|
||||
* Modify global environ based on `ignoreEnvironment`, `keep`, and
|
||||
* `unset`. It's expected that exec will be called before this class
|
||||
* goes out of scope, otherwise `environ` will become invalid.
|
||||
* Modify global environ based on `ignoreEnvironment`, `keep`,
|
||||
* `unset`, and `added`. It's expected that exec will be called
|
||||
* before this class goes out of scope, otherwise `environ` will
|
||||
* become invalid.
|
||||
*/
|
||||
void setEnviron();
|
||||
};
|
||||
|
@ -349,9 +352,6 @@ void completeFlakeRefWithFragment(
|
|||
std::string showVersions(const std::set<std::string> & versions);
|
||||
|
||||
void printClosureDiff(
|
||||
ref<Store> store,
|
||||
const StorePath & beforePath,
|
||||
const StorePath & afterPath,
|
||||
std::string_view indent);
|
||||
ref<Store> store, const StorePath & beforePath, const StorePath & afterPath, std::string_view indent);
|
||||
|
||||
}
|
||||
|
|
1
src/libexpr-test-support/.version
Symbolic link
1
src/libexpr-test-support/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/libexpr-test-support/build-utils-meson
Symbolic link
1
src/libexpr-test-support/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson
|
|
@ -22,9 +22,9 @@ mkMesonLibrary (finalAttrs: {
|
|||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions [
|
||||
../../../build-utils-meson
|
||||
../../build-utils-meson
|
||||
./build-utils-meson
|
||||
../../../.version
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
|
@ -43,7 +43,7 @@ mkMesonLibrary (finalAttrs: {
|
|||
# Do the meson utils, without modification.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${version} > ../../../.version
|
||||
echo ${version} > ../../.version
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
1
src/libexpr-tests/.version
Symbolic link
1
src/libexpr-tests/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/libexpr-tests/build-utils-meson
Symbolic link
1
src/libexpr-tests/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson
|
|
@ -20,9 +20,9 @@ libexpr-tests_SOURCES := \
|
|||
$(wildcard $(d)/flake/*.cc)
|
||||
|
||||
libexpr-tests_EXTRA_INCLUDES = \
|
||||
-I tests/unit/libexpr-support \
|
||||
-I tests/unit/libstore-support \
|
||||
-I tests/unit/libutil-support \
|
||||
-I src/libexpr-test-support \
|
||||
-I src/libstore-test-support \
|
||||
-I src/libutil-test-support \
|
||||
$(INCLUDE_libexpr) \
|
||||
$(INCLUDE_libexprc) \
|
||||
$(INCLUDE_libfetchers) \
|
|
@ -27,9 +27,9 @@ mkMesonExecutable (finalAttrs: {
|
|||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions [
|
||||
../../../build-utils-meson
|
||||
../../build-utils-meson
|
||||
./build-utils-meson
|
||||
../../../.version
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
|
@ -50,7 +50,7 @@ mkMesonExecutable (finalAttrs: {
|
|||
# Do the meson utils, without modification.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${version} > ../../../.version
|
||||
echo ${version} > ../../.version
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
1
src/libfetchers-tests/.version
Symbolic link
1
src/libfetchers-tests/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/libfetchers-tests/build-utils-meson
Symbolic link
1
src/libfetchers-tests/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson
|
|
@ -17,8 +17,8 @@ endif
|
|||
libfetchers-tests_SOURCES := $(wildcard $(d)/*.cc)
|
||||
|
||||
libfetchers-tests_EXTRA_INCLUDES = \
|
||||
-I tests/unit/libstore-support \
|
||||
-I tests/unit/libutil-support \
|
||||
-I src/libstore-test-support \
|
||||
-I src/libutil-test-support \
|
||||
$(INCLUDE_libfetchers) \
|
||||
$(INCLUDE_libstore) \
|
||||
$(INCLUDE_libutil)
|
|
@ -26,9 +26,9 @@ mkMesonExecutable (finalAttrs: {
|
|||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions [
|
||||
../../../build-utils-meson
|
||||
../../build-utils-meson
|
||||
./build-utils-meson
|
||||
../../../.version
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
|
@ -48,7 +48,7 @@ mkMesonExecutable (finalAttrs: {
|
|||
# Do the meson utils, without modification.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${version} > ../../../.version
|
||||
echo ${version} > ../../.version
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
|
@ -157,7 +157,11 @@ struct PathInputScheme : InputScheme
|
|||
});
|
||||
storePath = store->addToStoreFromDump(*src, "source");
|
||||
}
|
||||
input.attrs.insert_or_assign("lastModified", uint64_t(mtime));
|
||||
|
||||
/* Trust the lastModified value supplied by the user, if
|
||||
any. It's not a "secure" attribute so we don't care. */
|
||||
if (!input.getLastModified())
|
||||
input.attrs.insert_or_assign("lastModified", uint64_t(mtime));
|
||||
|
||||
return {makeStorePathAccessor(store, *storePath), std::move(input)};
|
||||
}
|
||||
|
|
1
src/libflake-tests/.version
Symbolic link
1
src/libflake-tests/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/libflake-tests/build-utils-meson
Symbolic link
1
src/libflake-tests/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson
|
|
@ -20,9 +20,9 @@ libflake-tests_SOURCES := \
|
|||
$(wildcard $(d)/flake/*.cc)
|
||||
|
||||
libflake-tests_EXTRA_INCLUDES = \
|
||||
-I tests/unit/libflake-support \
|
||||
-I tests/unit/libstore-support \
|
||||
-I tests/unit/libutil-support \
|
||||
-I src/libflake-test-support \
|
||||
-I src/libstore-test-support \
|
||||
-I src/libutil-test-support \
|
||||
$(INCLUDE_libflake) \
|
||||
$(INCLUDE_libexpr) \
|
||||
$(INCLUDE_libfetchers) \
|
|
@ -26,9 +26,9 @@ mkMesonExecutable (finalAttrs: {
|
|||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions [
|
||||
../../../build-utils-meson
|
||||
../../build-utils-meson
|
||||
./build-utils-meson
|
||||
../../../.version
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
|
@ -48,7 +48,7 @@ mkMesonExecutable (finalAttrs: {
|
|||
# Do the meson utils, without modification.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${version} > ../../../.version
|
||||
echo ${version} > ../../.version
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
1
src/libstore-test-support/.version
Symbolic link
1
src/libstore-test-support/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/libstore-test-support/build-utils-meson
Symbolic link
1
src/libstore-test-support/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson
|
|
@ -22,9 +22,9 @@ mkMesonLibrary (finalAttrs: {
|
|||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions [
|
||||
../../../build-utils-meson
|
||||
../../build-utils-meson
|
||||
./build-utils-meson
|
||||
../../../.version
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
|
@ -43,7 +43,7 @@ mkMesonLibrary (finalAttrs: {
|
|||
# Do the meson utils, without modification.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${version} > ../../../.version
|
||||
echo ${version} > ../../.version
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
1
src/libstore-tests/.version
Symbolic link
1
src/libstore-tests/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/libstore-tests/build-utils-meson
Symbolic link
1
src/libstore-tests/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson
|
|
@ -0,0 +1 @@
|
|||
../../../../tests/functional/derivation/advanced-attributes-defaults.drv
|
|
@ -0,0 +1 @@
|
|||
../../../../tests/functional/derivation/advanced-attributes-structured-attrs-defaults.drv
|
|
@ -0,0 +1 @@
|
|||
../../../../tests/functional/derivation/advanced-attributes-structured-attrs.drv
|
1
src/libstore-tests/data/derivation/advanced-attributes.drv
Symbolic link
1
src/libstore-tests/data/derivation/advanced-attributes.drv
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../../tests/functional/derivation/advanced-attributes.drv
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue