mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Merge branch 'master' (pre-reformat)
This commit is contained in:
commit
72e8f7cd35
23 changed files with 202 additions and 131 deletions
50
.github/actions/install-nix-action/action.yaml
vendored
Normal file
50
.github/actions/install-nix-action/action.yaml
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
name: "Install Nix"
|
||||||
|
description: "Helper action for installing Nix with support for dogfooding from master"
|
||||||
|
inputs:
|
||||||
|
dogfood:
|
||||||
|
description: "Whether to use Nix installed from the latest artifact from master branch"
|
||||||
|
required: true # Be explicit about the fact that we are using unreleased artifacts
|
||||||
|
extra_nix_config:
|
||||||
|
description: "Gets appended to `/etc/nix/nix.conf` if passed."
|
||||||
|
install_url:
|
||||||
|
description: "URL of the Nix installer"
|
||||||
|
required: false
|
||||||
|
default: "https://releases.nixos.org/nix/nix-2.30.1/install"
|
||||||
|
github_token:
|
||||||
|
description: "Github token"
|
||||||
|
required: true
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: "Download nix install artifact from master"
|
||||||
|
shell: bash
|
||||||
|
id: download-nix-installer
|
||||||
|
if: ${{ inputs.dogfood }}
|
||||||
|
run: |
|
||||||
|
RUN_ID=$(gh run list --repo "$DOGFOOD_REPO" --workflow ci.yml --branch master --status success --json databaseId --jq ".[0].databaseId")
|
||||||
|
|
||||||
|
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||||
|
INSTALLER_ARTIFACT="installer-linux"
|
||||||
|
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||||
|
INSTALLER_ARTIFACT="installer-darwin"
|
||||||
|
else
|
||||||
|
echo "::error ::Unsupported RUNNER_OS: $RUNNER_OS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
INSTALLER_DOWNLOAD_DIR="$GITHUB_WORKSPACE/$INSTALLER_ARTIFACT"
|
||||||
|
mkdir -p "$INSTALLER_DOWNLOAD_DIR"
|
||||||
|
|
||||||
|
gh run download "$RUN_ID" --repo "$DOGFOOD_REPO" -n "$INSTALLER_ARTIFACT" -D "$INSTALLER_DOWNLOAD_DIR"
|
||||||
|
echo "installer-path=file://$INSTALLER_DOWNLOAD_DIR" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "::notice ::Dogfooding Nix installer from master (https://github.com/$DOGFOOD_REPO/actions/runs/$RUN_ID)"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ inputs.github_token }}
|
||||||
|
DOGFOOD_REPO: "NixOS/nix"
|
||||||
|
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
|
||||||
|
with:
|
||||||
|
# Ternary operator in GHA: https://www.github.com/actions/runner/issues/409#issuecomment-752775072
|
||||||
|
install_url: ${{ inputs.dogfood && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }}
|
||||||
|
install_options: ${{ inputs.dogfood && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }}
|
||||||
|
extra_nix_config: ${{ inputs.extra_nix_config }}
|
||||||
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
|
|
@ -13,10 +13,13 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: cachix/install-nix-action@v31
|
- uses: ./.github/actions/install-nix-action
|
||||||
with:
|
with:
|
||||||
install_url: "https://releases.nixos.org/nix/nix-2.29.1/install"
|
dogfood: true
|
||||||
- run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json
|
extra_nix_config:
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- run: nix flake show --all-systems --json
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -36,9 +39,10 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: cachix/install-nix-action@v31
|
- uses: ./.github/actions/install-nix-action
|
||||||
with:
|
with:
|
||||||
install_url: "https://releases.nixos.org/nix/nix-2.29.1/install"
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
dogfood: true
|
||||||
# The sandbox would otherwise be disabled by default on Darwin
|
# The sandbox would otherwise be disabled by default on Darwin
|
||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
sandbox = true
|
sandbox = true
|
||||||
|
|
@ -178,7 +182,12 @@ jobs:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: DeterminateSystems/nix-installer-action@main
|
- uses: ./.github/actions/install-nix-action
|
||||||
|
with:
|
||||||
|
dogfood: true
|
||||||
|
extra_nix_config:
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- run: |
|
- run: |
|
||||||
nix build -L \
|
nix build -L \
|
||||||
|
|
@ -204,6 +213,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
repository: NixOS/flake-regressions-data
|
repository: NixOS/flake-regressions-data
|
||||||
path: flake-regressions/tests
|
path: flake-regressions/tests
|
||||||
- uses: DeterminateSystems/nix-installer-action@main
|
- uses: ./.github/actions/install-nix-action
|
||||||
|
with:
|
||||||
|
dogfood: true
|
||||||
|
extra_nix_config:
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
|
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ nix = find_program('nix', native : true)
|
||||||
|
|
||||||
mdbook = find_program('mdbook', native : true)
|
mdbook = find_program('mdbook', native : true)
|
||||||
bash = find_program('bash', native : true)
|
bash = find_program('bash', native : true)
|
||||||
|
rsync = find_program('rsync', required: true, native: true)
|
||||||
|
|
||||||
pymod = import('python')
|
pymod = import('python')
|
||||||
python = pymod.find_installation('python3')
|
python = pymod.find_installation('python3')
|
||||||
|
|
@ -84,7 +85,7 @@ manual = custom_target(
|
||||||
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
|
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
|
||||||
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
|
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
|
||||||
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
|
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
|
||||||
rsync -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
@4@ -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
||||||
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
|
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
|
||||||
rm -rf @2@/manual
|
rm -rf @2@/manual
|
||||||
mv @2@/html @2@/manual
|
mv @2@/html @2@/manual
|
||||||
|
|
@ -94,6 +95,7 @@ manual = custom_target(
|
||||||
mdbook.full_path(),
|
mdbook.full_path(),
|
||||||
meson.current_build_dir(),
|
meson.current_build_dir(),
|
||||||
meson.project_version(),
|
meson.project_version(),
|
||||||
|
rsync.full_path(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
input : [
|
input : [
|
||||||
|
|
|
||||||
44
docker.nix
44
docker.nix
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
# Core dependencies
|
# Core dependencies
|
||||||
pkgs,
|
pkgs ? import <nixpkgs> { },
|
||||||
lib,
|
lib ? pkgs.lib,
|
||||||
dockerTools,
|
dockerTools ? pkgs.dockerTools,
|
||||||
runCommand,
|
runCommand ? pkgs.runCommand,
|
||||||
buildPackages,
|
buildPackages ? pkgs.buildPackages,
|
||||||
# Image configuration
|
# Image configuration
|
||||||
name ? "nix",
|
name ? "nix",
|
||||||
tag ? "latest",
|
tag ? "latest",
|
||||||
|
|
@ -28,24 +28,24 @@
|
||||||
},
|
},
|
||||||
Cmd ? [ (lib.getExe bashInteractive) ],
|
Cmd ? [ (lib.getExe bashInteractive) ],
|
||||||
# Default Packages
|
# Default Packages
|
||||||
nix,
|
nix ? pkgs.nix,
|
||||||
bashInteractive,
|
bashInteractive ? pkgs.bashInteractive,
|
||||||
coreutils-full,
|
coreutils-full ? pkgs.coreutils-full,
|
||||||
gnutar,
|
gnutar ? pkgs.gnutar,
|
||||||
gzip,
|
gzip ? pkgs.gzip,
|
||||||
gnugrep,
|
gnugrep ? pkgs.gnugrep,
|
||||||
which,
|
which ? pkgs.which,
|
||||||
curl,
|
curl ? pkgs.curl,
|
||||||
less,
|
less ? pkgs.less,
|
||||||
wget,
|
wget ? pkgs.wget,
|
||||||
man,
|
man ? pkgs.man,
|
||||||
cacert,
|
cacert ? pkgs.cacert,
|
||||||
findutils,
|
findutils ? pkgs.findutils,
|
||||||
iana-etc,
|
iana-etc ? pkgs.iana-etc,
|
||||||
gitMinimal,
|
gitMinimal ? pkgs.gitMinimal,
|
||||||
openssh,
|
openssh ? pkgs.openssh,
|
||||||
# Other dependencies
|
# Other dependencies
|
||||||
shadow,
|
shadow ? pkgs.shadow,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
defaultPkgs = [
|
defaultPkgs = [
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,7 @@
|
||||||
#include "nix/util/error.hh"
|
#include "nix/util/error.hh"
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#define USE_FLAT_SYMBOL_SET (BOOST_VERSION >= 108100)
|
|
||||||
#if USE_FLAT_SYMBOL_SET
|
|
||||||
#include <boost/unordered/unordered_flat_set.hpp>
|
#include <boost/unordered/unordered_flat_set.hpp>
|
||||||
#else
|
|
||||||
# include <boost/unordered/unordered_set.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
@ -214,12 +209,7 @@ private:
|
||||||
* Transparent lookup of string view for a pointer to a ChunkedVector entry -> return offset into the store.
|
* Transparent lookup of string view for a pointer to a ChunkedVector entry -> return offset into the store.
|
||||||
* ChunkedVector references are never invalidated.
|
* ChunkedVector references are never invalidated.
|
||||||
*/
|
*/
|
||||||
#if USE_FLAT_SYMBOL_SET
|
|
||||||
boost::unordered_flat_set<SymbolStr, SymbolStr::Hash, SymbolStr::Equal> symbols{SymbolStr::chunkSize};
|
boost::unordered_flat_set<SymbolStr, SymbolStr::Hash, SymbolStr::Equal> symbols{SymbolStr::chunkSize};
|
||||||
#else
|
|
||||||
using SymbolValueAlloc = std::pmr::polymorphic_allocator<SymbolStr>;
|
|
||||||
boost::unordered_set<SymbolStr, SymbolStr::Hash, SymbolStr::Equal, SymbolValueAlloc> symbols{SymbolStr::chunkSize, {&buffer}};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -230,19 +220,7 @@ public:
|
||||||
// Most symbols are looked up more than once, so we trade off insertion performance
|
// Most symbols are looked up more than once, so we trade off insertion performance
|
||||||
// for lookup performance.
|
// for lookup performance.
|
||||||
// FIXME: make this thread-safe.
|
// FIXME: make this thread-safe.
|
||||||
return [&]<typename T>(T && key) -> Symbol {
|
return Symbol(*symbols.insert(SymbolStr::Key{store, s, stringAlloc}).first);
|
||||||
if constexpr (requires { symbols.insert<T>(key); }) {
|
|
||||||
auto [it, _] = symbols.insert<T>(key);
|
|
||||||
return Symbol(*it);
|
|
||||||
} else {
|
|
||||||
auto it = symbols.find<T>(key);
|
|
||||||
if (it != symbols.end())
|
|
||||||
return Symbol(*it);
|
|
||||||
|
|
||||||
it = symbols.emplace(key).first;
|
|
||||||
return Symbol(*it);
|
|
||||||
}
|
|
||||||
}(SymbolStr::Key{store, s, stringAlloc});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SymbolStr> resolve(const std::vector<Symbol> & symbols) const
|
std::vector<SymbolStr> resolve(const std::vector<Symbol> & symbols) const
|
||||||
|
|
@ -287,5 +265,3 @@ struct std::hash<nix::Symbol>
|
||||||
return std::hash<decltype(s.id)>{}(s.id);
|
return std::hash<decltype(s.id)>{}(s.id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef USE_FLAT_SYMBOL_SET
|
|
||||||
|
|
|
||||||
|
|
@ -545,15 +545,20 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
||||||
append(gitArgs, {"--depth", "1"});
|
append(gitArgs, {"--depth", "1"});
|
||||||
append(gitArgs, {std::string("--"), url, refspec});
|
append(gitArgs, {std::string("--"), url, refspec});
|
||||||
|
|
||||||
runProgram(RunOptions {
|
auto [status, output] = runProgram(RunOptions {
|
||||||
.program = "git",
|
.program = "git",
|
||||||
.lookupPath = true,
|
.lookupPath = true,
|
||||||
// FIXME: git stderr messes up our progress indicator, so
|
// FIXME: git stderr messes up our progress indicator, so
|
||||||
// we're using --quiet for now. Should process its stderr.
|
// we're using --quiet for now. Should process its stderr.
|
||||||
.args = gitArgs,
|
.args = gitArgs,
|
||||||
.input = {},
|
.input = {},
|
||||||
|
.mergeStderrToStdout = true,
|
||||||
.isInteractive = true
|
.isInteractive = true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (status > 0) {
|
||||||
|
throw Error("Failed to fetch git repository %s : %s", url, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void verifyCommit(
|
void verifyCommit(
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,11 @@ struct GitInputScheme : InputScheme
|
||||||
// repo, treat as a remote URI to force a clone.
|
// repo, treat as a remote URI to force a clone.
|
||||||
static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1"; // for testing
|
static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1"; // for testing
|
||||||
auto url = parseURL(getStrAttr(input.attrs, "url"));
|
auto url = parseURL(getStrAttr(input.attrs, "url"));
|
||||||
bool isBareRepository = url.scheme == "file" && !pathExists(url.path + "/.git");
|
|
||||||
|
// Why are we checking for bare repository?
|
||||||
|
// well if it's a bare repository we want to force a git fetch rather than copying the folder
|
||||||
|
bool isBareRepository = url.scheme == "file" && pathExists(url.path) &&
|
||||||
|
!pathExists(url.path + "/.git");
|
||||||
//
|
//
|
||||||
// FIXME: here we turn a possibly relative path into an absolute path.
|
// FIXME: here we turn a possibly relative path into an absolute path.
|
||||||
// This allows relative git flake inputs to be resolved against the
|
// This allows relative git flake inputs to be resolved against the
|
||||||
|
|
@ -462,6 +466,12 @@ struct GitInputScheme : InputScheme
|
||||||
"See https://github.com/NixOS/nix/issues/12281 for details.",
|
"See https://github.com/NixOS/nix/issues/12281 for details.",
|
||||||
url);
|
url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we don't check here for the path existence, then we can give libgit2 any directory
|
||||||
|
// and it will initialize them as git directories.
|
||||||
|
if (!pathExists(url.path)) {
|
||||||
|
throw Error("The path '%s' does not exist.", url.path);
|
||||||
|
}
|
||||||
repoInfo.location = std::filesystem::absolute(url.path);
|
repoInfo.location = std::filesystem::absolute(url.path);
|
||||||
} else {
|
} else {
|
||||||
if (url.scheme == "file")
|
if (url.scheme == "file")
|
||||||
|
|
@ -599,7 +609,7 @@ struct GitInputScheme : InputScheme
|
||||||
? cacheDir / ref
|
? cacheDir / ref
|
||||||
: cacheDir / "refs/heads" / ref;
|
: cacheDir / "refs/heads" / ref;
|
||||||
|
|
||||||
bool doFetch;
|
bool doFetch = false;
|
||||||
time_t now = time(0);
|
time_t now = time(0);
|
||||||
|
|
||||||
/* If a rev was specified, we need to fetch if it's not in the
|
/* If a rev was specified, we need to fetch if it's not in the
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,25 @@ static DownloadTarballResult downloadTarball_(
|
||||||
const Headers & headers,
|
const Headers & headers,
|
||||||
const std::string & displayPrefix)
|
const std::string & displayPrefix)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Some friendly error messages for common mistakes.
|
||||||
|
// Namely lets catch when the url is a local file path, but
|
||||||
|
// it is not in fact a tarball.
|
||||||
|
if (url.rfind("file://", 0) == 0) {
|
||||||
|
// Remove "file://" prefix to get the local file path
|
||||||
|
std::string localPath = url.substr(7);
|
||||||
|
if (!std::filesystem::exists(localPath)) {
|
||||||
|
throw Error("tarball '%s' does not exist.", localPath);
|
||||||
|
}
|
||||||
|
if (std::filesystem::is_directory(localPath)) {
|
||||||
|
if (std::filesystem::exists(localPath + "/.git")) {
|
||||||
|
throw Error(
|
||||||
|
"tarball '%s' is a git repository, not a tarball. Please use `git+file` as the scheme.", localPath);
|
||||||
|
}
|
||||||
|
throw Error("tarball '%s' is a directory, not a file.", localPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Cache::Key cacheKey{"tarball", {{"url", url}}};
|
Cache::Key cacheKey{"tarball", {{"url", url}}};
|
||||||
|
|
||||||
auto cached = settings.getCache()->lookupExpired(cacheKey);
|
auto cached = settings.getCache()->lookupExpired(cacheKey);
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ test(
|
||||||
env : {
|
env : {
|
||||||
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
|
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
|
||||||
'NIX_CONFIG': 'extra-experimental-features = flakes',
|
'NIX_CONFIG': 'extra-experimental-features = flakes',
|
||||||
|
'HOME': meson.current_build_dir() / 'test-home',
|
||||||
},
|
},
|
||||||
protocol : 'gtest',
|
protocol : 'gtest',
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
buildPackages,
|
buildPackages,
|
||||||
stdenv,
|
stdenv,
|
||||||
mkMesonExecutable,
|
mkMesonExecutable,
|
||||||
|
writableTmpDirAsHomeHook,
|
||||||
|
|
||||||
nix-flake,
|
nix-flake,
|
||||||
nix-flake-c,
|
nix-flake-c,
|
||||||
|
|
@ -55,19 +56,14 @@ mkMesonExecutable (finalAttrs: {
|
||||||
runCommand "${finalAttrs.pname}-run"
|
runCommand "${finalAttrs.pname}-run"
|
||||||
{
|
{
|
||||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||||
|
buildInputs = [ writableTmpDirAsHomeHook ];
|
||||||
}
|
}
|
||||||
(
|
(''
|
||||||
lib.optionalString stdenv.hostPlatform.isWindows ''
|
|
||||||
export HOME="$PWD/home-dir"
|
|
||||||
mkdir -p "$HOME"
|
|
||||||
''
|
|
||||||
+ ''
|
|
||||||
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
|
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
|
||||||
export NIX_CONFIG="extra-experimental-features = flakes"
|
export NIX_CONFIG="extra-experimental-features = flakes"
|
||||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||||
touch $out
|
touch $out
|
||||||
''
|
'');
|
||||||
);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ test(
|
||||||
this_exe,
|
this_exe,
|
||||||
env : {
|
env : {
|
||||||
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
|
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
|
||||||
|
'HOME': meson.current_build_dir() / 'test-home',
|
||||||
|
'NIX_REMOTE': meson.current_build_dir() / 'test-home' / 'store',
|
||||||
},
|
},
|
||||||
protocol : 'gtest',
|
protocol : 'gtest',
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,6 @@ TEST_F(nix_api_store_test, nix_store_get_uri)
|
||||||
|
|
||||||
TEST_F(nix_api_util_context, nix_store_get_storedir_default)
|
TEST_F(nix_api_util_context, nix_store_get_storedir_default)
|
||||||
{
|
{
|
||||||
if (nix::getEnv("HOME").value_or("") == "/homeless-shelter") {
|
|
||||||
// skipping test in sandbox because nix_store_open tries to create /nix/var/nix/profiles
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
nix_libstore_init(ctx);
|
nix_libstore_init(ctx);
|
||||||
Store * store = nix_store_open(ctx, nullptr, nullptr);
|
Store * store = nix_store_open(ctx, nullptr, nullptr);
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
|
|
@ -141,10 +137,6 @@ TEST_F(nix_api_store_test, nix_store_real_path)
|
||||||
|
|
||||||
TEST_F(nix_api_util_context, nix_store_real_path_relocated)
|
TEST_F(nix_api_util_context, nix_store_real_path_relocated)
|
||||||
{
|
{
|
||||||
if (nix::getEnv("HOME").value_or("") == "/homeless-shelter") {
|
|
||||||
// Can't open default store from within sandbox
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
auto tmp = nix::createTempDir();
|
auto tmp = nix::createTempDir();
|
||||||
std::string storeRoot = tmp + "/store";
|
std::string storeRoot = tmp + "/store";
|
||||||
std::string stateDir = tmp + "/state";
|
std::string stateDir = tmp + "/state";
|
||||||
|
|
@ -184,13 +176,7 @@ TEST_F(nix_api_util_context, nix_store_real_path_relocated)
|
||||||
|
|
||||||
TEST_F(nix_api_util_context, nix_store_real_path_binary_cache)
|
TEST_F(nix_api_util_context, nix_store_real_path_binary_cache)
|
||||||
{
|
{
|
||||||
if (nix::getEnv("HOME").value_or("") == "/homeless-shelter") {
|
Store * store = nix_store_open(ctx, nix::fmt("file://%s/binary-cache", nix::createTempDir()).c_str(), nullptr);
|
||||||
// TODO: override NIX_CACHE_HOME?
|
|
||||||
// skipping test in sandbox because narinfo cache can't be written
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
|
|
||||||
Store * store = nix_store_open(ctx, "https://cache.nixos.org", nullptr);
|
|
||||||
assert_ctx_ok();
|
assert_ctx_ok();
|
||||||
ASSERT_NE(store, nullptr);
|
ASSERT_NE(store, nullptr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
buildPackages,
|
buildPackages,
|
||||||
stdenv,
|
stdenv,
|
||||||
mkMesonExecutable,
|
mkMesonExecutable,
|
||||||
|
writableTmpDirAsHomeHook,
|
||||||
|
|
||||||
nix-store,
|
nix-store,
|
||||||
nix-store-c,
|
nix-store-c,
|
||||||
|
|
@ -72,18 +73,14 @@ mkMesonExecutable (finalAttrs: {
|
||||||
runCommand "${finalAttrs.pname}-run"
|
runCommand "${finalAttrs.pname}-run"
|
||||||
{
|
{
|
||||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||||
|
buildInputs = [ writableTmpDirAsHomeHook ];
|
||||||
}
|
}
|
||||||
(
|
(''
|
||||||
lib.optionalString stdenv.hostPlatform.isWindows ''
|
|
||||||
export HOME="$PWD/home-dir"
|
|
||||||
mkdir -p "$HOME"
|
|
||||||
''
|
|
||||||
+ ''
|
|
||||||
export _NIX_TEST_UNIT_DATA=${data + "/src/libstore-tests/data"}
|
export _NIX_TEST_UNIT_DATA=${data + "/src/libstore-tests/data"}
|
||||||
|
export NIX_REMOTE=$HOME/store
|
||||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||||
touch $out
|
touch $out
|
||||||
''
|
'');
|
||||||
);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ struct LocalBinaryCacheStore :
|
||||||
, BinaryCacheStore{*config}
|
, BinaryCacheStore{*config}
|
||||||
, config{config}
|
, config{config}
|
||||||
{
|
{
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
|
|
@ -126,10 +125,12 @@ StringSet LocalBinaryCacheStoreConfig::uriSchemes()
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<Store> LocalBinaryCacheStoreConfig::openStore() const {
|
ref<Store> LocalBinaryCacheStoreConfig::openStore() const {
|
||||||
return make_ref<LocalBinaryCacheStore>(ref{
|
auto store = make_ref<LocalBinaryCacheStore>(ref{
|
||||||
// FIXME we shouldn't actually need a mutable config
|
// FIXME we shouldn't actually need a mutable config
|
||||||
std::const_pointer_cast<LocalBinaryCacheStore::Config>(shared_from_this())
|
std::const_pointer_cast<LocalBinaryCacheStore::Config>(shared_from_this())
|
||||||
});
|
});
|
||||||
|
store->init();
|
||||||
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterStoreImplementation<LocalBinaryCacheStore::Config> regLocalBinaryCacheStore;
|
static RegisterStoreImplementation<LocalBinaryCacheStore::Config> regLocalBinaryCacheStore;
|
||||||
|
|
|
||||||
|
|
@ -289,8 +289,6 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStore
|
||||||
, s3Helper(config->profile, config->region, config->scheme, config->endpoint)
|
, s3Helper(config->profile, config->region, config->scheme, config->endpoint)
|
||||||
{
|
{
|
||||||
diskCache = getNarInfoDiskCache();
|
diskCache = getNarInfoDiskCache();
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getUri() override
|
std::string getUri() override
|
||||||
|
|
@ -597,10 +595,12 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStore
|
||||||
|
|
||||||
ref<Store> S3BinaryCacheStoreImpl::Config::openStore() const
|
ref<Store> S3BinaryCacheStoreImpl::Config::openStore() const
|
||||||
{
|
{
|
||||||
return make_ref<S3BinaryCacheStoreImpl>(ref{
|
auto store = make_ref<S3BinaryCacheStoreImpl>(ref{
|
||||||
// FIXME we shouldn't actually need a mutable config
|
// FIXME we shouldn't actually need a mutable config
|
||||||
std::const_pointer_cast<S3BinaryCacheStore::Config>(shared_from_this())
|
std::const_pointer_cast<S3BinaryCacheStore::Config>(shared_from_this())
|
||||||
});
|
});
|
||||||
|
store->init();
|
||||||
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterStoreImplementation<S3BinaryCacheStoreImpl::Config> regS3BinaryCacheStore;
|
static RegisterStoreImplementation<S3BinaryCacheStoreImpl::Config> regS3BinaryCacheStore;
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning)
|
||||||
if (now > nextWarning) {
|
if (now > nextWarning) {
|
||||||
nextWarning = now + 10;
|
nextWarning = now + 10;
|
||||||
logWarning({
|
logWarning({
|
||||||
.msg = HintFmt(e.what())
|
.msg = e.info().msg
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ boost = dependency(
|
||||||
'boost',
|
'boost',
|
||||||
modules : ['context', 'coroutine', 'iostreams'],
|
modules : ['context', 'coroutine', 'iostreams'],
|
||||||
include_type: 'system',
|
include_type: 'system',
|
||||||
|
version: '>=1.82.0'
|
||||||
)
|
)
|
||||||
# boost is a public dependency, but not a pkg-config dependency unfortunately, so we
|
# boost is a public dependency, but not a pkg-config dependency unfortunately, so we
|
||||||
# put in `deps_other`.
|
# put in `deps_other`.
|
||||||
|
|
|
||||||
|
|
@ -194,10 +194,6 @@ size_t StringSource::read(char * data, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if BOOST_VERSION >= 106300 && BOOST_VERSION < 106600
|
|
||||||
#error Coroutines are broken in this version of Boost!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
|
std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
|
||||||
{
|
{
|
||||||
struct SourceToSink : FinishSink
|
struct SourceToSink : FinishSink
|
||||||
|
|
|
||||||
|
|
@ -190,8 +190,10 @@ void ignoreExceptionInDestructor(Verbosity lvl)
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
|
} catch (Error & e) {
|
||||||
|
printMsg(lvl, ANSI_RED "error (ignored):" ANSI_NORMAL " %s", e.info().msg);
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
printMsg(lvl, "error (ignored): %1%", e.what());
|
printMsg(lvl, ANSI_RED "error (ignored):" ANSI_NORMAL " %s", e.what());
|
||||||
}
|
}
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
|
|
@ -202,8 +204,10 @@ void ignoreExceptionExceptInterrupt(Verbosity lvl)
|
||||||
throw;
|
throw;
|
||||||
} catch (const Interrupted & e) {
|
} catch (const Interrupted & e) {
|
||||||
throw;
|
throw;
|
||||||
|
} catch (Error & e) {
|
||||||
|
printMsg(lvl, ANSI_RED "error (ignored):" ANSI_NORMAL " %s", e.info().msg);
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
printMsg(lvl, "error (ignored): %1%", e.what());
|
printMsg(lvl, ANSI_RED "error (ignored):" ANSI_NORMAL " %s", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#include "nix/util/windows-async-pipe.hh"
|
|
||||||
#include "nix/util/windows-error.hh"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
# include "nix/util/windows-async-pipe.hh"
|
||||||
|
# include "nix/util/windows-error.hh"
|
||||||
|
|
||||||
namespace nix::windows {
|
namespace nix::windows {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#include "nix/util/windows-error.hh"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include "nix/util/windows-error.hh"
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,14 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
|
||||||
lowdown. */
|
lowdown. */
|
||||||
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
||||||
{
|
{
|
||||||
|
// Check for aliases if subcommand has exactly one element
|
||||||
|
if (subcommand.size() == 1) {
|
||||||
|
auto alias = toplevel.aliases.find(subcommand[0]);
|
||||||
|
if (alias != toplevel.aliases.end()) {
|
||||||
|
subcommand = alias->second.replacement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
||||||
|
|
||||||
evalSettings.restrictEval = false;
|
evalSettings.restrictEval = false;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,27 @@ rm -rf $TEST_HOME/.cache/nix
|
||||||
path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
||||||
[[ $(cat $path/hello) = world ]]
|
[[ $(cat $path/hello) = world ]]
|
||||||
|
|
||||||
|
# Fetch again. This should be cached.
|
||||||
|
# NOTE: This has to be done before the test case below which tries to pack-refs
|
||||||
|
# the reason being that the lookup on the cache uses the ref-file `/refs/heads/master`
|
||||||
|
# which does not exist after packing.
|
||||||
|
mv $repo ${repo}-tmp
|
||||||
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
||||||
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
|
[[ $(nix eval --impure --expr "(builtins.fetchGit file://$repo).revCount") = 2 ]]
|
||||||
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).rev") = $rev2 ]]
|
||||||
|
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).shortRev") = ${rev2:0:7} ]]
|
||||||
|
|
||||||
|
# Fetching with a explicit hash should succeed.
|
||||||
|
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
||||||
|
[[ $path = $path2 ]]
|
||||||
|
|
||||||
|
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev1\"; }).outPath")
|
||||||
|
[[ $(cat $path2/hello) = utrecht ]]
|
||||||
|
|
||||||
|
mv ${repo}-tmp $repo
|
||||||
|
|
||||||
# Fetch when the cache has packed-refs
|
# Fetch when the cache has packed-refs
|
||||||
# Regression test of #8822
|
# Regression test of #8822
|
||||||
git -C $TEST_HOME/.cache/nix/gitv3/*/ pack-refs --all
|
git -C $TEST_HOME/.cache/nix/gitv3/*/ pack-refs --all
|
||||||
|
|
@ -83,24 +104,6 @@ path2=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"
|
||||||
# But without a hash, it fails.
|
# But without a hash, it fails.
|
||||||
expectStderr 1 nix eval --expr 'builtins.fetchGit "file:///foo"' | grepQuiet "'fetchGit' doesn't fetch unlocked input"
|
expectStderr 1 nix eval --expr 'builtins.fetchGit "file:///foo"' | grepQuiet "'fetchGit' doesn't fetch unlocked input"
|
||||||
|
|
||||||
# Fetch again. This should be cached.
|
|
||||||
mv $repo ${repo}-tmp
|
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
|
||||||
[[ $path = $path2 ]]
|
|
||||||
|
|
||||||
[[ $(nix eval --impure --expr "(builtins.fetchGit file://$repo).revCount") = 2 ]]
|
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).rev") = $rev2 ]]
|
|
||||||
[[ $(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).shortRev") = ${rev2:0:7} ]]
|
|
||||||
|
|
||||||
# Fetching with a explicit hash should succeed.
|
|
||||||
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev2\"; }).outPath")
|
|
||||||
[[ $path = $path2 ]]
|
|
||||||
|
|
||||||
path2=$(nix eval --refresh --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev1\"; }).outPath")
|
|
||||||
[[ $(cat $path2/hello) = utrecht ]]
|
|
||||||
|
|
||||||
mv ${repo}-tmp $repo
|
|
||||||
|
|
||||||
# Using a clean working tree should produce the same result.
|
# Using a clean working tree should produce the same result.
|
||||||
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit $repo).outPath")
|
path2=$(nix eval --impure --raw --expr "(builtins.fetchGit $repo).outPath")
|
||||||
[[ $path = $path2 ]]
|
[[ $path = $path2 ]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue