aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--src/libexpr/flake/config.cc2
-rw-r--r--src/libexpr/tests/local.mk2
-rw-r--r--src/libfetchers/github.cc10
-rw-r--r--src/nix-build/nix-build.cc4
-rw-r--r--src/nix-env/nix-env.cc2
-rw-r--r--src/nix-store/nix-store.cc2
-rw-r--r--src/nix/develop.cc23
-rw-r--r--src/nix/develop.md4
-rw-r--r--src/nix/flake.md7
-rw-r--r--src/nix/main.cc4
11 files changed, 39 insertions, 23 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d01ef4768..aae5b93e0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -100,7 +100,7 @@ jobs:
- run: docker tag nix:$NIX_VERSION nixos/nix:$NIX_VERSION
- run: docker tag nix:$NIX_VERSION nixos/nix:master
- name: Login to Docker Hub
- uses: docker/login-action@v1
+ uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
diff --git a/src/libexpr/flake/config.cc b/src/libexpr/flake/config.cc
index 92ec27046..3e9d264b4 100644
--- a/src/libexpr/flake/config.cc
+++ b/src/libexpr/flake/config.cc
@@ -31,7 +31,7 @@ static void writeTrustedList(const TrustedList & trustedList)
void ConfigFile::apply()
{
- std::set<std::string> whitelist{"bash-prompt", "bash-prompt-suffix", "flake-registry"};
+ std::set<std::string> whitelist{"bash-prompt", "bash-prompt-prefix", "bash-prompt-suffix", "flake-registry"};
for (auto & [name, value] : settings) {
diff --git a/src/libexpr/tests/local.mk b/src/libexpr/tests/local.mk
index cb1c4a977..b95980cab 100644
--- a/src/libexpr/tests/local.mk
+++ b/src/libexpr/tests/local.mk
@@ -10,6 +10,6 @@ libexpr-tests_SOURCES := $(wildcard $(d)/*.cc)
libexpr-tests_CXXFLAGS += -I src/libexpr -I src/libutil -I src/libstore -I src/libexpr/tests
-libexpr-tests_LIBS = libexpr libutil libstore
+libexpr-tests_LIBS = libexpr libutil libstore libfetchers
libexpr-tests_LDFLAGS := $(GTEST_LIBS) -lgmock
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc
index a1084c984..0631fb6e8 100644
--- a/src/libfetchers/github.cc
+++ b/src/libfetchers/github.cc
@@ -243,7 +243,10 @@ struct GitHubInputScheme : GitArchiveInputScheme
Hash getRevFromRef(nix::ref<Store> store, const Input & input) const override
{
auto host = maybeGetStrAttr(input.attrs, "host").value_or("github.com");
- auto url = fmt("https://api.%s/repos/%s/%s/commits/%s", // FIXME: check
+ auto url = fmt(
+ host == "github.com"
+ ? "https://api.%s/repos/%s/%s/commits/%s"
+ : "https://%s/api/v3/repos/%s/%s/commits/%s",
host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"), *input.getRef());
Headers headers = makeHeadersWithAuthTokens(host);
@@ -262,7 +265,10 @@ struct GitHubInputScheme : GitArchiveInputScheme
// FIXME: use regular /archive URLs instead? api.github.com
// might have stricter rate limits.
auto host = maybeGetStrAttr(input.attrs, "host").value_or("github.com");
- auto url = fmt("https://api.%s/repos/%s/%s/tarball/%s", // FIXME: check if this is correct for self hosted instances
+ auto url = fmt(
+ host == "github.com"
+ ? "https://api.%s/repos/%s/%s/tarball/%s"
+ : "https://%s/api/v3/repos/%s/%s/tarball/%s",
host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"),
input.getRev()->to_string(Base16, false));
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 519855ea3..426f23905 100644
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -543,8 +543,6 @@ static void main_nix_build(int argc, char * * argv)
restoreProcessContext();
- logger->stop();
-
execvp(shell->c_str(), argPtrs.data());
throw SysError("executing shell '%s'", *shell);
@@ -603,8 +601,6 @@ static void main_nix_build(int argc, char * * argv)
outPaths.push_back(outputPath);
}
- logger->stop();
-
for (auto & path : outPaths)
std::cout << store->printStorePath(path) << '\n';
}
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 96f3c3b26..c412bb814 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -1489,8 +1489,6 @@ static int main_nix_env(int argc, char * * argv)
globals.state->printStats();
- logger->stop();
-
return 0;
}
}
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 153b84137..9163eefd0 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -1095,8 +1095,6 @@ static int main_nix_store(int argc, char * * argv)
op(opFlags, opArgs);
- logger->stop();
-
return 0;
}
}
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index 1190b8348..2a3fc0213 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -18,6 +18,9 @@ struct DevelopSettings : Config
Setting<std::string> bashPrompt{this, "", "bash-prompt",
"The bash prompt (`PS1`) in `nix develop` shells."};
+ Setting<std::string> bashPromptPrefix{this, "", "bash-prompt-prefix",
+ "Prefix prepended to the `PS1` environment variable in `nix develop` shells."};
+
Setting<std::string> bashPromptSuffix{this, "", "bash-prompt-suffix",
"Suffix appended to the `PS1` environment variable in `nix develop` shells."};
};
@@ -482,6 +485,9 @@ struct CmdDevelop : Common, MixEnvironment
if (developSettings.bashPrompt != "")
script += fmt("[ -n \"$PS1\" ] && PS1=%s;\n",
shellEscape(developSettings.bashPrompt.get()));
+ if (developSettings.bashPromptPrefix != "")
+ script += fmt("[ -n \"$PS1\" ] && PS1=%s\"$PS1\";\n",
+ shellEscape(developSettings.bashPromptPrefix.get()));
if (developSettings.bashPromptSuffix != "")
script += fmt("[ -n \"$PS1\" ] && PS1+=%s;\n",
shellEscape(developSettings.bashPromptSuffix.get()));
@@ -512,9 +518,20 @@ struct CmdDevelop : Common, MixEnvironment
Strings{"legacyPackages." + settings.thisSystem.get() + "."},
nixpkgsLockFlags);
- shell = store->printStorePath(
- Installable::toStorePath(getEvalStore(), store, Realise::Outputs, OperateOn::Output, bashInstallable))
- + "/bin/bash";
+ bool found = false;
+
+ for (auto & path : Installable::toStorePaths(getEvalStore(), store, Realise::Outputs, OperateOn::Output, {bashInstallable})) {
+ auto s = store->printStorePath(path) + "/bin/bash";
+ if (pathExists(s)) {
+ shell = s;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ throw Error("package 'nixpkgs#bashInteractive' does not provide a 'bin/bash'");
+
} catch (Error &) {
ignoreException();
}
diff --git a/src/nix/develop.md b/src/nix/develop.md
index 8bcff66c9..e036ec6b9 100644
--- a/src/nix/develop.md
+++ b/src/nix/develop.md
@@ -80,8 +80,8 @@ initialised by `stdenv` and exits. This build environment can be
recorded into a profile using `--profile`.
The prompt used by the `bash` shell can be customised by setting the
-`bash-prompt` and `bash-prompt-suffix` settings in `nix.conf` or in
-the flake's `nixConfig` attribute.
+`bash-prompt`, `bash-prompt-prefix`, and `bash-prompt-suffix` settings in
+`nix.conf` or in the flake's `nixConfig` attribute.
# Flake output attributes
diff --git a/src/nix/flake.md b/src/nix/flake.md
index c8251eb74..aa3f9f303 100644
--- a/src/nix/flake.md
+++ b/src/nix/flake.md
@@ -331,9 +331,10 @@ The following attributes are supported in `flake.nix`:
* `nixConfig`: a set of `nix.conf` options to be set when evaluating any
part of a flake. In the interests of security, only a small set of
- whitelisted options (currently `bash-prompt`, `bash-prompt-suffix`,
- and `flake-registry`) are allowed to be set without confirmation so long as
- `accept-flake-config` is not set in the global configuration.
+ whitelisted options (currently `bash-prompt`, `bash-prompt-prefix`,
+ `bash-prompt-suffix`, and `flake-registry`) are allowed to be set without
+ confirmation so long as `accept-flake-config` is not set in the global
+ configuration.
## Flake inputs
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 6d0f6ce6e..dadb54306 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -261,6 +261,8 @@ void mainWrapped(int argc, char * * argv)
}
#endif
+ Finally f([] { logger->stop(); });
+
programPath = argv[0];
auto programName = std::string(baseNameOf(programPath));
@@ -279,8 +281,6 @@ void mainWrapped(int argc, char * * argv)
verbosity = lvlInfo;
}
- Finally f([] { logger->stop(); });
-
NixArgs args;
if (argc == 2 && std::string(argv[1]) == "__dump-args") {