Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64a2f038b1 |
@@ -16,10 +16,6 @@ Checks:
|
||||
- -bugprone-unchecked-optional-access
|
||||
# many warnings, seems like a questionable lint
|
||||
- -bugprone-branch-clone
|
||||
# extremely noisy before clang 19: https://github.com/llvm/llvm-project/issues/93959
|
||||
- -bugprone-multi-level-implicit-pointer-conversion
|
||||
# we don't compile out our asserts
|
||||
- -bugprone-assert-side-effect
|
||||
# all thrown exceptions must derive from std::exception
|
||||
- hicpp-exception-baseclass
|
||||
# capturing async lambdas are dangerous
|
||||
@@ -37,4 +33,3 @@ Checks:
|
||||
|
||||
CheckOptions:
|
||||
bugprone-reserved-identifier.AllowedIdentifiers: '__asan_default_options'
|
||||
bugprone-unused-return-value.AllowCastToVoid: true
|
||||
|
||||
@@ -17,13 +17,10 @@ For systems that **already have a Nix implementation installed**, such as NixOS
|
||||
|
||||
## Building And Developing
|
||||
|
||||
See our [Hacking guide](https://git.lix.systems/lix-project/lix/src/branch/main/doc/manual/src/contributing/hacking.md) in our manual for instruction on how to set up a development environment and build Lix from source.
|
||||
See our [Hacking guide](https://git.lix.systems/lix-project/lix/src/branch/main/doc/manual/src/contributing/hacking.md) in our manual for instruction on how to to set up a development environment and build Lix from source.
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- The Lix reference manual:
|
||||
- [Stable](https://docs.lix.systems/manual/lix/stable/)
|
||||
- [Nightly](https://docs.lix.systems/manual/lix/nightly/) (NOTE: [not automatically updated, yet](https://git.lix.systems/lix-project/lix/issues/742))
|
||||
- [Our wiki](https://wiki.lix.systems)
|
||||
- [Matrix - #space:lix.systems](https://matrix.to/#/#space:lix.systems)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
bench-*.json
|
||||
bench-*.md
|
||||
perf-*.json
|
||||
nixpkgs
|
||||
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p python3 -p hyperfine -p "if stdenv.isLinux then linuxPackages.perf else null"
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import os
|
||||
import json
|
||||
import tempfile
|
||||
import platform
|
||||
|
||||
flake_args = ["--extra-experimental-features","'nix-command flakes'"]
|
||||
# hyperfine has its own variable substitution, so we use that and pass build="{BUILD}" here.
|
||||
# perf doesn't have variable substitution, so we call these with build being the actual build directory.
|
||||
cases = {
|
||||
"search": lambda build: [f"{build}/bin/nix", *flake_args, "search", "--no-eval-cache", "github:nixos/nixpkgs/e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870", "hello"],
|
||||
"rebuild": lambda build: [f"{build}/bin/nix", *flake_args, "eval", "--raw", "--impure", "--expr", "'with import <nixpkgs/nixos> {}; system'"],
|
||||
"rebuild_lh": lambda build: ["GC_INITIAL_HEAP_SIZE=10g", f"{build}/bin/nix", *flake_args, "eval", "--raw", "--impure", "--expr", "'with import <nixpkgs/nixos> {}; system'"],
|
||||
"parse": lambda build: [f"{build}/bin/nix", *flake_args, "eval", "-f", "bench/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix"],
|
||||
}
|
||||
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
# FIXME(jade, gilice): it is a reasonable use case to want to run a benchmark run
|
||||
# on just one build. However, since we are using hyperfine in comparison
|
||||
# mode, we would have to combine the JSON ourselves to support that, which
|
||||
# would probably be better done by writing a benchmarking script in
|
||||
# not-bash.
|
||||
arg_parser.add_argument('builds', nargs='+', help="At least two build directories to compare, containing bin/nix")
|
||||
arg_parser.add_argument('--cases', type=str, help="A comma-separated list of cases you want to run. Defaults to running all")
|
||||
available_modes = [ "walltime" ] + [ "icount" ] if platform.system() == 'Linux' else [] # perf doesn't run on Darwin
|
||||
arg_parser.add_argument('--mode', choices=available_modes, default="walltime")
|
||||
args = arg_parser.parse_args()
|
||||
if len(args.builds) < 2:
|
||||
raise ValueError("need at least two build directories to compare")
|
||||
|
||||
benchmarks: list[str] = []
|
||||
if args.cases is None:
|
||||
benchmarks = list(cases.keys())
|
||||
else:
|
||||
for case in args.cases.split(","):
|
||||
if case not in cases: raise ValueError(f"no such case: {case}")
|
||||
benchmarks.append(case)
|
||||
|
||||
def bench_walltime(env):
|
||||
hyperfine_args = ["--parameter-list", "BUILD", ','.join(args.builds), "--warmup", "2", "--runs", "10"]
|
||||
for case in benchmarks:
|
||||
case_command = cases[case]("{BUILD}") # see the comment on cases
|
||||
subprocess.run([
|
||||
"taskset", "-c", "2,3",
|
||||
"chrt", "-f","50",
|
||||
"hyperfine", *hyperfine_args, "--export-json", f"bench/bench-{case}.json", "--export-markdown", f"bench/bench-{case}.md", "--", " ".join(case_command)
|
||||
], env=env, check=True)
|
||||
|
||||
print("Benchmarks summary\n---\n")
|
||||
for case in benchmarks:
|
||||
fd = open(f"bench/bench-{case}.json")
|
||||
result_json = json.load(fd)
|
||||
fd.close()
|
||||
for result in result_json["results"]:
|
||||
print(result["command"])
|
||||
print("-" * min(80,len(result["command"])))
|
||||
attr_rounded = lambda attr: f"{result[attr]:.3f}"
|
||||
print(" mean: ", attr_rounded("mean"), "±", attr_rounded("stddev"))
|
||||
print(" user:", attr_rounded("user"), "| system", attr_rounded("system"))
|
||||
print(" median: ", attr_rounded("median"))
|
||||
print(" range: ", attr_rounded("min") + "s.." + attr_rounded("max")+"s")
|
||||
print(" relative:", f"{result["mean"]/result_json["results"][0]["mean"]:.3f}")
|
||||
print("\n")
|
||||
|
||||
|
||||
def bench_icount(env):
|
||||
perf_results_for: dict[str, list[tuple[str, float]]] = {}
|
||||
for case in benchmarks:
|
||||
for build in args.builds:
|
||||
case_command = cases[case](build)
|
||||
# the perf stat -j output (incorrectly) localizes numbers, which will trip up the json parser.
|
||||
env["LC_ALL"]="C"
|
||||
commandline = [
|
||||
"perf", "stat", "-o", f"bench/perf-{case}.json", "-j", "sh", "-c", " ".join(case_command)
|
||||
]
|
||||
subprocess.run(commandline, env=env, check=True, stdout=subprocess.DEVNULL) # warmup run
|
||||
subprocess.run(commandline, env=env, check=True, stdout=subprocess.DEVNULL)
|
||||
perf_fd = open(f"bench/perf-{case}.json")
|
||||
perf_data = [json.loads(x) for x in perf_fd.readlines()]
|
||||
perf_fd.close()
|
||||
|
||||
instr = next(x for x in perf_data if x["event"] in ["instructions", "instructions:u"]) # an implementation of a find_first iterator
|
||||
if case not in perf_results_for: perf_results_for[case] = []
|
||||
perf_results_for[case].append((" ".join(case_command), float(instr["counter-value"])))
|
||||
|
||||
print("Benchmarks summary\n---\n")
|
||||
for (case, entries) in perf_results_for.items():
|
||||
for entry in entries:
|
||||
cmd,instr = entry
|
||||
print(cmd)
|
||||
print("-" * min(80,len(cmd)))
|
||||
print(" instructions: ", int(instr))
|
||||
print(" relative instructions:", int(instr)/perf_results_for[case][0][1])
|
||||
print("\n")
|
||||
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
subprocess.run([
|
||||
"nix", "build",
|
||||
"--extra-experimental-features", "nix-command flakes",
|
||||
"--impure", "--expr",'(builtins.getFlake "git+file:.").inputs.nixpkgs.outPath',
|
||||
"-o","bench/nixpkgs"
|
||||
], check=True)
|
||||
subenv = os.environ.copy()
|
||||
subenv["NIX_CONF_DIR"] = "/var/empty"
|
||||
subenv["NIX_REMOTE"] = tmp_dir
|
||||
subenv["NIX_PATH"] = "nixpkgs=bench/nixpkgs:nixos-config=bench/configuration.nix"
|
||||
|
||||
if args.mode == "walltime":
|
||||
bench_walltime(subenv)
|
||||
else:
|
||||
bench_icount(subenv)
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p bash -p hyperfine
|
||||
|
||||
set -euo pipefail
|
||||
shopt -s inherit_errexit
|
||||
|
||||
scriptdir=$(cd "$(dirname -- "$0")" ; pwd -P)
|
||||
cd "$scriptdir/.."
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
# FIXME(jade): it is a reasonable use case to want to run a benchmark run
|
||||
# on just one build. However, since we are using hyperfine in comparison
|
||||
# mode, we would have to combine the JSON ourselves to support that, which
|
||||
# would probably be better done by writing a benchmarking script in
|
||||
# not-bash.
|
||||
echo "Fewer than two result dirs given, nothing to compare!" >&2
|
||||
echo "Pass some directories (with names indicating which alternative they are) with bin/nix in them" >&2
|
||||
echo "Usage: ./bench/bench.sh result-1 result-2 [result-3...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_exit=""
|
||||
trap "$_exit" EXIT
|
||||
|
||||
flake_args=("--extra-experimental-features" "nix-command flakes")
|
||||
|
||||
# XXX: yes this is very silly. flakes~!!
|
||||
nix build "${flake_args[@]}" --impure --expr '(builtins.getFlake "git+file:.").inputs.nixpkgs.outPath' -o bench/nixpkgs
|
||||
|
||||
# We must ignore the global config, or else NIX_PATH won't work reliably.
|
||||
# See https://github.com/NixOS/nix/issues/9574
|
||||
export NIX_CONF_DIR='/var/empty'
|
||||
export NIX_REMOTE="$(mktemp -d)"
|
||||
_exit='rm -rfv "$NIX_REMOTE"; $_exit'
|
||||
export NIX_PATH="nixpkgs=bench/nixpkgs:nixos-config=bench/configuration.nix"
|
||||
|
||||
builds=("$@")
|
||||
|
||||
flake_args="${flake_args[*]@Q}"
|
||||
|
||||
hyperfineArgs=(
|
||||
--parameter-list BUILD "$(IFS=,; echo "${builds[*]}")"
|
||||
--warmup 2 --runs 10
|
||||
)
|
||||
|
||||
declare -A cases
|
||||
cases=(
|
||||
[search]="{BUILD}/bin/nix $flake_args search --no-eval-cache github:nixos/nixpkgs/e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870 hello"
|
||||
[rebuild]="{BUILD}/bin/nix $flake_args eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'"
|
||||
[rebuild-lh]="GC_INITIAL_HEAP_SIZE=10g {BUILD}/bin/nix eval $flake_args --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'"
|
||||
[parse]="{BUILD}/bin/nix $flake_args eval -f bench/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix"
|
||||
)
|
||||
|
||||
benches=(
|
||||
rebuild
|
||||
rebuild-lh
|
||||
search
|
||||
parse
|
||||
)
|
||||
|
||||
for k in "${benches[@]}"; do
|
||||
taskset -c 2,3 \
|
||||
chrt -f 50 \
|
||||
hyperfine "${hyperfineArgs[@]}" --export-json="bench/bench-${k}.json" --export-markdown="bench/bench-${k}.md" "${cases[$k]}"
|
||||
done
|
||||
|
||||
echo "Benchmarks summary (from ./bench/summarize.jq bench/bench-*.json)"
|
||||
bench/summarize.jq bench/*.json
|
||||
+21
-10
@@ -32,8 +32,8 @@
|
||||
hardware = {
|
||||
enableRedistributableFirmware = true;
|
||||
cpu.intel.updateMicrocode = true;
|
||||
graphics.enable32Bit = true;
|
||||
graphics.extraPackages = with pkgs; [
|
||||
opengl.driSupport32Bit = true;
|
||||
opengl.extraPackages = with pkgs; [
|
||||
vaapiIntel
|
||||
intel-media-driver
|
||||
intel-compute-runtime
|
||||
@@ -93,17 +93,16 @@
|
||||
|
||||
i18n = {
|
||||
defaultLocale = "en_US.UTF-8";
|
||||
inputMethod.enable = true;
|
||||
inputMethod.type = "ibus";
|
||||
inputMethod.enabled = "ibus";
|
||||
};
|
||||
|
||||
services = {
|
||||
libinput.enable = true;
|
||||
xserver = {
|
||||
enable = true;
|
||||
xkb.layout = "us";
|
||||
xkb.variant = "altgr-intl";
|
||||
xkb.options = "ctrl:nocaps";
|
||||
layout = "us";
|
||||
xkbVariant = "altgr-intl";
|
||||
xkbOptions = "ctrl:nocaps";
|
||||
libinput.enable = true;
|
||||
wacom.enable = true;
|
||||
videoDrivers = [ "modesetting" ];
|
||||
modules = [ pkgs.xf86_input_wacom ];
|
||||
@@ -122,6 +121,17 @@
|
||||
'';
|
||||
};
|
||||
|
||||
sound.enable = true;
|
||||
hardware.pulseaudio = {
|
||||
enable = true;
|
||||
package = pkgs.pulseaudioFull;
|
||||
daemon.config = {
|
||||
lock-memory = "yes";
|
||||
realtime-scheduling = "yes";
|
||||
rlimit-rtprio = "-1";
|
||||
};
|
||||
};
|
||||
|
||||
programs = {
|
||||
light.enable = true;
|
||||
wireshark = {
|
||||
@@ -136,7 +146,7 @@
|
||||
fonts.packages = with pkgs; [
|
||||
font-awesome
|
||||
noto-fonts
|
||||
noto-fonts-cjk-sans
|
||||
noto-fonts-cjk
|
||||
noto-fonts-emoji
|
||||
noto-fonts-extra
|
||||
dejavu_fonts
|
||||
@@ -229,7 +239,7 @@
|
||||
file
|
||||
firefox
|
||||
fluidsynth
|
||||
adwaita-icon-theme
|
||||
gnome3.adwaita-icon-theme
|
||||
gnuplot
|
||||
graphviz
|
||||
helm
|
||||
@@ -242,6 +252,7 @@
|
||||
libqalculate
|
||||
libreoffice
|
||||
man-pages
|
||||
nheko
|
||||
nix-diff
|
||||
nix-index
|
||||
nix-output-monitor
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env -S jq -Mrf
|
||||
|
||||
def round3:
|
||||
. * 1000 | round | . / 1000
|
||||
;
|
||||
|
||||
def stats($first):
|
||||
[
|
||||
" mean: \(.mean | round3)s ± \(.stddev | round3)s",
|
||||
" user: \(.user | round3)s | system: \(.system | round3)s",
|
||||
" median: \(.median | round3)s",
|
||||
" range: \(.min | round3)s ... \(.max | round3)s",
|
||||
" relative: \(.mean / $first.mean | round3)"
|
||||
]
|
||||
| join("\n")
|
||||
;
|
||||
|
||||
def fmt($first):
|
||||
"\(.command)\n" + (. | stats($first))
|
||||
;
|
||||
|
||||
[.results | .[0] as $first | .[] | fmt($first)] | join("\n\n") | (. + "\n\n---\n")
|
||||
@@ -7,8 +7,9 @@ create-missing = false
|
||||
[output.html]
|
||||
additional-css = ["custom.css"]
|
||||
additional-js = ["redirects.js"]
|
||||
# Jumps directly into a new Gerrit CL editing the file in question.
|
||||
edit-url-template = "https://gerrit.lix.systems/admin/repos/edit/repo/lix/branch/main/file/doc/manual/{path}"
|
||||
# Using our GitHub mirror enables easier typo fixes since there is no easy way
|
||||
# to just submit a Gerrit CL by the web for trivial stuff.
|
||||
edit-url-template = "https://github.com/lix-project/lix/tree/main/doc/manual/{path}"
|
||||
git-repository-url = "https://git.lix.systems/lix-project/lix"
|
||||
# Folding by default would prevent things like "Ctrl+F for nix-env" from working
|
||||
# trivially, but the user should be able to fold if they want to.
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
forgejo: rbt
|
||||
github: 9999years
|
||||
|
||||
9p4:
|
||||
display_name: Ersei Saggi
|
||||
github: 9p4
|
||||
|
||||
Artturin:
|
||||
github: Artturin
|
||||
|
||||
@@ -40,23 +36,10 @@ alois31:
|
||||
forgejo: alois31
|
||||
github: alois31
|
||||
|
||||
andrewhamon:
|
||||
display_name: Andrew Hamon
|
||||
github: andrewhamon
|
||||
|
||||
artemist:
|
||||
display_name: Artemis Tosini
|
||||
forgejo: artemist
|
||||
|
||||
bb010g:
|
||||
display_name: Dusk Banks
|
||||
forgejo: bb010g
|
||||
github: bb010g
|
||||
|
||||
blitz:
|
||||
display_name: Julian Stecklina
|
||||
github: blitz
|
||||
|
||||
cole-h:
|
||||
display_name: Cole Helbling
|
||||
github: cole-h
|
||||
@@ -66,10 +49,6 @@ delan:
|
||||
forgejo: delan
|
||||
github: delan
|
||||
|
||||
detroyejr:
|
||||
display_name: Jonathan De Troye
|
||||
github: detroyejr
|
||||
|
||||
edolstra:
|
||||
display_name: Eelco Dolstra
|
||||
github: edolstra
|
||||
@@ -78,9 +57,6 @@ ericson:
|
||||
display_name: John Ericson
|
||||
github: ericson2314
|
||||
|
||||
gilice:
|
||||
forgejo: gilice
|
||||
|
||||
goldstein:
|
||||
display_name: goldstein
|
||||
forgejo: goldstein
|
||||
@@ -94,10 +70,6 @@ horrors:
|
||||
iFreilicht:
|
||||
github: iFreilicht
|
||||
|
||||
ian-h-chamberlain:
|
||||
forgejo: ian-h-chamberlain
|
||||
github: ian-h-chamberlain
|
||||
|
||||
isabelroses:
|
||||
forgejo: isabelroses
|
||||
github: isabelroses
|
||||
@@ -106,14 +78,6 @@ jade:
|
||||
forgejo: jade
|
||||
github: lf-
|
||||
|
||||
just1602:
|
||||
forgejo: just1602
|
||||
|
||||
kfears:
|
||||
display_name: KFears
|
||||
forgejo: kfearsoff
|
||||
github: kfearsoff
|
||||
|
||||
kiara:
|
||||
github: KiaraGrouwstra
|
||||
|
||||
@@ -129,10 +93,6 @@ lheckemann:
|
||||
forgejo: lheckemann
|
||||
github: lheckemann
|
||||
|
||||
lily:
|
||||
forgejo: lilyinstarlight
|
||||
github: lilyinstarlight
|
||||
|
||||
lilyball:
|
||||
forgejo: lilyball
|
||||
github: lilyball
|
||||
@@ -155,32 +115,16 @@ midnightveil:
|
||||
ncfavier:
|
||||
github: ncfavier
|
||||
|
||||
p-e-meunier:
|
||||
display_name: Pierre-Etienne Meunier
|
||||
github: P-E-Meunier
|
||||
|
||||
pamplemousse:
|
||||
display_name: Xavier Maso
|
||||
github: pamplemousse
|
||||
|
||||
piegames:
|
||||
display_name: piegames
|
||||
forgejo: piegames
|
||||
github: piegamesde
|
||||
|
||||
poliorcetics:
|
||||
display_name: Poliorcetics
|
||||
github: poliorcetics
|
||||
|
||||
puck:
|
||||
display_name: puck
|
||||
forgejo: puck
|
||||
github: puckipedia
|
||||
|
||||
quantenzitrone:
|
||||
display_name: Zitrone
|
||||
forgejo: quantenzitrone
|
||||
|
||||
quantumjump:
|
||||
display_name: Quantum Jump
|
||||
github: QuantumBJump
|
||||
@@ -197,18 +141,6 @@ roberth:
|
||||
display_name: Robert Hensing
|
||||
github: roberth
|
||||
|
||||
seppel3210:
|
||||
github: Seppel3210
|
||||
|
||||
teofilc:
|
||||
forgejo: teofilc
|
||||
github: TeofilC
|
||||
|
||||
thubrecht:
|
||||
display_name: Tom Hubrecht
|
||||
forgejo: tom-hubrecht
|
||||
github: Tom-Hubrecht
|
||||
|
||||
thufschmitt:
|
||||
display_name: Théophane Hufschmitt
|
||||
github: thufschmitt
|
||||
@@ -230,12 +162,6 @@ winter:
|
||||
forgejo: winter
|
||||
github: winterqt
|
||||
|
||||
xanderio:
|
||||
github: xanderio
|
||||
|
||||
yorickvp:
|
||||
github: yorickvp
|
||||
|
||||
yshui:
|
||||
github: yshui
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
nix_env_for_docs = {
|
||||
'HOME': '/dummy',
|
||||
'NIX_CONF_DIR': '/dummy',
|
||||
'XDG_CONFIG_HOME': '/dummy',
|
||||
'NIX_SSL_CERT_FILE': '/dummy/no-ca-bundle.crt',
|
||||
'NIX_STATE_DIR': '/dummy',
|
||||
'NIX_CONFIG': 'cores = 0',
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
synopsis: "Build failures caused by `allowSubstitutes = false` while being the wrong system now produce a decent error"
|
||||
issues: [fj#484]
|
||||
cls: [1841]
|
||||
category: Fixes
|
||||
credits: jade
|
||||
---
|
||||
|
||||
Nix allows derivations to set `allowSubstitutes = false` in order to force them to be built locally without querying substituters for them.
|
||||
This is useful for derivations that are very fast to build (especially if they produce large output).
|
||||
However, this can shoot you in the foot if the derivation *has* to be substituted such as if the derivation is for another architecture, which is what `--always-allow-substitutes` is for.
|
||||
|
||||
Perhaps such derivations that are known to be impossible to build locally should ignore `allowSubstitutes` (irrespective of remote builders) in the future, but this at least reports the failure and solution directly.
|
||||
|
||||
```
|
||||
$ nix build -f fail.nix
|
||||
error: a 'unicornsandrainbows-linux' with features {} is required to build '/nix/store/...-meow.drv', but I am a 'x86_64-linux' with features {...}
|
||||
|
||||
Hint: the failing derivation has allowSubstitutes set to false, forcing it to be built rather than substituted.
|
||||
Passing --always-allow-substitutes to force substitution may resolve this failure if the path is available in a substituter.
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
synopsis: "`Alt+Left` and `Alt+Right` go back/forwards by words in `nix repl`"
|
||||
issues: [fj#501]
|
||||
cls: [1883]
|
||||
category: Fixes
|
||||
credits: 9999years
|
||||
---
|
||||
|
||||
`nix repl` now recognizes `Alt+Left` and `Alt+Right` for navigating by words
|
||||
when entering input in `nix repl` on more terminals/platforms.
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
synopsis: "Drop support for `xz` and `bzip2` Content-Encoding"
|
||||
category: Miscellany
|
||||
cls: [2134]
|
||||
credits: horrors
|
||||
---
|
||||
|
||||
Lix no longer supports the non-standard HTTP Content-Encoding values `xz` and `bzip2`.
|
||||
We do not expect this to cause any problems in practice since these encodings *aren't*
|
||||
standard, and any server delivering them anyway without being asked to is already well
|
||||
and truly set on the path of causing inexplicable client breakages.
|
||||
|
||||
Lix's ability to decompress files compressed with `xz` or `bzip2` is unaffected. We're
|
||||
only bringing Lix more in line with the HTTP standard; all post-transfer data handling
|
||||
remains as it was before.
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
synopsis: Ctrl-C stops Nix commands much more reliably and responsively
|
||||
issues: [7245, fj#393]
|
||||
cls: [2016]
|
||||
prs: [11618]
|
||||
category: Fixes
|
||||
credits: [roberth, 9999years]
|
||||
---
|
||||
|
||||
CTRL-C will now stop Nix commands much more reliably and responsively. While
|
||||
there are still some cases where a Nix command can be slow or unresponsive
|
||||
following a `SIGINT` (please report these as issues!), the vast majority of
|
||||
signals will now cause the Nix command to quit quickly and consistently.
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
synopsis: Deprecated language features
|
||||
issues: [fj#437, 861]
|
||||
cls: [1785, 1736, 1735, 1744, 2206]
|
||||
category: Breaking Changes
|
||||
credits: [piegames, horrors]
|
||||
---
|
||||
|
||||
A system for deprecation (and then the planned removal) of undesired language features has been put into place.
|
||||
It is controlled via feature flags much like experimental features, except that the deprecations are enabled default,
|
||||
and can be disabled via the flags for backwards compatibility (opt-out with `--extra-deprecated-features` or the Nix configuration file).
|
||||
|
||||
- `url-literals`: **URL literals** have long been obsolete and discouraged of use, and now they are officially deprecated.
|
||||
This means that all URLs must be properly put within quotes like all other strings.
|
||||
- `rec-set-overrides`: **__overrides** is an old arcane syntax which has not been in use for more than a decade.
|
||||
It is soft-deprecated with a warning only, with the plan to turn that into an error in a future release.
|
||||
- `ancient-let`: **The old `let` syntax** (`let { body = …; … }`) is soft-deprecated with a warning as well. Use the regular `let … in` instead.
|
||||
- `shadow-internal-symbols`: Arithmetic expressions like `5 - 3` internally expand to `__sub 5 3`, where `__sub` maps to a subtraction builtin. Shadowing such a symbols would affect the evaluation of such operations, but in a very inconsistent way, and is therefore deprecated now. **Affected symbols are:** `__sub`, `__mul`, `__div`, `__lessThan`, `__findFile` and `__nixPath`. Note that these symbols may still be used as variable names as long as they do not shadow internal operations, so e.g. `let __sub = x: y: x + y; in __sub 3 5` remains valid code.
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
synopsis: "transfers no longer allow arbitrary url schemas"
|
||||
category: Breaking Changes
|
||||
cls: [2106]
|
||||
credits: horrors
|
||||
---
|
||||
|
||||
Lix no longer allows transfers using arbitrary url schemas. Only `http://`, `https://`, `ftp://`, `ftps://`, and `file://` urls are supported going forward. This affects `builtins.fetchurl`, `<nix/fetchurl.nix>`, transfers to and from binary caches, and all other uses of the internal file transfer code. Flake inputs using multi-protocol schemas (e.g. `git+ssh`) are not affected as those use external utilities to transfer data.
|
||||
|
||||
The `s3://` scheme is not affected at all by this change and continues to work if S3 support is built into Lix.
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
synopsis: restore backwards-compatibility of `builtins.fetchGit` with Nix 2.3
|
||||
issues: [5291, 5128]
|
||||
credits: [ma27]
|
||||
category: Fixes
|
||||
---
|
||||
|
||||
Compatibility with `builtins.fetchGit` from Nix 2.3 has been restored as follows:
|
||||
|
||||
* Until now, each `ref` was prefixed with `refs/heads` unless it starts with `refs/` itself.
|
||||
|
||||
Now, this is not done if the `ref` looks like a commit hash.
|
||||
|
||||
* Specifying `builtins.fetchGit { ref = "a-tag"; /* … */ }` was broken because `refs/heads` was appended.
|
||||
|
||||
Now, the fetcher doesn't turn a ref into `refs/heads/ref`, but into `refs/*/ref`. That way,
|
||||
the value in `ref` can be either a tag or a branch.
|
||||
|
||||
* The ref resolution happens the same way as in git:
|
||||
|
||||
* If `refs/ref` exists, it's used.
|
||||
* If a tag `refs/tags/ref` exists, it's used.
|
||||
* If a branch `refs/heads/ref` exists, it's used.
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
synopsis: HTTP proxy environment variables are now respected for S3 binary cache stores
|
||||
issues: [fj#433]
|
||||
cls: [1788]
|
||||
category: Fixes
|
||||
credits: jade
|
||||
---
|
||||
|
||||
Due to "legacy reasons" (according to the AWS C++ SDK docs), the AWS SDK ignores system proxy configuration by default.
|
||||
We turned it back on.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
synopsis: "Includes are now qualified with library name"
|
||||
category: Development
|
||||
cls: [2178]
|
||||
credits: jade
|
||||
---
|
||||
|
||||
The Lix includes have all been rearranged to be of the form `"lix/libexpr/foo.hh"` instead of `"foo.hh"`.
|
||||
This was already supported externally for a migration period, but it is now being applied to all the internal usages within Lix itself.
|
||||
The goal of this change is to both clarify where a file is from and to avoid polluting global include paths with things like `config.h` that might conflict with other projects.
|
||||
|
||||
For other details, see the release notes of Lix 2.90.0, under "Rename all the libraries" in Breaking Changes.
|
||||
|
||||
To fix an external project with sources in `src` which has a separate build directory (such that headers are in `../src` relative to where the compiler is running):
|
||||
|
||||
```
|
||||
lix_root=$HOME/lix
|
||||
(cd $lix_root && nix develop -c 'meson setup build && ninja -C build subprojects/lix-clang-tidy/liblix-clang-tidy.so')
|
||||
run-clang-tidy -checks='-*,lix-fixincludes' -load=$lix_root/build/subprojects/lix-clang-tidy/liblix-clang-tidy.so -p build/ -header-filter '\.\./src/.*\.h' -fix src
|
||||
```
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
synopsis: "Improvements to interactive flake config"
|
||||
cls: [2066]
|
||||
category: Improvements
|
||||
credits: ma27
|
||||
---
|
||||
|
||||
If `accept-flake-config` is set to `ask` and a `flake.nix` defines `nixConfig`,
|
||||
Lix will ask on the CLI which of these settings should be used for the command.
|
||||
|
||||
Now, it's possible to answer with `N` (as opposed to `n` to only reject the setting
|
||||
that is asked for) to reject _all untrusted_ entries from the flake's `nixConf`
|
||||
section.
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
synopsis: Fix potential store corruption with auto-optimise-store
|
||||
issues: [7273]
|
||||
cls: [2100]
|
||||
category: Fixes
|
||||
credits: lilyball
|
||||
---
|
||||
|
||||
Optimising store paths (and other operations involving temporary files) no longer use `random(3)`
|
||||
to generate filenames. On darwin systems this was observed to potentially cause store corruption
|
||||
when using [`auto-optimise-store`](@docroot@/command-ref/conf-file.md#conf-auto-optimise-store),
|
||||
though this corruption was possible on any system whose `random(3)` does not have locking around
|
||||
the global state.
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
synopsis: Change `nix-build -o ""` to behave like `--no-out-link`
|
||||
cls: [2103]
|
||||
category: Fixes
|
||||
credits: lilyball
|
||||
---
|
||||
|
||||
[`nix-build`](@docroot@/command-ref/nix-build.md)now treats <code>[--out-link](@docroot@/command-ref/nix-build.md#opt-out-link) ''</code>
|
||||
the same as [`--no-out-link`](@docroot@/command-ref/nix-build.md#opt-no-out-link). This matches
|
||||
[`nix build`](@docroot@/command-ref/new-cli/nix3-build.md) behavior. Previously when building the default output it
|
||||
would have resulted in throwing an error saying the current working directory already exists, and when building any
|
||||
other output it would have resulted in a symlink starting with a hyphen such as `-doc`, which is a footgun for
|
||||
terminal commands.
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
synopsis: Removing the `.` default argument passed to the `nix fmt` formatter
|
||||
issues: []
|
||||
prs: [11438]
|
||||
cls: [1902]
|
||||
category: Breaking Changes
|
||||
credits: zimbatm
|
||||
---
|
||||
|
||||
The underlying formatter no longer receives the ". " default argument when `nix fmt` is called with no arguments.
|
||||
|
||||
This change was necessary as the formatter wasn't able to distinguish between
|
||||
a user wanting to format the current folder with `nix fmt .` or the generic
|
||||
`nix fmt`.
|
||||
|
||||
The default behaviour is now the responsibility of the formatter itself, and
|
||||
allows tools such as treefmt to format the whole tree instead of only the
|
||||
current directory and below.
|
||||
|
||||
This may cause issues with some formatters: nixfmt, nixpkgs-fmt and alejandra currently format stdin when no arguments are passed.
|
||||
|
||||
Here is a small wrapper example that will restore the previous behaviour for such a formatter:
|
||||
|
||||
```nix
|
||||
{
|
||||
outputs = { self, nixpkgs, systems }:
|
||||
let
|
||||
eachSystem = nixpkgs.lib.genAttrs (import systems) (system: nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
formatter = eachSystem (pkgs:
|
||||
pkgs.writeShellScriptBin "formatter" ''
|
||||
if [[ $# = 0 ]]; set -- .; fi
|
||||
exec "${pkgs.nixfmt-rfc-style}/bin/nixfmt "$@"
|
||||
'');
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
synopsis: "The beginnings of a new pytest-based functional test suite"
|
||||
category: Development
|
||||
cls: [2036, 2037]
|
||||
credits: jade
|
||||
---
|
||||
|
||||
The existing integration/functional test suite is based on a large volume of shell scripts.
|
||||
This often makes it somewhat challenging to debug at the best of times.
|
||||
The goal of the pytest test suite is to make tests have more obvious dependencies on files and to make tests more concise and easier to write, as well as making new testing methods like snapshot testing easy.
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
synopsis: readline support removed
|
||||
cls: [1885]
|
||||
category: Packaging
|
||||
credits: [9999years]
|
||||
---
|
||||
|
||||
Support for building Lix with [`readline`][readline] instead of
|
||||
[`editline`][editline] has been removed. `readline` support hasn't worked for a
|
||||
long time (attempting to use it would lead to build errors) and would make Lix
|
||||
subject to the GPL if it did work. In the future, we're hoping to replace
|
||||
`editline` with [`rustyline`][rustyline] for improved ergonomics in the `nix
|
||||
repl`.
|
||||
|
||||
[readline]: https://en.wikipedia.org/wiki/GNU_Readline
|
||||
[editline]: https://github.com/troglobit/editline
|
||||
[rustyline]: https://github.com/kkawakam/rustyline
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
synopsis: Relative and tilde paths in configuration
|
||||
issues: [fj#482]
|
||||
cls: [1851, 1863, 1864]
|
||||
category: Features
|
||||
credits: [9999years]
|
||||
---
|
||||
|
||||
[Configuration settings](@docroot@/command-ref/conf-file.md) can now refer to
|
||||
files with paths relative to the file they're written in or relative to your
|
||||
home directory (with `~/`).
|
||||
|
||||
This makes settings like
|
||||
[`repl-overlays`](@docroot@/command-ref/conf-file.md#conf-repl-overlays) and
|
||||
[`secret-key-files`](@docroot@/command-ref/conf-file.md#conf-repl-overlays)
|
||||
much easier to set, especially if you'd like to refer to files in an existing
|
||||
dotfiles repo cloned into your home directory.
|
||||
|
||||
If you put `repl-overlays = repl.nix` in your `~/.config/nix/nix.conf`, it'll
|
||||
load `~/.config/nix/repl.nix`. Similarly, you can set `repl-overlays =
|
||||
~/.dotfiles/repl.nix` to load a file relative to your home directory.
|
||||
|
||||
Configuration files can also
|
||||
[`include`](@docroot@/command-ref/conf-file.md#file-format) paths relative to
|
||||
your home directory.
|
||||
|
||||
Only user configuration files (like `$XDG_CONFIG_HOME/nix/nix.conf` or the
|
||||
files listed in `$NIX_USER_CONF_FILES`) can use tilde paths relative to your
|
||||
home directory. Configuration listed in the `$NIX_CONFIG` environment variable
|
||||
may not use relative paths.
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
synopsis: "Dependency on monolithic coreutils removed"
|
||||
category: Development
|
||||
cls: [2108]
|
||||
credits: vigress8
|
||||
---
|
||||
|
||||
Previously, the build erroneously depended on a `coreutils` binary, which requires `coreutils` to be built with a specific configuration. This was only used in one test and was not required to be a single binary. This dependency is removed now.
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
synopsis: "Reproducibility check builds now report all differing outputs"
|
||||
cls: [2069]
|
||||
category: Improvements
|
||||
credits: [lheckemann]
|
||||
---
|
||||
|
||||
`nix-build --check` allows rerunning the build of an already-built derivation to check that it produces the same output again.
|
||||
|
||||
If a multiple-output derivation with impure behaviour is built with `--check`, only the first output would be shown in the resulting error message (and kept for comparison):
|
||||
|
||||
```
|
||||
error: derivation '/nix/store/4spy3nz1661zm15gkybsy1h5f36aliwx-python3.11-test-1.0.0.drv' may not be deterministic: output '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test
|
||||
-1.0.0-dist' differs from '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test-1.0.0-dist.check'
|
||||
```
|
||||
|
||||
Now, all differing outputs are kept and reported:
|
||||
```
|
||||
error: derivation '4spy3nz1661zm15gkybsy1h5f36aliwx-python3.11-test-1.0.0.drv' may not be deterministic: outputs differ
|
||||
output differs: output '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test-1.0.0-dist' differs from '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test-1.0.0-dist.check'
|
||||
output differs: output '/nix/store/yl59v08356i841c560alb0zmk7q16klb-python3.11-test-1.0.0' differs from '/nix/store/yl59v08356i841c560alb0zmk7q16klb-python3.11-test-1.0.0.check'
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
synopsis: Ignore broken `/etc/ssl/certs/ca-certificates.crt` symlink
|
||||
issues: [fj#560]
|
||||
cls: [2144]
|
||||
category: Fixes
|
||||
credits: lilyball
|
||||
---
|
||||
|
||||
[`ssl-cert-file`](@docroot@/command-ref/conf-file.md#conf-ssl-cert-file) now checks its default
|
||||
value for a broken symlink before using it. This fixes a problem on macOS where uninstalling
|
||||
nix-darwin may leave behind a broken symlink at `/etc/ssl/certs/ca-certificates.crt` that was
|
||||
stopping Lix from using the cert at `/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt`.
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
synopsis: "Some Lix crashes now produce reporting instructions and a stack trace, then abort"
|
||||
cls: [1854]
|
||||
category: Improvements
|
||||
credits: jade
|
||||
---
|
||||
|
||||
Lix, being a C++ program, can crash in a few kinds of ways.
|
||||
It can obviously do a memory access violation, which will generate a core dump and thus be relatively debuggable.
|
||||
But, worse, it could throw an unhandled exception, and, in the past, we would just show the message but not where it comes from, in spite of this always being a bug, since we expect all such errors to be translated to a Lix specific error.
|
||||
Now the latter kind of bug should print reporting instructions, a rudimentary stack trace and (depending on system configuration) generate a core dump.
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
Lix crashed. This is a bug. We would appreciate if you report it along with what caused it at https://git.lix.systems/lix-project/lix/issues with the following information included:
|
||||
|
||||
Exception: std::runtime_error: test exception
|
||||
Stack trace:
|
||||
0# nix::printStackTrace() in /home/jade/lix/lix3/build/lix/nix/../libutil/liblixutil.so
|
||||
1# 0x000073C9862331F2 in /home/jade/lix/lix3/build/lix/nix/../libmain/liblixmain.so
|
||||
2# 0x000073C985F2E21A in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++.so.6
|
||||
3# 0x000073C985F2E285 in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++.so.6
|
||||
4# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /home/jade/lix/lix3/build/lix/nix/../libmain/liblixmain.so
|
||||
...
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
synopsis: Add a `temp-dir` setting to set the temporary directory location
|
||||
issues: [7731, 8995, fj#112, fj#253]
|
||||
cls: [2103]
|
||||
category: Improvements
|
||||
credits: lilyball
|
||||
---
|
||||
|
||||
[`temp-dir`](@docroot@/command-ref/conf-file.md#conf-temp-dir) can now be set in the Nix
|
||||
configuration to change the temporary directory. This can be used to relocate all temporary files
|
||||
to another filesystem without affecting the `TMPDIR` env var inherited by interactive
|
||||
`nix-shell`/`nix shell` shells or `nix run` commands.
|
||||
|
||||
Also on macOS, the `TMPDIR` env var is no longer unset for interactive shells when pointing
|
||||
to a per-session `/var/folders/` directory.
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
synopsis: All Lix threads are named
|
||||
cls: [2210]
|
||||
category: Development
|
||||
credits: [jade]
|
||||
---
|
||||
|
||||
Lix now sets thread names on all of its secondary threads, which will make debugger usage slightly nicer and easier.
|
||||
|
||||
```
|
||||
(gdb) info thr
|
||||
Id Target Id Frame
|
||||
* 1 LWP 3719283 "nix-daemon" 0x00007e558587da0f in accept ()
|
||||
from target:/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libc.so.6
|
||||
2 LWP 3719284 "signal handler" 0x00007e55857b2bea in sigtimedwait ()
|
||||
from target:/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libc.so.6
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
synopsis: "`<nix/fetchurl.nix>` now uses TLS verification"
|
||||
category: Fixes
|
||||
prs: [11585]
|
||||
credits: edolstra
|
||||
---
|
||||
|
||||
Previously `<nix/fetchurl.nix>` did not do TLS verification. This was because the Nix sandbox in the past did not have access to TLS certificates, and Nix checks the hash of the fetched file anyway. However, this can expose authentication data from `netrc` and URLs to man-in-the-middle attackers. In addition, Nix now in some cases (such as when using impure derivations) does *not* check the hash. Therefore we have now enabled TLS verification. This means that downloads by `<nix/fetchurl.nix>` will now fail if you're fetching from a HTTPS server that does not have a valid certificate.
|
||||
|
||||
`<nix/fetchurl.nix>` is also known as the builtin derivation builder `builtin:fetchurl`. It's not to be confused with the evaluation-time function `builtins.fetchurl`, which was not affected by this issue.
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
synopsis: "Set `X-GitHub-Api-Version` header"
|
||||
issues: [fj#255]
|
||||
cls: [1925]
|
||||
category: Development
|
||||
credits: kiara
|
||||
---
|
||||
|
||||
Sets the `X-GitHub-Api-Version` header to `2022-11-28` for calls to the
|
||||
GitHub API.
|
||||
This follows the later version as per
|
||||
https://docs.github.com/en/rest/about-the-rest-api/api-versions?apiVersion=2022-11-28.
|
||||
|
||||
This affected the check on whether to use the API versus unauthenticated
|
||||
calls as well, given the headers would no longer be empty if the
|
||||
authentication token were missing.
|
||||
The workaround to this used here is to use a check similar to an existing
|
||||
check for the token.
|
||||
|
||||
In the current implementation, headers are (still) similarly sent to
|
||||
non-authenticated as well as GitHub on-prem calls.
|
||||
For what it's worth, manual curl calls with such a header seemed to
|
||||
break nor unauthenticated calls nor ones to the github.com API.
|
||||
@@ -198,8 +198,6 @@
|
||||
- [Release Notes](release-notes/release-notes.md)
|
||||
- [Upcoming release](release-notes/rl-next.md)
|
||||
<!-- RELENG-AUTO-INSERTION-MARKER (see releng/release_notes.py) -->
|
||||
- [Lix 2.93 (2025-05-09)](release-notes/rl-2.93.md)
|
||||
- [Lix 2.92 (2025-01-18)](release-notes/rl-2.92.md)
|
||||
- [Lix 2.91 (2024-08-12)](release-notes/rl-2.91.md)
|
||||
- [Lix 2.90 (2024-07-10)](release-notes/rl-2.90.md)
|
||||
- [Nix 2.18 (2023-09-20)](release-notes/rl-2.18.md)
|
||||
|
||||
@@ -75,9 +75,7 @@ by spaces. Only the first element is required. To leave a field at its
|
||||
default, set it to `-`.
|
||||
|
||||
1. The URI of the remote store in the format
|
||||
`ssh://[username@]hostname[?port=<port>]`, e.g. `ssh://nix@mac` or `ssh://mac`.
|
||||
If the ssh server is not listening on port 22 (e.g. port 1337 in this case)
|
||||
the URI would be `ssh://nix@mac?port=1337`
|
||||
`ssh://[username@]hostname`, e.g. `ssh://nix@mac` or `ssh://mac`.
|
||||
For backward compatibility, `ssh://` may be omitted. The hostname
|
||||
may be an alias defined in your `~/.ssh/config`.
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ The following [concept map] shows its main components (rectangles), the objects
|
||||
| |
|
||||
+----------|-------------------|--------------------------------+
|
||||
| Nix impl.| V |
|
||||
| (Lix) | +------------------------+ |
|
||||
| | | command line interface |------. |
|
||||
| | +------------------------+ | |
|
||||
| (Lix) | +-------------------------+ |
|
||||
| | | commmand line interface |------. |
|
||||
| | +-------------------------+ | |
|
||||
| | | | |
|
||||
| evaluated by calls manages |
|
||||
| | | | |
|
||||
|
||||
@@ -34,15 +34,9 @@ keep-outputs = true # Nice for developers
|
||||
keep-derivations = true # Idem
|
||||
```
|
||||
|
||||
Other files can be included with a line like `include <path>`.
|
||||
Other files can be included with a line like `include <path>`, where `<path>` is interpreted relative to the current configuration file.
|
||||
A missing file is an error unless `!include` is used instead.
|
||||
|
||||
Paths in `include`s and option values are interpreted relative to the current configuration file.
|
||||
In user configuration files, paths starting with `~/` are tilde expanded (by replacing the tilde by the value of `$HOME`).
|
||||
|
||||
Only user configuration files (like `$XDG_CONFIG_HOME/nix/nix.conf` or the files listed in `$NIX_USER_CONF_FILES`) can use tilde paths relative to your home directory.
|
||||
Configuration listed in the `$NIX_CONFIG` environment variable may not use relative paths.
|
||||
|
||||
A configuration setting usually overrides any previous value.
|
||||
However, for settings that take a list of items, you can prefix the name of the setting by `extra-` to *append* to the previous value.
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<!--
|
||||
File-ish argument syntax summary.
|
||||
This file gets included into pages like nix-build.md and nix-instantiate.md, and each individual page that includes
|
||||
this also links to nix-build.md for the full explanation.
|
||||
-->
|
||||
- A normal filesystem path, like `/home/meow/nixfiles/default.nix`
|
||||
- Or a directory, like `/home/meow/nixfiles`, equivalent to above
|
||||
- A single lookup path, like `<nixpkgs>` or `<nixos>`
|
||||
- A URL to a tarball, like `https://github.com/NixOS/nixpkgs/archive/refs/heads/release-23.11.tar.gz`
|
||||
- A [flakeref](@docroot@/command-ref/new-cli/nix3-flake.md#flake-references), introduced by the prefix `flake:`, like `flake:git+https://git.lix.systems/lix-project/lix`
|
||||
- A *nixpkgs* channel tarball name, introduced by the prefix `channel:`, like `channel:nixos-unstable`.
|
||||
- This uses a hard-coded URL pattern and is *not* related to the subscribed channels managed by the [nix-channel](@docroot@/command-ref/nix-channel.md) command.
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
# Synopsis
|
||||
|
||||
`nix-build` [*fileish…*]
|
||||
`nix-build` [*paths…*]
|
||||
[`--arg` *name* *value*]
|
||||
[`--argstr` *name* *value*]
|
||||
[{`--attr` | `-A`} *attrPath*]
|
||||
@@ -20,55 +20,19 @@ For documentation on the latter, run `nix build --help` or see `man nix3-build`.
|
||||
# Description
|
||||
|
||||
The `nix-build` command builds the derivations described by the Nix
|
||||
expressions in each *fileish*. If the build succeeds, it places a symlink to
|
||||
expressions in *paths*. If the build succeeds, it places a symlink to
|
||||
the result in the current directory. The symlink is called `result`. If
|
||||
there are multiple Nix expressions, or the Nix expressions evaluate to
|
||||
multiple derivations, multiple sequentially numbered symlinks are
|
||||
created (`result`, `result-2`, and so on).
|
||||
|
||||
If no *fileish* is specified, then `nix-build` will use `default.nix` in
|
||||
If no *paths* are specified, then `nix-build` will use `default.nix` in
|
||||
the current directory, if it exists.
|
||||
|
||||
## Fileish Syntax
|
||||
|
||||
A given *fileish* may take one of a few different forms, the first being a simple filesystem path, e.g. `nix-build /tmp/some-file.nix`.
|
||||
Like the [import builtin](../language/builtins.md#builtins-import) specifying a directory is equivalent to specifying `default.nix` within that directory.
|
||||
It may also be a [search path](./env-common.md#env-NIX_PATH) (also known as a lookup path) like `<nixpkgs>`, which is convenient to use with `--attr`/`-A`:
|
||||
|
||||
```console
|
||||
$ nix-build '<nixpkgs>' -A firefox
|
||||
```
|
||||
|
||||
(Note the quotation marks around `<nixpkgs>`, which will be necessary in most Unix shells.)
|
||||
|
||||
If a *fileish* starts with `http://` or `https://`, it is interpreted as the URL of a tarball which will be fetched and unpacked.
|
||||
Lix will then `import` the unpacked directory, so these tarballs must include at least a single top-level directory with a file called `default.nix`
|
||||
For example, you could build from a specific version of Nixpkgs with something like:
|
||||
|
||||
```console
|
||||
$ nix-build "https://github.com/NixOS/nixpkgs/archive/refs/heads/release-23.11.tar.gz" -A firefox
|
||||
```
|
||||
|
||||
If a path starts with `flake:`, the rest of the argument is interpreted as a [flakeref](./new-cli/nix3-flake.md#flake-references) (see `nix flake --help` or `man nix3-flake`), which requires the "flakes" experimental feature to be enabled.
|
||||
Lix will fetch the flake, and then `import` its unpacked directory, so the flake must include a file called `default.nix`.
|
||||
For example, the flake analogues to the above `nix-build` commands are:
|
||||
|
||||
```console
|
||||
$ nix-build flake:nixpkgs -A firefox
|
||||
$ nix-build flake:github:NixOS/nixpkgs/release-23.11 -A firefox
|
||||
```
|
||||
|
||||
Finally, for legacy reasons, if a path starts with `channel:`, the rest of the argument is interpreted as the name of a *nixpkgs* channel tarball to fetch from `https://nixos.org/channels/$CHANNEL_NAME/nixexprs.tar.xz`.
|
||||
This is a **hard coded URL** pattern and is *not* related to the subscribed channels managed by the [nix-channel](./nix-channel.md) command.
|
||||
|
||||
> **Note**: any of the special syntaxes may always be disambiguated by prefixing the path.
|
||||
> For example: a file in the current directory literally called `<nixpkgs>` can be addressed as `./<nixpkgs>`, to escape the special interpretation.
|
||||
|
||||
In summary, a path argument may be one of:
|
||||
|
||||
{{#include ./fileish-summary.md}}
|
||||
|
||||
## Notes
|
||||
If an element of *paths* starts with `http://` or `https://`, it is
|
||||
interpreted as the URL of a tarball that will be downloaded and unpacked
|
||||
to a temporary location. The tarball must include a single top-level
|
||||
directory containing at least a file named `default.nix`.
|
||||
|
||||
`nix-build` is essentially a wrapper around
|
||||
[`nix-instantiate`](nix-instantiate.md) (to translate a high-level Nix
|
||||
|
||||
@@ -14,7 +14,7 @@ The moving parts of channels are:
|
||||
- The official channels listed at <https://nixos.org/channels>
|
||||
- The user-specific list of [subscribed channels](#subscribed-channels)
|
||||
- The [downloaded channel contents](#channels)
|
||||
- The [Nix expression search path](@docroot@/command-ref/conf-file.md#conf-nix-path), set with the [`-I` option](#opt-I) or the [`NIX_PATH` environment variable](#env-NIX_PATH)
|
||||
- The [Nix expression search path](@docroot@/command-ref/conf-file.md#conf-nix-path), set with the [`-I` option](#opt-i) or the [`NIX_PATH` environment variable](#env-NIX_PATH)
|
||||
|
||||
> **Note**
|
||||
>
|
||||
|
||||
@@ -36,7 +36,7 @@ Instead, it looks in a few locations, and acts on all profiles it finds there:
|
||||
>
|
||||
> Not stable; subject to change
|
||||
>
|
||||
> Do not rely on this functionality; it just exists for migration purposes and may change in the future.
|
||||
> Do not rely on this functionality; it just exists for migration purposes and is may change in the future.
|
||||
> These deprecated paths remain a private implementation detail of Lix.
|
||||
|
||||
<!-- FIXME(Qyriad): this is inconsistent with https://git.lix.systems/lix-project/lix/issues/215, needs updating when that happens -->
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
[`--option` *name* *value*]
|
||||
[`--arg` *name* *value*]
|
||||
[`--argstr` *name* *value*]
|
||||
[{`--file` | `-f`} *fileish*]
|
||||
[{`--file` | `-f`} *path*]
|
||||
[{`--profile` | `-p`} *path*]
|
||||
[`--system-filter` *system*]
|
||||
[`--dry-run`]
|
||||
|
||||
@@ -26,7 +26,7 @@ This operation deletes the specified generations of the current profile.
|
||||
>
|
||||
> Older *and newer* generations will be deleted by this operation.
|
||||
>
|
||||
> One might expect this to just delete older generations than the current one, but that is only true if the current generation is also the latest.
|
||||
> One might expect this to just delete older generations than the curent one, but that is only true if the current generation is also the latest.
|
||||
> Because one can roll back to a previous generation, it is possible to have generations newer than the current one.
|
||||
> They will also be deleted.
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
[`--from-profile` *path*]
|
||||
[`--preserve-installed` | `-P`]
|
||||
[`--remove-all` | `-r`]
|
||||
[`--priority` *priority*]
|
||||
|
||||
# Description
|
||||
|
||||
@@ -60,11 +59,6 @@ a number of possible ways:
|
||||
unambiguous way, which is necessary if there are multiple
|
||||
derivations with the same name.
|
||||
|
||||
- If `--priority` *priority* is given, the priority of the derivations being
|
||||
installed is set to *priority*. This can be used to override the priority of
|
||||
the derivations being installed. This is useful if *args* are store paths,
|
||||
which don't have any priority information.
|
||||
|
||||
- If *args* are [store derivations](@docroot@/glossary.md#gloss-store-derivation), then these are
|
||||
[realised](@docroot@/command-ref/nix-store/realise.md), and the resulting output paths
|
||||
are installed.
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
The following options are allowed for all `nix-env` operations, but may not always have an effect.
|
||||
|
||||
- `--file` / `-f` *fileish*\
|
||||
- `--file` / `-f` *path*\
|
||||
Specifies the Nix expression (designated below as the *active Nix
|
||||
expression*) used by the `--install`, `--upgrade`, and `--query
|
||||
--available` operations to obtain derivations. The default is
|
||||
`~/.nix-defexpr`.
|
||||
|
||||
*fileish* is interpreted the same as with [nix-build](../nix-build.md#fileish-syntax).
|
||||
See that section for complete details (`nix-build --help`), but in summary, a path argument may be one of:
|
||||
|
||||
{{#include ../fileish-summary.md}}
|
||||
If the argument starts with `http://` or `https://`, it is
|
||||
interpreted as the URL of a tarball that will be downloaded and
|
||||
unpacked to a temporary location. The tarball must include a single
|
||||
top-level directory containing at least a file named `default.nix`.
|
||||
|
||||
- `--profile` / `-p` *path*\
|
||||
Specifies the profile to be used by those operations that operate on
|
||||
|
||||
@@ -22,7 +22,7 @@ left untouched; this is not an error. It is also not an error if an
|
||||
element of *args* matches no installed derivations.
|
||||
|
||||
For a description of how *args* is mapped to a set of store paths, see
|
||||
[`--install`](install.md). If *args* describes multiple
|
||||
[`--install`](#operation---install). If *args* describes multiple
|
||||
store paths with the same symbolic name, only the one with the highest
|
||||
version is installed.
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
[{`--attr`| `-A`} *attrPath*]
|
||||
[`--add-root` *path*]
|
||||
[`--expr` | `-E`]
|
||||
*fileish…*
|
||||
*files…*
|
||||
|
||||
`nix-instantiate` `--find-file` *files…*
|
||||
|
||||
@@ -25,11 +25,8 @@ of the resulting store derivations are printed on standard output.
|
||||
|
||||
[store derivation]: ../glossary.md#gloss-store-derivation
|
||||
|
||||
If *fileish* is the character `-`, then a Nix expression will be read from standard input.
|
||||
Otherwise, each *fileish* is interpreted the same as with [nix-build](./nix-build.md#fileish-syntax).
|
||||
See that section for complete details (`nix-build --help`), but in summary, a path argument may be one of:
|
||||
|
||||
{{#include ./fileish-summary.md}}
|
||||
If *files* is the character `-`, then a Nix expression will be read from
|
||||
standard input.
|
||||
|
||||
# Options
|
||||
|
||||
@@ -38,14 +35,7 @@ See that section for complete details (`nix-build --help`), but in summary, a pa
|
||||
|
||||
- `--parse`\
|
||||
Just parse the input files, and print their abstract syntax trees on
|
||||
standard output. The output format of the AST depends on the current
|
||||
internal representation and may change in the future.
|
||||
|
||||
Tooling can use the stderr and exit code of `--parse` to check any
|
||||
Nix code for correctness, but should not rely on stdout without careful
|
||||
versioning. Note that `--parse` also checks for unbound variables.
|
||||
In cases where this is undesired, `with {};` can be prepended
|
||||
to the program to transform all such parse errors into eval errors.
|
||||
standard output as a Nix expression.
|
||||
|
||||
- `--eval`\
|
||||
Just parse and evaluate the input files, and print the resulting
|
||||
|
||||
@@ -33,9 +33,10 @@ the environment of a derivation for development.
|
||||
If *path* is not given, `nix-shell` defaults to `shell.nix` if it
|
||||
exists, and `default.nix` otherwise.
|
||||
|
||||
If *path* is given it is interpreted like a [*fileish* argument to nix-build](./nix-build.md#fileish-syntax):
|
||||
|
||||
{{#include ./fileish-summary.md}}
|
||||
If *path* starts with `http://` or `https://`, it is interpreted as the
|
||||
URL of a tarball that will be downloaded and unpacked to a temporary
|
||||
location. The tarball must include a single top-level directory
|
||||
containing at least a file named `default.nix`.
|
||||
|
||||
If the derivation defines the variable `shellHook`, it will be run
|
||||
after `$stdenv/setup` has been sourced. Since this hook is not executed
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
# Synopsis
|
||||
|
||||
`nix-store` `--delete` [`--ignore-liveness`] [`--skip-live`] [`--delete-closure`] *paths…*
|
||||
`nix-store` `--delete` [`--ignore-liveness`] *paths…*
|
||||
|
||||
# Description
|
||||
|
||||
@@ -18,13 +18,6 @@ With the option `--ignore-liveness`, reachability from the roots is
|
||||
ignored. However, the path still won’t be deleted if there are other
|
||||
paths in the store that refer to it (i.e., depend on it).
|
||||
|
||||
This operation will raise an error if any of the paths are still live
|
||||
and `--ignore-liveness` is not passed. Passing `--skip-live` will
|
||||
prevent this from being considered an error.
|
||||
|
||||
The option `--delete-closure` will also attempt to delete any paths
|
||||
that are in the given path's dependency closure.
|
||||
|
||||
{{#include ./opt-common.md}}
|
||||
|
||||
{{#include ../opt-common.md}}
|
||||
|
||||
@@ -93,12 +93,9 @@ symlink.
|
||||
[deriver]: ../../glossary.md#gloss-deriver
|
||||
|
||||
- `--valid-derivers`\
|
||||
Prints the set of all [derivers](../../glossary.md#gloss-deriver) that can be
|
||||
used to build the store paths *paths*.
|
||||
This differs from `--deriver`, which prints the deriver that actually
|
||||
produced *paths*.
|
||||
No deriver may be returned if is not present in the store,
|
||||
eg, if *paths* were substituted from a binary cache.
|
||||
Prints a set of derivation files (`.drv`) which are supposed produce
|
||||
said paths when realized. Might print nothing, for example for source paths
|
||||
or paths subsituted from a binary cache.
|
||||
|
||||
- `--graph`\
|
||||
Prints the references graph of the store paths *paths* in the format
|
||||
|
||||
@@ -85,7 +85,7 @@ Most commands in Lix accept the following command-line options:
|
||||
|
||||
- `multiline-with-logs`
|
||||
|
||||
Display the raw logs, with a progress bar and activities each in a new line at the bottom.
|
||||
Displayes the raw logs, with a progress bar and activities each in a new line at the bottom.
|
||||
|
||||
|
||||
- <span id="opt-no-build-output">[`--no-build-output`](#opt-no-build-output)</span> / `-Q`
|
||||
|
||||
@@ -39,28 +39,17 @@ $ nix-shell -A native-clangStdenvPackages
|
||||
|
||||
### Building from the development shell
|
||||
|
||||
Run a clean build and test with `just clean build install test`.
|
||||
|
||||
You can also run the unit tests and integration tests separately:
|
||||
You can build and test Lix with just:
|
||||
|
||||
```bash
|
||||
$ just setup build test-unit
|
||||
$ just install test-integration
|
||||
$ just setup
|
||||
$ just build
|
||||
$ just test --suite=check
|
||||
$ just install
|
||||
$ just test --suite=installcheck
|
||||
```
|
||||
|
||||
Many targets have a `-custom` variant which pass extra arguments to `meson`.
|
||||
For example, to work on both Lix and nix-eval-jobs you can run:
|
||||
|
||||
```
|
||||
$ just setup-custom -Dnix-eval-jobs=enabled
|
||||
$ # or
|
||||
$ mesonFlags=-Dnix-eval-jobs=enabled just setup
|
||||
```
|
||||
|
||||
Note that only targets which don't accept extra arguments can be used when
|
||||
running multiple targets at once; `just setup build` is fine, but `just
|
||||
setup-custom build` is an error. The `test` target is usually the last one to
|
||||
run, so it always accepts extra arguments.
|
||||
(Check and installcheck may both be done after install, allowing you to omit the --suite argument entirely, but this is the order package.nix runs them in.)
|
||||
|
||||
You can also build Lix manually:
|
||||
|
||||
@@ -148,11 +137,10 @@ You can also build Lix for one of the [supported platforms](#platforms).
|
||||
|
||||
Lix can be built for various platforms, as specified in [`flake.nix`]:
|
||||
|
||||
[`flake.nix`]: https://git.lix.systems/lix-project/lix/src/branch/main/flake.nix
|
||||
[`flake.nix`]: https://git.lix.systems/lix-project/lix/lix/branch/main/flake.nix
|
||||
|
||||
- `x86_64-linux`
|
||||
- `x86_64-darwin`
|
||||
- `x86_64-freebsd`
|
||||
- `i686-linux`
|
||||
- `aarch64-linux`
|
||||
- `aarch64-darwin`
|
||||
@@ -229,7 +217,7 @@ Lix uses a string with the following format to identify the *system type* or *pl
|
||||
|
||||
It is set when Lix is compiled for the given system, and determined by [Meson's `host_machine.cpu_family()` and `host_machine.system()` values](https://mesonbuild.com/Reference-manual_builtin_host_machine.html).
|
||||
|
||||
For historic reasons and backward-compatibility, some CPU and OS identifiers are translated from the GNU Autotools naming convention in [`meson.build`](https://git.lix.systems/lix-project/lix/src/branch/main/meson.build) as follows:
|
||||
For historic reasons and backward-compatibility, some CPU and OS identifiers are translated from the GNU Autotools naming convention in [`meson.build`](https://git.lix.systems/lix-project/lix/blob/main/meson.build) as follows:
|
||||
|
||||
| `host_machine.cpu_family()` | Nix |
|
||||
|----------------------------|---------------------|
|
||||
@@ -256,13 +244,13 @@ To build with one of those environments, you can use
|
||||
$ nix build .#nix-ccacheStdenv
|
||||
```
|
||||
|
||||
for <a id="nix-with-flakes">flake-enabled Nix</a>, or
|
||||
for flake-enabled Nix, or
|
||||
|
||||
```console
|
||||
$ nix-build --attr nix-ccacheStdenv
|
||||
```
|
||||
|
||||
for <a id="classic-nix">classic Nix</a>.
|
||||
for classic Nix.
|
||||
|
||||
You can use any of the other supported environments in place of `nix-ccacheStdenv`.
|
||||
|
||||
@@ -463,11 +451,11 @@ The following metadata properties are supported for builtin functions:
|
||||
* `implementation` (optional): a C++ expression specifying the implementation of the builtin.
|
||||
It must be a function of signature `void(EvalState &, PosIdx, Value * *, Value &)`.
|
||||
If not specified, defaults to `prim_${name}`.
|
||||
* `renameInGlobalScope` (optional): whether the definition should be "hidden" in the global scope by prefixing its name with two underscores.
|
||||
* `renameInGlobalScope` (optional): whether the definiton should be "hidden" in the global scope by prefixing its name with two underscores.
|
||||
If not specified, defaults to `true`.
|
||||
* `args` (required): list containing the names of the arguments, as shown in the documentation.
|
||||
All arguments must be listed here since the function arity is derived as the length of this list.
|
||||
* `experimental_feature` (optional): the user-facing name of the experimental feature which needs to be enabled for the builtin function to be available.
|
||||
* `experimental_feature` (optional): the user-facing name of the experimental feature which needs to be enabled for the bultin function to be available.
|
||||
If not specified, no experimental feature is required.
|
||||
|
||||
New builtin function definition files must be added to `lix/libexpr/builtins` and registered in the `builtin_definitions` list in `lix/libexpr/meson.build`.
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
See [File System Object](@docroot@/architecture/file-system-object.md) for details.
|
||||
|
||||
[file system object]: #gloss-store-path
|
||||
[file system object]: #gloss-file-system-object
|
||||
|
||||
- [store object]{#gloss-store-object}
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
links. NARs are generated and unpacked using `nix-store --dump`
|
||||
and `nix-store --restore`.
|
||||
|
||||
- [`∅`]{#gloss-empty-set}
|
||||
- [`∅`]{#gloss-emtpy-set}
|
||||
|
||||
The empty set symbol. In the context of profile history, this denotes a package is not present in a particular version of the profile.
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ paths) are set.
|
||||
|
||||
For example, the following command gets all dependencies of the
|
||||
Pan newsreader, as described by [its
|
||||
Nix expression](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/pa/pan/package.nix):
|
||||
Nix expression](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/newsreaders/pan/default.nix):
|
||||
|
||||
```console
|
||||
$ nix-shell '<nixpkgs>' --attr pan
|
||||
|
||||
@@ -261,7 +261,7 @@ Derivations can declare some infrequently used optional attributes.
|
||||
useful for very trivial derivations (such as `writeText` in Nixpkgs)
|
||||
that are cheaper to build than to substitute from a binary cache.
|
||||
|
||||
You may disable the effects of this attribute by enabling the
|
||||
You may disable the effects of this attibute by enabling the
|
||||
`always-allow-substitutes` configuration option in Lix.
|
||||
|
||||
> **Note**
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
| Logical conjunction (`AND`) | *bool* `&&` *bool* | left | 12 |
|
||||
| Logical disjunction (`OR`) | *bool* <code>\|\|</code> *bool* | left | 13 |
|
||||
| [Logical implication] | *bool* `->` *bool* | none | 14 |
|
||||
| \[Experimental\] [Function piping] | *expr* `\|>` *func* | left | 15 |
|
||||
| \[Experimental\] [Function piping] | *expr* `<\|` *func* | right | 16 |
|
||||
| \[Experimental\] [Function piping] | *expr* |> *func* | left | 15 |
|
||||
| \[Experimental\] [Function piping] | *expr* <| *func* | right | 16 |
|
||||
|
||||
[string]: ./values.md#type-string
|
||||
[path]: ./values.md#type-path
|
||||
|
||||
@@ -164,7 +164,7 @@ Note that lists are only lazy in values, and they are strict in length.
|
||||
|
||||
An attribute set is a collection of name-value-pairs (called *attributes*) enclosed in curly brackets (`{ }`).
|
||||
|
||||
An attribute name can be an identifier or a [string](#type-string).
|
||||
An attribute name can be an identifier or a [string](#string).
|
||||
An identifier must start with a letter (`a-z`, `A-Z`) or underscore (`_`), and can otherwise contain letters (`a-z`, `A-Z`), numbers (`0-9`), underscores (`_`), apostrophes (`'`), or dashes (`-`).
|
||||
|
||||
> *name* = *identifier* | *string* \
|
||||
|
||||
@@ -126,7 +126,7 @@ $ nix-env --install --attr nixpkgs.subversion
|
||||
```
|
||||
|
||||
will install the package called `subversion` from `nixpkgs` channel (which is, of course, the
|
||||
[Subversion version management system](https://subversion.apache.org/)).
|
||||
[Subversion version management system](http://subversion.tigris.org/)).
|
||||
|
||||
> **Note**
|
||||
>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
- The `discard-references` feature has been stabilized.
|
||||
This means that the
|
||||
`unsafeDiscardReferences`
|
||||
[unsafeDiscardReferences](@docroot@/contributing/experimental-features.md#xp-feature-discard-references)
|
||||
attribute is no longer guarded by an experimental flag and can be used
|
||||
freely.
|
||||
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
# Lix 2.92 "Bombe glacée" (2025-01-18)
|
||||
|
||||
|
||||
# Lix 2.92.0 (2025-01-18)
|
||||
|
||||
## Breaking Changes
|
||||
- Deprecated language features [fj#437](https://git.lix.systems/lix-project/lix/issues/437) [#861](https://github.com/NixOS/nix/issues/861) [cl/1785](https://gerrit.lix.systems/c/lix/+/1785) [cl/1736](https://gerrit.lix.systems/c/lix/+/1736) [cl/1735](https://gerrit.lix.systems/c/lix/+/1735) [cl/1744](https://gerrit.lix.systems/c/lix/+/1744) [cl/2206](https://gerrit.lix.systems/c/lix/+/2206)
|
||||
|
||||
A system for deprecation (and then the planned removal) of undesired language features has been put into place.
|
||||
It is controlled via feature flags much like experimental features, except that the deprecations are enabled default,
|
||||
and can be disabled via the flags for backwards compatibility (opt-out with `--extra-deprecated-features` or the Nix configuration file).
|
||||
|
||||
- `url-literals`: **URL literals** have long been obsolete and discouraged of use, and now they are officially deprecated.
|
||||
This means that all URLs must be properly put within quotes like all other strings.
|
||||
- `rec-set-overrides`: **__overrides** is an old arcane syntax which has not been in use for more than a decade.
|
||||
It is soft-deprecated with a warning only, with the plan to turn that into an error in a future release.
|
||||
- `ancient-let`: **The old `let` syntax** (`let { body = …; … }`) is soft-deprecated with a warning as well. Use the regular `let … in` instead.
|
||||
- `shadow-internal-symbols`: Arithmetic expressions like `5 - 3` internally expand to `__sub 5 3`, where `__sub` maps to a subtraction builtin. Shadowing such a symbols would affect the evaluation of such operations, but in a very inconsistent way, and is therefore deprecated now. **Affected symbols are:** `__sub`, `__mul`, `__div` and `__lessThan`. Note that these symbols may still be used as variable names as long as they do not shadow internal operations, so e.g. `let __sub = x: y: x + y; in __sub 3 5` remains valid code.
|
||||
- **Call to action:** If you have any use cases or workflows that depend on being able to override the `__nixPath` and `__findFile` symbols, please reach out to us. We want to eventually deprecate overriding these as well, and need input on how to design a better alternative.
|
||||
|
||||
Many thanks to [piegames](https://git.lix.systems/piegames) and [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
- transfers no longer allow arbitrary url schemas [cl/2106](https://gerrit.lix.systems/c/lix/+/2106)
|
||||
|
||||
Lix no longer allows transfers using arbitrary url schemas. Only `http://`, `https://`, `ftp://`, `ftps://`, and `file://` urls are supported going forward. This affects `builtins.fetchurl`, `<nix/fetchurl.nix>`, transfers to and from binary caches, and all other uses of the internal file transfer code. Flake inputs using multi-protocol schemas (e.g. `git+ssh`) are not affected as those use external utilities to transfer data.
|
||||
|
||||
The `s3://` scheme is not affected at all by this change and continues to work if S3 support is built into Lix.
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
- Removing the `.` default argument passed to the `nix fmt` formatter [#11438](https://github.com/NixOS/nix/pull/11438) [cl/1902](https://gerrit.lix.systems/c/lix/+/1902)
|
||||
|
||||
The underlying formatter no longer receives the ". " default argument when `nix fmt` is called with no arguments.
|
||||
|
||||
This change was necessary as the formatter wasn't able to distinguish between
|
||||
a user wanting to format the current folder with `nix fmt .` or the generic
|
||||
`nix fmt`.
|
||||
|
||||
The default behaviour is now the responsibility of the formatter itself, and
|
||||
allows tools such as treefmt to format the whole tree instead of only the
|
||||
current directory and below.
|
||||
|
||||
This may cause issues with some formatters: nixfmt, nixpkgs-fmt and alejandra currently format stdin when no arguments are passed.
|
||||
|
||||
Here is a small wrapper example that will restore the previous behaviour for such a formatter:
|
||||
|
||||
```nix
|
||||
{
|
||||
outputs = { self, nixpkgs, systems }:
|
||||
let
|
||||
eachSystem = nixpkgs.lib.genAttrs (import systems) (system: nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
formatter = eachSystem (pkgs:
|
||||
pkgs.writeShellScriptBin "formatter" ''
|
||||
if [[ $# = 0 ]]; then set -- .; fi
|
||||
exec "${pkgs.nixfmt-rfc-style}/bin/nixfmt" "$@"
|
||||
'');
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Many thanks to [zimbatm](https://github.com/zimbatm) for this.
|
||||
|
||||
## Features
|
||||
- Relative and tilde paths in configuration [fj#482](https://git.lix.systems/lix-project/lix/issues/482) [cl/1851](https://gerrit.lix.systems/c/lix/+/1851) [cl/1863](https://gerrit.lix.systems/c/lix/+/1863) [cl/1864](https://gerrit.lix.systems/c/lix/+/1864)
|
||||
|
||||
[Configuration settings](@docroot@/command-ref/conf-file.md) can now refer to
|
||||
files with paths relative to the file they're written in or relative to your
|
||||
home directory (with `~/`).
|
||||
|
||||
This makes settings like
|
||||
[`repl-overlays`](@docroot@/command-ref/conf-file.md#conf-repl-overlays) and
|
||||
[`secret-key-files`](@docroot@/command-ref/conf-file.md#conf-repl-overlays)
|
||||
much easier to set, especially if you'd like to refer to files in an existing
|
||||
dotfiles repo cloned into your home directory.
|
||||
|
||||
If you put `repl-overlays = repl.nix` in your `~/.config/nix/nix.conf`, it'll
|
||||
load `~/.config/nix/repl.nix`. Similarly, you can set `repl-overlays =
|
||||
~/.dotfiles/repl.nix` to load a file relative to your home directory.
|
||||
|
||||
Configuration files can also
|
||||
[`include`](@docroot@/command-ref/conf-file.md#file-format) paths relative to
|
||||
your home directory.
|
||||
|
||||
Only user configuration files (like `$XDG_CONFIG_HOME/nix/nix.conf` or the
|
||||
files listed in `$NIX_USER_CONF_FILES`) can use tilde paths relative to your
|
||||
home directory. Configuration listed in the `$NIX_CONFIG` environment variable
|
||||
may not use relative paths.
|
||||
|
||||
Many thanks to [wiggles](https://git.lix.systems/rbt) for this.
|
||||
|
||||
## Improvements
|
||||
- Improved error messages for bad attr paths [cl/2277](https://gerrit.lix.systems/c/lix/+/2277) [cl/2280](https://gerrit.lix.systems/c/lix/+/2280)
|
||||
|
||||
Lix now includes much more detail when a bad attribute path is accessed at the command line:
|
||||
|
||||
```
|
||||
» nix eval -f '<nixpkgs>' lixVersions.lix_2_92
|
||||
error: attribute 'lix_2_92' in selection path 'lixVersions.lix_2_92' not found
|
||||
Did you mean one of lix_2_90 or lix_2_91?
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
» nix eval --impure -f '<nixpkgs>' lixVersions.lix_2_92
|
||||
error: attribute 'lix_2_92' in selection path 'lixVersions.lix_2_92' not found inside path 'lixVersions', whose contents are: { __unfix__ = «lambda @ /nix/store/hfz1qqd0z8amlgn8qwich1dvkmldik36-source/lib/fixed-points.nix:
|
||||
447:7»; buildLix = «thunk»; extend = «thunk»; latest = «thunk»; lix_2_90 = «thunk»; lix_2_91 = «thunk»; override = «thunk»; overrideDerivation = «thunk»; recurseForDerivations = true; stable = «thunk»; }
|
||||
Did you mean one of lix_2_90 or lix_2_91?
|
||||
```
|
||||
|
||||
This should avoid some unnecessary trips to the repl or to the debugger by giving some information about the value being selected on that was unexpected.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- Small error message improvements [cl/2185](https://gerrit.lix.systems/c/lix/+/2185) [cl/2187](https://gerrit.lix.systems/c/lix/+/2187)
|
||||
|
||||
When an attribute selection fails, the error message now correctly points to the attribute in the chain that failed instead of at the beginning of the entire chain.
|
||||
```diff
|
||||
error: attribute 'x' missing
|
||||
- at /pwd/lang/eval-fail-remove.nix:4:3:
|
||||
+ at /pwd/lang/eval-fail-remove.nix:4:29:
|
||||
3| in
|
||||
4| (removeAttrs attrs ["x"]).x
|
||||
- | ^
|
||||
+ | ^
|
||||
5|
|
||||
```
|
||||
|
||||
Failed asserts don't print the failed assertion expression anymore in the error message. That code was buggy and the information was redundant anyways, given that the error position already more accurately shows what exactly failed.
|
||||
|
||||
Many thanks to [piegames](https://git.lix.systems/piegames) for this.
|
||||
- Improvements to interactive flake config [cl/2066](https://gerrit.lix.systems/c/lix/+/2066)
|
||||
|
||||
If `accept-flake-config` is set to `ask` and a `flake.nix` defines `nixConfig`,
|
||||
Lix will ask on the CLI which of these settings should be used for the command.
|
||||
|
||||
Now, it's possible to answer with `N` (as opposed to `n` to only reject the setting
|
||||
that is asked for) to reject _all untrusted_ entries from the flake's `nixConf`
|
||||
section.
|
||||
|
||||
Many thanks to [ma27](https://git.lix.systems/ma27) for this.
|
||||
- `nix --version` now shows details about the installation by default [fj#620](https://git.lix.systems/lix-project/lix/issues/620) [cl/2365](https://gerrit.lix.systems/c/lix/+/2365)
|
||||
|
||||
This happened with `nix-env --version` by default, but due to [oddities around the nix3 CLI's verbosity](https://gerrit.lix.systems/c/lix/+/1370), it used to be `nix --verbose --version`.
|
||||
|
||||
No longer:
|
||||
|
||||
```
|
||||
$ nix --version
|
||||
nix (Lix, like Nix) 2.92.0-dev-pre20250117-0d14c2b
|
||||
System type: x86_64-linux
|
||||
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
|
||||
Features: gc, signed-caches
|
||||
System configuration file: /etc/nix/nix.conf
|
||||
User configuration files: /home/jade/.config/nix/nix.conf:/etc/xdg/nix/nix.conf
|
||||
Store directory: /nix/store
|
||||
State directory: /nix/var/nix
|
||||
Data directory: /nix/store/rliimcnqkplrqdgm4z6yqclpr6c32wh6-lix-2.92.0-dev-pre20250117-0d14c2b/share
|
||||
```
|
||||
|
||||
Many thanks to [just1602](https://git.lix.systems/just1602) for this.
|
||||
- `nix repl` correctly tab-completes attribute names that require quotes [cl/1783](https://gerrit.lix.systems/c/lix/+/1783)
|
||||
|
||||
The REPL (`nix repl`) now includes quotes as part of attribute names while completing with `<TAB>`,
|
||||
if necessary. For example, attribute names like `"hello@example.com"` or `"hello world"` would
|
||||
be suggested without quotes, resulting in invalid syntax.
|
||||
|
||||
Many thanks to [ian-h-chamberlain](https://git.lix.systems/ian-h-chamberlain) for this.
|
||||
- Reproducibility check builds now report all differing outputs [cl/2069](https://gerrit.lix.systems/c/lix/+/2069)
|
||||
|
||||
`nix-build --check` allows rerunning the build of an already-built derivation to check that it produces the same output again.
|
||||
|
||||
If a multiple-output derivation with impure behaviour is built with `--check`, only the first output would be shown in the resulting error message (and kept for comparison):
|
||||
|
||||
```
|
||||
error: derivation '/nix/store/4spy3nz1661zm15gkybsy1h5f36aliwx-python3.11-test-1.0.0.drv' may not be deterministic: output '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test
|
||||
-1.0.0-dist' differs from '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test-1.0.0-dist.check'
|
||||
```
|
||||
|
||||
Now, all differing outputs are kept and reported:
|
||||
```
|
||||
error: derivation '4spy3nz1661zm15gkybsy1h5f36aliwx-python3.11-test-1.0.0.drv' may not be deterministic: outputs differ
|
||||
output differs: output '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test-1.0.0-dist' differs from '/nix/store/ccqcp01zg18wp9iadzmzimqzdi3ll08d-python3.11-test-1.0.0-dist.check'
|
||||
output differs: output '/nix/store/yl59v08356i841c560alb0zmk7q16klb-python3.11-test-1.0.0' differs from '/nix/store/yl59v08356i841c560alb0zmk7q16klb-python3.11-test-1.0.0.check'
|
||||
```
|
||||
|
||||
Many thanks to [lheckemann](https://git.lix.systems/lheckemann) for this.
|
||||
- Some Lix crashes now produce reporting instructions and a stack trace, then abort [cl/1854](https://gerrit.lix.systems/c/lix/+/1854)
|
||||
|
||||
Lix, being a C++ program, can crash in a few kinds of ways.
|
||||
It can obviously do a memory access violation, which will generate a core dump and thus be relatively debuggable.
|
||||
But, worse, it could throw an unhandled exception, and, in the past, we would just show the message but not where it comes from, in spite of this always being a bug, since we expect all such errors to be translated to a Lix specific error.
|
||||
Now the latter kind of bug should print reporting instructions, a rudimentary stack trace and (depending on system configuration) generate a core dump.
|
||||
|
||||
Sample output:
|
||||
|
||||
```
|
||||
Lix crashed. This is a bug. We would appreciate if you report it along with what caused it at https://git.lix.systems/lix-project/lix/issues with the following information included:
|
||||
|
||||
Exception: std::runtime_error: test exception
|
||||
Stack trace:
|
||||
0# nix::printStackTrace() in /home/jade/lix/lix3/build/lix/nix/../libutil/liblixutil.so
|
||||
1# 0x000073C9862331F2 in /home/jade/lix/lix3/build/lix/nix/../libmain/liblixmain.so
|
||||
2# 0x000073C985F2E21A in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++.so.6
|
||||
3# 0x000073C985F2E285 in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++.so.6
|
||||
4# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /home/jade/lix/lix3/build/lix/nix/../libmain/liblixmain.so
|
||||
...
|
||||
```
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- Add a `temp-dir` setting to set the temporary directory location [#7731](https://github.com/NixOS/nix/issues/7731) [#8995](https://github.com/NixOS/nix/issues/8995) [fj#112](https://git.lix.systems/lix-project/lix/issues/112) [fj#253](https://git.lix.systems/lix-project/lix/issues/253) [cl/2103](https://gerrit.lix.systems/c/lix/+/2103)
|
||||
|
||||
[`temp-dir`](@docroot@/command-ref/conf-file.md#conf-temp-dir) can now be set in the Nix
|
||||
configuration to change the temporary directory. This can be used to relocate all temporary files
|
||||
to another filesystem without affecting the `TMPDIR` env var inherited by interactive
|
||||
`nix-shell`/`nix shell` shells or `nix run` commands.
|
||||
|
||||
Also on macOS, the `TMPDIR` env var is no longer unset for interactive shells when pointing
|
||||
to a per-session `/var/folders/` directory.
|
||||
|
||||
Many thanks to [lilyball](https://git.lix.systems/lilyball) for this.
|
||||
|
||||
## Fixes
|
||||
- Build failures caused by `allowSubstitutes = false` while being the wrong system now produce a decent error [fj#484](https://git.lix.systems/lix-project/lix/issues/484) [cl/1841](https://gerrit.lix.systems/c/lix/+/1841)
|
||||
|
||||
Nix allows derivations to set `allowSubstitutes = false` in order to force them to be built locally without querying substituters for them.
|
||||
This is useful for derivations that are very fast to build (especially if they produce large output).
|
||||
However, this can shoot you in the foot if the derivation *has* to be substituted such as if the derivation is for another architecture, which is what `--always-allow-substitutes` is for.
|
||||
|
||||
Perhaps such derivations that are known to be impossible to build locally should ignore `allowSubstitutes` (irrespective of remote builders) in the future, but this at least reports the failure and solution directly.
|
||||
|
||||
```
|
||||
$ nix build -f fail.nix
|
||||
error: a 'unicornsandrainbows-linux' with features {} is required to build '/nix/store/...-meow.drv', but I am a 'x86_64-linux' with features {...}
|
||||
|
||||
Hint: the failing derivation has allowSubstitutes set to false, forcing it to be built rather than substituted.
|
||||
Passing --always-allow-substitutes to force substitution may resolve this failure if the path is available in a substituter.
|
||||
```
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- `Alt+Left` and `Alt+Right` go back/forwards by words in `nix repl` [fj#501](https://git.lix.systems/lix-project/lix/issues/501) [cl/1883](https://gerrit.lix.systems/c/lix/+/1883)
|
||||
|
||||
`nix repl` now recognizes `Alt+Left` and `Alt+Right` for navigating by words
|
||||
when entering input in `nix repl` on more terminals/platforms.
|
||||
|
||||
Many thanks to [wiggles](https://git.lix.systems/rbt) for this.
|
||||
- Ctrl-C stops Nix commands much more reliably and responsively [#7245](https://github.com/NixOS/nix/issues/7245) [fj#393](https://git.lix.systems/lix-project/lix/issues/393) [#11618](https://github.com/NixOS/nix/pull/11618) [cl/2016](https://gerrit.lix.systems/c/lix/+/2016)
|
||||
|
||||
CTRL-C will now stop Nix commands much more reliably and responsively. While
|
||||
there are still some cases where a Nix command can be slow or unresponsive
|
||||
following a `SIGINT` (please report these as issues!), the vast majority of
|
||||
signals will now cause the Nix command to quit quickly and consistently.
|
||||
|
||||
Many thanks to [Robert Hensing](https://github.com/roberth) and [wiggles](https://git.lix.systems/rbt) for this.
|
||||
- restore backwards-compatibility of `builtins.fetchGit` with Nix 2.3 [#5291](https://github.com/NixOS/nix/issues/5291) [#5128](https://github.com/NixOS/nix/issues/5128)
|
||||
|
||||
Compatibility with `builtins.fetchGit` from Nix 2.3 has been restored as follows:
|
||||
|
||||
* Until now, each `ref` was prefixed with `refs/heads` unless it starts with `refs/` itself.
|
||||
|
||||
Now, this is not done if the `ref` looks like a commit hash.
|
||||
|
||||
* Specifying `builtins.fetchGit { ref = "a-tag"; /* … */ }` was broken because `refs/heads` was appended.
|
||||
|
||||
Now, the fetcher doesn't turn a ref into `refs/heads/ref`, but into `refs/*/ref`. That way,
|
||||
the value in `ref` can be either a tag or a branch.
|
||||
|
||||
* The ref resolution happens the same way as in git:
|
||||
|
||||
* If `refs/ref` exists, it's used.
|
||||
* If a tag `refs/tags/ref` exists, it's used.
|
||||
* If a branch `refs/heads/ref` exists, it's used.
|
||||
|
||||
Many thanks to [ma27](https://git.lix.systems/ma27) for this.
|
||||
- Flakes/restrict-eval no longer allow reading contents of impure paths
|
||||
|
||||
Flakes and `--restrict-eval` now correctly restrict access to paths as intended.
|
||||
In prior versions since at least 2.18, `nix eval --raw .#lol` for the following flake didn't throw an error and acted as if `--impure` was passed.
|
||||
|
||||
Thanks to the person who reported this for telling us about it.
|
||||
This was handled as a low-severity security bug, but is not a violation of the [documented security model](../installation/multi-user.md) as untrusted Nix code should be assumed to have the privileges of the user running the evaluator.
|
||||
To report a security bug, email a report to `security at lix dot systems`.
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {};
|
||||
outputs = {...}: {
|
||||
lol = builtins.readFile "${/etc/passwd}";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
- HTTP proxy environment variables are now respected for S3 binary cache stores [fj#433](https://git.lix.systems/lix-project/lix/issues/433) [cl/1788](https://gerrit.lix.systems/c/lix/+/1788)
|
||||
|
||||
Due to "legacy reasons" (according to the AWS C++ SDK docs), the AWS SDK ignores system proxy configuration by default.
|
||||
We turned it back on.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- Fix potential store corruption with auto-optimise-store [#7273](https://github.com/NixOS/nix/issues/7273) [cl/2100](https://gerrit.lix.systems/c/lix/+/2100)
|
||||
|
||||
Optimising store paths (and other operations involving temporary files) no longer use `random(3)`
|
||||
to generate filenames. On darwin systems this was observed to potentially cause store corruption
|
||||
when using [`auto-optimise-store`](@docroot@/command-ref/conf-file.md#conf-auto-optimise-store),
|
||||
though this corruption was possible on any system whose `random(3)` does not have locking around
|
||||
the global state.
|
||||
|
||||
Many thanks to [lilyball](https://git.lix.systems/lilyball) for this.
|
||||
- Change `nix-build -o ""` to behave like `--no-out-link` [cl/2103](https://gerrit.lix.systems/c/lix/+/2103)
|
||||
|
||||
[`nix-build`](@docroot@/command-ref/nix-build.md) now treats <code>[--out-link](@docroot@/command-ref/nix-build.md#opt-out-link) ''</code>
|
||||
the same as [`--no-out-link`](@docroot@/command-ref/nix-build.md#opt-no-out-link). This matches
|
||||
[`nix build`](@docroot@/command-ref/new-cli/nix3-build.md) behavior. Previously when building the default output it
|
||||
would have resulted in throwing an error saying the current working directory already exists, and when building any
|
||||
other output it would have resulted in a symlink starting with a hyphen such as `-doc`, which is a footgun for
|
||||
terminal commands.
|
||||
|
||||
Many thanks to [lilyball](https://git.lix.systems/lilyball) for this.
|
||||
- Ignore broken `/etc/ssl/certs/ca-certificates.crt` symlink [fj#560](https://git.lix.systems/lix-project/lix/issues/560) [cl/2144](https://gerrit.lix.systems/c/lix/+/2144)
|
||||
|
||||
[`ssl-cert-file`](@docroot@/command-ref/conf-file.md#conf-ssl-cert-file) now checks its default
|
||||
value for a broken symlink before using it. This fixes a problem on macOS where uninstalling
|
||||
nix-darwin may leave behind a broken symlink at `/etc/ssl/certs/ca-certificates.crt` that was
|
||||
stopping Lix from using the cert at `/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt`.
|
||||
|
||||
Many thanks to [lilyball](https://git.lix.systems/lilyball) for this.
|
||||
- `<nix/fetchurl.nix>` now uses TLS verification [#11585](https://github.com/NixOS/nix/pull/11585)
|
||||
|
||||
Previously `<nix/fetchurl.nix>` did not do TLS verification. This was because the Nix sandbox in the past did not have access to TLS certificates, and Nix checks the hash of the fetched file anyway. However, this can expose authentication data from `netrc` and URLs to man-in-the-middle attackers. In addition, Nix now in some cases (such as when using impure derivations) does *not* check the hash. Therefore we have now enabled TLS verification. This means that downloads by `<nix/fetchurl.nix>` will now fail if you're fetching from a HTTPS server that does not have a valid certificate.
|
||||
|
||||
`<nix/fetchurl.nix>` is also known as the builtin derivation builder `builtin:fetchurl`. It's not to be confused with the evaluation-time function `builtins.fetchurl`, which was not affected by this issue.
|
||||
|
||||
Many thanks to [Eelco Dolstra](https://github.com/edolstra) for this.
|
||||
|
||||
## Packaging
|
||||
- readline support removed [cl/1885](https://gerrit.lix.systems/c/lix/+/1885)
|
||||
|
||||
Support for building Lix with [`readline`][readline] instead of
|
||||
[`editline`][editline] has been removed. `readline` support hasn't worked for a
|
||||
long time (attempting to use it would lead to build errors) and would make Lix
|
||||
subject to the GPL if it did work. In the future, we're hoping to replace
|
||||
`editline` with [`rustyline`][rustyline] for improved ergonomics in the `nix
|
||||
repl`.
|
||||
|
||||
[readline]: https://en.wikipedia.org/wiki/GNU_Readline
|
||||
[editline]: https://github.com/troglobit/editline
|
||||
[rustyline]: https://github.com/kkawakam/rustyline
|
||||
|
||||
Many thanks to [wiggles](https://git.lix.systems/rbt) for this.
|
||||
|
||||
## Development
|
||||
- Includes are now qualified with library name everywhere [cl/2178](https://gerrit.lix.systems/c/lix/+/2178) [cl/2362](https://gerrit.lix.systems/c/lix/+/2362)
|
||||
|
||||
The Lix includes have all been rearranged to be of the form `"lix/libexpr/foo.hh"` instead of `"foo.hh"`.
|
||||
This was already supported externally for a migration period, but it is now being applied to all the internal usages within Lix itself.
|
||||
The goal of this change is to both clarify where a file is from and to avoid polluting global include paths with things like `config.h` that might conflict with other projects.
|
||||
|
||||
Lix 2.92 removes support for the old `"foo.hh"` include form either internally or externally (that is, via pkg-config for things linking to Lix).
|
||||
|
||||
For other details, see the release notes of Lix 2.90.0, under "Rename all the libraries" in Breaking Changes.
|
||||
|
||||
To fix an external project with sources in `src` which has a separate build directory (such that headers are in `../src` relative to where the compiler is running), use a checkout of Lix 2.91 to run the following:
|
||||
|
||||
```
|
||||
lix_root=$HOME/lix
|
||||
(cd $lix_root && nix develop -c 'meson setup build && ninja -C build subprojects/lix-clang-tidy/liblix-clang-tidy.so')
|
||||
run-clang-tidy -checks='-*,lix-fixincludes' -load=$lix_root/build/subprojects/lix-clang-tidy/liblix-clang-tidy.so -p build/ -header-filter '\.\./src/.*\.h' -fix src
|
||||
```
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- The beginnings of a new pytest-based functional test suite [cl/2036](https://gerrit.lix.systems/c/lix/+/2036) [cl/2037](https://gerrit.lix.systems/c/lix/+/2037)
|
||||
|
||||
The existing integration/functional test suite is based on a large volume of shell scripts.
|
||||
This often makes it somewhat challenging to debug at the best of times.
|
||||
The goal of the pytest test suite is to make tests have more obvious dependencies on files and to make tests more concise and easier to write, as well as making new testing methods like snapshot testing easy.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- Dependency on monolithic coreutils removed [cl/2108](https://gerrit.lix.systems/c/lix/+/2108)
|
||||
|
||||
Previously, the build erroneously depended on a `coreutils` binary, which requires `coreutils` to be built with a specific configuration. This was only used in one test and was not required to be a single binary. This dependency is removed now.
|
||||
|
||||
Many thanks to [Vigress](https://git.lix.systems/vigress8) for this.
|
||||
- All Lix threads are named [cl/2210](https://gerrit.lix.systems/c/lix/+/2210)
|
||||
|
||||
Lix now sets thread names on all of its secondary threads, which will make debugger usage slightly nicer and easier.
|
||||
|
||||
```
|
||||
(gdb) info thr
|
||||
Id Target Id Frame
|
||||
* 1 LWP 3719283 "nix-daemon" 0x00007e558587da0f in accept ()
|
||||
from target:/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libc.so.6
|
||||
2 LWP 3719284 "signal handler" 0x00007e55857b2bea in sigtimedwait ()
|
||||
from target:/nix/store/c10zhkbp6jmyh0xc5kd123ga8yy2p4hk-glibc-2.39-52/lib/libc.so.6
|
||||
```
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
- Set `X-GitHub-Api-Version` header [fj#255](https://git.lix.systems/lix-project/lix/issues/255) [cl/1925](https://gerrit.lix.systems/c/lix/+/1925)
|
||||
|
||||
Sets the `X-GitHub-Api-Version` header to `2022-11-28` for calls to the
|
||||
GitHub API.
|
||||
This follows the later version as per
|
||||
https://docs.github.com/en/rest/about-the-rest-api/api-versions?apiVersion=2022-11-28.
|
||||
|
||||
This affected the check on whether to use the API versus unauthenticated
|
||||
calls as well, given the headers would no longer be empty if the
|
||||
authentication token were missing.
|
||||
The workaround to this used here is to use a check similar to an existing
|
||||
check for the token.
|
||||
|
||||
In the current implementation, headers are (still) similarly sent to
|
||||
non-authenticated as well as GitHub on-prem calls.
|
||||
For what it's worth, manual curl calls with such a header seemed to
|
||||
break nor unauthenticated calls nor ones to the github.com API.
|
||||
|
||||
Many thanks to [kiara](https://github.com/KiaraGrouwstra) for this.
|
||||
|
||||
## Miscellany
|
||||
- Drop support for `xz` and `bzip2` Content-Encoding [cl/2134](https://gerrit.lix.systems/c/lix/+/2134)
|
||||
|
||||
Lix no longer supports the non-standard HTTP Content-Encoding values `xz` and `bzip2`.
|
||||
We do not expect this to cause any problems in practice since these encodings *aren't*
|
||||
standard, and any server delivering them anyway without being asked to is already well
|
||||
and truly set on the path of causing inexplicable client breakages.
|
||||
|
||||
Lix's ability to decompress files compressed with `xz` or `bzip2` is unaffected. We're
|
||||
only bringing Lix more in line with the HTTP standard; all post-transfer data handling
|
||||
remains as it was before.
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
@@ -1,715 +0,0 @@
|
||||
# Lix 2.93 "Bici Bici" (2025-05-09)
|
||||
|
||||
|
||||
# Lix 2.93.0 (2025-05-09)
|
||||
## Breaking Changes
|
||||
|
||||
- more deprecated features
|
||||
|
||||
This release cycle features a new batch of deprecated (anti-)features.
|
||||
You can opt in into the old behavior with `--extra-deprecated-features` or any equivalent configuration option.
|
||||
|
||||
- `cr-line-endings`: Current handling of CR (`\r`) or CRLF (`\r\n`) line endings in Nix is inconsistent and broken, and will lead to unexpected evaluation results with certain strings. Given that fixing the semantics might silently alter the evaluation result of derivations, the only option at the moment is to disallow them altogether. More proper support for CRLF is planned to be added back again in the future. Until then, all files must use `\n` exclusively.
|
||||
- `nul-bytes`: Currently the Nix grammar allows NUL bytes (`\0`) in strings, and thus indirectly also in identifiers. Unfortunately, several core parts of the code base still work with NUL-terminated strings and cannot easily be migrated. Also note that it is still possible to introduce NUL bytes and thus problematic behavior via other means, those are tracked separately.
|
||||
|
||||
Many thanks to [piegames](https://git.lix.systems/piegames) and [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
- Removal of the `recursive-nix` experimental feature [fj#767](https://git.lix.systems/lix-project/lix/issues/767) [cl/2872](https://gerrit.lix.systems/c/lix/+/2872)
|
||||
|
||||
The `recursive-nix` experimental feature and all associated code have been removed.
|
||||
|
||||
`recursive-nix` enabled running Nix operations (like evaluations and builds) *inside* a derivation builder. This worked by spawning a temporary Nix daemon socket within the build environment, allowing the derivation to emit outputs that appeared in the outer store. This was primarily used to prototype **dynamic derivations** (dyndrvs), where build plans are generated on-the-fly during a build.
|
||||
|
||||
However, this approach introduced critical issues:
|
||||
|
||||
- It entrenched the legacy Nix daemon protocol as part of the derivation ABI, which is a blocker for future stabilization.
|
||||
- It imposed tight coupling between sandbox setup code and knowledge of Nix internals, complicating refactoring and long-term maintenance.
|
||||
- It was never intended to be the final design for dynamic derivations. The original Nix implementation team, who are leading dyndrv development, have agreed it will be replaced (likely via `varlink` or similar) before any stabilization.
|
||||
- There is currently no known usage of `recursive-nix` on `lix` or elsewhere **in production**.
|
||||
|
||||
If you're using `recursive-nix` for something niche or experimental, we'd love to hear from you on the RFD issue.
|
||||
You can still run `nix` inside a builder manually if needed — including with isolated user namespaces and fake stores — but the special daemon-handshake machinery is gone.
|
||||
|
||||
This removal unblocks several important internal cleanups.
|
||||
|
||||
Many thanks to [Raito Bezarius](https://git.lix.systems/raito) for this.
|
||||
|
||||
- Flake inputs/`builtins.fetchTree` invocations with `type = "file"` now have consistent (but different from previous versions) resulting paths [fj#750](https://git.lix.systems/lix-project/lix/issues/750) [cl/2864](https://gerrit.lix.systems/c/lix/+/2864)
|
||||
|
||||
Previously `fetchTree { type = "file"; url = "...", narHash = "sha256-..."; }` could return a different result depending on whether someone has run `nix store add-path --name source ...` on a path with the same `narHash` as the flake input/`fetchTree` invocation (or if such a path exists in an accessible binary cache).
|
||||
|
||||
In the past `type = "file"` flake inputs were, in contrast to all other flake inputs, hashed in *flat* hash mode rather than *recursive* hash mode.
|
||||
The difference between the two is that *flat* mode hashes are just what you get from `sha256sum` of a single file, whereas *recursive* hashes are the SHA256 sum of a NAR (Nix ARchive, a deterministic tarball-like format) of a file tree.
|
||||
|
||||
Much of flakes assumes that everything is recursive-hashed including `nix flake archive`, substitution of flake inputs from binary caches, and more, which led to the substitution path code being taken if such a path is present, yielding a different store path non-deterministically.
|
||||
|
||||
To fix this non-deterministic evaluation bug, we needed to break derivation hash stability, so some Nix evaluations now produce different results than previous versions of Lix.
|
||||
Lix now has consistent behaviour with CppNix 2.24 with respect to `file` flake inputs: they are *always* recursively hashed.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Builders are always started in a fresh cgroup namespace [cl/1996](https://gerrit.lix.systems/c/lix/+/1996)
|
||||
|
||||
If you haven't enabled the experimental `cgroups` feature, Nix previously launched builder processes in new namespaces but did not create new cgroup namespaces. As a result, derivations could access and observe the parent cgroup namespace.
|
||||
|
||||
Although this update introduces a breaking change, it ensures that all derivations now start in a fresh cgroup namespace by default. This reduces potential impurities observable within the sandbox, improving the likelihood of reproducible builds across different environments.
|
||||
|
||||
Many thanks to [Raito Bezarius](https://git.lix.systems/raito) for this.
|
||||
|
||||
- `nix-instantiate --parse` outputs json [fj#487](https://git.lix.systems/lix-project/lix/issues/487) [nix#11124](https://github.com/NixOS/nix/issues/11124) [nix#4726](https://github.com/NixOS/nix/issues/4726) [nix#3077](https://github.com/NixOS/nix/issues/3077) [cl/2190](https://gerrit.lix.systems/c/lix/+/2190)
|
||||
|
||||
`nix-instantiate --parse` does not print out the AST in a Nix-like format anymore.
|
||||
Instead, it now prints a JSON representation of the internal expression tree.
|
||||
Tooling should not rely on the stdout of `nix-instantiate --parse`.
|
||||
|
||||
We've done our best to ensure that the new behavior is as compatible with the old one as possible.
|
||||
If you depend on the old behavior in ways that are not covered anymore or are otherwise negatively affected by this change,
|
||||
then please reach out so that we can find a sustainable solution together.
|
||||
|
||||
Many thanks to [piegames](https://git.lix.systems/piegames) and [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
- Remove experimental repl-flake [gh#10103](https://github.com/NixOS/nix/issues/10103) [fj#557](https://git.lix.systems/lix-project/lix/issues/557) [gh#10299](https://github.com/NixOS/nix/pull/10299) [cl/2147](https://gerrit.lix.systems/c/lix/+/2147)
|
||||
|
||||
The `repl-flake` experimental feature flag has been removed, its functionality is now the default when `flakes` experimental feature is active. The `nix repl` command now works like the rest of the new CLI in that `nix repl {path}` now tries to load a flake at `{path}` (or fails if the `flakes` experimental feature isn't enabled).
|
||||
|
||||
Many thanks to [Jonathan De Troye](https://github.com/detroyejr) and [KFears](https://git.lix.systems/kfearsoff) for this.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- `lix foo` now invokes `lix-foo` from PATH [cl/2119](https://gerrit.lix.systems/c/lix/+/2119)
|
||||
|
||||
Lix introduces the ability to extend the Nix command line by adding custom
|
||||
binaries to the `PATH`, similar to how Git integrates with other tools. This
|
||||
feature allows developers and end users to enhance their workflow by
|
||||
integrating additional functionalities directly into the Nix CLI.
|
||||
|
||||
#### Examples
|
||||
|
||||
For example, a user can create a custom deployment tool, `lix-deploy-tool`, and
|
||||
place it in their `PATH`. This allows them to execute `lix deploy-tool`
|
||||
directly from the command line, streamlining the process of deploying
|
||||
applications without needing to switch contexts or use separate commands.
|
||||
|
||||
#### Limitations
|
||||
|
||||
For now, autocompletion is supported to discover new custom commands, but the
|
||||
documentation will not render them. Argument autocompletion of the custom
|
||||
command is not supported either.
|
||||
|
||||
This is also locked behind a new experimental feature called
|
||||
`lix-custom-sub-commands` to enable developing all the required features.
|
||||
|
||||
Only the top-level `lix` command can be extended, this is an artificial
|
||||
limitation for the time being until we flesh out this feature.
|
||||
|
||||
#### Outline
|
||||
|
||||
In the future, this feature may pave the way for moving the Flake subcommand
|
||||
line to its own standalone binary, allowing for a more focused approach to
|
||||
managing Nix Flakes while letting the community explore alternatives to
|
||||
dependency management.
|
||||
|
||||
Many thanks to [Raito Bezarius](https://git.lix.systems/raito) for this.
|
||||
|
||||
- `nix-env --install` now accepts a `--priority` flag [cl/2607](https://gerrit.lix.systems/c/lix/+/2607)
|
||||
|
||||
`nix-env --install` now has an optional `--priority` flag.
|
||||
|
||||
Previously, it was only possible to specify a priority by adding a
|
||||
`meta.priority` attribute to a derivation. `meta` attributes only exist during
|
||||
eval, so that wouldn't work for installing a store path. It was also possible
|
||||
to change a priority after initial installation using `nix-env --set-flag`,
|
||||
however if there is already a conflict that needs to be resolved via priorities,
|
||||
this will not work.
|
||||
|
||||
Now, a priority can be set at install time using `--priority`, which allows for
|
||||
cleanly overriding the priority at install time.
|
||||
|
||||
#### Example
|
||||
|
||||
```console
|
||||
$ nix-build
|
||||
$ nix-env --install --priority 100 ./result
|
||||
```
|
||||
|
||||
Many thanks to [Andrew Hamon](https://github.com/andrewhamon) for this.
|
||||
|
||||
- Add support for eBPF USDT/dtrace probes inside Lix [fj#727](https://git.lix.systems/lix-project/lix/issues/727) [cl/2884](https://gerrit.lix.systems/c/lix/+/2884)
|
||||
|
||||
eBPF tracers like `bpftrace` and `dtrace` are a group of similar tools for debugging production systems.
|
||||
User-space statically defined tracing probes (USDT) allow for defining zero or near-zero disabled-probe-effect probes, thus allowing instrumentation of hot paths in production builds.
|
||||
Lix now has internal support for defining these probes and has shipped its first probe.
|
||||
|
||||
As of this writing it is available by default in the Linux build of Lix.
|
||||
|
||||
To try it out on Linux, you can use the following example command:
|
||||
|
||||
```
|
||||
$ sudo bpftrace -l 'usdt:/path/to/liblixstore.so:*:*'
|
||||
usdt:/path/to/liblixstore.so:lix_store:filetransfer__read
|
||||
|
||||
$ sudo bpftrace -e 'usdt:*:lix_store:filetransfer__read { printf("%s read %d\n", str(arg0), arg1); }'
|
||||
Attaching 1 probe...
|
||||
https://cache.nixos.org/wvpzaycmvs39h5bcsfrxkjsg48mj4h73.narinf.. read 8192
|
||||
https://cache.nixos.org/wvpzaycmvs39h5bcsfrxkjsg48mj4h73.narinf.. read 8192
|
||||
https://cache.nixos.org/nar/1qshsc30nlarzdig0v9b1aasdkwaxhnv0a0.. read 65536
|
||||
https://cache.nixos.org/nar/1qshsc30nlarzdig0v9b1aasdkwaxhnv0a0.. read 65536
|
||||
```
|
||||
|
||||
Note that bpftrace does not offer any way to list the arguments to USDT probes in a human readable form.
|
||||
To get the probe definitions, see the `*.d` files in the Lix source code, for example, `lix/libstore/trace-probes.d`.
|
||||
|
||||
For more resources on eBPF/bpftrace and dtrace, see:
|
||||
* The book "BPF Performance Tools" by Brendan Gregg, which discusses bpftrace at length.
|
||||
* <https://ebpf.io/get-started/>
|
||||
* [Illumos' dtrace book](https://illumos.org/books/dtrace/preface.html)
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
|
||||
## Improvements
|
||||
|
||||
- Always print `post-build-hook` logs [fj#675](https://git.lix.systems/lix-project/lix/issues/675) [cl/2801](https://gerrit.lix.systems/c/lix/+/2801)
|
||||
|
||||
Logs of `post-build-hook` are now printed unconditionally.
|
||||
They used to be tied to whether print-build-logs is set, which made debugging them a nightmare when they fail, since the failure output would be eaten if build logs are disabled.
|
||||
Most usages of `post-build-hook` are pretty quiet especially compared to build logs, so it should not be that bothersome to not be able to turn off.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Crashes land in syslog now [cl/2640](https://gerrit.lix.systems/c/lix/+/2640)
|
||||
|
||||
When Lix crashes with unexpected exceptions and in some other conditions, it prints bug reporting instructions.
|
||||
Previously, these only landed in stderr and not in syslog.
|
||||
However, on larger Lix installations, it may be the case that Lix crashes in the client without the logs landing in the system logs, which impeded diagnosis.
|
||||
|
||||
Now, such crashes always land in syslog too.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Deletion of specific paths no longer fails fast [cl/2778](https://gerrit.lix.systems/c/lix/+/2778)
|
||||
|
||||
`nix-store --delete` and `nix store delete` now continue deleting
|
||||
paths even if some of the given paths are still live. An error is only
|
||||
thrown once deletion of all the given paths has been
|
||||
attempted. Previously, if some paths were deletable and others
|
||||
weren't, the deletable ones would be deleted iff they preceded the
|
||||
live ones in lexical sort order.
|
||||
|
||||
The error message for still-live paths no longer reports the paths
|
||||
that could not be deleted, because there could potentially be many of
|
||||
these.
|
||||
|
||||
Many thanks to [lheckemann](https://git.lix.systems/lheckemann) for this.
|
||||
|
||||
- `--skip-live` for path deletion [cl/2778](https://gerrit.lix.systems/c/lix/+/2778)
|
||||
|
||||
`nix-store --delete` and `nix store delete` now support a
|
||||
`--skip-live` option and a `--delete-closure` option.
|
||||
|
||||
This makes custom garbage-collection logic a lot easier to implement
|
||||
and experiment with:
|
||||
|
||||
- Paths known to be large can be thrown at `nix store delete` without
|
||||
having to manually filter out those that are still reachable from a
|
||||
root, e.g.
|
||||
`nix store delete /nix/store/*mbrola-voices*`
|
||||
|
||||
- The `--delete-closure` option allows extending this to paths that are
|
||||
not large themselves but do have a large closure size, e.g.
|
||||
`nix store delete /nix/store/*nixos-system-gamingpc*`.
|
||||
|
||||
- Other heuristics like atime-based deletion can be applied more
|
||||
easily, because `nix store delete` once again takes over the task of
|
||||
working out which paths can't be deleted.
|
||||
|
||||
Many thanks to [lheckemann](https://git.lix.systems/lheckemann) for this.
|
||||
|
||||
- Allow `nix store diff-closures` to output JSON [cl/2360](https://gerrit.lix.systems/c/lix/+/2360)
|
||||
|
||||
Add the `--json` option to the `nix store diff-closures` command to allow users to collect diff information into a machine readable format.
|
||||
|
||||
```bash
|
||||
$ build/lix/nix/nix store diff-closures --json /run/current-system /nix/store/n1prick95pihd4lkv58nn3pzg1yivcdb-neovim-0.10.4/bin/nvim | jq | head -n 23
|
||||
{
|
||||
"packages": {
|
||||
"02overridedns": {
|
||||
"sizeDelta": -688,
|
||||
"versionsAfter": [],
|
||||
"versionsBefore": [
|
||||
""
|
||||
]
|
||||
},
|
||||
"50-coredump.conf": {
|
||||
"sizeDelta": -1976,
|
||||
"versionsAfter": [],
|
||||
"versionsBefore": [
|
||||
""
|
||||
]
|
||||
},
|
||||
"Diff": {
|
||||
"sizeDelta": -514864,
|
||||
"versionsAfter": [],
|
||||
"versionsBefore": [
|
||||
"0.4.1"
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
Many thanks to [Xavier Maso](https://github.com/pamplemousse) for this.
|
||||
|
||||
- Show all missing and unexpected arguments in erroneous function calls [cl/2477](https://gerrit.lix.systems/c/lix/+/2477)
|
||||
|
||||
When calling a function that expects an attribute set, lix will now show all
|
||||
missing and unexpected arguments.
|
||||
e.g. with `({ a, b, c } : a + b + c) { a = 1; d = 1; }` lix will now show the error:
|
||||
```
|
||||
[...]
|
||||
error: function 'anonymous lambda' called without required arguments 'b' and 'c' and with unexpected argument 'd'
|
||||
[...]
|
||||
```
|
||||
Previously lix would just show `b`.
|
||||
Furthermore lix will now only suggest arguments that aren't yet used.
|
||||
e.g. with `({ a?1, b?1, c?1 } : a + b + c) { a = 1; d = 1; e = 1; }` lix will now show the error:
|
||||
```
|
||||
[...]
|
||||
error: function 'anonymous lambda' called with unexpected arguments 'd' and 'e'
|
||||
at «string»:1:2:
|
||||
1| ({ a?1, b?1, c?1 } : a + b + c) { a = 1; d = 1; e = 1; }
|
||||
| ^
|
||||
Did you mean one of b or c?
|
||||
```
|
||||
Previously lix would also suggest `a`.
|
||||
Suggestions are unfortunately still currently just for the first missing argument.
|
||||
|
||||
Many thanks to [Zitrone](https://git.lix.systems/quantenzitrone) for this.
|
||||
|
||||
- REPL improvements [cl/2319](https://gerrit.lix.systems/c/lix/+/2319) [cl/2320](https://gerrit.lix.systems/c/lix/+/2320) [cl/2321](https://gerrit.lix.systems/c/lix/+/2321)
|
||||
|
||||
The REPL has seen various minor improvements:
|
||||
|
||||
- Variable declarations have been improved, making copy-pasting code from attrsets a lot easier:
|
||||
- Declarations can now optionally end with a semicolon
|
||||
- Multiple declarations can be done within one command, separated by semicolon
|
||||
- The `foo.bar = "baz";` syntax from attrsets is also supported, however without the attrset merging rules and with restrictions on dynamic attrs like in `let` bindings.
|
||||
- Variable names now use the proper Nix grammar rules, instead of a regex that only vaguely matched legal identifiers.
|
||||
- Better error messages overall
|
||||
- The `:env` command to print currently available variables now also works outside of debug mode
|
||||
- Adding variables to the REPL now prints a small message on success
|
||||
|
||||
Many thanks to [piegames](https://git.lix.systems/piegames) for this.
|
||||
|
||||
- Consistently use SRI hashes in hash mismatch errors [cl/2868](https://gerrit.lix.systems/c/lix/+/2868)
|
||||
|
||||
Previously there were a few weird cases (flake inputs, e.g., among others) where Lix would print the old Nix base-32 hash format (sha256:abcd...) rather than the newer [SRI base64 format](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) (sha256-AAAA...) that is used in most Lix hash mismatch errors.
|
||||
This made it annoying to compare them to hashes shown by most of the modern UI surface of Lix which uses SRI.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Allow specifying ports for remote ssh[-ng] stores [cl/2432](https://gerrit.lix.systems/c/lix/+/2432)
|
||||
|
||||
You can now specify which port should be used for a remote ssh store (e.g. for remote/distributed builds) through a uri parameter.
|
||||
E.g., when a remote builder `foo` is listening on port `1234` instead of the default, it can be specified like this `ssh://foo?port=1234`.
|
||||
|
||||
Many thanks to [seppel3210](https://github.com/Seppel3210) for this.
|
||||
|
||||
- Implicit `__toString` now have stack trace entries [cl/3055](https://gerrit.lix.systems/c/lix/+/3055)
|
||||
|
||||
Coercion of attribute sets to strings via their `__toString` attribute now produce stack
|
||||
frames pointing to the coercion site and the attribute definition. This makes locating a
|
||||
coercion function error easier as the fault location is now more likely to be presented.
|
||||
|
||||
Previously:
|
||||
```
|
||||
nix-repl> builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
error:
|
||||
… while calling the 'substring' builtin
|
||||
at «string»:1:1:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
… caused by explicit throw
|
||||
at «string»:1:48:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
error: bar
|
||||
```
|
||||
|
||||
Now:
|
||||
```
|
||||
nix-repl> builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
error:
|
||||
… while calling the 'substring' builtin
|
||||
at «string»:1:1:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
… while converting a set to string
|
||||
at «string»:1:25:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
… from call site
|
||||
at «string»:1:29:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
… while calling '__toString'
|
||||
at «string»:1:42:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
… caused by explicit throw
|
||||
at «string»:1:48:
|
||||
1| builtins.substring 1 1 "${{ __toString = self: throw ''bar''; }}"
|
||||
| ^
|
||||
|
||||
error: bar
|
||||
```
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
|
||||
## Fixes
|
||||
|
||||
- Avoid unnecessarily killing processes for the build user's UID [nix#9142](https://github.com/NixOS/nix/issues/9142) [fj#667](https://git.lix.systems/lix-project/lix/issues/667)
|
||||
|
||||
We no longer kill all processes under the build user's UID before and after
|
||||
builds on Linux with sandboxes enabled.
|
||||
|
||||
This avoids unrelated processes being killed. This might happen for instance,
|
||||
if the user is running Lix inside a container, wherein the build users use the same UIDs as the daemon's.
|
||||
|
||||
Many thanks to [teofilc](https://git.lix.systems/teofilc) for this.
|
||||
|
||||
- Forbid impure path accesses in pure evaluation mode again [cl/2708](https://gerrit.lix.systems/c/lix/+/2708)
|
||||
|
||||
Lix 2.92.0 mistakenly started allowing the access to ancestors of allowed paths in pure evaluation mode.
|
||||
This made it possible to bypass the purity restrictions, for example by copying arbitrary files to the store:
|
||||
```nix
|
||||
builtins.path {
|
||||
path = "/";
|
||||
filter = …;
|
||||
}
|
||||
```
|
||||
Restore the previous behaviour of prohibiting such impure accesses.
|
||||
|
||||
Many thanks to [alois31](https://git.lix.systems/alois31) for this.
|
||||
|
||||
- Ctrl-C works correctly on macOS again [fj#729](https://git.lix.systems/lix-project/lix/issues/729) [cl/3066](https://gerrit.lix.systems/c/lix/+/3066)
|
||||
|
||||
Due to a kernel bug in macOS's `poll(2)` implementation where it would forget about event subscriptions, our detection of closed connections in the Lix daemon didn't work and left around lingering daemon processes.
|
||||
We have rewritten that thread to use `kqueue(2)`, which is what the `poll(2)` implementation uses internally in the macOS kernel, so now Ctrl-C on clients will reliably terminate daemons once more.
|
||||
|
||||
This FD close monitoring has had the highest Apple bug ID references per line of code anywhere in the project, and hopefully not using poll anymore will stop us hitting bugs in poll.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Fetch peer PID for daemon connections on macOS [fj#640](https://git.lix.systems/lix-project/lix/issues/640) [cl/2453](https://gerrit.lix.systems/c/lix/+/2453)
|
||||
|
||||
`nix-daemon` will now fetch the peer PID for connections on macOS, to match behavior with Linux.
|
||||
Besides showing up in the log output line, If `nix-daemon` is given an argument (such as `--daemon`)
|
||||
that argument will be overwritten with the peer PID for the forked process that handles the connection,
|
||||
which can be used for debugging purposes.
|
||||
|
||||
Many thanks to [lilyball](https://git.lix.systems/lilyball) for this.
|
||||
|
||||
- Test group membership better on macOS [gh#5885](https://github.com/NixOS/nix/issues/5885) [cl/2566](https://gerrit.lix.systems/c/lix/+/2566)
|
||||
|
||||
`nix-daemon` will now test group membership better on macOS for `trusted-users` and `allowed-users`.
|
||||
It not only fetches the peer gid (which fixes `@staff`) but it also asks opendirectory for group
|
||||
membership checks instead of just using the group database, which means nested groups (like `@_developer`)
|
||||
and groups with synthesized membership (like `@localaccounts`) will work.
|
||||
|
||||
Many thanks to [lilyball](https://git.lix.systems/lilyball) for this.
|
||||
|
||||
- `nix store delete` no longer builds paths [cl/2782](https://gerrit.lix.systems/c/lix/+/2782)
|
||||
|
||||
`nix store delete` no longer realises the installables
|
||||
specified. Previously, `nix store delete nixpkgs#hello` would download
|
||||
hello only to immediately delete it again. Now, it exits with an error
|
||||
if given an installable that isn't in the store.
|
||||
|
||||
Many thanks to [lheckemann](https://git.lix.systems/lheckemann) for this.
|
||||
|
||||
- Fix nix-store --delete on paths with remaining referrers [cl/2783](https://gerrit.lix.systems/c/lix/+/2783)
|
||||
|
||||
Nix 2.5 introduced a regression whereby `nix-store --delete` and `nix
|
||||
store delete` started to fail when trying to delete a path that was
|
||||
still referenced by other paths, even if the referrers were not
|
||||
reachable from any GC roots. The old behaviour, where attempting to
|
||||
delete a store path would also delete its referrer closure, is now
|
||||
restored.
|
||||
|
||||
Many thanks to [lheckemann](https://git.lix.systems/lheckemann) for this.
|
||||
|
||||
- Add a straightforward way to detect if in a Nix3 Shell [nix#6677](https://github.com/NixOS/nix/issues/6677) [nix#3862](https://github.com/NixOS/nix/issues/3862) [cl/2090](https://gerrit.lix.systems/c/lix/+/2090)
|
||||
|
||||
Running `nix shell` or `nix develop` will now set `IN_NIX_SHELL` to
|
||||
either `pure` or `impure`, depending on whether `--ignore-environment`
|
||||
is passed. `nix develop` will always be an impure environment.
|
||||
|
||||
Many thanks to [Ersei Saggi](https://github.com/9p4) for this.
|
||||
|
||||
- Fix experimental and deprecated features showing as integers in `nix config show --json` [fj#738](https://git.lix.systems/lix-project/lix/issues/738) [cl/2882](https://gerrit.lix.systems/c/lix/+/2882)
|
||||
|
||||
Internal changes in 2.92 caused `nix config show --json` to show deprecated and experimental features not as the list of named features 2.91 and earlier produced, but as integers. This has been fixed.
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
- `builtins.fetchTree` is no longer visible in `builtins` when flakes are disabled [cl/2399](https://gerrit.lix.systems/c/lix/+/2399)
|
||||
|
||||
`builtins.fetchTree` is the foundation of flake inputs and flake lock files, but is not fully specified in behaviour, which leads to regressions, behaviour differences with CppNix, and other unfun times.
|
||||
It's gated behind the `flakes` experimental feature, but prior to now, would throw an uncatchable error at runtime when used without the `flakes` feature enabled.
|
||||
Now it's like other builtins which are experimental feature gated, where it is not visible without the relevant feature enabled.
|
||||
|
||||
This fixes a bug in using Eelco Dolstra's version of flake-compat on Lix (and a divergence with CppNix): https://github.com/edolstra/flake-compat/issues/66
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- fix usage of `builtins.filterSource` and `builtins.path` with the filter argument when using chroot stores [nix#11503](https://github.com/NixOS/nix/issues/11503)
|
||||
|
||||
The semantics of `builtins.filterSource` (and the `filter` argument for
|
||||
`builtins.path`) have been adjusted regarding how paths inside the Nix store
|
||||
are handled.
|
||||
|
||||
Previously, when evaluating whether a path should be included, the filtering
|
||||
function received the **physical path** if the source was inside the chroot store.
|
||||
|
||||
Now, it receives the **logical path** instead.
|
||||
|
||||
This ensures consistency in path handling and avoids potential
|
||||
misinterpretations of paths within the evaluator, which led to various fallouts
|
||||
mentioned in <https://github.com/NixOS/nixpkgs/pull/369694>.
|
||||
|
||||
Many thanks to [lily](https://git.lix.systems/lilyinstarlight), [alois31](https://git.lix.systems/alois31), and [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
- Fix `--help` formatting [fj#622](https://git.lix.systems/lix-project/lix/issues/622) [cl/2776](https://gerrit.lix.systems/c/lix/+/2776)
|
||||
|
||||
The help printed when invoking `nix` or `nix-store` and subcommands with `--help` previously contained garbled terminal escapes. These have been removed.
|
||||
|
||||
Many thanks to [lheckemann](https://git.lix.systems/lheckemann) for this.
|
||||
|
||||
- Parsing failures in flake.lock no longer crash Lix [fj#559](https://git.lix.systems/lix-project/lix/issues/559) [cl/2401](https://gerrit.lix.systems/c/lix/+/2401)
|
||||
|
||||
Failure to parse `flake.lock` no longer hard-crashes Lix and instead produces a nice error message.
|
||||
|
||||
```
|
||||
error:
|
||||
… while updating the lock file of flake 'git+file:///Users/jade/lix/lix2'
|
||||
|
||||
… while parsing the lock file at /nix/store/mm5dqh8a729yazzj82cjffxl97n5c62s-source//flake.lock
|
||||
|
||||
error: [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal;
|
||||
last read: '#'
|
||||
```
|
||||
|
||||
Many thanks to [gilice](https://git.lix.systems/gilice) for this.
|
||||
|
||||
- Flakes follow `--eval-system` where it makes sense [fj#673](https://git.lix.systems/lix-project/lix/issues/673) [fj#692](https://git.lix.systems/lix-project/lix/issues/692) [gh#11359](https://github.com/NixOS/nix/issues/11359) [cl/2657](https://gerrit.lix.systems/c/lix/+/2657)
|
||||
|
||||
Most flake commands now follow `--eval-system` when choosing attributes to build/evaluate/etc.
|
||||
|
||||
The exceptions are commands that actually run something on the local machine:
|
||||
- nix develop
|
||||
- nix run
|
||||
- nix upgrade-nix
|
||||
- nix fmt
|
||||
- nix bundle
|
||||
|
||||
This is not a principled approach to cross compilation or anything, flakes still impede rather than support cross compilation, but this unbreaks many remote build use cases.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Remove some gremlins from path garbage collection [fj#621](https://git.lix.systems/lix-project/lix/issues/621) [fj#524](https://git.lix.systems/lix-project/lix/issues/524) [cl/2465](https://gerrit.lix.systems/c/lix/+/2465) [cl/2387](https://gerrit.lix.systems/c/lix/+/2387)
|
||||
|
||||
Path garbage collection had some known unsoundness issues where it would delete things improperly and cause desynchronization between the filesystem state and the database state.
|
||||
Now Lix tolerates better if such a condition exists by not failing the entire GC if a path fails to delete.
|
||||
We also fixed a bug in our file locking implementation that is one possible root cause, but may not be every root cause.
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) and [Raito Bezarius](https://git.lix.systems/raito) for this.
|
||||
|
||||
- Show illegal path references in fixed-outputs derivations [fj#530](https://git.lix.systems/lix-project/lix/issues/530) [cl/2726](https://gerrit.lix.systems/c/lix/+/2726)
|
||||
|
||||
The error created when referencing a store path in a Fixed-Output Derivation is now more verbose, listing the offending paths.
|
||||
This allows for better pinpointing where the issue might be.
|
||||
|
||||
An offender is the following derivation:
|
||||
|
||||
```nix
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "illegal-fod";
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
cp -R ${pkgs.hello} $out
|
||||
'';
|
||||
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = pkgs.lib.fakeHash;
|
||||
}
|
||||
```
|
||||
|
||||
The previous error shown would have been:
|
||||
|
||||
```
|
||||
error: illegal path references in fixed-output derivation '/nix/store/rpq4m1y79s2nhs1hj7k47yiyykxykiqa-illegal-fod.drv'
|
||||
```
|
||||
|
||||
and is now:
|
||||
|
||||
```
|
||||
error: the fixed-output derivation '/nix/store/rpq4m1y79s2nhs1hj7k47yiyykxykiqa-illegal-fod.drv' must not reference store paths but 2 such references were found:
|
||||
/nix/store/1q8w6gl1ll0mwfkqc3c2yx005s6wwfrl-hello-2.12.1
|
||||
/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36
|
||||
```
|
||||
|
||||
Many thanks to [Tom Hubrecht](https://git.lix.systems/tom-hubrecht) for this.
|
||||
|
||||
- Show error when item from NIX_PATH cannot be downloaded
|
||||
|
||||
For e.g. `nix-instantiate -I https://example.com/404`, you'd only get a warning if the download failed, such as
|
||||
|
||||
warning: Nix search path entry 'https://example.com/404' cannot be downloaded, ignoring
|
||||
|
||||
Now, the full error that caused the download failure is displayed with a note that the search
|
||||
path entry is ignored, e.g.
|
||||
|
||||
warning:
|
||||
… while downloading https://example.com/404 to satisfy NIX_PATH lookup, ignoring search path entry
|
||||
|
||||
warning: unable to download 'https://example.com/404': HTTP error 404 ()
|
||||
|
||||
response body: […]
|
||||
|
||||
Many thanks to [ma27](https://git.lix.systems/ma27) for this.
|
||||
|
||||
- Fix Lix crashing on invalid json [fj#642](https://git.lix.systems/lix-project/lix/issues/642) [fj#753](https://git.lix.systems/lix-project/lix/issues/753) [fj#759](https://git.lix.systems/lix-project/lix/issues/759) [fj#769](https://git.lix.systems/lix-project/lix/issues/769) [cl/2907](https://gerrit.lix.systems/c/lix/+/2907)
|
||||
|
||||
Lix no longer crashes when it receives invalid JSON. Instead it'll point to the syntax error and give some context about what happened, for example
|
||||
|
||||
```
|
||||
❯ nix derivation add <<<"""
|
||||
error:
|
||||
… while parsing a derivation from stdin
|
||||
|
||||
error: failed to parse JSON: [json.exception.parse_error.101] parse error at line 2, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal
|
||||
```
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
- Fix handling of `lastModified` in tarball inputs [cl/2792](https://gerrit.lix.systems/c/lix/+/2792)
|
||||
|
||||
Previous versions of Lix would fail with the following error, if a
|
||||
[tarball flake input](@docroot@/protocols/tarball-fetcher.md) redirect
|
||||
to a URL that contains a `lastModified` field:
|
||||
|
||||
```
|
||||
error: input attribute 'lastModified' is not an integer
|
||||
```
|
||||
|
||||
This is now fixed.
|
||||
|
||||
Many thanks to [xanderio](https://github.com/xanderio) and [Julian Stecklina](https://github.com/blitz) for this.
|
||||
|
||||
- Fix `--debugger --ignore-try` [cl/2440](https://gerrit.lix.systems/c/lix/+/2440)
|
||||
|
||||
When in debug mode (e.g. from using the `--debugger` flag), enabling [`ignore-try`](@docroot@/command-ref/conf-file.md#conf-ignore-try) once again properly disables debug REPLs within [`builtins.tryEval`](@docroot@/language/builtins.md#builtins-tryEval) calls. Previously, a debug REPL would be started as if `ignore-try` was disabled, but that REPL wouldn't actually be in debug mode, and upon exiting the REPL the evaluating process would segfault.
|
||||
|
||||
Many thanks to [Dusk Banks](https://git.lix.systems/bb010g) for this.
|
||||
|
||||
- Don't consider a path with a specified rev to be `locked` [cl/2064](https://gerrit.lix.systems/c/lix/+/2064)
|
||||
|
||||
Until now it was allowed to do e.g.
|
||||
|
||||
$ echo 'lalala' > testfile
|
||||
$ nix eval --expr '(builtins.fetchTree { path = "/home/ma27/testfile"; rev = "0000000000000000000000000000000000000000"; type = "path"; })'
|
||||
{ lastModified = 1723656303; lastModifiedDate = "20240814172503"; narHash = "sha256-hOMY06A0ohaaCLwnhpZIMoAqi/8kG2vk30NRiqi0dfc="; outPath = "/nix/store/lhfz259iipmv9ky995rml8018jvriynh-source"; rev = "0000000000000000000000000000000000000000"; shortRev = "0000000"; }
|
||||
$ cat /nix/store/lhfz259iipmv9ky995rml8018jvriynh-source
|
||||
lalala
|
||||
|
||||
because any kind of input with a `rev` specified is considered to be locked.
|
||||
|
||||
With this change, inputs of type `path`, `indirect` and `tarball` are no longer
|
||||
considered locked with a rev, but no hash specified.
|
||||
|
||||
This behavior was changed in
|
||||
[CppNix 2.21 as well](https://github.com/nixos/nix/commit/071dd2b3a4e6c0b2106f1b6f14ec26e153d97446) as well.
|
||||
|
||||
Many thanks to [ma27](https://git.lix.systems/ma27) for this.
|
||||
|
||||
- Fix macOS sandbox profile size errors [fj#752](https://git.lix.systems/lix-project/lix/issues/752) [fj#718](https://git.lix.systems/lix-project/lix/issues/718) [cl/2861](https://gerrit.lix.systems/c/lix/+/2861)
|
||||
|
||||
Fixed an issue on macOS where the sandbox profile could exceed size limits when building derivations with many dependencies. The profile is now split into multiple allowed sections to stay under the interpreter's limits.
|
||||
|
||||
This resolves errors like
|
||||
|
||||
```
|
||||
error: (failed with exit code 1, previous messages: sandbox initialization failed: data object length 65730 exceeds maximum (65535)|failed to configure sandbox)
|
||||
|
||||
error: unexpected EOF reading a line
|
||||
```
|
||||
|
||||
Many thanks to [Pierre-Etienne Meunier](https://github.com/P-E-Meunier) and [Poliorcetics](https://github.com/poliorcetics) for this.
|
||||
|
||||
- Fix interference of the multiline progress bar with output [cl/2774](https://gerrit.lix.systems/c/lix/+/2774)
|
||||
|
||||
In some situations, the progress indicator of the multiline progress bar would interfere with persistent output.
|
||||
This would result in progress bar headers being visible in place of the desired text, for example the outputs shown after a `:b` command in the repl.
|
||||
The underlying ordering issue has been fixed, so that the undesired interference does not happen any more.
|
||||
|
||||
Many thanks to [alois31](https://git.lix.systems/alois31) for this.
|
||||
|
||||
- Paralellise `nix store sign` using a thread pool [fj#399](https://git.lix.systems/lix-project/lix/issues/399) [cl/2606](https://gerrit.lix.systems/c/lix/+/2606)
|
||||
|
||||
`nix store sign` with a large collection of provided paths (such as when using with `--all`) has historically
|
||||
signed these paths serially. Taking extreme amounts of time when preforming operations such as fixing binary
|
||||
caches. This has been changed. Now these signatures are performed using a thread pool like `nix store copy-sigs`.
|
||||
|
||||
Many thanks to [Lunaphied](https://git.lix.systems/Lunaphied) for this.
|
||||
|
||||
- `post-build-hook` only receives settings that are set [fj#739](https://git.lix.systems/lix-project/lix/issues/739) [cl/2800](https://gerrit.lix.systems/c/lix/+/2800)
|
||||
|
||||
If one is using `post-build-hook` to upload paths to a cache, it used to be broken if CppNix was used inside the script, since CppNix would fail about unsupported configuration option values in some of Lix's defaults.
|
||||
This is because `post-build-hook` receives the settings of the nix daemon in the `NIX_CONFIG` environment variable.
|
||||
Now Lix only emits overridden settings to `post-build-hook` invocations, which fixes this issue in the majority of cases: where the configuration is not explicitly incompatible.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) for this.
|
||||
|
||||
- Remove lix-initiated ssh connection sharing [fj#304](https://git.lix.systems/lix-project/lix/issues/304) [fj#644](https://git.lix.systems/lix-project/lix/issues/644) [cl/3005](https://gerrit.lix.systems/c/lix/+/3005)
|
||||
|
||||
Lix no longer explicitly requests ssh connection sharing (ControlMaster/ControlPath SSH
|
||||
options, see also ssh_config(5) man page) when connecting to remote stores. This may
|
||||
impact command latency when `NIX_REMOTE` is set to a `ssh://` or `ssh-ng://` url, or if
|
||||
`--store` is specified. Remote build connections did not use ssh connection sharing.
|
||||
|
||||
Connection sharing configuration is now inherited from user configuration at all times. It
|
||||
is now advisable to configure connection sharing for remote builders for improved latency.
|
||||
|
||||
Many thanks to [eldritch horrors](https://git.lix.systems/pennae) for this.
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
- Add `nix_plugin_entry` entry point for plugins [fj#740](https://git.lix.systems/lix-project/lix/issues/740) [fj#359](https://git.lix.systems/lix-project/lix/issues/359) [gh#8699](https://github.com/NixOS/nix/pull/8699) [cl/2826](https://gerrit.lix.systems/c/lix/+/2826)
|
||||
|
||||
Plugins are an exceptionally rarely used feature in Lix, but they are important as a prototyping tool for code destined for Lix itself, and we want to keep supporting them as a low-maintenance-cost feature.
|
||||
As part of the overall move towards getting rid of static initializers for stability and predictability reasons, we added an explicit `nix_plugin_entry` function like CppNix has, which is called immediately after plugin load, if present.
|
||||
This makes control flow more explicit and allows for easily registering things that have had their static initializer registration classes removed.
|
||||
|
||||
Many thanks to [jade](https://git.lix.systems/jade) and [yorickvp](https://github.com/yorickvp) for this.
|
||||
|
||||
|
||||
## Miscellany
|
||||
|
||||
- Set default of `connect-timeout` to `5` [cl/2799](https://gerrit.lix.systems/c/lix/+/2799)
|
||||
|
||||
By default, the connection timeout to substituters is now 5s instead of 300s.
|
||||
That way, unavailable substituters are detected quicker.
|
||||
|
||||
Many thanks to [ma27](https://git.lix.systems/ma27) for this.
|
||||
@@ -1,21 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Preprocesses mdbook markdown, primarily for include directives.
|
||||
|
||||
The include directive format is as follows:
|
||||
{{#include foo/bar/baz.md}}
|
||||
|
||||
The content of includes will be indented as much as the directive itself.
|
||||
|
||||
Including a generated file (from building Lix; generally for the 'new' CLI):
|
||||
{{#include @generated@/foo/bar/baz.md}}
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os, os.path
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
name = 'substitute.py'
|
||||
|
||||
@@ -23,12 +11,6 @@ def log(*args, **kwargs):
|
||||
kwargs['file'] = sys.stderr
|
||||
return print(f'{name}:', *args, **kwargs)
|
||||
|
||||
def remove_prefix_if_present(s: str, prefix: str) -> str | None:
|
||||
if s.startswith(prefix):
|
||||
return s.removeprefix(prefix)
|
||||
else:
|
||||
return None
|
||||
|
||||
def do_include(content: str, relative_md_path: Path, source_root: Path, search_path: Path):
|
||||
assert not relative_md_path.is_absolute(), f'{relative_md_path=} from mdbook should be relative'
|
||||
|
||||
@@ -38,32 +20,16 @@ def do_include(content: str, relative_md_path: Path, source_root: Path, search_p
|
||||
|
||||
lines = []
|
||||
for l in content.splitlines(keepends=True):
|
||||
if remain := remove_prefix_if_present(l.strip(), "{{#include"):
|
||||
requested = remain[1:-2]
|
||||
# We indent bodies of indent directives by the indent of the
|
||||
# directive itself.
|
||||
num_leading_indent = len(l) - len(l.lstrip())
|
||||
|
||||
if subpath := remove_prefix_if_present(requested, "@generated@/"):
|
||||
included = search_path / Path(subpath)
|
||||
if l.strip().startswith("{{#include "):
|
||||
requested = l.strip()[11:][:-2]
|
||||
if requested.startswith("@generated@/"):
|
||||
included = search_path / Path(requested[12:])
|
||||
requested = included.relative_to(search_path)
|
||||
else:
|
||||
included = source_root / relative_md_path.parent / requested
|
||||
requested = included.resolve().relative_to(source_root)
|
||||
assert included.exists(), f"{requested} not found at {included}"
|
||||
|
||||
lines.append(
|
||||
textwrap.indent(
|
||||
do_include(
|
||||
included.read_text(),
|
||||
requested,
|
||||
source_root,
|
||||
search_path,
|
||||
),
|
||||
" " * num_leading_indent
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
lines.append(do_include(included.read_text(), requested, source_root, search_path) + "\n")
|
||||
else:
|
||||
lines.append(l)
|
||||
return "".join(lines)
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@ let
|
||||
|
||||
nixConfContents =
|
||||
(lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (
|
||||
lib.mapAttrsFlatten (
|
||||
n: v:
|
||||
let
|
||||
vStr = if builtins.isList v then lib.concatStringsSep " " v else v;
|
||||
|
||||
Generated
+7
-7
@@ -34,16 +34,16 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1733348545,
|
||||
"narHash": "sha256-b4JrUmqT0vFNx42aEN9LTWOHomkTKL/ayLopflVf81U=",
|
||||
"lastModified": 1727184566,
|
||||
"narHash": "sha256-mgdK8BcFsLSNhe780+cHbEUbZ3OruLa1T/xgQlL4Aj4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9ecb50d2fae8680be74c08bb0a995c5383747f89",
|
||||
"rev": "48c3030083c46042584531bc9d931020f1975677",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.11-small",
|
||||
"ref": "nixos-24.05-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
@@ -67,11 +67,11 @@
|
||||
"pre-commit-hooks": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1733318908,
|
||||
"narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=",
|
||||
"lastModified": 1726745158,
|
||||
"narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "6f4e2a2112050951a314d2733a994fbab94864c6",
|
||||
"rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
description = "Lix: A modern, delicious implementation of the Nix package manager";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11-small";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small";
|
||||
nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/git-hooks.nix";
|
||||
@@ -36,7 +36,6 @@
|
||||
sgr = builtins.fromJSON ''"\u001b["'';
|
||||
freezePage = "https://wiki.lix.systems/books/lix-contributors/page/freezes-and-recommended-contributions";
|
||||
codebaseOverview = "https://wiki.lix.systems/books/lix-contributors/page/codebase-overview";
|
||||
gerritWiki = "https://wiki.lix.systems/books/lix-contributors/page/gerrit";
|
||||
contribNotice = builtins.toFile "lix-contrib-notice" ''
|
||||
Hey there!
|
||||
|
||||
@@ -54,10 +53,6 @@
|
||||
and we'd like to work together with all contributors as much as possible.
|
||||
Lix is a collaborative project :)
|
||||
|
||||
If you want to submit a patch and you never used gerrit before, please
|
||||
check our gerrit wiki section:
|
||||
${sgr}32m${gerritWiki}${sgr}0m
|
||||
|
||||
You can open an issue at https://git.lix.systems/lix-project/lix/issues
|
||||
or chat with us on Matrix: #space:lix.systems.
|
||||
|
||||
@@ -97,7 +92,8 @@
|
||||
"armv7l-linux"
|
||||
"riscv64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-freebsd"
|
||||
# FIXME: still broken in 24.05: fails to build rustc(??) due to missing -lstdc++ dep
|
||||
# "x86_64-freebsd"
|
||||
# FIXME: broken dev shell due to python
|
||||
# "x86_64-netbsd"
|
||||
];
|
||||
@@ -201,21 +197,6 @@
|
||||
|
||||
lix-clang-tidy = final.callPackage ./subprojects/lix-clang-tidy { };
|
||||
|
||||
nix-eval-jobs = final.callPackage ./subprojects/nix-eval-jobs {
|
||||
srcDir = ./subprojects/nix-eval-jobs;
|
||||
};
|
||||
|
||||
# HACK: We need nix-prefetch-git for fetchCargoVendor for Rust stuff,
|
||||
# so it can't use Lix, or we infrec:
|
||||
# lix -> Rust stuff -> fetchCargoVendor -> nix-prefetch-git -> nix (lix)
|
||||
# This will eventually become a problem upstream, but until then,
|
||||
# apply some duct tape and pray.
|
||||
nix-prefetch-git =
|
||||
if (lib.functionArgs prev.nix-prefetch-git.override) ? "nix" then
|
||||
prev.nix-prefetch-git.override { nix = prev.nix; }
|
||||
else
|
||||
prev.nix-prefetch-git;
|
||||
|
||||
# Export the patched version of boehmgc that Lix uses into the overlay
|
||||
# for consumers of this flake.
|
||||
boehmgc-nix = final.nix.passthru.boehmgc-nix;
|
||||
@@ -265,9 +246,6 @@
|
||||
# Perl bindings for various platforms.
|
||||
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix.passthru.perl-bindings);
|
||||
|
||||
# nix-eval-jobs can be built against this Lix.
|
||||
nix-eval-jobs = forAllSystems (system: nixpkgsFor.${system}.native.nix-eval-jobs);
|
||||
|
||||
# Binary tarball for various platforms, containing a Nix store
|
||||
# with the closure of 'nix' package.
|
||||
binaryTarball = forAllSystems (system: nixpkgsFor.${system}.native.nix.passthru.binaryTarball);
|
||||
@@ -299,98 +277,87 @@
|
||||
});
|
||||
|
||||
# System tests.
|
||||
tests =
|
||||
import ./tests/nixos {
|
||||
inherit
|
||||
self
|
||||
lib
|
||||
nixpkgs
|
||||
nixpkgsFor
|
||||
;
|
||||
}
|
||||
// {
|
||||
nix-eval-jobs = forAllSystems (system: self.packages.${system}.nix-eval-jobs.tests.nix-eval-jobs);
|
||||
tests = import ./tests/nixos { inherit lib nixpkgs nixpkgsFor; } // {
|
||||
# This is x86_64-linux only, just because we have significantly
|
||||
# cheaper x86_64-linux compute in CI.
|
||||
# It is clangStdenv because clang's sanitizers are nicer.
|
||||
asanBuild = self.packages.x86_64-linux.nix-clangStdenv.override {
|
||||
# Improve caching of non-code changes by not changing the
|
||||
# derivation name every single time, since this will never be seen
|
||||
# by users anyway.
|
||||
versionSuffix = "";
|
||||
sanitize = [
|
||||
"address"
|
||||
"undefined"
|
||||
];
|
||||
# it is very hard to make *every* CI build use this option such
|
||||
# that we don't wind up building Lix twice, so we do it here where
|
||||
# we are already doing so.
|
||||
werror = true;
|
||||
};
|
||||
|
||||
# This is x86_64-linux only, just because we have significantly
|
||||
# cheaper x86_64-linux compute in CI.
|
||||
# It is clangStdenv because clang's sanitizers are nicer.
|
||||
asanBuild = self.packages.x86_64-linux.nix-clangStdenv.override {
|
||||
# Improve caching of non-code changes by not changing the
|
||||
# derivation name every single time, since this will never be seen
|
||||
# by users anyway.
|
||||
# Although this might be nicer to do with pre-commit, that would
|
||||
# require adding 12MB of nodejs to the dev shell, whereas building it
|
||||
# in CI with Nix avoids that at a cost of slower feedback on rarely
|
||||
# touched files.
|
||||
jsSyntaxCheck =
|
||||
let
|
||||
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||
inherit (nixpkgs) pkgs;
|
||||
docSources = lib.fileset.toSource {
|
||||
root = ./doc;
|
||||
fileset = lib.fileset.fileFilter (f: f.hasExt "js") ./doc;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "js-syntax-check" { } ''
|
||||
find ${docSources} -type f -print -exec ${pkgs.nodejs-slim}/bin/node --check '{}' ';'
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# clang-tidy run against the Lix codebase using the Lix clang-tidy plugin
|
||||
clang-tidy =
|
||||
let
|
||||
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||
inherit (nixpkgs) pkgs;
|
||||
in
|
||||
pkgs.callPackage ./package.nix {
|
||||
# Required since we don't support gcc stdenv
|
||||
stdenv = pkgs.clangStdenv;
|
||||
versionSuffix = "";
|
||||
sanitize = [
|
||||
"address"
|
||||
"undefined"
|
||||
];
|
||||
# it is very hard to make *every* CI build use this option such
|
||||
# that we don't wind up building Lix twice, so we do it here where
|
||||
# we are already doing so.
|
||||
werror = true;
|
||||
lintInsteadOfBuild = true;
|
||||
};
|
||||
|
||||
# Although this might be nicer to do with pre-commit, that would
|
||||
# require adding 12MB of nodejs to the dev shell, whereas building it
|
||||
# in CI with Nix avoids that at a cost of slower feedback on rarely
|
||||
# touched files.
|
||||
jsSyntaxCheck =
|
||||
let
|
||||
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||
inherit (nixpkgs) pkgs;
|
||||
docSources = lib.fileset.toSource {
|
||||
root = ./doc;
|
||||
fileset = lib.fileset.fileFilter (f: f.hasExt "js") ./doc;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "js-syntax-check" { } ''
|
||||
find ${docSources} -type f -print -exec ${pkgs.nodejs-slim}/bin/node --check '{}' ';'
|
||||
touch $out
|
||||
'';
|
||||
# Make sure that nix-env still produces the exact same result
|
||||
# on a particular version of Nixpkgs.
|
||||
evalNixpkgs =
|
||||
with nixpkgsFor.x86_64-linux.native;
|
||||
runCommand "eval-nixos" { buildInputs = [ nix ]; } ''
|
||||
type -p nix-env
|
||||
# Note: we're filtering out nixos-install-tools because https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1020530593.
|
||||
time nix-env --store dummy:// -f ${nixpkgs-regression} -qaP --drv-path | sort | grep -v nixos-install-tools > packages
|
||||
[[ $(sha1sum < packages | cut -c1-40) = 402242fca90874112b34718b8199d844e8b03d12 ]]
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
# clang-tidy run against the Lix codebase using the Lix clang-tidy plugin
|
||||
clang-tidy =
|
||||
let
|
||||
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||
inherit (nixpkgs) pkgs;
|
||||
in
|
||||
pkgs.callPackage ./package.nix {
|
||||
# Required since we don't support gcc stdenv
|
||||
stdenv = pkgs.clangStdenv;
|
||||
versionSuffix = "";
|
||||
lintInsteadOfBuild = true;
|
||||
};
|
||||
|
||||
# Make sure that nix-env still produces the exact same result
|
||||
# on a particular version of Nixpkgs.
|
||||
evalNixpkgs =
|
||||
with nixpkgsFor.x86_64-linux.native;
|
||||
runCommand "eval-nixos" { buildInputs = [ nix ]; } ''
|
||||
type -p nix-env
|
||||
# Note: we're filtering out nixos-install-tools because https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1020530593.
|
||||
time nix-env --store dummy:// -f ${nixpkgs-regression} -qaP --drv-path | sort | grep -v nixos-install-tools > packages
|
||||
[[ $(sha1sum < packages | cut -c1-40) = 402242fca90874112b34718b8199d844e8b03d12 ]]
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
nixpkgsLibTests = forAllSystems (
|
||||
system:
|
||||
let
|
||||
inherit (self.packages.${system}) nix;
|
||||
pkgs = nixpkgsFor.${system}.native;
|
||||
testWithNix = import (nixpkgs + "/lib/tests/test-with-nix.nix") { inherit pkgs lib nix; };
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "nixpkgs-lib-tests";
|
||||
paths =
|
||||
[ testWithNix ]
|
||||
# NOTE: nixpkgs 24.11 is being ... *creative*, and requires this dance to override
|
||||
# the evaluator used for the test. it will break again in the future, don't worry.
|
||||
++ lib.optionals pkgs.stdenv.isLinux [
|
||||
(pkgs.callPackage "${nixpkgs}/ci/eval" { nixVersions.nix_2_24 = nix; }).attrpathsSuperset
|
||||
];
|
||||
}
|
||||
);
|
||||
};
|
||||
nixpkgsLibTests = forAllSystems (
|
||||
system:
|
||||
let
|
||||
inherit (self.packages.${system}) nix;
|
||||
pkgs = nixpkgsFor.${system}.native;
|
||||
testWithNix = import (nixpkgs + "/lib/tests/test-with-nix.nix") { inherit pkgs lib nix; };
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "nixpkgs-lib-tests";
|
||||
paths =
|
||||
[ testWithNix ]
|
||||
# FIXME: This is disabled on darwin due to a nixpkgs bug https://github.com/NixOS/nixpkgs/issues/319147
|
||||
# After that is fixed, it should be restored to use lib/tests/release.nix as before, rather than this reimplementation.
|
||||
++ lib.optionals pkgs.stdenv.isLinux [
|
||||
(import (nixpkgs + "/pkgs/test/release") { inherit pkgs lib nix; })
|
||||
];
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
pre-commit = forAvailableSystems (
|
||||
system:
|
||||
@@ -438,7 +405,6 @@
|
||||
|
||||
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
||||
perlBindings = self.hydraJobs.perlBindings.${system};
|
||||
nix-eval-jobs = self.hydraJobs.nix-eval-jobs.${system};
|
||||
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
|
||||
rl-next = self.hydraJobs.rl-next.${system}.user;
|
||||
# Will be empty attr set on i686-linux, and filtered out by forAvailableSystems.
|
||||
@@ -456,7 +422,7 @@
|
||||
inherit (nixpkgsFor.${system}.native) nix;
|
||||
default = nix;
|
||||
|
||||
inherit (nixpkgsFor.${system}.native) lix-clang-tidy nix-eval-jobs;
|
||||
inherit (nixpkgsFor.${system}.native) lix-clang-tidy;
|
||||
}
|
||||
// (
|
||||
lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
||||
|
||||
@@ -8,47 +8,30 @@ list:
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
# Prepare meson for building with extra options
|
||||
setup-custom *OPTIONS:
|
||||
# Prepare meson for building
|
||||
setup *OPTIONS:
|
||||
meson setup build --prefix="$PWD/outputs/out" $mesonFlags {{ OPTIONS }}
|
||||
|
||||
# Prepare meson for building
|
||||
setup: (setup-custom)
|
||||
|
||||
# Build lix with extra options
|
||||
build-custom *OPTIONS:
|
||||
meson compile -C build {{ OPTIONS }}
|
||||
|
||||
# Build lix
|
||||
build: (build-custom)
|
||||
build *OPTIONS:
|
||||
meson compile -C build {{ OPTIONS }}
|
||||
|
||||
alias compile := build
|
||||
|
||||
# Install lix for local development with extra options
|
||||
install-custom *OPTIONS: (build-custom OPTIONS)
|
||||
# Install lix for local development
|
||||
install *OPTIONS: (build OPTIONS)
|
||||
meson install -C build
|
||||
|
||||
# Install lix for local development
|
||||
install: (install-custom)
|
||||
|
||||
# Run tests (usually requires `install`) with extra options
|
||||
# Run tests
|
||||
test *OPTIONS:
|
||||
meson test -C build --print-errorlogs {{ OPTIONS }}
|
||||
|
||||
# Run unit tests only
|
||||
test-unit *OPTIONS: (test "--suite" "check")
|
||||
|
||||
# Run integration tests only
|
||||
test-integration *OPTIONS: install (test "--suite" "installcheck")
|
||||
|
||||
alias clang-tidy := lint
|
||||
|
||||
# Lint with `clang-tidy`
|
||||
lint:
|
||||
ninja -C build clang-tidy
|
||||
|
||||
alias clang-tidy-fix := lint-fix
|
||||
|
||||
# Fix lints with `clang-tidy-fix`
|
||||
lint-fix:
|
||||
ninja -C build clang-tidy-fix
|
||||
|
||||
+31
-36
@@ -1,5 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
@@ -24,6 +23,9 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
static void handleAlarm(int sig) {
|
||||
}
|
||||
|
||||
std::string escapeUri(std::string uri)
|
||||
{
|
||||
std::replace(uri.begin(), uri.end(), '/', '_');
|
||||
@@ -53,7 +55,7 @@ static bool allSupportedLocally(Store & store, const std::set<std::string>& requ
|
||||
return true;
|
||||
}
|
||||
|
||||
static int main_build_remote(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_build_remote(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
logger = makeJSONLogger(*logger);
|
||||
@@ -84,12 +86,12 @@ static int main_build_remote(AsyncIoRoot & aio, std::string programName, Strings
|
||||
|
||||
initPlugins();
|
||||
|
||||
auto store = aio.blockOn(openStore());
|
||||
auto store = openStore();
|
||||
|
||||
/* It would be more appropriate to use $XDG_RUNTIME_DIR, since
|
||||
that gets cleared on reboot, but it wouldn't work on macOS. */
|
||||
auto currentLoadName = "/current-load";
|
||||
if (auto localStore = store.try_cast_shared<LocalFSStore>())
|
||||
if (auto localStore = store.dynamic_pointer_cast<LocalFSStore>())
|
||||
currentLoad = std::string { localStore->config().stateDir } + currentLoadName;
|
||||
else
|
||||
currentLoad = settings.nixStateDir + currentLoadName;
|
||||
@@ -135,7 +137,7 @@ static int main_build_remote(AsyncIoRoot & aio, std::string programName, Strings
|
||||
while (true) {
|
||||
bestSlotLock.reset();
|
||||
AutoCloseFD lock = openLockFile(currentLoad + "/main-lock", true);
|
||||
lockFile(lock.get(), ltWrite);
|
||||
lockFile(lock.get(), ltWrite, true);
|
||||
|
||||
bool rightType = false;
|
||||
|
||||
@@ -154,7 +156,7 @@ static int main_build_remote(AsyncIoRoot & aio, std::string programName, Strings
|
||||
uint64_t load = 0;
|
||||
for (uint64_t slot = 0; slot < m.maxJobs; ++slot) {
|
||||
auto slotLock = openSlotLock(m, slot);
|
||||
if (tryLockFile(slotLock.get(), ltWrite)) {
|
||||
if (lockFile(slotLock.get(), ltWrite, false)) {
|
||||
if (!free) {
|
||||
free = std::move(slotLock);
|
||||
}
|
||||
@@ -243,11 +245,11 @@ static int main_build_remote(AsyncIoRoot & aio, std::string programName, Strings
|
||||
|
||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("connecting to '%s'", bestMachine->storeUri));
|
||||
|
||||
sshStore = aio.blockOn(bestMachine->openStore());
|
||||
aio.blockOn(sshStore->connect());
|
||||
sshStore = bestMachine->openStore();
|
||||
sshStore->connect();
|
||||
storeUri = bestMachine->storeUri;
|
||||
|
||||
} catch (std::exception & e) { // NOLINT(lix-foreign-exceptions)
|
||||
} catch (std::exception & e) {
|
||||
auto msg = chomp(drainFD(5, false));
|
||||
printError("cannot build on '%s': %s%s",
|
||||
bestMachine->storeUri, e.what(),
|
||||
@@ -277,27 +279,24 @@ connected:
|
||||
{
|
||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri));
|
||||
|
||||
if (!unsafeLockFileSingleThreaded(uploadLock.get(), ltWrite, std::chrono::minutes(15)))
|
||||
auto old = signal(SIGALRM, handleAlarm);
|
||||
alarm(15 * 60);
|
||||
if (!lockFile(uploadLock.get(), ltWrite, true))
|
||||
printError("somebody is hogging the upload lock for '%s', continuing...");
|
||||
alarm(0);
|
||||
signal(SIGALRM, old);
|
||||
}
|
||||
|
||||
auto substitute = settings.buildersUseSubstitutes ? Substitute : NoSubstitute;
|
||||
|
||||
{
|
||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri));
|
||||
aio.blockOn(copyPaths(
|
||||
*store,
|
||||
*sshStore,
|
||||
store->parseStorePathSet(inputs),
|
||||
NoRepair,
|
||||
NoCheckSigs,
|
||||
substitute
|
||||
));
|
||||
copyPaths(*store, *sshStore, store->parseStorePathSet(inputs), NoRepair, NoCheckSigs, substitute);
|
||||
}
|
||||
|
||||
uploadLock.reset();
|
||||
|
||||
auto drv = aio.blockOn(store->readDerivation(*drvPath));
|
||||
auto drv = store->readDerivation(*drvPath);
|
||||
|
||||
std::optional<BuildResult> optResult;
|
||||
|
||||
@@ -305,7 +304,7 @@ connected:
|
||||
// stores), we assume we are. This is necessary for backwards
|
||||
// compat.
|
||||
bool trustedOrLegacy = ({
|
||||
std::optional trusted = aio.blockOn(sshStore->isTrustedClient());
|
||||
std::optional trusted = sshStore->isTrustedClient();
|
||||
!trusted || *trusted;
|
||||
});
|
||||
|
||||
@@ -326,34 +325,32 @@ connected:
|
||||
// output ids, which break CA derivations
|
||||
if (!drv.inputDrvs.map.empty())
|
||||
drv.inputSrcs = store->parseStorePathSet(inputs);
|
||||
optResult = aio.blockOn(sshStore->buildDerivation(*drvPath, (const BasicDerivation &) drv));
|
||||
optResult = sshStore->buildDerivation(*drvPath, (const BasicDerivation &) drv);
|
||||
auto & result = *optResult;
|
||||
if (!result.success())
|
||||
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
|
||||
} else {
|
||||
aio.blockOn(copyClosure(
|
||||
*store, *sshStore, StorePathSet{*drvPath}, NoRepair, NoCheckSigs, substitute
|
||||
));
|
||||
auto res = aio.blockOn(sshStore->buildPathsWithResults({
|
||||
copyClosure(*store, *sshStore, StorePathSet {*drvPath}, NoRepair, NoCheckSigs, substitute);
|
||||
auto res = sshStore->buildPathsWithResults({
|
||||
DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(*drvPath),
|
||||
.outputs = OutputsSpec::All {},
|
||||
}
|
||||
}));
|
||||
});
|
||||
// One path to build should produce exactly one build result
|
||||
assert(res.size() == 1);
|
||||
optResult = std::move(res[0]);
|
||||
}
|
||||
|
||||
|
||||
auto outputHashes = aio.blockOn(staticOutputHashes(*store, drv));
|
||||
auto outputHashes = staticOutputHashes(*store, drv);
|
||||
std::set<Realisation> missingRealisations;
|
||||
StorePathSet missingPaths;
|
||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations) && !drv.type().hasKnownOutputPaths()) {
|
||||
for (auto & outputName : wantedOutputs) {
|
||||
auto thisOutputHash = outputHashes.at(outputName);
|
||||
auto thisOutputId = DrvOutput{ thisOutputHash, outputName };
|
||||
if (!aio.blockOn(store->queryRealisation(thisOutputId))) {
|
||||
if (!store->queryRealisation(thisOutputId)) {
|
||||
debug("missing output %s", outputName);
|
||||
assert(optResult);
|
||||
auto & result = *optResult;
|
||||
@@ -368,34 +365,32 @@ connected:
|
||||
auto outputPaths = drv.outputsAndOptPaths(*store);
|
||||
for (auto & [outputName, hopefullyOutputPath] : outputPaths) {
|
||||
assert(hopefullyOutputPath.second);
|
||||
if (!aio.blockOn(store->isValidPath(*hopefullyOutputPath.second)))
|
||||
if (!store->isValidPath(*hopefullyOutputPath.second))
|
||||
missingPaths.insert(*hopefullyOutputPath.second);
|
||||
}
|
||||
}
|
||||
|
||||
if (!missingPaths.empty()) {
|
||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri));
|
||||
if (auto localStore = store.try_cast_shared<LocalStore>())
|
||||
if (auto localStore = store.dynamic_pointer_cast<LocalStore>())
|
||||
for (auto & path : missingPaths)
|
||||
localStore->locksHeld.insert(store->printStorePath(path)); /* FIXME: ugly */
|
||||
aio.blockOn(
|
||||
copyPaths(*sshStore, *store, missingPaths, NoRepair, NoCheckSigs, NoSubstitute)
|
||||
);
|
||||
copyPaths(*sshStore, *store, missingPaths, NoRepair, NoCheckSigs, NoSubstitute);
|
||||
}
|
||||
// XXX: Should be done as part of `copyPaths`
|
||||
for (auto & realisation : missingRealisations) {
|
||||
// Should hold, because if the feature isn't enabled the set
|
||||
// of missing realisations should be empty
|
||||
experimentalFeatureSettings.require(Xp::CaDerivations);
|
||||
aio.blockOn(store->registerDrvOutput(realisation));
|
||||
store->registerDrvOutput(realisation);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyBuildRemote() {
|
||||
LegacyCommandRegistry::add("build-remote", main_build_remote);
|
||||
void registerBuildRemote() {
|
||||
LegacyCommands::add("build-remote", main_build_remote);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyBuildRemote();
|
||||
void registerBuildRemote();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "dotgraph.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -43,8 +41,8 @@ static std::string makeNode(std::string_view id, std::string_view label,
|
||||
}
|
||||
|
||||
|
||||
kj::Promise<Result<void>> printDotGraph(ref<Store> store, StorePathSet && roots)
|
||||
try {
|
||||
void printDotGraph(ref<Store> store, StorePathSet && roots)
|
||||
{
|
||||
StorePathSet workList(std::move(roots));
|
||||
StorePathSet doneSet;
|
||||
|
||||
@@ -57,7 +55,7 @@ try {
|
||||
|
||||
cout << makeNode(std::string(path.to_string()), path.name(), "#ff0000");
|
||||
|
||||
for (auto & p : TRY_AWAIT(store->queryPathInfo(path))->references) {
|
||||
for (auto & p : store->queryPathInfo(path)->references) {
|
||||
if (p != path) {
|
||||
workList.insert(p);
|
||||
cout << makeEdge(std::string(p.to_string()), std::string(path.to_string()));
|
||||
@@ -66,9 +64,6 @@ try {
|
||||
}
|
||||
|
||||
cout << "}\n";
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
kj::Promise<Result<void>> printDotGraph(ref<Store> store, StorePathSet && roots);
|
||||
void printDotGraph(ref<Store> store, StorePathSet && roots);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "graphml.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -48,8 +46,8 @@ static std::string makeNode(const ValidPathInfo & info)
|
||||
}
|
||||
|
||||
|
||||
kj::Promise<Result<void>> printGraphML(ref<Store> store, StorePathSet && roots)
|
||||
try {
|
||||
void printGraphML(ref<Store> store, StorePathSet && roots)
|
||||
{
|
||||
StorePathSet workList(std::move(roots));
|
||||
StorePathSet doneSet;
|
||||
std::pair<StorePathSet::iterator, bool> ret;
|
||||
@@ -69,7 +67,7 @@ try {
|
||||
ret = doneSet.insert(path);
|
||||
if (ret.second == false) continue;
|
||||
|
||||
auto info = TRY_AWAIT(store->queryPathInfo(path));
|
||||
auto info = store->queryPathInfo(path);
|
||||
cout << makeNode(*info);
|
||||
|
||||
for (auto & p : info->references) {
|
||||
@@ -83,9 +81,6 @@ try {
|
||||
|
||||
cout << "</graph>\n";
|
||||
cout << "</graphml>\n";
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
kj::Promise<Result<void>> printGraphML(ref<Store> store, StorePathSet && roots);
|
||||
void printGraphML(ref<Store> store, StorePathSet && roots);
|
||||
|
||||
}
|
||||
|
||||
+53
-62
@@ -1,10 +1,14 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "lix/libstore/parsed-derivations.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libstore/local-fs-store.hh"
|
||||
@@ -14,11 +18,11 @@
|
||||
#include "lix/libmain/shared.hh"
|
||||
#include "lix/libstore/path-with-outputs.hh"
|
||||
#include "lix/libexpr/eval.hh"
|
||||
#include "lix/libexpr/eval-inline.hh"
|
||||
#include "lix/libexpr/get-drvs.hh"
|
||||
#include "lix/libcmd/common-eval-args.hh"
|
||||
#include "lix/libexpr/attr-path.hh"
|
||||
#include "lix/libcmd/legacy.hh"
|
||||
#include "lix/libutil/regex.hh"
|
||||
#include "lix/libutil/shlex.hh"
|
||||
#include "nix-build.hh"
|
||||
#include "lix/libstore/temporary-dir.hh"
|
||||
@@ -29,10 +33,10 @@ namespace nix {
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static void main_nix_build(std::string programName, Strings argv)
|
||||
{
|
||||
auto dryRun = false;
|
||||
auto runEnv = std::regex_search(programName, regex::parse("nix-shell$"));
|
||||
auto runEnv = std::regex_search(programName, std::regex("nix-shell$"));
|
||||
auto pure = false;
|
||||
auto fromArgs = false;
|
||||
auto packages = false;
|
||||
@@ -69,7 +73,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
script = argv.front();
|
||||
try {
|
||||
auto lines = tokenizeString<Strings>(readFile(script), "\n");
|
||||
if (std::regex_search(lines.front(), regex::parse("^#!"))) {
|
||||
if (std::regex_search(lines.front(), std::regex("^#!"))) {
|
||||
lines.pop_front();
|
||||
inShebang = true;
|
||||
savedArgs = {std::next(argv.begin()), argv.end()};
|
||||
@@ -77,7 +81,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
for (auto line : lines) {
|
||||
line = chomp(line);
|
||||
std::smatch match;
|
||||
if (std::regex_match(line, match, regex::parse("^#!\\s*nix-shell\\s+(.*)$")))
|
||||
if (std::regex_match(line, match, std::regex("^#!\\s*nix-shell\\s+(.*)$")))
|
||||
for (const auto & word : shell_split(match[1].str()))
|
||||
argv.push_back(word);
|
||||
}
|
||||
@@ -90,7 +94,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(aio, myName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(myName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help") {
|
||||
showManPage(myName);
|
||||
}
|
||||
@@ -149,14 +153,14 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
// executes it unless it contains the string "perl" or "indir",
|
||||
// or (undocumented) argv[0] does not contain "perl". Exploit
|
||||
// the latter by doing "exec -a".
|
||||
if (std::regex_search(interpreter, regex::parse("perl")))
|
||||
if (std::regex_search(interpreter, std::regex("perl")))
|
||||
execArgs = "-a PERL";
|
||||
|
||||
std::ostringstream joined;
|
||||
for (const auto & i : savedArgs)
|
||||
joined << shellEscape(i) << ' ';
|
||||
|
||||
if (std::regex_search(interpreter, regex::parse("ruby"))) {
|
||||
if (std::regex_search(interpreter, std::regex("ruby"))) {
|
||||
// Hack for Ruby. Ruby also examines the shebang. It tries to
|
||||
// read the shebang to understand which packages to read from. Since
|
||||
// this is handled via nix-shell -p, we wrap our ruby script execution
|
||||
@@ -191,19 +195,18 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
if (outLink.empty())
|
||||
outLink = (Path) tmpDir + "/result";
|
||||
|
||||
auto store = aio.blockOn(openStore());
|
||||
auto evalStore = myArgs.evalStoreUrl ? aio.blockOn(openStore(*myArgs.evalStoreUrl)) : store;
|
||||
auto store = openStore();
|
||||
auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store;
|
||||
|
||||
auto evaluator = std::make_unique<Evaluator>(aio, myArgs.searchPath, evalStore, store);
|
||||
evaluator->repair = myArgs.repair;
|
||||
auto state = evaluator->begin(aio);
|
||||
auto state = std::make_unique<EvalState>(myArgs.searchPath, evalStore, store);
|
||||
state->repair = myArgs.repair;
|
||||
if (myArgs.repair) buildMode = bmRepair;
|
||||
|
||||
auto autoArgs = myArgs.getAutoArgs(*evaluator);
|
||||
auto autoArgs = myArgs.getAutoArgs(*state);
|
||||
|
||||
auto autoArgsWithInNixShell = autoArgs;
|
||||
if (runEnv) {
|
||||
auto newArgs = evaluator->buildBindings(autoArgsWithInNixShell->size() + 1);
|
||||
auto newArgs = state->buildBindings(autoArgsWithInNixShell->size() + 1);
|
||||
newArgs.alloc("inNixShell").mkBool(true);
|
||||
for (auto & i : *autoArgs) newArgs.insert(i);
|
||||
autoArgsWithInNixShell = newArgs.finish();
|
||||
@@ -233,11 +236,11 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
std::vector<std::reference_wrapper<Expr>> exprs;
|
||||
|
||||
if (readStdin)
|
||||
exprs = {evaluator->parseStdin()};
|
||||
exprs = {state->parseStdin()};
|
||||
else
|
||||
for (auto i : left) {
|
||||
if (fromArgs)
|
||||
exprs.push_back(evaluator->parseExprFromString(std::move(i), CanonPath::fromCwd()));
|
||||
exprs.push_back(state->parseExprFromString(std::move(i), CanonPath::fromCwd()));
|
||||
else {
|
||||
auto absolute = i;
|
||||
try {
|
||||
@@ -245,16 +248,12 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
} catch (Error & e) {};
|
||||
auto [path, outputNames] = parsePathWithOutputs(absolute);
|
||||
if (evalStore->isStorePath(path) && path.ends_with(".drv"))
|
||||
drvs.push_back(aio.blockOn(DrvInfo::create(evalStore, absolute)));
|
||||
drvs.push_back(DrvInfo(*state, evalStore, absolute));
|
||||
else
|
||||
/* If we're in a #! script, interpret filenames
|
||||
relative to the script. */
|
||||
exprs.push_back(evaluator->parseExprFromFile(
|
||||
evaluator->paths.resolveExprPath(aio.blockOn(lookupFileArg(
|
||||
*evaluator,
|
||||
inShebang && !packages ? absPath(i, absPath(dirOf(script))) : i
|
||||
)).unwrap())
|
||||
));
|
||||
exprs.push_back(state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state,
|
||||
inShebang && !packages ? absPath(i, absPath(dirOf(script))) : i)))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,13 +270,11 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
return false;
|
||||
}
|
||||
bool add = false;
|
||||
if (v.type() == nFunction) {
|
||||
if (auto pattern = dynamic_cast<AttrsPattern *>(v.lambda.fun->pattern.get())) {
|
||||
for (auto & i : pattern->formals) {
|
||||
if (evaluator->symbols[i.name] == "inNixShell") {
|
||||
add = true;
|
||||
break;
|
||||
}
|
||||
if (v.type() == nFunction && v.lambda.fun->hasFormals()) {
|
||||
for (auto & i : v.lambda.fun->formals->formals) {
|
||||
if (state->symbols[i.name] == "inNixShell") {
|
||||
add = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,7 +288,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
takesNixShellAttr(vRoot) ? *autoArgsWithInNixShell : *autoArgs,
|
||||
vRoot
|
||||
).first);
|
||||
state->forceValue(v, noPos);
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
getDerivations(
|
||||
*state,
|
||||
v,
|
||||
@@ -303,24 +300,21 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
}
|
||||
}
|
||||
|
||||
evaluator->maybePrintStats();
|
||||
state->maybePrintStats();
|
||||
|
||||
auto buildPaths = [&](const std::vector<DerivedPath> & paths) {
|
||||
/* Note: we do this even when !printMissing to efficiently
|
||||
fetch binary cache data. */
|
||||
uint64_t downloadSize, narSize;
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
aio.blockOn(store->queryMissing(paths,
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize));
|
||||
store->queryMissing(paths,
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
|
||||
if (settings.printMissing) {
|
||||
aio.blockOn(printMissing(
|
||||
ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize
|
||||
));
|
||||
}
|
||||
if (settings.printMissing)
|
||||
printMissing(ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
|
||||
if (!dryRun)
|
||||
aio.blockOn(store->buildPaths(paths, buildMode, evalStore));
|
||||
store->buildPaths(paths, buildMode, evalStore);
|
||||
};
|
||||
|
||||
if (runEnv) {
|
||||
@@ -328,7 +322,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
throw UsageError("nix-shell requires a single derivation");
|
||||
|
||||
auto & drvInfo = drvs.front();
|
||||
auto drv = aio.blockOn(evalStore->derivationFromPath(drvInfo.requireDrvPath(*state)));
|
||||
auto drv = evalStore->derivationFromPath(drvInfo.requireDrvPath());
|
||||
|
||||
std::vector<DerivedPath> pathsToBuild;
|
||||
RealisedPath::Set pathsToCopy;
|
||||
@@ -342,7 +336,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
if (!shell) {
|
||||
|
||||
try {
|
||||
auto & expr = evaluator->parseExprFromString(
|
||||
auto & expr = state->parseExprFromString(
|
||||
"(import <nixpkgs> {}).bashInteractive",
|
||||
CanonPath::fromCwd());
|
||||
|
||||
@@ -353,7 +347,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
if (!drv)
|
||||
throw Error("the 'bashInteractive' attribute in <nixpkgs> did not evaluate to a derivation");
|
||||
|
||||
auto bashDrv = drv->requireDrvPath(*state);
|
||||
auto bashDrv = drv->requireDrvPath();
|
||||
pathsToBuild.push_back(DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(bashDrv),
|
||||
.outputs = OutputsSpec::Names {"out"},
|
||||
@@ -389,7 +383,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
const auto & inputDrv = inputDrv0;
|
||||
if (std::all_of(envExclude.cbegin(), envExclude.cend(),
|
||||
[&](const std::string & exclude) {
|
||||
return !std::regex_search(store->printStorePath(inputDrv), regex::parse(exclude));
|
||||
return !std::regex_search(store->printStorePath(inputDrv), std::regex(exclude));
|
||||
}))
|
||||
{
|
||||
accumDerivedPath(makeConstantStorePathRef(inputDrv), inputNode);
|
||||
@@ -406,13 +400,12 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
if (dryRun) return;
|
||||
|
||||
if (shellDrv) {
|
||||
auto shellDrvOutputs =
|
||||
aio.blockOn(store->queryPartialDerivationOutputMap(shellDrv.value(), &*evalStore));
|
||||
auto shellDrvOutputs = store->queryPartialDerivationOutputMap(shellDrv.value(), &*evalStore);
|
||||
shell = store->printStorePath(shellDrvOutputs.at("out").value()) + "/bin/bash";
|
||||
}
|
||||
|
||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
||||
auto resolvedDrv = aio.blockOn(drv.tryResolve(*store));
|
||||
auto resolvedDrv = drv.tryResolve(*store);
|
||||
assert(resolvedDrv && "Successfully resolved the derivation");
|
||||
drv = *resolvedDrv;
|
||||
}
|
||||
@@ -458,11 +451,10 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
std::function<void(const StorePath &, const DerivedPathMap<StringSet>::ChildNode &)> accumInputClosure;
|
||||
|
||||
accumInputClosure = [&](const StorePath & inputDrv, const DerivedPathMap<StringSet>::ChildNode & inputNode) {
|
||||
auto outputs =
|
||||
aio.blockOn(store->queryPartialDerivationOutputMap(inputDrv, &*evalStore));
|
||||
auto outputs = store->queryPartialDerivationOutputMap(inputDrv, &*evalStore);
|
||||
for (auto & i : inputNode.value) {
|
||||
auto o = outputs.at(i);
|
||||
aio.blockOn(store->computeFSClosure(*o, inputs));
|
||||
store->computeFSClosure(*o, inputs);
|
||||
}
|
||||
for (const auto & [outputName, childNode] : inputNode.childMap)
|
||||
accumInputClosure(*outputs.at(outputName), childNode);
|
||||
@@ -471,9 +463,9 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
for (const auto & [inputDrv, inputNode] : drv.inputDrvs.map)
|
||||
accumInputClosure(inputDrv, inputNode);
|
||||
|
||||
ParsedDerivation parsedDrv(drvInfo.requireDrvPath(*state), drv);
|
||||
ParsedDerivation parsedDrv(drvInfo.requireDrvPath(), drv);
|
||||
|
||||
if (auto structAttrs = aio.blockOn(parsedDrv.prepareStructuredAttrs(*store, inputs))) {
|
||||
if (auto structAttrs = parsedDrv.prepareStructuredAttrs(*store, inputs)) {
|
||||
auto json = structAttrs.value();
|
||||
structuredAttrsRC = writeStructuredAttrsShell(json);
|
||||
|
||||
@@ -574,9 +566,9 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
std::map<StorePath, std::pair<size_t, StringSet>> drvMap;
|
||||
|
||||
for (auto & drvInfo : drvs) {
|
||||
auto drvPath = drvInfo.requireDrvPath(*state);
|
||||
auto drvPath = drvInfo.requireDrvPath();
|
||||
|
||||
auto outputName = drvInfo.queryOutputName(*state);
|
||||
auto outputName = drvInfo.queryOutputName();
|
||||
if (outputName == "")
|
||||
throw Error("derivation '%s' lacks an 'outputName' attribute", store->printStorePath(drvPath));
|
||||
|
||||
@@ -606,17 +598,16 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
if (counter)
|
||||
drvPrefix += fmt("-%d", counter + 1);
|
||||
|
||||
auto builtOutputs =
|
||||
aio.blockOn(store->queryPartialDerivationOutputMap(drvPath, &*evalStore));
|
||||
auto builtOutputs = store->queryPartialDerivationOutputMap(drvPath, &*evalStore);
|
||||
|
||||
auto maybeOutputPath = builtOutputs.at(outputName);
|
||||
assert(maybeOutputPath);
|
||||
auto outputPath = *maybeOutputPath;
|
||||
|
||||
if (auto store2 = store.try_cast_shared<LocalFSStore>()) {
|
||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
|
||||
std::string symlink = drvPrefix;
|
||||
if (outputName != "out") symlink += "-" + outputName;
|
||||
aio.blockOn(store2->addPermRoot(outputPath, absPath(symlink)));
|
||||
store2->addPermRoot(outputPath, absPath(symlink));
|
||||
}
|
||||
|
||||
outPaths.push_back(outputPath);
|
||||
@@ -629,9 +620,9 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixBuildAndNixShell() {
|
||||
LegacyCommandRegistry::add("nix-build", main_nix_build);
|
||||
LegacyCommandRegistry::add("nix-shell", main_nix_build);
|
||||
void registerNixBuildAndNixShell() {
|
||||
LegacyCommands::add("nix-build", main_nix_build);
|
||||
LegacyCommands::add("nix-shell", main_nix_build);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixBuildAndNixShell();
|
||||
void registerNixBuildAndNixShell();
|
||||
|
||||
}
|
||||
|
||||
+18
-31
@@ -7,8 +7,6 @@
|
||||
#include "lix/libfetchers/fetchers.hh"
|
||||
#include "lix/libexpr/eval-settings.hh" // for defexpr
|
||||
#include "lix/libstore/temporary-dir.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/regex.hh"
|
||||
#include "lix/libutil/users.hh"
|
||||
#include "nix-channel.hh"
|
||||
|
||||
@@ -31,10 +29,10 @@ static void readChannels()
|
||||
|
||||
for (const auto & line : tokenizeString<std::vector<std::string>>(channelsFile, "\n")) {
|
||||
chomp(line);
|
||||
if (std::regex_search(line, regex::parse("^\\s*\\#")))
|
||||
if (std::regex_search(line, std::regex("^\\s*\\#")))
|
||||
continue;
|
||||
auto split = tokenizeString<std::vector<std::string>>(line, " ");
|
||||
auto url = std::regex_replace(split[0], regex::parse("/*$"), "");
|
||||
auto url = std::regex_replace(split[0], std::regex("/*$"), "");
|
||||
auto name = split.size() > 1 ? split[1] : std::string(baseNameOf(url));
|
||||
channels[name] = url;
|
||||
}
|
||||
@@ -53,9 +51,9 @@ static void writeChannels()
|
||||
// Adds a channel.
|
||||
static void addChannel(const std::string & url, const std::string & name)
|
||||
{
|
||||
if (!regex_search(url, regex::parse("^(file|http|https)://")))
|
||||
if (!regex_search(url, std::regex("^(file|http|https)://")))
|
||||
throw Error("invalid channel URL '%1%'", url);
|
||||
if (!regex_search(name, regex::parse("^[a-zA-Z0-9_][a-zA-Z0-9_\\.-]*$")))
|
||||
if (!regex_search(name, std::regex("^[a-zA-Z0-9_][a-zA-Z0-9_\\.-]*$")))
|
||||
throw Error("invalid channel identifier '%1%'", name);
|
||||
readChannels();
|
||||
channels[name] = url;
|
||||
@@ -77,11 +75,11 @@ static void removeChannel(const std::string & name)
|
||||
static Path nixDefExpr;
|
||||
|
||||
// Fetch Nix expressions and binary cache URLs from the subscribed channels.
|
||||
static void update(AsyncIoRoot & aio, const StringSet & channelNames)
|
||||
static void update(const StringSet & channelNames)
|
||||
{
|
||||
readChannels();
|
||||
|
||||
auto store = aio.blockOn(openStore());
|
||||
auto store = openStore();
|
||||
|
||||
auto [fd, unpackChannelPath] = createTempFile();
|
||||
writeFull(fd.get(),
|
||||
@@ -102,7 +100,7 @@ static void update(AsyncIoRoot & aio, const StringSet & channelNames)
|
||||
auto cname = name;
|
||||
std::smatch match;
|
||||
auto urlBase = std::string(baseNameOf(url));
|
||||
if (std::regex_search(urlBase, match, regex::parse("(-\\d.*)$")))
|
||||
if (std::regex_search(urlBase, match, std::regex("(-\\d.*)$")))
|
||||
cname = cname + match.str(1);
|
||||
|
||||
std::string extraAttrs;
|
||||
@@ -116,17 +114,12 @@ static void update(AsyncIoRoot & aio, const StringSet & channelNames)
|
||||
// We want to download the url to a file to see if it's a tarball while also checking if we
|
||||
// got redirected in the process, so that we can grab the various parts of a nix channel
|
||||
// definition from a consistent location if the redirect changes mid-download.
|
||||
auto result = aio.blockOn(fetchers::downloadFile(
|
||||
store,
|
||||
url,
|
||||
std::string(baseNameOf(url)),
|
||||
false
|
||||
));
|
||||
auto result = fetchers::downloadFile(store, url, std::string(baseNameOf(url)), false);
|
||||
auto filename = store->toRealPath(result.storePath);
|
||||
url = result.effectiveUrl;
|
||||
|
||||
bool unpacked = false;
|
||||
if (std::regex_search(filename, regex::parse("\\.tar\\.(gz|bz2|xz)$"))) {
|
||||
if (std::regex_search(filename, std::regex("\\.tar\\.(gz|bz2|xz)$"))) {
|
||||
runProgram(settings.nixBinDir + "/nix-build", false, { "--no-out-link", "--expr", "import " + unpackChannelPath +
|
||||
"{ name = \"" + cname + "\"; channelName = \"" + name + "\"; src = builtins.storePath \"" + filename + "\"; }" });
|
||||
unpacked = true;
|
||||
@@ -134,17 +127,11 @@ static void update(AsyncIoRoot & aio, const StringSet & channelNames)
|
||||
|
||||
if (!unpacked) {
|
||||
// Download the channel tarball.
|
||||
std::optional<fetchers::DownloadFileResult> exprs;
|
||||
try {
|
||||
exprs = aio.blockOn(fetchers::downloadFile(
|
||||
store, url + "/nixexprs.tar.xz", "nixexprs.tar.xz", false
|
||||
));
|
||||
filename = store->toRealPath(fetchers::downloadFile(store, url + "/nixexprs.tar.xz", "nixexprs.tar.xz", false).storePath);
|
||||
} catch (FileTransferError & e) {
|
||||
exprs = aio.blockOn(fetchers::downloadFile(
|
||||
store, url + "/nixexprs.tar.bz2", "nixexprs.tar.bz2", false
|
||||
));
|
||||
filename = store->toRealPath(fetchers::downloadFile(store, url + "/nixexprs.tar.bz2", "nixexprs.tar.bz2", false).storePath);
|
||||
}
|
||||
filename = store->toRealPath(exprs->storePath);
|
||||
}
|
||||
// Regardless of where it came from, add the expression representing this channel to accumulated expression
|
||||
exprs.push_back("f: f { name = \"" + cname + "\"; channelName = \"" + name + "\"; src = builtins.storePath \"" + filename + "\"; " + extraAttrs + " }");
|
||||
@@ -175,7 +162,7 @@ static void update(AsyncIoRoot & aio, const StringSet & channelNames)
|
||||
replaceSymlink(profile, channelLink);
|
||||
}
|
||||
|
||||
static int main_nix_channel(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_nix_channel(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
// Figure out the name of the `.nix-channels' file to use
|
||||
@@ -197,7 +184,7 @@ static int main_nix_channel(AsyncIoRoot & aio, std::string programName, Strings
|
||||
cRollback
|
||||
} cmd = cNone;
|
||||
std::vector<std::string> args;
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help") {
|
||||
showManPage("nix-channel");
|
||||
} else if (*arg == "--version") {
|
||||
@@ -235,8 +222,8 @@ static int main_nix_channel(AsyncIoRoot & aio, std::string programName, Strings
|
||||
name = args[1];
|
||||
} else {
|
||||
name = baseNameOf(url);
|
||||
name = std::regex_replace(name, regex::parse("-unstable$"), "");
|
||||
name = std::regex_replace(name, regex::parse("-stable$"), "");
|
||||
name = std::regex_replace(name, std::regex("-unstable$"), "");
|
||||
name = std::regex_replace(name, std::regex("-stable$"), "");
|
||||
}
|
||||
addChannel(url, name);
|
||||
}
|
||||
@@ -254,7 +241,7 @@ static int main_nix_channel(AsyncIoRoot & aio, std::string programName, Strings
|
||||
std::cout << channel.first << ' ' << channel.second << '\n';
|
||||
break;
|
||||
case cUpdate:
|
||||
update(aio, StringSet(args.begin(), args.end()));
|
||||
update(StringSet(args.begin(), args.end()));
|
||||
break;
|
||||
case cListGenerations:
|
||||
if (!args.empty())
|
||||
@@ -279,8 +266,8 @@ static int main_nix_channel(AsyncIoRoot & aio, std::string programName, Strings
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixChannel() {
|
||||
LegacyCommandRegistry::add("nix-channel", main_nix_channel);
|
||||
void registerNixChannel() {
|
||||
LegacyCommands::add("nix-channel", main_nix_channel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixChannel();
|
||||
void registerNixChannel();
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "lix/libstore/globals.hh"
|
||||
#include "lix/libcmd/legacy.hh"
|
||||
#include "lix/libutil/signals.hh"
|
||||
#include "lix/libutil/types.hh"
|
||||
#include "nix-collect-garbage.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
|
||||
namespace nix {
|
||||
@@ -22,7 +22,7 @@ bool dryRun = false;
|
||||
* Of course, this makes rollbacks to before this point in time
|
||||
* impossible. */
|
||||
|
||||
static void removeOldGenerations(std::string dir, NeverAsync = {})
|
||||
void removeOldGenerations(std::string dir)
|
||||
{
|
||||
if (access(dir.c_str(), R_OK) != 0) return;
|
||||
|
||||
@@ -56,14 +56,14 @@ static void removeOldGenerations(std::string dir, NeverAsync = {})
|
||||
}
|
||||
}
|
||||
|
||||
static int main_nix_collect_garbage(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_nix_collect_garbage(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
bool removeOld = false;
|
||||
|
||||
GCOptions options;
|
||||
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-collect-garbage");
|
||||
else if (*arg == "--version")
|
||||
@@ -94,11 +94,11 @@ static int main_nix_collect_garbage(AsyncIoRoot & aio, std::string programName,
|
||||
} else {
|
||||
options.action = GCOptions::gcReturnDead;
|
||||
}
|
||||
auto store = aio.blockOn(openStore());
|
||||
auto store = openStore();
|
||||
auto & gcStore = require<GcStore>(*store);
|
||||
GCResults results;
|
||||
PrintFreed freed(true, results);
|
||||
aio.blockOn(gcStore.collectGarbage(options, results));
|
||||
gcStore.collectGarbage(options, results);
|
||||
|
||||
if (dryRun) {
|
||||
// Only print results for dry run; when !dryRun, paths will be printed as they're deleted.
|
||||
@@ -111,8 +111,8 @@ static int main_nix_collect_garbage(AsyncIoRoot & aio, std::string programName,
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixCollectGarbage() {
|
||||
LegacyCommandRegistry::add("nix-collect-garbage", main_nix_collect_garbage);
|
||||
void registerNixCollectGarbage() {
|
||||
LegacyCommands::add("nix-collect-garbage", main_nix_collect_garbage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixCollectGarbage();
|
||||
void registerNixCollectGarbage();
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
static int main_nix_copy_closure(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_nix_copy_closure(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
auto gzip = false;
|
||||
@@ -16,7 +16,7 @@ static int main_nix_copy_closure(AsyncIoRoot & aio, std::string programName, Str
|
||||
std::string sshHost;
|
||||
PathSet storePaths;
|
||||
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-copy-closure");
|
||||
else if (*arg == "--version")
|
||||
@@ -48,21 +48,21 @@ static int main_nix_copy_closure(AsyncIoRoot & aio, std::string programName, Str
|
||||
throw UsageError("no host name specified");
|
||||
|
||||
auto remoteUri = "ssh://" + sshHost + (gzip ? "?compress=true" : "");
|
||||
auto to = aio.blockOn(toMode ? openStore(remoteUri) : openStore());
|
||||
auto from = aio.blockOn(toMode ? openStore() : openStore(remoteUri));
|
||||
auto to = toMode ? openStore(remoteUri) : openStore();
|
||||
auto from = toMode ? openStore() : openStore(remoteUri);
|
||||
|
||||
RealisedPath::Set storePaths2;
|
||||
for (auto & path : storePaths)
|
||||
storePaths2.insert(from->followLinksToStorePath(path));
|
||||
|
||||
aio.blockOn(copyClosure(*from, *to, storePaths2, NoRepair, NoCheckSigs, useSubstitutes));
|
||||
copyClosure(*from, *to, storePaths2, NoRepair, NoCheckSigs, useSubstitutes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixCopyClosure() {
|
||||
LegacyCommandRegistry::add("nix-copy-closure", main_nix_copy_closure);
|
||||
void registerNixCopyClosure() {
|
||||
LegacyCommands::add("nix-copy-closure", main_nix_copy_closure);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixCopyClosure();
|
||||
void registerNixCopyClosure();
|
||||
|
||||
}
|
||||
|
||||
+162
-192
@@ -1,4 +1,3 @@
|
||||
#include "lix/libcmd/cmd-profiles.hh"
|
||||
#include "lix/libexpr/attr-path.hh"
|
||||
#include "lix/libcmd/common-eval-args.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
@@ -28,6 +27,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using std::cout;
|
||||
|
||||
@@ -56,10 +56,9 @@ struct InstallSourceInfo
|
||||
|
||||
struct Globals
|
||||
{
|
||||
AsyncIoRoot & aio;
|
||||
InstallSourceInfo instSource;
|
||||
Path profile;
|
||||
std::shared_ptr<Evaluator> state;
|
||||
std::shared_ptr<EvalState> state;
|
||||
bool dryRun;
|
||||
bool preserveInstalled;
|
||||
bool removeAll;
|
||||
@@ -96,24 +95,19 @@ static bool parseInstallSourceOptions(Globals & globals,
|
||||
}
|
||||
|
||||
|
||||
static bool isNixExpr(EvalPaths & paths, const CheckedSourcePath & path, struct InputAccessor::Stat & st)
|
||||
static bool isNixExpr(const SourcePath & path, struct InputAccessor::Stat & st)
|
||||
{
|
||||
if (st.type == InputAccessor::tRegular) {
|
||||
return true;
|
||||
} else if (st.type != InputAccessor::tDirectory) {
|
||||
return false;
|
||||
} else {
|
||||
auto defaultNix = paths.checkSourcePath(path + "default.nix");
|
||||
return defaultNix.pathExists();
|
||||
}
|
||||
return
|
||||
st.type == InputAccessor::tRegular
|
||||
|| (st.type == InputAccessor::tDirectory && (path + "default.nix").pathExists());
|
||||
}
|
||||
|
||||
|
||||
static constexpr size_t maxAttrs = 1024;
|
||||
|
||||
|
||||
static void getAllExprs(Evaluator & state,
|
||||
const CheckedSourcePath & path, StringSet & seen, BindingsBuilder & attrs)
|
||||
static void getAllExprs(EvalState & state,
|
||||
const SourcePath & path, StringSet & seen, BindingsBuilder & attrs)
|
||||
{
|
||||
StringSet namesSorted;
|
||||
for (auto & [name, _] : path.readDirectory()) namesSorted.insert(name);
|
||||
@@ -124,16 +118,16 @@ static void getAllExprs(Evaluator & state,
|
||||
are implemented using profiles). */
|
||||
if (i == "manifest.nix") continue;
|
||||
|
||||
auto path2 = state.paths.checkSourcePath(path + i);
|
||||
SourcePath path2 = path + i;
|
||||
|
||||
InputAccessor::Stat st;
|
||||
try {
|
||||
st = path2.stat();
|
||||
st = path2.resolveSymlinks().lstat();
|
||||
} catch (Error &) {
|
||||
continue; // ignore dangling symlinks in ~/.nix-defexpr
|
||||
}
|
||||
|
||||
if (isNixExpr(state.paths, path2, st) && (st.type != InputAccessor::tRegular || path2.baseName().ends_with(".nix"))) {
|
||||
if (isNixExpr(path2, st) && (st.type != InputAccessor::tRegular || path2.baseName().ends_with(".nix"))) {
|
||||
/* Strip off the `.nix' filename suffix (if applicable),
|
||||
otherwise the attribute cannot be selected with the
|
||||
`-A' option. Useful if you want to stick a Nix
|
||||
@@ -143,7 +137,7 @@ static void getAllExprs(Evaluator & state,
|
||||
attrName = std::string(attrName, 0, attrName.size() - 4);
|
||||
if (!seen.insert(attrName).second) {
|
||||
std::string suggestionMessage = "";
|
||||
if (path2.to_string().find("channels") != std::string::npos && path.to_string().find("channels") != std::string::npos)
|
||||
if (path2.path.abs().find("channels") != std::string::npos && path.path.abs().find("channels") != std::string::npos)
|
||||
suggestionMessage = fmt("\nsuggestion: remove '%s' from either the root channels or the user channels", attrName);
|
||||
printError("warning: name collision in input Nix expressions, skipping '%1%'"
|
||||
"%2%", path2, suggestionMessage);
|
||||
@@ -151,7 +145,7 @@ static void getAllExprs(Evaluator & state,
|
||||
}
|
||||
/* Load the expression on demand. */
|
||||
auto vArg = state.mem.allocValue();
|
||||
vArg->mkString(path2.canonical().abs());
|
||||
vArg->mkString(path2.path.abs());
|
||||
if (seen.size() == maxAttrs)
|
||||
throw Error("too many Nix expressions in directory '%1%'", path);
|
||||
attrs.alloc(attrName).mkApp(&state.builtins.get("import"), vArg);
|
||||
@@ -165,12 +159,11 @@ static void getAllExprs(Evaluator & state,
|
||||
|
||||
|
||||
|
||||
static void loadSourceExpr(EvalState & state, const SourcePath & path_, Value & v)
|
||||
static void loadSourceExpr(EvalState & state, const SourcePath & path, Value & v)
|
||||
{
|
||||
auto path = state.ctx.paths.checkSourcePath(path_);
|
||||
auto st = path.stat();
|
||||
auto st = path.resolveSymlinks().lstat();
|
||||
|
||||
if (isNixExpr(state.ctx.paths, path, st))
|
||||
if (isNixExpr(path, st))
|
||||
state.evalFile(path, v);
|
||||
|
||||
/* The path is a directory. Put the Nix expressions in the
|
||||
@@ -180,10 +173,10 @@ static void loadSourceExpr(EvalState & state, const SourcePath & path_, Value &
|
||||
~/.nix-defexpr directory that includes some system-wide
|
||||
directory). */
|
||||
else if (st.type == InputAccessor::tDirectory) {
|
||||
auto attrs = state.ctx.buildBindings(maxAttrs);
|
||||
auto attrs = state.buildBindings(maxAttrs);
|
||||
attrs.alloc("_combineChannels").mkList(0);
|
||||
StringSet seen;
|
||||
getAllExprs(state.ctx, path, seen, attrs);
|
||||
getAllExprs(state, path, seen, attrs);
|
||||
v.mkAttrs(attrs);
|
||||
}
|
||||
|
||||
@@ -206,7 +199,7 @@ static void loadDerivations(EvalState & state, const SourcePath & nixExprPath,
|
||||
system. */
|
||||
for (DrvInfos::iterator i = elems.begin(), j; i != elems.end(); i = j) {
|
||||
j = i; j++;
|
||||
if (systemFilter != "*" && i->querySystem(state) != systemFilter)
|
||||
if (systemFilter != "*" && i->querySystem() != systemFilter)
|
||||
elems.erase(i);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +207,7 @@ static void loadDerivations(EvalState & state, const SourcePath & nixExprPath,
|
||||
|
||||
static NixInt getPriority(EvalState & state, DrvInfo & drv)
|
||||
{
|
||||
return drv.queryMetaInt(state, "priority", NixInt(0));
|
||||
return drv.queryMetaInt("priority", NixInt(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -228,9 +221,9 @@ static std::strong_ordering comparePriorities(EvalState & state, DrvInfo & drv1,
|
||||
// at a time.
|
||||
static bool isPrebuilt(EvalState & state, DrvInfo & elem)
|
||||
{
|
||||
auto path = elem.queryOutPath(state);
|
||||
if (state.aio.blockOn(state.ctx.store->isValidPath(path))) return true;
|
||||
return state.aio.blockOn(state.ctx.store->querySubstitutablePaths({path})).count(path);
|
||||
auto path = elem.queryOutPath();
|
||||
if (state.store->isValidPath(path)) return true;
|
||||
return state.store->querySubstitutablePaths({path}).count(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +238,11 @@ static void checkSelectorUse(DrvNames & selectors)
|
||||
|
||||
namespace {
|
||||
|
||||
std::set<std::string> searchByPrefix(EvalState & state, DrvInfos & allElems, std::string_view prefix) {
|
||||
std::set<std::string> searchByPrefix(DrvInfos & allElems, std::string_view prefix) {
|
||||
constexpr std::size_t maxResults = 3;
|
||||
std::set<std::string> result;
|
||||
for (auto & drvInfo : allElems) {
|
||||
const auto drvName = DrvName { drvInfo.queryName(state) };
|
||||
const auto drvName = DrvName { drvInfo.queryName() };
|
||||
if (drvName.name.starts_with(prefix)) {
|
||||
result.emplace(drvName.name);
|
||||
|
||||
@@ -287,7 +280,7 @@ std::vector<Match> pickNewestOnly(EvalState & state, std::vector<Match> matches)
|
||||
for (auto & match : matches) {
|
||||
auto & oneDrv = match.drvInfo;
|
||||
|
||||
const auto drvName = DrvName { oneDrv.queryName(state) };
|
||||
const auto drvName = DrvName { oneDrv.queryName() };
|
||||
std::strong_ordering comparison = std::strong_ordering::greater;
|
||||
|
||||
const auto itOther = newest.find(drvName.name);
|
||||
@@ -296,13 +289,13 @@ std::vector<Match> pickNewestOnly(EvalState & state, std::vector<Match> matches)
|
||||
auto & newestDrv = itOther->second.drvInfo;
|
||||
|
||||
comparison =
|
||||
oneDrv.querySystem(state) == newestDrv.querySystem(state) ? std::strong_ordering::equal :
|
||||
oneDrv.querySystem(state) == settings.thisSystem ? std::strong_ordering::greater :
|
||||
newestDrv.querySystem(state) == settings.thisSystem ? std::strong_ordering::less : std::strong_ordering::equal;
|
||||
oneDrv.querySystem() == newestDrv.querySystem() ? std::strong_ordering::equal :
|
||||
oneDrv.querySystem() == settings.thisSystem ? std::strong_ordering::greater :
|
||||
newestDrv.querySystem() == settings.thisSystem ? std::strong_ordering::less : std::strong_ordering::equal;
|
||||
if (comparison == 0)
|
||||
comparison = comparePriorities(state, oneDrv, newestDrv);
|
||||
if (comparison == 0)
|
||||
comparison = compareVersions(drvName.version, DrvName{newestDrv.queryName(state)}.version);
|
||||
comparison = compareVersions(drvName.version, DrvName { newestDrv.queryName() }.version);
|
||||
}
|
||||
|
||||
if (comparison > 0) {
|
||||
@@ -341,7 +334,7 @@ static DrvInfos filterBySelector(EvalState & state, DrvInfos & allElems,
|
||||
for (auto & selector : selectors) {
|
||||
std::vector<Match> matches;
|
||||
for (auto && [index, drvInfo] : enumerate(allElems)) {
|
||||
const auto drvName = DrvName { drvInfo.queryName(state) };
|
||||
const auto drvName = DrvName { drvInfo.queryName() };
|
||||
if (selector.matches(drvName)) {
|
||||
++selector.hits;
|
||||
matches.emplace_back(drvInfo, index);
|
||||
@@ -359,7 +352,7 @@ static DrvInfos filterBySelector(EvalState & state, DrvInfos & allElems,
|
||||
elems.push_back(match.drvInfo);
|
||||
|
||||
if (selector.hits == 0 && selector.fullName != "*") {
|
||||
const auto prefixHits = searchByPrefix(state, allElems, selector.name);
|
||||
const auto prefixHits = searchByPrefix(allElems, selector.name);
|
||||
|
||||
if (prefixHits.empty()) {
|
||||
throw Error("selector '%1%' matches no derivations", selector.fullName);
|
||||
@@ -422,7 +415,7 @@ static void queryInstSources(EvalState & state,
|
||||
loadSourceExpr(state, *instSource.nixExprPath, vArg);
|
||||
|
||||
for (auto & i : args) {
|
||||
Expr & eFun = state.ctx.parseExprFromString(i, CanonPath::fromCwd());
|
||||
Expr & eFun = state.parseExprFromString(i, CanonPath::fromCwd());
|
||||
Value vFun, vTmp;
|
||||
state.eval(eFun, vFun);
|
||||
vTmp.mkApp(&vFun, &vArg);
|
||||
@@ -438,17 +431,16 @@ static void queryInstSources(EvalState & state,
|
||||
case srcStorePaths: {
|
||||
|
||||
for (auto & i : args) {
|
||||
auto path = state.ctx.store->followLinksToStorePath(i);
|
||||
auto path = state.store->followLinksToStorePath(i);
|
||||
|
||||
std::string name(path.name());
|
||||
|
||||
DrvInfo elem("", nullptr);
|
||||
DrvInfo elem(state, "", nullptr);
|
||||
elem.setName(name);
|
||||
|
||||
if (path.isDerivation()) {
|
||||
elem.setDrvPath(path);
|
||||
auto outputs =
|
||||
state.aio.blockOn(state.ctx.store->queryDerivationOutputMap(path));
|
||||
auto outputs = state.store->queryDerivationOutputMap(path);
|
||||
elem.setOutPath(outputs.at("out"));
|
||||
if (name.size() >= drvExtension.size() &&
|
||||
std::string(name, name.size() - drvExtension.size()) == drvExtension)
|
||||
@@ -493,47 +485,38 @@ static void printMissing(EvalState & state, DrvInfos & elems)
|
||||
{
|
||||
std::vector<DerivedPath> targets;
|
||||
for (auto & i : elems)
|
||||
if (auto drvPath = i.queryDrvPath(state))
|
||||
if (auto drvPath = i.queryDrvPath())
|
||||
targets.emplace_back(DerivedPath::Built{
|
||||
.drvPath = makeConstantStorePathRef(*drvPath),
|
||||
.outputs = OutputsSpec::All { },
|
||||
});
|
||||
else
|
||||
targets.emplace_back(DerivedPath::Opaque{
|
||||
.path = i.queryOutPath(state),
|
||||
.path = i.queryOutPath(),
|
||||
});
|
||||
|
||||
state.aio.blockOn(printMissing(state.ctx.store, targets));
|
||||
printMissing(state.store, targets);
|
||||
}
|
||||
|
||||
|
||||
static bool keep(EvalState & state, DrvInfo & drv)
|
||||
static bool keep(DrvInfo & drv)
|
||||
{
|
||||
return drv.queryMetaBool(state, "keep", false);
|
||||
return drv.queryMetaBool("keep", false);
|
||||
}
|
||||
|
||||
static void setMetaFlag(EvalState & state, DrvInfo & drv,
|
||||
const std::string & name, const std::string & value)
|
||||
{
|
||||
auto v = state.ctx.mem.allocValue();
|
||||
v->mkString(value);
|
||||
drv.setMeta(state, name, v);
|
||||
}
|
||||
|
||||
static void installDerivations(Globals & globals,
|
||||
const Strings & args, const Path & profile, std::optional<int> priority)
|
||||
const Strings & args, const Path & profile)
|
||||
{
|
||||
debug("installing derivations");
|
||||
|
||||
auto state = globals.state->begin(globals.aio);
|
||||
|
||||
/* Get the set of user environment elements to be installed. */
|
||||
DrvInfos newElems, newElemsTmp;
|
||||
queryInstSources(*state, globals.instSource, args, newElemsTmp, true);
|
||||
queryInstSources(*globals.state, globals.instSource, args, newElemsTmp, true);
|
||||
|
||||
/* If --prebuilt-only is given, filter out source-only packages. */
|
||||
for (auto & i : newElemsTmp)
|
||||
if (!globals.prebuiltOnly || isPrebuilt(*state, i))
|
||||
if (!globals.prebuiltOnly || isPrebuilt(*globals.state, i))
|
||||
newElems.push_back(i);
|
||||
|
||||
StringSet newNames;
|
||||
@@ -544,14 +527,9 @@ static void installDerivations(Globals & globals,
|
||||
`java-front-0.9pre15899'). */
|
||||
if (globals.forceName != "")
|
||||
i.setName(globals.forceName);
|
||||
newNames.insert(DrvName(i.queryName(*state)).name);
|
||||
newNames.insert(DrvName(i.queryName()).name);
|
||||
}
|
||||
|
||||
if (priority) {
|
||||
for (auto & drv : newElems) {
|
||||
setMetaFlag(*state, drv, "priority", std::to_string((priority.value())));
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
auto lockToken = optimisticLockProfile(profile);
|
||||
@@ -561,27 +539,27 @@ static void installDerivations(Globals & globals,
|
||||
/* Add in the already installed derivations, unless they have
|
||||
the same name as a to-be-installed element. */
|
||||
if (!globals.removeAll) {
|
||||
DrvInfos installedElems = queryInstalled(*state, profile);
|
||||
DrvInfos installedElems = queryInstalled(*globals.state, profile);
|
||||
|
||||
for (auto & i : installedElems) {
|
||||
DrvName drvName(i.queryName(*state));
|
||||
DrvName drvName(i.queryName());
|
||||
if (!globals.preserveInstalled &&
|
||||
newNames.find(drvName.name) != newNames.end() &&
|
||||
!keep(*state, i))
|
||||
printInfo("replacing old '%s'", i.queryName(*state));
|
||||
!keep(i))
|
||||
printInfo("replacing old '%s'", i.queryName());
|
||||
else
|
||||
allElems.push_back(i);
|
||||
}
|
||||
|
||||
for (auto & i : newElems)
|
||||
printInfo("installing '%s'", i.queryName(*state));
|
||||
printInfo("installing '%s'", i.queryName());
|
||||
}
|
||||
|
||||
printMissing(*state, newElems);
|
||||
printMissing(*globals.state, newElems);
|
||||
|
||||
if (globals.dryRun) return;
|
||||
|
||||
if (createUserEnv(*state, allElems,
|
||||
if (createUserEnv(*globals.state, allElems,
|
||||
profile, settings.envKeepDerivations, lockToken)) break;
|
||||
}
|
||||
}
|
||||
@@ -589,7 +567,6 @@ static void installDerivations(Globals & globals,
|
||||
|
||||
static void opInstall(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
std::optional<int> priority;
|
||||
for (Strings::iterator i = opFlags.begin(); i != opFlags.end(); ) {
|
||||
auto arg = *i++;
|
||||
if (parseInstallSourceOptions(globals, i, opFlags, arg)) ;
|
||||
@@ -597,17 +574,10 @@ static void opInstall(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
globals.preserveInstalled = true;
|
||||
else if (arg == "--remove-all" || arg == "-r")
|
||||
globals.removeAll = true;
|
||||
else if (arg == "--priority") {
|
||||
if (i == opFlags.end())
|
||||
throw UsageError("'%1%' requires an argument", arg);
|
||||
priority = string2Int<int>(*i++);
|
||||
if (!priority)
|
||||
throw UsageError("'--priority' requires an integer argument");
|
||||
}
|
||||
else throw UsageError("unknown flag '%1%'", arg);
|
||||
}
|
||||
|
||||
installDerivations(globals, opArgs, globals.profile, priority);
|
||||
installDerivations(globals, opArgs, globals.profile);
|
||||
}
|
||||
|
||||
|
||||
@@ -619,8 +589,6 @@ static void upgradeDerivations(Globals & globals,
|
||||
{
|
||||
debug("upgrading derivations");
|
||||
|
||||
auto state = globals.state->begin(globals.aio);
|
||||
|
||||
/* Upgrade works as follows: we take all currently installed
|
||||
derivations, and for any derivation matching any selector, look
|
||||
for a derivation in the input Nix expression that has the same
|
||||
@@ -629,20 +597,20 @@ static void upgradeDerivations(Globals & globals,
|
||||
while (true) {
|
||||
auto lockToken = optimisticLockProfile(globals.profile);
|
||||
|
||||
DrvInfos installedElems = queryInstalled(*state, globals.profile);
|
||||
DrvInfos installedElems = queryInstalled(*globals.state, globals.profile);
|
||||
|
||||
/* Fetch all derivations from the input file. */
|
||||
DrvInfos availElems;
|
||||
queryInstSources(*state, globals.instSource, args, availElems, false);
|
||||
queryInstSources(*globals.state, globals.instSource, args, availElems, false);
|
||||
|
||||
/* Go through all installed derivations. */
|
||||
DrvInfos newElems;
|
||||
for (auto & i : installedElems) {
|
||||
DrvName drvName(i.queryName(*state));
|
||||
DrvName drvName(i.queryName());
|
||||
|
||||
try {
|
||||
|
||||
if (keep(*state, i)) {
|
||||
if (keep(i)) {
|
||||
newElems.push_back(i);
|
||||
continue;
|
||||
}
|
||||
@@ -657,9 +625,9 @@ static void upgradeDerivations(Globals & globals,
|
||||
DrvInfos::iterator bestElem = availElems.end();
|
||||
std::string bestVersion;
|
||||
for (auto j = availElems.begin(); j != availElems.end(); ++j) {
|
||||
if (comparePriorities(*state, i, *j) > 0)
|
||||
if (comparePriorities(*globals.state, i, *j) > 0)
|
||||
continue;
|
||||
DrvName newName(j->queryName(*state));
|
||||
DrvName newName(j->queryName());
|
||||
if (newName.name == drvName.name) {
|
||||
std::strong_ordering d = compareVersions(drvName.version, newName.version);
|
||||
if ((upgradeType == utLt && d < 0) ||
|
||||
@@ -669,10 +637,10 @@ static void upgradeDerivations(Globals & globals,
|
||||
{
|
||||
std::strong_ordering d2 = std::strong_ordering::less;
|
||||
if (bestElem != availElems.end()) {
|
||||
d2 = comparePriorities(*state, *bestElem, *j);
|
||||
d2 = comparePriorities(*globals.state, *bestElem, *j);
|
||||
if (d2 == 0) d2 = compareVersions(bestVersion, newName.version);
|
||||
}
|
||||
if (d2 < 0 && (!globals.prebuiltOnly || isPrebuilt(*state, *j))) {
|
||||
if (d2 < 0 && (!globals.prebuiltOnly || isPrebuilt(*globals.state, *j))) {
|
||||
bestElem = j;
|
||||
bestVersion = newName.version;
|
||||
}
|
||||
@@ -681,27 +649,27 @@ static void upgradeDerivations(Globals & globals,
|
||||
}
|
||||
|
||||
if (bestElem != availElems.end() &&
|
||||
i.queryOutPath(*state) !=
|
||||
bestElem->queryOutPath(*state))
|
||||
i.queryOutPath() !=
|
||||
bestElem->queryOutPath())
|
||||
{
|
||||
const char * action = compareVersions(drvName.version, bestVersion) <= 0
|
||||
? "upgrading" : "downgrading";
|
||||
printInfo("%1% '%2%' to '%3%'",
|
||||
action, i.queryName(*state), bestElem->queryName(*state));
|
||||
action, i.queryName(), bestElem->queryName());
|
||||
newElems.push_back(*bestElem);
|
||||
} else newElems.push_back(i);
|
||||
|
||||
} catch (Error & e) {
|
||||
e.addTrace(nullptr, "while trying to find an upgrade for '%s'", i.queryName(*state));
|
||||
e.addTrace(nullptr, "while trying to find an upgrade for '%s'", i.queryName());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
printMissing(*state, newElems);
|
||||
printMissing(*globals.state, newElems);
|
||||
|
||||
if (globals.dryRun) return;
|
||||
|
||||
if (createUserEnv(*state, newElems,
|
||||
if (createUserEnv(*globals.state, newElems,
|
||||
globals.profile, settings.envKeepDerivations, lockToken)) break;
|
||||
}
|
||||
}
|
||||
@@ -724,6 +692,15 @@ static void opUpgrade(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void setMetaFlag(EvalState & state, DrvInfo & drv,
|
||||
const std::string & name, const std::string & value)
|
||||
{
|
||||
auto v = state.mem.allocValue();
|
||||
v->mkString(value);
|
||||
drv.setMeta(name, v);
|
||||
}
|
||||
|
||||
|
||||
static void opSetFlag(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (opFlags.size() > 0)
|
||||
@@ -736,21 +713,19 @@ static void opSetFlag(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
std::string flagValue = *arg++;
|
||||
DrvNames selectors = drvNamesFromArgs(Strings(arg, opArgs.end()));
|
||||
|
||||
auto state = globals.state->begin(globals.aio);
|
||||
|
||||
while (true) {
|
||||
std::string lockToken = optimisticLockProfile(globals.profile);
|
||||
|
||||
DrvInfos installedElems = queryInstalled(*state, globals.profile);
|
||||
DrvInfos installedElems = queryInstalled(*globals.state, globals.profile);
|
||||
|
||||
/* Update all matching derivations. */
|
||||
for (auto & i : installedElems) {
|
||||
DrvName drvName(i.queryName(*state));
|
||||
DrvName drvName(i.queryName());
|
||||
for (auto & j : selectors)
|
||||
if (j.matches(drvName)) {
|
||||
printInfo("setting flag on '%1%'", i.queryName(*state));
|
||||
printInfo("setting flag on '%1%'", i.queryName());
|
||||
j.hits++;
|
||||
setMetaFlag(*state, i, flagName, flagValue);
|
||||
setMetaFlag(*globals.state, i, flagName, flagValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -758,7 +733,7 @@ static void opSetFlag(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
checkSelectorUse(selectors);
|
||||
|
||||
/* Write the new user environment. */
|
||||
if (createUserEnv(*state, installedElems,
|
||||
if (createUserEnv(*globals.state, installedElems,
|
||||
globals.profile, settings.envKeepDerivations, lockToken)) break;
|
||||
}
|
||||
}
|
||||
@@ -766,9 +741,7 @@ static void opSetFlag(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
|
||||
static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
auto state = globals.state->begin(globals.aio);
|
||||
|
||||
auto store2 = globals.state->store.try_cast_shared<LocalFSStore>();
|
||||
auto store2 = globals.state->store.dynamic_pointer_cast<LocalFSStore>();
|
||||
if (!store2) throw Error("--set is not supported for this Nix store");
|
||||
|
||||
for (Strings::iterator i = opFlags.begin(); i != opFlags.end(); ) {
|
||||
@@ -778,7 +751,7 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
DrvInfos elems;
|
||||
queryInstSources(*state, globals.instSource, opArgs, elems, true);
|
||||
queryInstSources(*globals.state, globals.instSource, opArgs, elems, true);
|
||||
|
||||
if (elems.size() != 1)
|
||||
throw Error("--set requires exactly one derivation");
|
||||
@@ -788,7 +761,7 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
if (globals.forceName != "")
|
||||
drv.setName(globals.forceName);
|
||||
|
||||
auto drvPath = drv.queryDrvPath(*state);
|
||||
auto drvPath = drv.queryDrvPath();
|
||||
std::vector<DerivedPath> paths {
|
||||
drvPath
|
||||
? (DerivedPath) (DerivedPath::Built {
|
||||
@@ -796,20 +769,18 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
.outputs = OutputsSpec::All { },
|
||||
})
|
||||
: (DerivedPath) (DerivedPath::Opaque {
|
||||
.path = drv.queryOutPath(*state),
|
||||
.path = drv.queryOutPath(),
|
||||
}),
|
||||
};
|
||||
globals.aio.blockOn(printMissing(globals.state->store, paths));
|
||||
printMissing(globals.state->store, paths);
|
||||
if (globals.dryRun) return;
|
||||
globals.aio.blockOn(
|
||||
globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal)
|
||||
);
|
||||
globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal);
|
||||
|
||||
debug("switching to new user environment");
|
||||
Path generation = globals.aio.blockOn(createGeneration(
|
||||
Path generation = createGeneration(
|
||||
*store2,
|
||||
globals.profile,
|
||||
drv.queryOutPath(*state)));
|
||||
drv.queryOutPath());
|
||||
switchLink(globals.profile, generation);
|
||||
}
|
||||
|
||||
@@ -817,12 +788,10 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
static void uninstallDerivations(Globals & globals, Strings & selectors,
|
||||
Path & profile)
|
||||
{
|
||||
auto state = globals.state->begin(globals.aio);
|
||||
|
||||
while (true) {
|
||||
auto lockToken = optimisticLockProfile(profile);
|
||||
|
||||
DrvInfos workingElems = queryInstalled(*state, profile);
|
||||
DrvInfos workingElems = queryInstalled(*globals.state, profile);
|
||||
|
||||
for (auto & selector : selectors) {
|
||||
DrvInfos::iterator split = workingElems.begin();
|
||||
@@ -830,16 +799,16 @@ static void uninstallDerivations(Globals & globals, Strings & selectors,
|
||||
StorePath selectorStorePath = globals.state->store->followLinksToStorePath(selector);
|
||||
split = std::partition(
|
||||
workingElems.begin(), workingElems.end(),
|
||||
[&selectorStorePath, &state](auto &elem) {
|
||||
return selectorStorePath != elem.queryOutPath(*state);
|
||||
[&selectorStorePath, globals](auto &elem) {
|
||||
return selectorStorePath != elem.queryOutPath();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
DrvName selectorName(selector);
|
||||
split = std::partition(
|
||||
workingElems.begin(), workingElems.end(),
|
||||
[&selectorName, &state](auto &elem){
|
||||
DrvName elemName(elem.queryName(*state));
|
||||
[&selectorName](auto &elem){
|
||||
DrvName elemName(elem.queryName());
|
||||
return !selectorName.matches(elemName);
|
||||
}
|
||||
);
|
||||
@@ -847,14 +816,14 @@ static void uninstallDerivations(Globals & globals, Strings & selectors,
|
||||
if (split == workingElems.end())
|
||||
warn("selector '%s' matched no installed derivations", selector);
|
||||
for (auto removedElem = split; removedElem != workingElems.end(); removedElem++) {
|
||||
printInfo("uninstalling '%s'", removedElem->queryName(*state));
|
||||
printInfo("uninstalling '%s'", removedElem->queryName());
|
||||
}
|
||||
workingElems.erase(split, workingElems.end());
|
||||
}
|
||||
|
||||
if (globals.dryRun) return;
|
||||
|
||||
if (createUserEnv(*state, workingElems,
|
||||
if (createUserEnv(*globals.state, workingElems,
|
||||
profile, settings.envKeepDerivations, lockToken)) break;
|
||||
}
|
||||
}
|
||||
@@ -874,10 +843,10 @@ static bool cmpChars(char a, char b)
|
||||
}
|
||||
|
||||
|
||||
static bool cmpElemByName(EvalState & state, DrvInfo & a, DrvInfo & b)
|
||||
static bool cmpElemByName(DrvInfo & a, DrvInfo & b)
|
||||
{
|
||||
auto a_name = a.queryName(state);
|
||||
auto b_name = b.queryName(state);
|
||||
auto a_name = a.queryName();
|
||||
auto b_name = b.queryName();
|
||||
return lexicographical_compare(
|
||||
a_name.begin(), a_name.end(),
|
||||
b_name.begin(), b_name.end(), cmpChars);
|
||||
@@ -927,15 +896,15 @@ void printTable(Table & table)
|
||||
typedef enum { cvLess, cvEqual, cvGreater, cvUnavail } VersionDiff;
|
||||
|
||||
static VersionDiff compareVersionAgainstSet(
|
||||
EvalState & state, DrvInfo & elem, DrvInfos & elems, std::string & version)
|
||||
DrvInfo & elem, DrvInfos & elems, std::string & version)
|
||||
{
|
||||
DrvName name(elem.queryName(state));
|
||||
DrvName name(elem.queryName());
|
||||
|
||||
VersionDiff diff = cvUnavail;
|
||||
version = "?";
|
||||
|
||||
for (auto & i : elems) {
|
||||
DrvName name2(i.queryName(state));
|
||||
DrvName name2(i.queryName());
|
||||
if (name.name == name2.name) {
|
||||
std::strong_ordering d = compareVersions(name.version, name2.version);
|
||||
if (d < 0) {
|
||||
@@ -958,28 +927,29 @@ static VersionDiff compareVersionAgainstSet(
|
||||
}
|
||||
|
||||
|
||||
static void queryJSON(EvalState & state, Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printDrvPath, bool printMeta)
|
||||
static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printDrvPath, bool printMeta)
|
||||
{
|
||||
JSON topObj = JSON::object();
|
||||
using nlohmann::json;
|
||||
json topObj = json::object();
|
||||
for (auto & i : elems) {
|
||||
try {
|
||||
if (i.hasFailed()) continue;
|
||||
|
||||
|
||||
auto drvName = DrvName(i.queryName(state));
|
||||
JSON &pkgObj = topObj[i.attrPath];
|
||||
auto drvName = DrvName(i.queryName());
|
||||
json &pkgObj = topObj[i.attrPath];
|
||||
pkgObj = {
|
||||
{"name", drvName.fullName},
|
||||
{"pname", drvName.name},
|
||||
{"version", drvName.version},
|
||||
{"system", i.querySystem(state)},
|
||||
{"outputName", i.queryOutputName(state)},
|
||||
{"system", i.querySystem()},
|
||||
{"outputName", i.queryOutputName()},
|
||||
};
|
||||
|
||||
{
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(state, printOutPath);
|
||||
JSON &outputObj = pkgObj["outputs"];
|
||||
outputObj = JSON::object();
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(printOutPath);
|
||||
json &outputObj = pkgObj["outputs"];
|
||||
outputObj = json::object();
|
||||
for (auto & j : outputs) {
|
||||
if (j.second)
|
||||
outputObj[j.first] = globals.state->store->printStorePath(*j.second);
|
||||
@@ -989,29 +959,29 @@ static void queryJSON(EvalState & state, Globals & globals, std::vector<DrvInfo>
|
||||
}
|
||||
|
||||
if (printDrvPath) {
|
||||
auto drvPath = i.queryDrvPath(state);
|
||||
auto drvPath = i.queryDrvPath();
|
||||
if (drvPath) pkgObj["drvPath"] = globals.state->store->printStorePath(*drvPath);
|
||||
}
|
||||
|
||||
if (printMeta) {
|
||||
JSON &metaObj = pkgObj["meta"];
|
||||
metaObj = JSON::object();
|
||||
StringSet metaNames = i.queryMetaNames(state);
|
||||
json &metaObj = pkgObj["meta"];
|
||||
metaObj = json::object();
|
||||
StringSet metaNames = i.queryMetaNames();
|
||||
for (auto & j : metaNames) {
|
||||
Value * v = i.queryMeta(state, j);
|
||||
Value * v = i.queryMeta(j);
|
||||
if (!v) {
|
||||
printError("derivation '%s' has invalid meta attribute '%s'", i.queryName(state), j);
|
||||
printError("derivation '%s' has invalid meta attribute '%s'", i.queryName(), j);
|
||||
metaObj[j] = nullptr;
|
||||
} else {
|
||||
NixStringContext context;
|
||||
metaObj[j] = printValueAsJSON(state, true, *v, noPos, context);
|
||||
metaObj[j] = printValueAsJSON(*globals.state, true, *v, noPos, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (AssertionError & e) {
|
||||
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName(state));
|
||||
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName());
|
||||
} catch (Error & e) {
|
||||
e.addTrace(nullptr, "while querying the derivation named '%1%'", i.queryName(state));
|
||||
e.addTrace(nullptr, "while querying the derivation named '%1%'", i.queryName());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -1022,7 +992,6 @@ static void queryJSON(EvalState & state, Globals & globals, std::vector<DrvInfo>
|
||||
static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
{
|
||||
auto & store { *globals.state->store };
|
||||
auto state = globals.state->begin(globals.aio);
|
||||
|
||||
Strings remaining;
|
||||
std::string attrPath;
|
||||
@@ -1071,14 +1040,14 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
DrvInfos availElems, installedElems;
|
||||
|
||||
if (source == sInstalled || compareVersions || printStatus)
|
||||
installedElems = queryInstalled(*state, globals.profile);
|
||||
installedElems = queryInstalled(*globals.state, globals.profile);
|
||||
|
||||
if (source == sAvailable || compareVersions)
|
||||
loadDerivations(*state, *globals.instSource.nixExprPath,
|
||||
loadDerivations(*globals.state, *globals.instSource.nixExprPath,
|
||||
globals.instSource.systemFilter, *globals.instSource.autoArgs,
|
||||
attrPath, availElems);
|
||||
|
||||
DrvInfos elems_ = filterBySelector(*state,
|
||||
DrvInfos elems_ = filterBySelector(*globals.state,
|
||||
source == sInstalled ? installedElems : availElems,
|
||||
opArgs, false);
|
||||
|
||||
@@ -1089,7 +1058,8 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
/* !!! */
|
||||
std::vector<DrvInfo> elems;
|
||||
for (auto & i : elems_) elems.push_back(i);
|
||||
sort(elems.begin(), elems.end(), [&] (auto& a, auto& b) { return cmpElemByName(*state, a, b); });
|
||||
sort(elems.begin(), elems.end(), cmpElemByName);
|
||||
|
||||
|
||||
/* We only need to know the installed paths when we are querying
|
||||
the status of the derivation. */
|
||||
@@ -1097,7 +1067,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
|
||||
if (printStatus)
|
||||
for (auto & i : installedElems)
|
||||
installed.insert(i.queryOutPath(*state));
|
||||
installed.insert(i.queryOutPath());
|
||||
|
||||
|
||||
/* Query which paths have substitutes. */
|
||||
@@ -1107,19 +1077,19 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
StorePathSet paths;
|
||||
for (auto & i : elems)
|
||||
try {
|
||||
paths.insert(i.queryOutPath(*state));
|
||||
paths.insert(i.queryOutPath());
|
||||
} catch (AssertionError & e) {
|
||||
printMsg(lvlTalkative, "skipping derivation named '%s' which gives an assertion failure", i.queryName(*state));
|
||||
printMsg(lvlTalkative, "skipping derivation named '%s' which gives an assertion failure", i.queryName());
|
||||
i.setFailed();
|
||||
}
|
||||
validPaths = globals.aio.blockOn(store.queryValidPaths(paths));
|
||||
substitutablePaths = globals.aio.blockOn(store.querySubstitutablePaths(paths));
|
||||
validPaths = store.queryValidPaths(paths);
|
||||
substitutablePaths = store.querySubstitutablePaths(paths);
|
||||
}
|
||||
|
||||
|
||||
/* Print the desired columns, or XML output. */
|
||||
if (jsonOutput) {
|
||||
queryJSON(*state, globals, elems, printOutPath, printDrvPath, printMeta);
|
||||
queryJSON(globals, elems, printOutPath, printDrvPath, printMeta);
|
||||
cout << '\n';
|
||||
return;
|
||||
}
|
||||
@@ -1138,8 +1108,8 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
//Activity act(*logger, lvlDebug, "outputting query result '%1%'", i.attrPath);
|
||||
|
||||
if (globals.prebuiltOnly &&
|
||||
!validPaths.count(i.queryOutPath(*state)) &&
|
||||
!substitutablePaths.count(i.queryOutPath(*state)))
|
||||
!validPaths.count(i.queryOutPath()) &&
|
||||
!substitutablePaths.count(i.queryOutPath()))
|
||||
continue;
|
||||
|
||||
/* For table output. */
|
||||
@@ -1149,7 +1119,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
XMLAttrs attrs;
|
||||
|
||||
if (printStatus) {
|
||||
auto outPath = i.queryOutPath(*state);
|
||||
auto outPath = i.queryOutPath();
|
||||
bool hasSubs = substitutablePaths.count(outPath);
|
||||
bool isInstalled = installed.count(outPath);
|
||||
bool isValid = validPaths.count(outPath);
|
||||
@@ -1170,12 +1140,12 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
columns.push_back(i.attrPath);
|
||||
|
||||
if (xmlOutput) {
|
||||
auto drvName = DrvName(i.queryName(*state));
|
||||
auto drvName = DrvName(i.queryName());
|
||||
attrs["name"] = drvName.fullName;
|
||||
attrs["pname"] = drvName.name;
|
||||
attrs["version"] = drvName.version;
|
||||
} else if (printName) {
|
||||
columns.push_back(i.queryName(*state));
|
||||
columns.push_back(i.queryName());
|
||||
}
|
||||
|
||||
if (compareVersions) {
|
||||
@@ -1184,7 +1154,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
elements, or the set of installed elements. !!!
|
||||
This is O(N * M), should be O(N * lg M). */
|
||||
std::string version;
|
||||
VersionDiff diff = compareVersionAgainstSet(*state, i, otherElems, version);
|
||||
VersionDiff diff = compareVersionAgainstSet(i, otherElems, version);
|
||||
|
||||
char ch;
|
||||
switch (diff) {
|
||||
@@ -1209,13 +1179,13 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
if (xmlOutput) {
|
||||
if (i.querySystem(*state) != "") attrs["system"] = i.querySystem(*state);
|
||||
if (i.querySystem() != "") attrs["system"] = i.querySystem();
|
||||
}
|
||||
else if (printSystem)
|
||||
columns.push_back(i.querySystem(*state));
|
||||
columns.push_back(i.querySystem());
|
||||
|
||||
if (printDrvPath) {
|
||||
auto drvPath = i.queryDrvPath(*state);
|
||||
auto drvPath = i.queryDrvPath();
|
||||
if (xmlOutput) {
|
||||
if (drvPath) attrs["drvPath"] = store.printStorePath(*drvPath);
|
||||
} else
|
||||
@@ -1223,10 +1193,10 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
if (xmlOutput)
|
||||
attrs["outputName"] = i.queryOutputName(*state);
|
||||
attrs["outputName"] = i.queryOutputName();
|
||||
|
||||
if (printOutPath && !xmlOutput) {
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(*state);
|
||||
DrvInfo::Outputs outputs = i.queryOutputs();
|
||||
std::string s;
|
||||
for (auto & j : outputs) {
|
||||
if (!s.empty()) s += ';';
|
||||
@@ -1237,7 +1207,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
if (printDescription) {
|
||||
auto descr = i.queryMetaString(*state, "description");
|
||||
auto descr = i.queryMetaString("description");
|
||||
if (xmlOutput) {
|
||||
if (descr != "") attrs["description"] = descr;
|
||||
} else
|
||||
@@ -1246,7 +1216,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
|
||||
if (xmlOutput) {
|
||||
XMLOpenElement item(xml, "item", attrs);
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(*state, printOutPath);
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(printOutPath);
|
||||
for (auto & j : outputs) {
|
||||
XMLAttrs attrs2;
|
||||
attrs2["name"] = j.first;
|
||||
@@ -1255,15 +1225,15 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
xml.writeEmptyElement("output", attrs2);
|
||||
}
|
||||
if (printMeta) {
|
||||
StringSet metaNames = i.queryMetaNames(*state);
|
||||
StringSet metaNames = i.queryMetaNames();
|
||||
for (auto & j : metaNames) {
|
||||
XMLAttrs attrs2;
|
||||
attrs2["name"] = j;
|
||||
Value * v = i.queryMeta(*state, j);
|
||||
Value * v = i.queryMeta(j);
|
||||
if (!v)
|
||||
printError(
|
||||
"derivation '%s' has invalid meta attribute '%s'",
|
||||
i.queryName(*state), j);
|
||||
i.queryName(), j);
|
||||
else {
|
||||
if (v->type() == nString) {
|
||||
attrs2["type"] = "string";
|
||||
@@ -1312,9 +1282,9 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
cout.flush();
|
||||
|
||||
} catch (AssertionError & e) {
|
||||
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName(*state));
|
||||
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName());
|
||||
} catch (Error & e) {
|
||||
e.addTrace(nullptr, "while querying the derivation named '%1%'", i.queryName(*state));
|
||||
e.addTrace(nullptr, "while querying the derivation named '%1%'", i.queryName());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -1345,7 +1315,7 @@ static void opSwitchGeneration(Globals & globals, Strings opFlags, Strings opArg
|
||||
throw UsageError("exactly one argument expected");
|
||||
|
||||
if (auto dstGen = string2Int<GenerationNumber>(opArgs.front()))
|
||||
switchGeneration(globals.profile, dstGen, globals.dryRun);
|
||||
switchGeneration(globals.profile, *dstGen, globals.dryRun);
|
||||
else
|
||||
throw UsageError("expected a generation number");
|
||||
}
|
||||
@@ -1369,7 +1339,8 @@ static void opListGenerations(Globals & globals, Strings opFlags, Strings opArgs
|
||||
if (opArgs.size() != 0)
|
||||
throw UsageError("no arguments expected");
|
||||
|
||||
PathLock lock = lockProfile(globals.profile);
|
||||
PathLocks lock;
|
||||
lockProfile(lock, globals.profile);
|
||||
|
||||
auto [gens, curGen] = findGenerations(globals.profile);
|
||||
|
||||
@@ -1424,7 +1395,7 @@ static void opVersion(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_nix_env(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
@@ -1433,7 +1404,7 @@ static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv
|
||||
bool showHelp = false;
|
||||
std::string file;
|
||||
|
||||
Globals globals{aio, {}, {}, {}, {}, {}, {}, {}, {}};
|
||||
Globals globals;
|
||||
|
||||
globals.instSource.type = srcUnknown;
|
||||
globals.instSource.systemFilter = "*";
|
||||
@@ -1463,7 +1434,7 @@ static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
Operation oldOp = op;
|
||||
|
||||
if (*arg == "--help")
|
||||
@@ -1532,8 +1503,7 @@ static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv
|
||||
opFlags.push_back(*arg);
|
||||
/* FIXME: hacky */
|
||||
if (*arg == "--from-profile" ||
|
||||
(op == opQuery && (*arg == "--attr" || *arg == "-A")) ||
|
||||
(op == opInstall && (*arg == "--priority")))
|
||||
(op == opQuery && (*arg == "--attr" || *arg == "-A")))
|
||||
opFlags.push_back(getArg(*arg, arg, end));
|
||||
}
|
||||
else
|
||||
@@ -1550,14 +1520,14 @@ static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv
|
||||
if (showHelp) showManPage("nix-env" + opName);
|
||||
if (!op) throw UsageError("no operation specified");
|
||||
|
||||
auto store = aio.blockOn(openStore());
|
||||
auto store = openStore();
|
||||
|
||||
globals.state = std::make_shared<Evaluator>(aio, myArgs.searchPath, store);
|
||||
globals.state = std::shared_ptr<EvalState>(new EvalState(myArgs.searchPath, store));
|
||||
globals.state->repair = myArgs.repair;
|
||||
|
||||
globals.instSource.nixExprPath = std::make_shared<SourcePath>(
|
||||
file != ""
|
||||
? aio.blockOn(lookupFileArg(*globals.state, file)).unwrap()
|
||||
? lookupFileArg(*globals.state, file)
|
||||
: CanonPath(nixExprPath));
|
||||
|
||||
globals.instSource.autoArgs = myArgs.getAutoArgs(*globals.state);
|
||||
@@ -1576,8 +1546,8 @@ static int main_nix_env(AsyncIoRoot & aio, std::string programName, Strings argv
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixEnv() {
|
||||
LegacyCommandRegistry::add("nix-env", main_nix_env);
|
||||
void registerNixEnv() {
|
||||
LegacyCommands::add("nix-env", main_nix_env);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixEnv();
|
||||
void registerNixEnv();
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "lix/libexpr/print-ambiguous.hh"
|
||||
#include "lix/libmain/shared.hh"
|
||||
#include "lix/libexpr/eval.hh"
|
||||
#include "lix/libexpr/eval-inline.hh"
|
||||
#include "lix/libexpr/get-drvs.hh"
|
||||
#include "lix/libexpr/attr-path.hh"
|
||||
#include "lix/libexpr/value-to-xml.hh"
|
||||
@@ -12,6 +13,7 @@
|
||||
#include "lix/libcmd/legacy.hh"
|
||||
#include "nix-instantiate.hh"
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -29,7 +31,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
bool evalOnly, OutputKind output, bool location, Expr & e)
|
||||
{
|
||||
if (parseOnly) {
|
||||
std::cout << e.toJSON(state.ctx.symbols).dump(2);
|
||||
e.show(state.symbols, std::cout);
|
||||
std::cout << "\n";
|
||||
return;
|
||||
}
|
||||
@@ -39,7 +41,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
|
||||
for (auto & i : attrPaths) {
|
||||
Value & v(*findAlongAttrPath(state, i, autoArgs, vRoot).first);
|
||||
state.forceValue(v, noPos);
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
|
||||
NixStringContext context;
|
||||
if (evalOnly) {
|
||||
@@ -47,27 +49,27 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
if (autoArgs.empty())
|
||||
vRes = v;
|
||||
else
|
||||
state.autoCallFunction(autoArgs, v, vRes, noPos);
|
||||
state.autoCallFunction(autoArgs, v, vRes);
|
||||
if (output == okXML)
|
||||
printValueAsXML(state, strict, location, vRes, std::cout, context, noPos);
|
||||
else if (output == okJSON) {
|
||||
printValueAsJSON(state, strict, vRes, noPos, std::cout, context);
|
||||
printValueAsJSON(state, strict, vRes, v.determinePos(noPos), std::cout, context);
|
||||
std::cout << std::endl;
|
||||
} else {
|
||||
if (strict) state.forceValueDeep(vRes);
|
||||
std::set<const void *> seen;
|
||||
printAmbiguous(vRes, state.ctx.symbols, std::cout, &seen, std::numeric_limits<int>::max());
|
||||
printAmbiguous(vRes, state.symbols, std::cout, &seen, std::numeric_limits<int>::max());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
} else {
|
||||
DrvInfos drvs;
|
||||
getDerivations(state, v, "", autoArgs, drvs, false);
|
||||
for (auto & i : drvs) {
|
||||
auto drvPath = i.requireDrvPath(state);
|
||||
auto drvPathS = state.ctx.store->printStorePath(drvPath);
|
||||
auto drvPath = i.requireDrvPath();
|
||||
auto drvPathS = state.store->printStorePath(drvPath);
|
||||
|
||||
/* What output do we want? */
|
||||
std::string outputName = i.queryOutputName(state);
|
||||
std::string outputName = i.queryOutputName();
|
||||
if (outputName == "")
|
||||
throw Error("derivation '%1%' lacks an 'outputName' attribute", drvPathS);
|
||||
|
||||
@@ -76,9 +78,9 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
else {
|
||||
Path rootName = absPath(gcRoot);
|
||||
if (++rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
auto store2 = state.ctx.store.try_cast_shared<LocalFSStore>();
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
if (store2)
|
||||
drvPathS = state.aio.blockOn(store2->addPermRoot(drvPath, rootName));
|
||||
drvPathS = store2->addPermRoot(drvPath, rootName);
|
||||
}
|
||||
std::cout << fmt("%s%s\n", drvPathS, (outputName != "out" ? "!" + outputName : ""));
|
||||
}
|
||||
@@ -87,7 +89,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
}
|
||||
|
||||
|
||||
static int main_nix_instantiate(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_nix_instantiate(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
Strings files;
|
||||
@@ -107,7 +109,7 @@ static int main_nix_instantiate(AsyncIoRoot & aio, std::string programName, Stri
|
||||
using LegacyArgs::LegacyArgs;
|
||||
};
|
||||
|
||||
MyArgs myArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
MyArgs myArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
if (*arg == "--help")
|
||||
showManPage("nix-instantiate");
|
||||
else if (*arg == "--version")
|
||||
@@ -152,49 +154,50 @@ static int main_nix_instantiate(AsyncIoRoot & aio, std::string programName, Stri
|
||||
if (evalOnly && !wantsReadWrite)
|
||||
settings.readOnlyMode = true;
|
||||
|
||||
auto store = aio.blockOn(openStore());
|
||||
auto evalStore = myArgs.evalStoreUrl ? aio.blockOn(openStore(*myArgs.evalStoreUrl)) : store;
|
||||
auto store = openStore();
|
||||
auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store;
|
||||
|
||||
auto evaluator = std::make_unique<Evaluator>(aio, myArgs.searchPath, evalStore, store);
|
||||
auto state = evaluator->begin(aio);
|
||||
evaluator->repair = myArgs.repair;
|
||||
auto state = std::make_unique<EvalState>(myArgs.searchPath, evalStore, store);
|
||||
state->repair = myArgs.repair;
|
||||
|
||||
Bindings & autoArgs = *myArgs.getAutoArgs(*evaluator);
|
||||
Bindings & autoArgs = *myArgs.getAutoArgs(*state);
|
||||
|
||||
if (attrPaths.empty()) attrPaths = {""};
|
||||
|
||||
if (findFile) {
|
||||
for (auto & i : files) {
|
||||
auto p = aio.blockOn(evaluator->paths.findFile(i)).unwrap();
|
||||
std::cout << p.canonical().abs() << std::endl;
|
||||
auto p = state->findFile(i);
|
||||
if (auto fn = p.getPhysicalPath())
|
||||
std::cout << fn->abs() << std::endl;
|
||||
else
|
||||
throw Error("'%s' has no physical path", p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (readStdin) {
|
||||
Expr & e = evaluator->parseStdin();
|
||||
Expr & e = state->parseStdin();
|
||||
processExpr(*state, attrPaths, parseOnly, strict, autoArgs,
|
||||
evalOnly, outputKind, xmlOutputSourceLocation, e);
|
||||
} else if (files.empty() && !fromArgs)
|
||||
files.push_back("./default.nix");
|
||||
|
||||
for (auto & i : files) {
|
||||
Expr & e = fromArgs ? evaluator->parseExprFromString(i, CanonPath::fromCwd())
|
||||
: evaluator->parseExprFromFile(evaluator->paths.resolveExprPath(
|
||||
aio.blockOn(lookupFileArg(*evaluator, i)).unwrap()
|
||||
));
|
||||
Expr & e = fromArgs
|
||||
? state->parseExprFromString(i, CanonPath::fromCwd())
|
||||
: state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state, i))));
|
||||
processExpr(*state, attrPaths, parseOnly, strict, autoArgs,
|
||||
evalOnly, outputKind, xmlOutputSourceLocation, e);
|
||||
}
|
||||
|
||||
evaluator->maybePrintStats();
|
||||
state->maybePrintStats();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixInstantiate() {
|
||||
LegacyCommandRegistry::add("nix-instantiate", main_nix_instantiate);
|
||||
void registerNixInstantiate() {
|
||||
LegacyCommands::add("nix-instantiate", main_nix_instantiate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixInstantiate();
|
||||
void registerNixInstantiate();
|
||||
|
||||
}
|
||||
|
||||
+134
-181
@@ -1,18 +1,16 @@
|
||||
#include "lix/libutil/archive.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
#include "dotgraph.hh"
|
||||
#include "lix/libutil/async-io.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/exit.hh"
|
||||
#include "lix/libstore/globals.hh"
|
||||
#include "lix/libstore/build-result.hh" // IWYU pragma: keep
|
||||
#include "lix/libstore/build-result.hh"
|
||||
#include "lix/libstore/store-cast.hh"
|
||||
#include "lix/libstore/gc-store.hh"
|
||||
#include "lix/libstore/log-store.hh"
|
||||
#include "lix/libstore/local-store.hh"
|
||||
#include "lix/libutil/monitor-fd.hh"
|
||||
#include "lix/libstore/serve-protocol.hh"
|
||||
#include "lix/libstore/serve-protocol-impl.hh" // IWYU pragma: keep
|
||||
#include "lix/libstore/serve-protocol-impl.hh"
|
||||
#include "lix/libmain/shared.hh"
|
||||
#include "graphml.hh"
|
||||
#include "lix/libcmd/legacy.hh"
|
||||
@@ -34,7 +32,7 @@ using std::cin;
|
||||
using std::cout;
|
||||
|
||||
|
||||
typedef void (* Operation) (AsyncIoRoot & aio, Strings opFlags, Strings opArgs);
|
||||
typedef void (* Operation) (Strings opFlags, Strings opArgs);
|
||||
|
||||
|
||||
static Path gcRoot;
|
||||
@@ -47,32 +45,30 @@ ref<LocalStore> ensureLocalStore()
|
||||
{
|
||||
auto store2 = std::dynamic_pointer_cast<LocalStore>(store);
|
||||
if (!store2) throw Error("you don't have sufficient rights to use this command");
|
||||
return ref<LocalStore>::unsafeFromPtr(store2);
|
||||
return ref<LocalStore>(store2);
|
||||
}
|
||||
|
||||
|
||||
static kj::Promise<Result<StorePath>> useDeriver(const StorePath & path)
|
||||
try {
|
||||
if (path.isDerivation()) co_return path;
|
||||
auto info = TRY_AWAIT(store->queryPathInfo(path));
|
||||
static StorePath useDeriver(const StorePath & path)
|
||||
{
|
||||
if (path.isDerivation()) return path;
|
||||
auto info = store->queryPathInfo(path);
|
||||
if (!info->deriver)
|
||||
throw Error("deriver of path '%s' is not known", store->printStorePath(path));
|
||||
co_return *info->deriver;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
return *info->deriver;
|
||||
}
|
||||
|
||||
|
||||
/* Realise the given path. For a derivation that means build it; for
|
||||
other paths it means ensure their validity. */
|
||||
static kj::Promise<Result<PathSet>> realisePath(StorePathWithOutputs path, bool build = true)
|
||||
try {
|
||||
static PathSet realisePath(StorePathWithOutputs path, bool build = true)
|
||||
{
|
||||
auto store2 = std::dynamic_pointer_cast<LocalFSStore>(store);
|
||||
|
||||
if (path.path.isDerivation()) {
|
||||
if (build) TRY_AWAIT(store->buildPaths({path.toDerivedPath()}));
|
||||
auto outputPaths = TRY_AWAIT(store->queryDerivationOutputMap(path.path));
|
||||
Derivation drv = TRY_AWAIT(store->derivationFromPath(path.path));
|
||||
if (build) store->buildPaths({path.toDerivedPath()});
|
||||
auto outputPaths = store->queryDerivationOutputMap(path.path);
|
||||
Derivation drv = store->derivationFromPath(path.path);
|
||||
rootNr++;
|
||||
|
||||
/* FIXME: Encode this empty special case explicitly in the type. */
|
||||
@@ -95,17 +91,17 @@ try {
|
||||
Path rootName = gcRoot;
|
||||
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
if (i->first != "out") rootName += "-" + i->first;
|
||||
retPath = TRY_AWAIT(store2->addPermRoot(outPath, rootName));
|
||||
retPath = store2->addPermRoot(outPath, rootName);
|
||||
}
|
||||
}
|
||||
outputs.insert(retPath);
|
||||
}
|
||||
co_return outputs;
|
||||
return outputs;
|
||||
}
|
||||
|
||||
else {
|
||||
if (build) TRY_AWAIT(store->ensurePath(path.path));
|
||||
else if (!TRY_AWAIT(store->isValidPath(path.path)))
|
||||
if (build) store->ensurePath(path.path);
|
||||
else if (!store->isValidPath(path.path))
|
||||
throw Error("path '%s' does not exist and cannot be created", store->printStorePath(path.path));
|
||||
if (store2) {
|
||||
if (gcRoot == "")
|
||||
@@ -114,18 +110,16 @@ try {
|
||||
Path rootName = gcRoot;
|
||||
rootNr++;
|
||||
if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
co_return PathSet{TRY_AWAIT(store2->addPermRoot(path.path, rootName))};
|
||||
return {store2->addPermRoot(path.path, rootName)};
|
||||
}
|
||||
}
|
||||
co_return PathSet{store->printStorePath(path.path)};
|
||||
return {store->printStorePath(path.path)};
|
||||
}
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
/* Realise the given paths. */
|
||||
static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opRealise(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool dryRun = false;
|
||||
BuildMode buildMode = bmNormal;
|
||||
@@ -144,9 +138,9 @@ static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
uint64_t downloadSize, narSize;
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
aio.blockOn(store->queryMissing(
|
||||
store->queryMissing(
|
||||
toDerivedPaths(paths),
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize));
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
|
||||
/* Filter out unknown paths from `paths`. */
|
||||
if (ignoreUnknown) {
|
||||
@@ -157,20 +151,17 @@ static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
unknown = StorePathSet();
|
||||
}
|
||||
|
||||
if (settings.printMissing) {
|
||||
aio.blockOn(printMissing(
|
||||
ref<Store>::unsafeFromPtr(store), willBuild, willSubstitute, unknown, downloadSize, narSize
|
||||
));
|
||||
}
|
||||
if (settings.printMissing)
|
||||
printMissing(ref<Store>(store), willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
|
||||
if (dryRun) return;
|
||||
|
||||
/* Build all paths at the same time to exploit parallelism. */
|
||||
aio.blockOn(store->buildPaths(toDerivedPaths(paths), buildMode));
|
||||
store->buildPaths(toDerivedPaths(paths), buildMode);
|
||||
|
||||
if (!ignoreUnknown)
|
||||
for (auto & i : paths) {
|
||||
auto paths2 = aio.blockOn(realisePath(i, false));
|
||||
auto paths2 = realisePath(i, false);
|
||||
if (!noOutput)
|
||||
for (auto & j : paths2)
|
||||
cout << fmt("%1%\n", j);
|
||||
@@ -179,24 +170,18 @@ static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Add files to the Nix store and print the resulting paths. */
|
||||
static void opAdd(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opAdd(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
|
||||
for (auto & i : opArgs) {
|
||||
cout << fmt(
|
||||
"%s\n",
|
||||
store->printStorePath(aio.blockOn(
|
||||
store->addToStoreRecursive(std::string(baseNameOf(i)), *prepareDump(i))
|
||||
))
|
||||
);
|
||||
}
|
||||
for (auto & i : opArgs)
|
||||
cout << fmt("%s\n", store->printStorePath(store->addToStore(std::string(baseNameOf(i)), i)));
|
||||
}
|
||||
|
||||
|
||||
/* Preload the output of a fixed-output derivation into the Nix
|
||||
store. */
|
||||
static void opAddFixed(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opAddFixed(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
auto method = FileIngestionMethod::Flat;
|
||||
|
||||
@@ -210,19 +195,13 @@ static void opAddFixed(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
HashType hashAlgo = parseHashType(opArgs.front());
|
||||
opArgs.pop_front();
|
||||
|
||||
for (auto & i : opArgs) {
|
||||
std::cout << fmt(
|
||||
"%s\n",
|
||||
store->printStorePath(
|
||||
aio.blockOn(store->addToStoreSlow(baseNameOf(i), i, method, hashAlgo)).path
|
||||
)
|
||||
);
|
||||
}
|
||||
for (auto & i : opArgs)
|
||||
std::cout << fmt("%s\n", store->printStorePath(store->addToStoreSlow(baseNameOf(i), i, method, hashAlgo).path));
|
||||
}
|
||||
|
||||
|
||||
/* Hack to support caching in `nix-prefetch-url'. */
|
||||
static void opPrintFixedPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
auto method = FileIngestionMethod::Flat;
|
||||
|
||||
@@ -246,31 +225,29 @@ static void opPrintFixedPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static kj::Promise<Result<StorePathSet>> maybeUseOutputs(const StorePath & storePath, bool useOutput, bool forceRealise)
|
||||
try {
|
||||
if (forceRealise) TRY_AWAIT(realisePath({storePath}));
|
||||
static StorePathSet maybeUseOutputs(const StorePath & storePath, bool useOutput, bool forceRealise)
|
||||
{
|
||||
if (forceRealise) realisePath({storePath});
|
||||
if (useOutput && storePath.isDerivation()) {
|
||||
auto drv = TRY_AWAIT(store->derivationFromPath(storePath));
|
||||
auto drv = store->derivationFromPath(storePath);
|
||||
StorePathSet outputs;
|
||||
if (forceRealise)
|
||||
co_return TRY_AWAIT(store->queryDerivationOutputs(storePath));
|
||||
return store->queryDerivationOutputs(storePath);
|
||||
for (auto & i : drv.outputsAndOptPaths(*store)) {
|
||||
if (!i.second.second)
|
||||
throw UsageError("Cannot use output path of floating content-addressed derivation until we know what it is (e.g. by building it)");
|
||||
outputs.insert(*i.second.second);
|
||||
}
|
||||
co_return outputs;
|
||||
return outputs;
|
||||
}
|
||||
else co_return StorePathSet{storePath};
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
else return {storePath};
|
||||
}
|
||||
|
||||
|
||||
/* Some code to print a tree representation of a derivation dependency
|
||||
graph. Topological sorting is used to keep the tree relatively
|
||||
flat. */
|
||||
static void printTree(AsyncIoRoot & aio, const StorePath & path,
|
||||
static void printTree(const StorePath & path,
|
||||
const std::string & firstPad, const std::string & tailPad, StorePathSet & done)
|
||||
{
|
||||
if (!done.insert(path).second) {
|
||||
@@ -280,18 +257,18 @@ static void printTree(AsyncIoRoot & aio, const StorePath & path,
|
||||
|
||||
cout << fmt("%s%s\n", firstPad, store->printStorePath(path));
|
||||
|
||||
auto info = aio.blockOn(store->queryPathInfo(path));
|
||||
auto info = store->queryPathInfo(path);
|
||||
|
||||
/* Topologically sort under the relation A < B iff A \in
|
||||
closure(B). That is, if derivation A is an (possibly indirect)
|
||||
input of B, then A is printed first. This has the effect of
|
||||
flattening the tree, preventing deeply nested structures. */
|
||||
auto sorted = aio.blockOn(store->topoSortPaths(info->references));
|
||||
auto sorted = store->topoSortPaths(info->references);
|
||||
reverse(sorted.begin(), sorted.end());
|
||||
|
||||
for (const auto &[n, i] : enumerate(sorted)) {
|
||||
bool last = n + 1 == sorted.size();
|
||||
printTree(aio, i,
|
||||
printTree(i,
|
||||
tailPad + (last ? treeLast : treeConn),
|
||||
tailPad + (last ? treeNull : treeLine),
|
||||
done);
|
||||
@@ -300,7 +277,7 @@ static void printTree(AsyncIoRoot & aio, const StorePath & path,
|
||||
|
||||
|
||||
/* Perform various sorts of queries. */
|
||||
static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opQuery(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
enum QueryType
|
||||
{ qOutputs, qRequisites, qReferences, qReferrers
|
||||
@@ -351,7 +328,7 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
case qOutputs: {
|
||||
for (auto & i : opArgs) {
|
||||
auto outputs = aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), true, forceRealise));
|
||||
auto outputs = maybeUseOutputs(store->followLinksToStorePath(i), true, forceRealise);
|
||||
for (auto & outputPath : outputs)
|
||||
cout << fmt("%1%\n", store->printStorePath(outputPath));
|
||||
}
|
||||
@@ -364,26 +341,23 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case qReferrersClosure: {
|
||||
StorePathSet paths;
|
||||
for (auto & i : opArgs) {
|
||||
auto ps = aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise));
|
||||
auto ps = maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise);
|
||||
for (auto & j : ps) {
|
||||
if (query == qRequisites) {
|
||||
aio.blockOn(store->computeFSClosure(j, paths, false, includeOutputs));
|
||||
}
|
||||
if (query == qRequisites) store->computeFSClosure(j, paths, false, includeOutputs);
|
||||
else if (query == qReferences) {
|
||||
for (auto & p : aio.blockOn(store->queryPathInfo(j))->references)
|
||||
for (auto & p : store->queryPathInfo(j)->references)
|
||||
paths.insert(p);
|
||||
}
|
||||
else if (query == qReferrers) {
|
||||
StorePathSet tmp;
|
||||
aio.blockOn(store->queryReferrers(j, tmp));
|
||||
store->queryReferrers(j, tmp);
|
||||
for (auto & i : tmp)
|
||||
paths.insert(i);
|
||||
}
|
||||
else if (query == qReferrersClosure)
|
||||
aio.blockOn(store->computeFSClosure(j, paths, true));
|
||||
else if (query == qReferrersClosure) store->computeFSClosure(j, paths, true);
|
||||
}
|
||||
}
|
||||
auto sorted = aio.blockOn(store->topoSortPaths(paths));
|
||||
auto sorted = store->topoSortPaths(paths);
|
||||
for (StorePaths::reverse_iterator i = sorted.rbegin();
|
||||
i != sorted.rend(); ++i)
|
||||
cout << fmt("%s\n", store->printStorePath(*i));
|
||||
@@ -392,7 +366,7 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
case qDeriver:
|
||||
for (auto & i : opArgs) {
|
||||
auto info = aio.blockOn(store->queryPathInfo(store->followLinksToStorePath(i)));
|
||||
auto info = store->queryPathInfo(store->followLinksToStorePath(i));
|
||||
cout << fmt("%s\n", info->deriver ? store->printStorePath(*info->deriver) : "unknown-deriver");
|
||||
}
|
||||
break;
|
||||
@@ -400,13 +374,12 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case qValidDerivers: {
|
||||
StorePathSet result;
|
||||
for (auto & i : opArgs) {
|
||||
auto derivers =
|
||||
aio.blockOn(store->queryValidDerivers(store->followLinksToStorePath(i)));
|
||||
for (const auto & i : derivers) {
|
||||
auto derivers = store->queryValidDerivers(store->followLinksToStorePath(i));
|
||||
for (const auto &i: derivers) {
|
||||
result.insert(i);
|
||||
}
|
||||
}
|
||||
auto sorted = aio.blockOn(store->topoSortPaths(result));
|
||||
auto sorted = store->topoSortPaths(result);
|
||||
for (StorePaths::reverse_iterator i = sorted.rbegin();
|
||||
i != sorted.rend(); ++i)
|
||||
cout << fmt("%s\n", store->printStorePath(*i));
|
||||
@@ -415,8 +388,8 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
case qBinding:
|
||||
for (auto & i : opArgs) {
|
||||
auto path = aio.blockOn(useDeriver(store->followLinksToStorePath(i)));
|
||||
Derivation drv = aio.blockOn(store->derivationFromPath(path));
|
||||
auto path = useDeriver(store->followLinksToStorePath(i));
|
||||
Derivation drv = store->derivationFromPath(path);
|
||||
StringPairs::iterator j = drv.env.find(bindingName);
|
||||
if (j == drv.env.end())
|
||||
throw Error("derivation '%s' has no environment binding named '%s'",
|
||||
@@ -428,8 +401,8 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case qHash:
|
||||
case qSize:
|
||||
for (auto & i : opArgs) {
|
||||
for (auto & j : aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise))) {
|
||||
auto info = aio.blockOn(store->queryPathInfo(j));
|
||||
for (auto & j : maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)) {
|
||||
auto info = store->queryPathInfo(j);
|
||||
if (query == qHash) {
|
||||
assert(info->narHash.type == HashType::SHA256);
|
||||
cout << fmt("%s\n", info->narHash.to_string(Base::Base32, true));
|
||||
@@ -442,25 +415,25 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case qTree: {
|
||||
StorePathSet done;
|
||||
for (auto & i : opArgs)
|
||||
printTree(aio, store->followLinksToStorePath(i), "", "", done);
|
||||
printTree(store->followLinksToStorePath(i), "", "", done);
|
||||
break;
|
||||
}
|
||||
|
||||
case qGraph: {
|
||||
StorePathSet roots;
|
||||
for (auto & i : opArgs)
|
||||
for (auto & j : aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)))
|
||||
for (auto & j : maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise))
|
||||
roots.insert(j);
|
||||
aio.blockOn(printDotGraph(ref<Store>::unsafeFromPtr(store), std::move(roots)));
|
||||
printDotGraph(ref<Store>(store), std::move(roots));
|
||||
break;
|
||||
}
|
||||
|
||||
case qGraphML: {
|
||||
StorePathSet roots;
|
||||
for (auto & i : opArgs)
|
||||
for (auto & j : aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)))
|
||||
for (auto & j : maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise))
|
||||
roots.insert(j);
|
||||
aio.blockOn(printGraphML(ref<Store>::unsafeFromPtr(store), std::move(roots)));
|
||||
printGraphML(ref<Store>(store), std::move(roots));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -473,15 +446,15 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case qRoots: {
|
||||
StorePathSet args;
|
||||
for (auto & i : opArgs)
|
||||
for (auto & p : aio.blockOn(maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise)))
|
||||
for (auto & p : maybeUseOutputs(store->followLinksToStorePath(i), useOutput, forceRealise))
|
||||
args.insert(p);
|
||||
|
||||
StorePathSet referrers;
|
||||
aio.blockOn(store->computeFSClosure(
|
||||
args, referrers, true, settings.gcKeepOutputs, settings.gcKeepDerivations));
|
||||
store->computeFSClosure(
|
||||
args, referrers, true, settings.gcKeepOutputs, settings.gcKeepDerivations);
|
||||
|
||||
auto & gcStore = require<GcStore>(*store);
|
||||
Roots roots = aio.blockOn(gcStore.findRoots(false));
|
||||
Roots roots = gcStore.findRoots(false);
|
||||
for (auto & [target, links] : roots)
|
||||
if (referrers.find(target) != referrers.end())
|
||||
for (auto & link : links)
|
||||
@@ -495,13 +468,13 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opPrintEnv(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opPrintEnv(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("'--print-env' requires one derivation store path");
|
||||
|
||||
Path drvPath = opArgs.front();
|
||||
Derivation drv = aio.blockOn(store->derivationFromPath(store->parseStorePath(drvPath)));
|
||||
Derivation drv = store->derivationFromPath(store->parseStorePath(drvPath));
|
||||
|
||||
/* Print each environment variable in the derivation in a format
|
||||
* that can be sourced by the shell. */
|
||||
@@ -521,7 +494,7 @@ static void opPrintEnv(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opReadLog(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opReadLog(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
|
||||
@@ -531,7 +504,7 @@ static void opReadLog(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
for (auto & i : opArgs) {
|
||||
auto path = logStore.followLinksToStorePath(i);
|
||||
auto log = aio.blockOn(logStore.getBuildLog(path));
|
||||
auto log = logStore.getBuildLog(path);
|
||||
if (!log)
|
||||
throw Error("build log of derivation '%s' is not available", logStore.printStorePath(path));
|
||||
std::cout << *log;
|
||||
@@ -539,23 +512,20 @@ static void opReadLog(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opDumpDB(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opDumpDB(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (!opArgs.empty()) {
|
||||
for (auto & i : opArgs) {
|
||||
cout << aio.blockOn(
|
||||
store->makeValidityRegistration({store->followLinksToStorePath(i)}, true, true)
|
||||
);
|
||||
}
|
||||
for (auto & i : opArgs)
|
||||
cout << store->makeValidityRegistration({store->followLinksToStorePath(i)}, true, true);
|
||||
} else {
|
||||
for (auto & i : aio.blockOn(store->queryAllValidPaths()))
|
||||
cout << aio.blockOn(store->makeValidityRegistration({i}, true, true));
|
||||
for (auto & i : store->queryAllValidPaths())
|
||||
cout << store->makeValidityRegistration({i}, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void registerValidity(AsyncIoRoot & aio, bool reregister, bool hashGiven, bool canonicalise)
|
||||
static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
||||
{
|
||||
ValidPathInfos infos;
|
||||
|
||||
@@ -565,7 +535,7 @@ static void registerValidity(AsyncIoRoot & aio, bool reregister, bool hashGiven,
|
||||
auto hashResultOpt = !hashGiven ? std::optional<HashResult> { {Hash::dummy, -1} } : std::nullopt;
|
||||
auto info = decodeValidPathInfo(*store, cin, hashResultOpt);
|
||||
if (!info) break;
|
||||
if (!aio.blockOn(store->isValidPath(info->path)) || reregister) {
|
||||
if (!store->isValidPath(info->path) || reregister) {
|
||||
/* !!! races */
|
||||
if (canonicalise)
|
||||
canonicalisePathMetaData(store->printStorePath(info->path), {});
|
||||
@@ -578,20 +548,20 @@ static void registerValidity(AsyncIoRoot & aio, bool reregister, bool hashGiven,
|
||||
}
|
||||
}
|
||||
|
||||
aio.blockOn(ensureLocalStore()->registerValidPaths(infos));
|
||||
ensureLocalStore()->registerValidPaths(infos);
|
||||
}
|
||||
|
||||
|
||||
static void opLoadDB(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opLoadDB(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (!opArgs.empty())
|
||||
throw UsageError("no arguments expected");
|
||||
registerValidity(aio, true, true, false);
|
||||
registerValidity(true, true, false);
|
||||
}
|
||||
|
||||
|
||||
static void opRegisterValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opRegisterValidity(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool reregister = false; // !!! maybe this should be the default
|
||||
bool hashGiven = false;
|
||||
@@ -603,11 +573,11 @@ static void opRegisterValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArg
|
||||
|
||||
if (!opArgs.empty()) throw UsageError("no arguments expected");
|
||||
|
||||
registerValidity(aio, reregister, hashGiven, true);
|
||||
registerValidity(reregister, hashGiven, true);
|
||||
}
|
||||
|
||||
|
||||
static void opCheckValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opCheckValidity(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool printInvalid = false;
|
||||
|
||||
@@ -617,7 +587,7 @@ static void opCheckValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
for (auto & i : opArgs) {
|
||||
auto path = store->followLinksToStorePath(i);
|
||||
if (!aio.blockOn(store->isValidPath(path))) {
|
||||
if (!store->isValidPath(path)) {
|
||||
if (printInvalid)
|
||||
cout << fmt("%s\n", store->printStorePath(path));
|
||||
else
|
||||
@@ -627,7 +597,7 @@ static void opCheckValidity(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opGC(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opGC(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool printRoots = false;
|
||||
GCOptions options;
|
||||
@@ -649,7 +619,7 @@ static void opGC(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
auto & gcStore = require<GcStore>(*store);
|
||||
|
||||
if (printRoots) {
|
||||
Roots roots = aio.blockOn(gcStore.findRoots(false));
|
||||
Roots roots = gcStore.findRoots(false);
|
||||
std::set<std::pair<Path, StorePath>> roots2;
|
||||
// Transpose and sort the roots.
|
||||
for (auto & [target, links] : roots)
|
||||
@@ -661,7 +631,7 @@ static void opGC(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
else {
|
||||
PrintFreed freed(options.action == GCOptions::gcDeleteDead, results);
|
||||
aio.blockOn(gcStore.collectGarbage(options, results));
|
||||
gcStore.collectGarbage(options, results);
|
||||
|
||||
if (options.action != GCOptions::gcDeleteDead)
|
||||
for (auto & i : results.paths)
|
||||
@@ -673,37 +643,28 @@ static void opGC(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
/* Remove paths from the Nix store if possible (i.e., if they do not
|
||||
have any remaining referrers and are not reachable from any GC
|
||||
roots). */
|
||||
static void opDelete(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opDelete(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
GCOptions options;
|
||||
options.action = GCOptions::gcDeleteSpecific;
|
||||
bool deleteClosure = false;
|
||||
|
||||
for (auto & i : opFlags)
|
||||
if (i == "--ignore-liveness") options.ignoreLiveness = true;
|
||||
else if (i == "--skip-live") options.action = GCOptions::gcTryDeleteSpecific;
|
||||
else if (i == "--delete-closure") deleteClosure = true;
|
||||
else throw UsageError("unknown flag '%1%'", i);
|
||||
|
||||
for (auto & arg : opArgs) {
|
||||
StorePath path = store->followLinksToStorePath(arg);
|
||||
if (deleteClosure) {
|
||||
aio.blockOn(store->computeFSClosure(path, options.pathsToDelete));
|
||||
} else {
|
||||
options.pathsToDelete.insert(path);
|
||||
}
|
||||
}
|
||||
for (auto & i : opArgs)
|
||||
options.pathsToDelete.insert(store->followLinksToStorePath(i));
|
||||
|
||||
auto & gcStore = require<GcStore>(*store);
|
||||
|
||||
GCResults results;
|
||||
PrintFreed freed(true, results);
|
||||
aio.blockOn(gcStore.collectGarbage(options, results));
|
||||
gcStore.collectGarbage(options, results);
|
||||
}
|
||||
|
||||
|
||||
/* Dump a path as a Nix archive. The archive is written to stdout */
|
||||
static void opDump(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opDump(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
|
||||
@@ -716,7 +677,7 @@ static void opDump(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Restore a value from a Nix archive. The archive is read from stdin. */
|
||||
static void opRestore(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opRestore(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
|
||||
@@ -726,7 +687,7 @@ static void opRestore(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opExport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opExport(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
for (auto & i : opFlags)
|
||||
throw UsageError("unknown flag '%1%'", i);
|
||||
@@ -737,12 +698,12 @@ static void opExport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
paths.insert(store->followLinksToStorePath(i));
|
||||
|
||||
FdSink sink(STDOUT_FILENO);
|
||||
aio.blockOn(store->exportPaths(paths, sink));
|
||||
store->exportPaths(paths, sink);
|
||||
sink.flush();
|
||||
}
|
||||
|
||||
|
||||
static void opImport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opImport(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
for (auto & i : opFlags)
|
||||
throw UsageError("unknown flag '%1%'", i);
|
||||
@@ -750,7 +711,7 @@ static void opImport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
if (!opArgs.empty()) throw UsageError("no arguments expected");
|
||||
|
||||
FdSource source(STDIN_FILENO);
|
||||
auto paths = aio.blockOn(store->importPaths(source, NoCheckSigs));
|
||||
auto paths = store->importPaths(source, NoCheckSigs);
|
||||
|
||||
for (auto & i : paths)
|
||||
cout << fmt("%s\n", store->printStorePath(i)) << std::flush;
|
||||
@@ -758,7 +719,7 @@ static void opImport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Initialise the Nix databases. */
|
||||
static void opInit(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opInit(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
if (!opArgs.empty())
|
||||
@@ -769,7 +730,7 @@ static void opInit(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Verify the consistency of the Nix environment. */
|
||||
static void opVerify(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opVerify(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opArgs.empty())
|
||||
throw UsageError("no arguments expected");
|
||||
@@ -782,7 +743,7 @@ static void opVerify(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
else if (i == "--repair") repair = Repair;
|
||||
else throw UsageError("unknown flag '%1%'", i);
|
||||
|
||||
if (aio.blockOn(store->verifyStore(checkContents, repair))) {
|
||||
if (store->verifyStore(checkContents, repair)) {
|
||||
warn("not all store errors were fixed");
|
||||
throw Exit(1);
|
||||
}
|
||||
@@ -790,7 +751,7 @@ static void opVerify(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
|
||||
/* Verify whether the contents of the given store path have not changed. */
|
||||
static void opVerifyPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opVerifyPath(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty())
|
||||
throw UsageError("no flags expected");
|
||||
@@ -800,15 +761,15 @@ static void opVerifyPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
for (auto & i : opArgs) {
|
||||
auto path = store->followLinksToStorePath(i);
|
||||
printMsg(lvlTalkative, "checking path '%s'...", store->printStorePath(path));
|
||||
auto info = aio.blockOn(store->queryPathInfo(path));
|
||||
auto info = store->queryPathInfo(path);
|
||||
HashSink sink(info->narHash.type);
|
||||
aio.blockOn(store->narFromPath(path))->drainInto(sink);
|
||||
sink << store->narFromPath(path);
|
||||
auto current = sink.finish();
|
||||
if (current.first != info->narHash) {
|
||||
printError("path '%s' was modified! expected hash '%s', got '%s'",
|
||||
store->printStorePath(path),
|
||||
info->narHash.to_string(Base::SRI, true),
|
||||
current.first.to_string(Base::SRI, true));
|
||||
info->narHash.to_string(Base::Base32, true),
|
||||
current.first.to_string(Base::Base32, true));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
@@ -819,27 +780,27 @@ static void opVerifyPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
/* Repair the contents of the given path by redownloading it using a
|
||||
substituter (if available). */
|
||||
static void opRepairPath(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opRepairPath(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty())
|
||||
throw UsageError("no flags expected");
|
||||
|
||||
for (auto & i : opArgs)
|
||||
aio.blockOn(store->repairPath(store->followLinksToStorePath(i)));
|
||||
store->repairPath(store->followLinksToStorePath(i));
|
||||
}
|
||||
|
||||
/* Optimise the disk space usage of the Nix store by hard-linking
|
||||
files with the same contents. */
|
||||
static void opOptimise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opOptimise(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opArgs.empty() || !opFlags.empty())
|
||||
throw UsageError("no arguments expected");
|
||||
|
||||
aio.blockOn(store->optimiseStore());
|
||||
store->optimiseStore();
|
||||
}
|
||||
|
||||
/* Serve the nix store in a way usable by a restricted ssh user. */
|
||||
static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opServe(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
bool writeAllowed = false;
|
||||
for (auto & i : opFlags)
|
||||
@@ -912,13 +873,13 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
auto paths = ServeProto::Serialise<StorePathSet>::read(*store, rconn);
|
||||
if (lock && writeAllowed)
|
||||
for (auto & path : paths)
|
||||
aio.blockOn(store->addTempRoot(path));
|
||||
store->addTempRoot(path);
|
||||
|
||||
if (substitute && writeAllowed) {
|
||||
aio.blockOn(store->substitutePaths(paths));
|
||||
store->substitutePaths(paths);
|
||||
}
|
||||
|
||||
auto valid = aio.blockOn(store->queryValidPaths(paths));
|
||||
auto valid = store->queryValidPaths(paths);
|
||||
out << ServeProto::write(*store, wconn, valid);
|
||||
break;
|
||||
}
|
||||
@@ -928,7 +889,7 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
// !!! Maybe we want a queryPathInfos?
|
||||
for (auto & i : paths) {
|
||||
try {
|
||||
auto info = aio.blockOn(store->queryPathInfo(i));
|
||||
auto info = store->queryPathInfo(i);
|
||||
out << store->printStorePath(info->path);
|
||||
out << ServeProto::write(*store, wconn, static_cast<const UnkeyedValidPathInfo &>(*info));
|
||||
} catch (InvalidPath &) {
|
||||
@@ -939,22 +900,19 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
case ServeProto::Command::DumpStorePath:
|
||||
aio.blockOn(store->narFromPath(store->parseStorePath(readString(in))))
|
||||
->drainInto(out);
|
||||
out << store->narFromPath(store->parseStorePath(readString(in)));
|
||||
break;
|
||||
|
||||
case ServeProto::Command::ImportPaths: {
|
||||
if (!writeAllowed) throw Error("importing paths is not allowed");
|
||||
aio.blockOn(store->importPaths(in, NoCheckSigs)); // FIXME: should we skip sig checking?
|
||||
store->importPaths(in, NoCheckSigs); // FIXME: should we skip sig checking?
|
||||
out << 1; // indicate success
|
||||
break;
|
||||
}
|
||||
|
||||
case ServeProto::Command::ExportPaths: {
|
||||
readInt(in); // obsolete
|
||||
aio.blockOn(store->exportPaths(
|
||||
ServeProto::Serialise<StorePathSet>::read(*store, rconn), out
|
||||
));
|
||||
store->exportPaths(ServeProto::Serialise<StorePathSet>::read(*store, rconn), out);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -970,7 +928,7 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
try {
|
||||
MonitorFdHup monitor(in.fd);
|
||||
aio.blockOn(store->buildPaths(toDerivedPaths(paths)));
|
||||
store->buildPaths(toDerivedPaths(paths));
|
||||
out << 0;
|
||||
} catch (Error & e) {
|
||||
assert(e.info().status);
|
||||
@@ -990,7 +948,7 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
getBuildSettings();
|
||||
|
||||
MonitorFdHup monitor(in.fd);
|
||||
auto status = aio.blockOn(store->buildDerivation(drvPath, drv));
|
||||
auto status = store->buildDerivation(drvPath, drv);
|
||||
|
||||
out << ServeProto::write(*store, wconn, status);
|
||||
break;
|
||||
@@ -999,12 +957,8 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case ServeProto::Command::QueryClosure: {
|
||||
bool includeOutputs = readInt(in);
|
||||
StorePathSet closure;
|
||||
aio.blockOn(store->computeFSClosure(
|
||||
ServeProto::Serialise<StorePathSet>::read(*store, rconn),
|
||||
closure,
|
||||
false,
|
||||
includeOutputs
|
||||
));
|
||||
store->computeFSClosure(ServeProto::Serialise<StorePathSet>::read(*store, rconn),
|
||||
closure, false, includeOutputs);
|
||||
out << ServeProto::write(*store, wconn, closure);
|
||||
break;
|
||||
}
|
||||
@@ -1029,9 +983,8 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
throw Error("narInfo is too old and missing the narSize field");
|
||||
|
||||
SizedSource sizedSource(in, info.narSize);
|
||||
AsyncSourceInputStream stream{sizedSource};
|
||||
|
||||
aio.blockOn(store->addToStore(info, stream, NoRepair, NoCheckSigs));
|
||||
store->addToStore(info, sizedSource, NoRepair, NoCheckSigs);
|
||||
|
||||
// consume all the data that has been sent before continuing.
|
||||
sizedSource.drainAll();
|
||||
@@ -1050,7 +1003,7 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
}
|
||||
|
||||
|
||||
static void opGenerateBinaryCacheKey(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
for (auto & i : opFlags)
|
||||
throw UsageError("unknown flag '%1%'", i);
|
||||
@@ -1069,7 +1022,7 @@ static void opGenerateBinaryCacheKey(AsyncIoRoot & aio, Strings opFlags, Strings
|
||||
}
|
||||
|
||||
|
||||
static void opVersion(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
static void opVersion(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
printVersion("nix-store");
|
||||
}
|
||||
@@ -1078,7 +1031,7 @@ static void opVersion(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
/* Scan the arguments; find the operation, set global flags, put all
|
||||
other flags in a list, and put all other arguments in another
|
||||
list. */
|
||||
static int main_nix_store(AsyncIoRoot & aio, std::string programName, Strings argv)
|
||||
static int main_nix_store(std::string programName, Strings argv)
|
||||
{
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
@@ -1087,7 +1040,7 @@ static int main_nix_store(AsyncIoRoot & aio, std::string programName, Strings ar
|
||||
std::string opName;
|
||||
bool showHelp = false;
|
||||
|
||||
LegacyArgs(aio, programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
LegacyArgs(programName, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
Operation oldOp = op;
|
||||
|
||||
if (*arg == "--help")
|
||||
@@ -1215,16 +1168,16 @@ static int main_nix_store(AsyncIoRoot & aio, std::string programName, Strings ar
|
||||
if (!op) throw UsageError("no operation specified");
|
||||
|
||||
if (op != opDump && op != opRestore) /* !!! hack */
|
||||
store = aio.blockOn(openStore());
|
||||
store = openStore();
|
||||
|
||||
op(aio, std::move(opFlags), std::move(opArgs));
|
||||
op(std::move(opFlags), std::move(opArgs));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void registerLegacyNixStore() {
|
||||
LegacyCommandRegistry::add("nix-store", main_nix_store);
|
||||
void registerNixStore() {
|
||||
LegacyCommands::add("nix-store", main_nix_store);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void registerLegacyNixStore();
|
||||
void registerNixStore();
|
||||
|
||||
}
|
||||
|
||||
+44
-41
@@ -3,8 +3,10 @@
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libstore/path-with-outputs.hh"
|
||||
#include "lix/libstore/local-fs-store.hh"
|
||||
#include "lix/libstore/globals.hh"
|
||||
#include "lix/libmain/shared.hh"
|
||||
#include "lix/libexpr/eval.hh"
|
||||
#include "lix/libexpr/eval-inline.hh"
|
||||
#include "lix/libstore/profiles.hh"
|
||||
#include "lix/libexpr/print-ambiguous.hh"
|
||||
|
||||
@@ -22,65 +24,65 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
exist already. */
|
||||
std::vector<StorePathWithOutputs> drvsToBuild;
|
||||
for (auto & i : elems)
|
||||
if (auto drvPath = i.queryDrvPath(state))
|
||||
if (auto drvPath = i.queryDrvPath())
|
||||
drvsToBuild.push_back({*drvPath});
|
||||
|
||||
debug("building user environment dependencies");
|
||||
state.aio.blockOn(state.ctx.store->buildPaths(
|
||||
state.store->buildPaths(
|
||||
toDerivedPaths(drvsToBuild),
|
||||
state.ctx.repair ? bmRepair : bmNormal));
|
||||
state.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Construct the whole top level derivation. */
|
||||
StorePathSet references;
|
||||
Value manifest = state.ctx.mem.newList(elems.size());
|
||||
Value manifest = state.mem.newList(elems.size());
|
||||
size_t n = 0;
|
||||
for (auto & i : elems) {
|
||||
/* Create a pseudo-derivation containing the name, system,
|
||||
output paths, and optionally the derivation path, as well
|
||||
as the meta attributes. */
|
||||
std::optional<StorePath> drvPath = keepDerivations ? i.queryDrvPath(state) : std::nullopt;
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(state, true, true);
|
||||
StringSet metaNames = i.queryMetaNames(state);
|
||||
std::optional<StorePath> drvPath = keepDerivations ? i.queryDrvPath() : std::nullopt;
|
||||
DrvInfo::Outputs outputs = i.queryOutputs(true, true);
|
||||
StringSet metaNames = i.queryMetaNames();
|
||||
|
||||
auto attrs = state.ctx.buildBindings(7 + outputs.size());
|
||||
auto attrs = state.buildBindings(7 + outputs.size());
|
||||
|
||||
attrs.alloc(state.ctx.s.type).mkString("derivation");
|
||||
attrs.alloc(state.ctx.s.name).mkString(i.queryName(state));
|
||||
auto system = i.querySystem(state);
|
||||
attrs.alloc(state.s.type).mkString("derivation");
|
||||
attrs.alloc(state.s.name).mkString(i.queryName());
|
||||
auto system = i.querySystem();
|
||||
if (!system.empty())
|
||||
attrs.alloc(state.ctx.s.system).mkString(system);
|
||||
attrs.alloc(state.ctx.s.outPath).mkString(state.ctx.store->printStorePath(i.queryOutPath(state)));
|
||||
attrs.alloc(state.s.system).mkString(system);
|
||||
attrs.alloc(state.s.outPath).mkString(state.store->printStorePath(i.queryOutPath()));
|
||||
if (drvPath)
|
||||
attrs.alloc(state.ctx.s.drvPath).mkString(state.ctx.store->printStorePath(*drvPath));
|
||||
attrs.alloc(state.s.drvPath).mkString(state.store->printStorePath(*drvPath));
|
||||
|
||||
// Copy each output meant for installation.
|
||||
auto & vOutputs = attrs.alloc(state.ctx.s.outputs);
|
||||
vOutputs = state.ctx.mem.newList(outputs.size());
|
||||
auto & vOutputs = attrs.alloc(state.s.outputs);
|
||||
vOutputs = state.mem.newList(outputs.size());
|
||||
for (const auto & [m, j] : enumerate(outputs)) {
|
||||
(vOutputs.listElems()[m] = state.ctx.mem.allocValue())->mkString(j.first);
|
||||
auto outputAttrs = state.ctx.buildBindings(2);
|
||||
outputAttrs.alloc(state.ctx.s.outPath).mkString(state.ctx.store->printStorePath(*j.second));
|
||||
(vOutputs.listElems()[m] = state.mem.allocValue())->mkString(j.first);
|
||||
auto outputAttrs = state.buildBindings(2);
|
||||
outputAttrs.alloc(state.s.outPath).mkString(state.store->printStorePath(*j.second));
|
||||
attrs.alloc(j.first).mkAttrs(outputAttrs);
|
||||
|
||||
/* This is only necessary when installing store paths, e.g.,
|
||||
`nix-env -i /nix/store/abcd...-foo'. */
|
||||
state.aio.blockOn(state.ctx.store->addTempRoot(*j.second));
|
||||
state.aio.blockOn(state.ctx.store->ensurePath(*j.second));
|
||||
state.store->addTempRoot(*j.second);
|
||||
state.store->ensurePath(*j.second);
|
||||
|
||||
references.insert(*j.second);
|
||||
}
|
||||
|
||||
// Copy the meta attributes.
|
||||
auto meta = state.ctx.buildBindings(metaNames.size());
|
||||
auto meta = state.buildBindings(metaNames.size());
|
||||
for (auto & j : metaNames) {
|
||||
Value * v = i.queryMeta(state, j);
|
||||
Value * v = i.queryMeta(j);
|
||||
if (!v) continue;
|
||||
meta.insert(state.ctx.symbols.create(j), v);
|
||||
meta.insert(state.symbols.create(j), v);
|
||||
}
|
||||
|
||||
attrs.alloc(state.ctx.s.meta).mkAttrs(meta);
|
||||
attrs.alloc(state.s.meta).mkAttrs(meta);
|
||||
|
||||
(manifest.listElems()[n++] = state.ctx.mem.allocValue())->mkAttrs(attrs);
|
||||
(manifest.listElems()[n++] = state.mem.allocValue())->mkAttrs(attrs);
|
||||
|
||||
if (drvPath) references.insert(*drvPath);
|
||||
}
|
||||
@@ -89,21 +91,21 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
the store; we need it for future modifications of the
|
||||
environment. */
|
||||
std::ostringstream str;
|
||||
printAmbiguous(manifest, state.ctx.symbols, str, nullptr, std::numeric_limits<int>::max());
|
||||
auto manifestFile = state.aio.blockOn(state.ctx.store->addTextToStore("env-manifest.nix",
|
||||
str.str(), references));
|
||||
printAmbiguous(manifest, state.symbols, str, nullptr, std::numeric_limits<int>::max());
|
||||
auto manifestFile = state.store->addTextToStore("env-manifest.nix",
|
||||
str.str(), references);
|
||||
|
||||
/* Get the environment builder expression. */
|
||||
Value envBuilder;
|
||||
state.eval(state.ctx.parseExprFromString(
|
||||
state.eval(state.parseExprFromString(
|
||||
#include "buildenv.nix.gen.hh"
|
||||
, CanonPath::root), envBuilder);
|
||||
|
||||
/* Construct a Nix expression that calls the user environment
|
||||
builder with the manifest as argument. */
|
||||
auto attrs = state.ctx.buildBindings(3);
|
||||
state.ctx.paths.mkStorePathString(manifestFile, attrs.alloc("manifest"));
|
||||
attrs.insert(state.ctx.symbols.create("derivations"), &manifest);
|
||||
auto attrs = state.buildBindings(3);
|
||||
state.mkStorePathString(manifestFile, attrs.alloc("manifest"));
|
||||
attrs.insert(state.symbols.create("derivations"), &manifest);
|
||||
Value args;
|
||||
args.mkAttrs(attrs);
|
||||
|
||||
@@ -112,26 +114,27 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
|
||||
/* Evaluate it. */
|
||||
debug("evaluating user environment builder");
|
||||
state.forceValue(topLevel, noPos);
|
||||
state.forceValue(topLevel, topLevel.determinePos(noPos));
|
||||
NixStringContext context;
|
||||
Attr & aDrvPath(*topLevel.attrs->find(state.ctx.s.drvPath));
|
||||
Attr & aDrvPath(*topLevel.attrs->find(state.s.drvPath));
|
||||
auto topLevelDrv = state.coerceToStorePath(aDrvPath.pos, *aDrvPath.value, context, "");
|
||||
Attr & aOutPath(*topLevel.attrs->find(state.ctx.s.outPath));
|
||||
Attr & aOutPath(*topLevel.attrs->find(state.s.outPath));
|
||||
auto topLevelOut = state.coerceToStorePath(aOutPath.pos, *aOutPath.value, context, "");
|
||||
|
||||
/* Realise the resulting store expression. */
|
||||
debug("building user environment");
|
||||
std::vector<StorePathWithOutputs> topLevelDrvs;
|
||||
topLevelDrvs.push_back({topLevelDrv});
|
||||
state.aio.blockOn(state.ctx.store->buildPaths(
|
||||
state.store->buildPaths(
|
||||
toDerivedPaths(topLevelDrvs),
|
||||
state.ctx.repair ? bmRepair : bmNormal));
|
||||
state.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Switch the current user environment to the output path. */
|
||||
auto store2 = state.ctx.store.try_cast_shared<LocalFSStore>();
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
|
||||
if (store2) {
|
||||
PathLock lock = lockProfile(profile);
|
||||
PathLocks lock;
|
||||
lockProfile(lock, profile);
|
||||
|
||||
Path lockTokenCur = optimisticLockProfile(profile);
|
||||
if (lockToken != lockTokenCur) {
|
||||
@@ -140,7 +143,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
}
|
||||
|
||||
debug("switching to new user environment");
|
||||
Path generation = state.aio.blockOn(createGeneration(*store2, profile, topLevelOut));
|
||||
Path generation = createGeneration(*store2, profile, topLevelOut);
|
||||
switchLink(profile, generation);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
DrvInfos queryInstalled(EvalState & state, const Path & userEnv);
|
||||
|
||||
bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
const Path & profile, bool keepDerivations,
|
||||
const std::string & lockToken);
|
||||
|
||||
+34
-60
@@ -1,11 +1,10 @@
|
||||
#include "lix/libcmd/built-path.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/json.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
|
||||
#include <kj/async.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace nix {
|
||||
|
||||
@@ -81,68 +80,49 @@ SingleDerivedPath SingleBuiltPath::discardOutputPath() const
|
||||
);
|
||||
}
|
||||
|
||||
kj::Promise<Result<JSON>> BuiltPath::Built::toJSON(const Store & store) const
|
||||
try {
|
||||
JSON res;
|
||||
res["drvPath"] = TRY_AWAIT(drvPath->toJSON(store));
|
||||
nlohmann::json BuiltPath::Built::toJSON(const Store & store) const
|
||||
{
|
||||
nlohmann::json res;
|
||||
res["drvPath"] = drvPath->toJSON(store);
|
||||
for (const auto & [outputName, outputPath] : outputs) {
|
||||
res["outputs"][outputName] = store.printStorePath(outputPath);
|
||||
}
|
||||
co_return res;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
return res;
|
||||
}
|
||||
|
||||
kj::Promise<Result<JSON>> SingleBuiltPath::Built::toJSON(const Store & store) const
|
||||
try {
|
||||
JSON res;
|
||||
res["drvPath"] = TRY_AWAIT(drvPath->toJSON(store));
|
||||
nlohmann::json SingleBuiltPath::Built::toJSON(const Store & store) const
|
||||
{
|
||||
nlohmann::json res;
|
||||
res["drvPath"] = drvPath->toJSON(store);
|
||||
auto & [outputName, outputPath] = output;
|
||||
res["output"] = outputName;
|
||||
res["outputPath"] = store.printStorePath(outputPath);
|
||||
co_return res;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
return res;
|
||||
}
|
||||
|
||||
kj::Promise<Result<JSON>> SingleBuiltPath::toJSON(const Store & store) const
|
||||
try {
|
||||
co_return TRY_AWAIT(std::visit([&](const auto & buildable) {
|
||||
nlohmann::json SingleBuiltPath::toJSON(const Store & store) const
|
||||
{
|
||||
return std::visit([&](const auto & buildable) {
|
||||
return buildable.toJSON(store);
|
||||
}, raw()));
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}, raw());
|
||||
}
|
||||
|
||||
|
||||
kj::Promise<Result<JSON>> BuiltPath::toJSON(const Store & store) const
|
||||
try {
|
||||
co_return TRY_AWAIT(std::visit([&](const auto & buildable) {
|
||||
nlohmann::json BuiltPath::toJSON(const Store & store) const
|
||||
{
|
||||
return std::visit([&](const auto & buildable) {
|
||||
return buildable.toJSON(store);
|
||||
}, raw()));
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}, raw());
|
||||
}
|
||||
|
||||
kj::Promise<Result<RealisedPath::Set>> BuiltPath::toRealisedPaths(Store & store) const
|
||||
try {
|
||||
RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
|
||||
{
|
||||
RealisedPath::Set res;
|
||||
auto handlers = overloaded{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
|
||||
[&](const BuiltPath::Opaque & p) -> kj::Promise<Result<void>> {
|
||||
try {
|
||||
res.insert(p.path);
|
||||
return {result::success()};
|
||||
} catch (...) {
|
||||
return {result::current_exception()};
|
||||
}
|
||||
},
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
|
||||
[&](const BuiltPath::Built & p) -> kj::Promise<Result<void>> {
|
||||
try {
|
||||
auto drvHashes = TRY_AWAIT(
|
||||
staticOutputHashes(store, TRY_AWAIT(store.readDerivation(p.drvPath->outPath())))
|
||||
);
|
||||
std::visit(
|
||||
overloaded{
|
||||
[&](const BuiltPath::Opaque & p) { res.insert(p.path); },
|
||||
[&](const BuiltPath::Built & p) {
|
||||
auto drvHashes =
|
||||
staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
|
||||
for (auto& [outputName, outputPath] : p.outputs) {
|
||||
if (experimentalFeatureSettings.isEnabled(
|
||||
Xp::CaDerivations)) {
|
||||
@@ -151,8 +131,8 @@ try {
|
||||
throw Error(
|
||||
"the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)",
|
||||
store.printStorePath(p.drvPath->outPath()), outputName);
|
||||
auto thisRealisation = TRY_AWAIT(store.queryRealisation(
|
||||
DrvOutput{*drvOutput, outputName}));
|
||||
auto thisRealisation = store.queryRealisation(
|
||||
DrvOutput{*drvOutput, outputName});
|
||||
assert(thisRealisation); // We’ve built it, so we must
|
||||
// have the realisation
|
||||
res.insert(*thisRealisation);
|
||||
@@ -160,16 +140,10 @@ try {
|
||||
res.insert(outputPath);
|
||||
}
|
||||
}
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
TRY_AWAIT(std::visit(handlers, raw()));
|
||||
co_return res;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
raw());
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
///@file
|
||||
#include "lix/libstore/derived-path.hh"
|
||||
#include "lix/libstore/realisation.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
#include <kj/async.h>
|
||||
|
||||
namespace nix {
|
||||
|
||||
@@ -17,7 +15,7 @@ struct SingleBuiltPathBuilt {
|
||||
|
||||
std::string to_string(const Store & store) const;
|
||||
static SingleBuiltPathBuilt parse(const Store & store, std::string_view, std::string_view);
|
||||
kj::Promise<Result<JSON>> toJSON(const Store & store) const;
|
||||
nlohmann::json toJSON(const Store & store) const;
|
||||
|
||||
DECLARE_CMP(SingleBuiltPathBuilt);
|
||||
};
|
||||
@@ -45,7 +43,7 @@ struct SingleBuiltPath : built_path::detail::SingleBuiltPathRaw {
|
||||
SingleDerivedPath discardOutputPath() const;
|
||||
|
||||
static SingleBuiltPath parse(const Store & store, std::string_view);
|
||||
kj::Promise<Result<JSON>> toJSON(const Store & store) const;
|
||||
nlohmann::json toJSON(const Store & store) const;
|
||||
};
|
||||
|
||||
static inline ref<SingleBuiltPath> staticDrv(StorePath drvPath)
|
||||
@@ -64,7 +62,7 @@ struct BuiltPathBuilt {
|
||||
|
||||
std::string to_string(const Store & store) const;
|
||||
static BuiltPathBuilt parse(const Store & store, std::string_view, std::string_view);
|
||||
kj::Promise<Result<JSON>> toJSON(const Store & store) const;
|
||||
nlohmann::json toJSON(const Store & store) const;
|
||||
|
||||
DECLARE_CMP(BuiltPathBuilt);
|
||||
};
|
||||
@@ -92,9 +90,9 @@ struct BuiltPath : built_path::detail::BuiltPathRaw {
|
||||
}
|
||||
|
||||
StorePathSet outPaths() const;
|
||||
kj::Promise<Result<RealisedPath::Set>> toRealisedPaths(Store & store) const;
|
||||
RealisedPath::Set toRealisedPaths(Store & store) const;
|
||||
|
||||
kj::Promise<Result<JSON>> toJSON(const Store & store) const;
|
||||
nlohmann::json toJSON(const Store & store) const;
|
||||
};
|
||||
|
||||
typedef std::vector<BuiltPath> BuiltPaths;
|
||||
|
||||
+17
-20
@@ -3,7 +3,6 @@
|
||||
#include "lix/libcmd/cmd-profiles.hh"
|
||||
#include "lix/libcmd/built-path.hh"
|
||||
#include "lix/libstore/builtins/buildenv.hh"
|
||||
#include "lix/libutil/async-io.hh"
|
||||
#include "lix/libutil/logging.hh"
|
||||
#include "lix/libstore/names.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
@@ -22,7 +21,7 @@ DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
|
||||
if (pathExists(manifestFile)) {
|
||||
Value v;
|
||||
state.evalFile(CanonPath(manifestFile), v);
|
||||
Bindings & bindings(*state.ctx.mem.allocBindings(0));
|
||||
Bindings & bindings(*state.mem.allocBindings(0));
|
||||
getDerivations(state, v, "", bindings, elems, false);
|
||||
}
|
||||
return elems;
|
||||
@@ -111,7 +110,7 @@ ProfileManifest::ProfileManifest(EvalState & state, const Path & profile)
|
||||
auto manifestPath = profile + "/manifest.json";
|
||||
|
||||
if (pathExists(manifestPath)) {
|
||||
auto json = json::parse(readFile(manifestPath), "a profile manifest");
|
||||
auto json = nlohmann::json::parse(readFile(manifestPath));
|
||||
|
||||
auto version = json.value("version", 0);
|
||||
std::string sUrl;
|
||||
@@ -137,7 +136,7 @@ ProfileManifest::ProfileManifest(EvalState & state, const Path & profile)
|
||||
auto & e = elem.value();
|
||||
ProfileElement element;
|
||||
for (auto & p : e["storePaths"]) {
|
||||
element.storePaths.insert(state.ctx.store->parseStorePath((std::string) p));
|
||||
element.storePaths.insert(state.store->parseStorePath((std::string) p));
|
||||
}
|
||||
element.active = e["active"];
|
||||
if (e.contains("priority")) {
|
||||
@@ -163,14 +162,14 @@ ProfileManifest::ProfileManifest(EvalState & state, const Path & profile)
|
||||
}
|
||||
} else if (pathExists(profile + "/manifest.nix")) {
|
||||
// FIXME: needed because of pure mode; ugly.
|
||||
state.ctx.paths.allowPath(state.ctx.store->followLinksToStore(profile));
|
||||
state.ctx.paths.allowPath(state.ctx.store->followLinksToStore(profile + "/manifest.nix"));
|
||||
state.allowPath(state.store->followLinksToStore(profile));
|
||||
state.allowPath(state.store->followLinksToStore(profile + "/manifest.nix"));
|
||||
|
||||
auto drvInfos = queryInstalled(state, state.ctx.store->followLinksToStore(profile));
|
||||
auto drvInfos = queryInstalled(state, state.store->followLinksToStore(profile));
|
||||
|
||||
for (auto & drvInfo : drvInfos) {
|
||||
ProfileElement element;
|
||||
element.storePaths = {drvInfo.queryOutPath(state)};
|
||||
element.storePaths = {drvInfo.queryOutPath()};
|
||||
addElement(std::move(element));
|
||||
}
|
||||
}
|
||||
@@ -198,15 +197,15 @@ void ProfileManifest::addElement(ProfileElement element)
|
||||
addElement(finalName, std::move(element));
|
||||
}
|
||||
|
||||
JSON ProfileManifest::toJSON(Store & store) const
|
||||
nlohmann::json ProfileManifest::toJSON(Store & store) const
|
||||
{
|
||||
auto es = JSON::object();
|
||||
auto es = nlohmann::json::object();
|
||||
for (auto & [name, element] : elements) {
|
||||
auto paths = JSON::array();
|
||||
auto paths = nlohmann::json::array();
|
||||
for (auto & path : element.storePaths) {
|
||||
paths.push_back(store.printStorePath(path));
|
||||
}
|
||||
JSON obj;
|
||||
nlohmann::json obj;
|
||||
obj["storePaths"] = paths;
|
||||
obj["active"] = element.active;
|
||||
obj["priority"] = element.priority;
|
||||
@@ -218,14 +217,14 @@ JSON ProfileManifest::toJSON(Store & store) const
|
||||
}
|
||||
es[name] = obj;
|
||||
}
|
||||
JSON json;
|
||||
nlohmann::json json;
|
||||
json["version"] = 3;
|
||||
json["elements"] = es;
|
||||
return json;
|
||||
}
|
||||
|
||||
kj::Promise<Result<StorePath>> ProfileManifest::build(ref<Store> store)
|
||||
try {
|
||||
StorePath ProfileManifest::build(ref<Store> store)
|
||||
{
|
||||
auto tempDir = createTempDir();
|
||||
|
||||
StorePathSet references;
|
||||
@@ -267,12 +266,10 @@ try {
|
||||
};
|
||||
info.narSize = sink.s.size();
|
||||
|
||||
AsyncStringInputStream source(sink.s);
|
||||
TRY_AWAIT(store->addToStore(info, source));
|
||||
StringSource source(sink.s);
|
||||
store->addToStore(info, source);
|
||||
|
||||
co_return std::move(info.path);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
return std::move(info.path);
|
||||
}
|
||||
|
||||
void ProfileManifest::printDiff(
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
#include "lix/libexpr/flake/flakeref.hh"
|
||||
#include "lix/libexpr/get-drvs.hh"
|
||||
#include "lix/libutil/types.hh"
|
||||
#include "lix/libutil/json-fwd.hh"
|
||||
#include "lix/libutil/url.hh"
|
||||
#include "lix/libutil/url-name.hh"
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace nix
|
||||
{
|
||||
|
||||
@@ -59,9 +62,9 @@ struct ProfileManifest
|
||||
|
||||
ProfileManifest(EvalState & state, const Path & profile);
|
||||
|
||||
JSON toJSON(Store & store) const;
|
||||
nlohmann::json toJSON(Store & store) const;
|
||||
|
||||
kj::Promise<Result<StorePath>> build(ref<Store> store);
|
||||
StorePath build(ref<Store> store);
|
||||
|
||||
void addElement(std::string_view nameCandidate, ProfileElement element);
|
||||
void addElement(ProfileElement element);
|
||||
|
||||
+30
-39
@@ -2,34 +2,29 @@
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libstore/local-fs-store.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
#include "lix/libexpr/nixexpr.hh"
|
||||
#include "lix/libstore/profiles.hh"
|
||||
#include "lix/libcmd/repl.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
extern char * * environ __attribute__((weak));
|
||||
|
||||
namespace nix {
|
||||
|
||||
CommandRegistry::CommandMap * CommandRegistry::commands = nullptr;
|
||||
RegisterCommand::Commands * RegisterCommand::commands = nullptr;
|
||||
|
||||
nix::CommandMap CommandRegistry::getCommandsFor(const std::vector<std::string> & prefix)
|
||||
nix::Commands RegisterCommand::getCommandsFor(const std::vector<std::string> & prefix)
|
||||
{
|
||||
if (!CommandRegistry::commands) {
|
||||
CommandRegistry::commands = new CommandMap;
|
||||
}
|
||||
nix::CommandMap res;
|
||||
for (auto & [name, command] : *CommandRegistry::commands) {
|
||||
nix::Commands res;
|
||||
for (auto & [name, command] : *RegisterCommand::commands)
|
||||
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 (equal) {
|
||||
for (size_t i = 0; i < prefix.size(); ++i)
|
||||
if (name[i] != prefix[i]) equal = false;
|
||||
if (equal)
|
||||
res.insert_or_assign(name[prefix.size()], command);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -41,12 +36,12 @@ ref<Store> StoreCommand::getStore()
|
||||
{
|
||||
if (!_store)
|
||||
_store = createStore();
|
||||
return *_store;
|
||||
return ref<Store>(_store);
|
||||
}
|
||||
|
||||
ref<Store> StoreCommand::createStore()
|
||||
{
|
||||
return aio().blockOn(openStore());
|
||||
return openStore();
|
||||
}
|
||||
|
||||
void StoreCommand::run()
|
||||
@@ -73,7 +68,7 @@ CopyCommand::CopyCommand()
|
||||
|
||||
ref<Store> CopyCommand::createStore()
|
||||
{
|
||||
return srcUri.empty() ? StoreCommand::createStore() : aio().blockOn(openStore(srcUri));
|
||||
return srcUri.empty() ? StoreCommand::createStore() : openStore(srcUri);
|
||||
}
|
||||
|
||||
ref<Store> CopyCommand::getDstStore()
|
||||
@@ -81,7 +76,7 @@ ref<Store> CopyCommand::getDstStore()
|
||||
if (srcUri.empty() && dstUri.empty())
|
||||
throw UsageError("you must pass '--from' and/or '--to'");
|
||||
|
||||
return aio().blockOn(dstUri.empty() ? openStore() : openStore(dstUri));
|
||||
return dstUri.empty() ? openStore() : openStore(dstUri);
|
||||
}
|
||||
|
||||
EvalCommand::EvalCommand()
|
||||
@@ -103,21 +98,24 @@ EvalCommand::~EvalCommand()
|
||||
ref<Store> EvalCommand::getEvalStore()
|
||||
{
|
||||
if (!evalStore)
|
||||
evalStore = evalStoreUrl ? aio().blockOn(openStore(*evalStoreUrl)) : getStore();
|
||||
return *evalStore;
|
||||
evalStore = evalStoreUrl ? openStore(*evalStoreUrl) : getStore();
|
||||
return ref<Store>(evalStore);
|
||||
}
|
||||
|
||||
ref<eval_cache::CachingEvaluator> EvalCommand::getEvaluator()
|
||||
ref<eval_cache::CachingEvalState> EvalCommand::getEvalState()
|
||||
{
|
||||
if (!evalState) {
|
||||
evalState = std::allocate_shared<eval_cache::CachingEvaluator>(
|
||||
TraceableAllocator<EvalState>(), aio(), searchPath, getEvalStore(), getStore(),
|
||||
startReplOnEvalErrors ? AbstractNixRepl::runSimple : nullptr
|
||||
evalState = std::allocate_shared<eval_cache::CachingEvalState>(
|
||||
TraceableAllocator<EvalState>(), searchPath, getEvalStore(), getStore()
|
||||
);
|
||||
|
||||
evalState->repair = repair;
|
||||
|
||||
if (startReplOnEvalErrors) {
|
||||
evalState->debug = std::make_unique<DebugState>(&AbstractNixRepl::runSimple);
|
||||
};
|
||||
}
|
||||
return ref<eval_cache::CachingEvaluator>::unsafeFromPtr(evalState);
|
||||
return ref<eval_cache::CachingEvalState>(evalState);
|
||||
}
|
||||
|
||||
MixOperateOnOptions::MixOperateOnOptions()
|
||||
@@ -164,17 +162,10 @@ void BuiltPathsCommand::run(ref<Store> store, Installables && installables)
|
||||
if (installables.size())
|
||||
throw UsageError("'--all' does not expect arguments");
|
||||
// XXX: Only uses opaque paths, ignores all the realisations
|
||||
for (auto & p : aio().blockOn(store->queryAllValidPaths()))
|
||||
for (auto & p : store->queryAllValidPaths())
|
||||
paths.emplace_back(BuiltPath::Opaque{p});
|
||||
} else {
|
||||
paths = Installable::toBuiltPaths(
|
||||
*getEvaluator()->begin(aio()),
|
||||
getEvalStore(),
|
||||
store,
|
||||
realiseMode,
|
||||
operateOn,
|
||||
installables
|
||||
);
|
||||
paths = Installable::toBuiltPaths(getEvalStore(), store, realiseMode, operateOn, installables);
|
||||
if (recursive) {
|
||||
// XXX: This only computes the store path closure, ignoring
|
||||
// intermediate realisations
|
||||
@@ -183,7 +174,7 @@ void BuiltPathsCommand::run(ref<Store> store, Installables && installables)
|
||||
auto rootFromThis = root.outPaths();
|
||||
pathsRoots.insert(rootFromThis.begin(), rootFromThis.end());
|
||||
}
|
||||
aio().blockOn(store->computeFSClosure(pathsRoots, pathsClosure));
|
||||
store->computeFSClosure(pathsRoots, pathsClosure);
|
||||
for (auto & path : pathsClosure)
|
||||
paths.emplace_back(BuiltPath::Opaque{path});
|
||||
}
|
||||
@@ -204,7 +195,7 @@ void StorePathsCommand::run(ref<Store> store, BuiltPaths && paths)
|
||||
for (auto & p : builtPath.outPaths())
|
||||
storePaths.insert(p);
|
||||
|
||||
auto sorted = aio().blockOn(store->topoSortPaths(storePaths));
|
||||
auto sorted = store->topoSortPaths(storePaths);
|
||||
std::reverse(sorted.begin(), sorted.end());
|
||||
|
||||
run(store, std::move(sorted));
|
||||
@@ -232,11 +223,11 @@ MixProfile::MixProfile()
|
||||
void MixProfile::updateProfile(const StorePath & storePath)
|
||||
{
|
||||
if (!profile) return;
|
||||
auto store = getStore().try_cast_shared<LocalFSStore>();
|
||||
auto store = getStore().dynamic_pointer_cast<LocalFSStore>();
|
||||
if (!store) throw Error("'--profile' is not supported for this Nix store");
|
||||
auto profile2 = absPath(*profile);
|
||||
switchLink(profile2,
|
||||
aio().blockOn(createGeneration(*store, profile2, storePath)));
|
||||
createGeneration(*store, profile2, storePath));
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(const BuiltPaths & buildables)
|
||||
|
||||
+22
-58
@@ -7,7 +7,6 @@
|
||||
#include "lix/libcmd/common-eval-args.hh"
|
||||
#include "lix/libstore/path.hh"
|
||||
#include "lix/libexpr/flake/lockfile.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -46,7 +45,7 @@ struct StoreCommand : virtual Command
|
||||
virtual void run(ref<Store>) = 0;
|
||||
|
||||
private:
|
||||
std::optional<ref<Store>> _store;
|
||||
std::shared_ptr<Store> _store;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -78,12 +77,12 @@ struct EvalCommand : virtual StoreCommand, MixEvalArgs
|
||||
|
||||
ref<Store> getEvalStore();
|
||||
|
||||
virtual ref<eval_cache::CachingEvaluator> getEvaluator();
|
||||
ref<eval_cache::CachingEvalState> getEvalState();
|
||||
|
||||
private:
|
||||
std::optional<ref<Store>> evalStore;
|
||||
std::shared_ptr<Store> evalStore;
|
||||
|
||||
std::shared_ptr<eval_cache::CachingEvaluator> evalState;
|
||||
std::shared_ptr<eval_cache::CachingEvalState> evalState;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -115,13 +114,11 @@ struct SourceExprCommand : virtual Args, MixFlakeOptions
|
||||
|
||||
SourceExprCommand();
|
||||
|
||||
ref<eval_cache::CachingEvaluator> getEvaluator() override;
|
||||
|
||||
Installables parseInstallables(
|
||||
EvalState & state, ref<Store> store, std::vector<std::string> ss);
|
||||
ref<Store> store, std::vector<std::string> ss);
|
||||
|
||||
ref<Installable> parseInstallable(
|
||||
EvalState & state, ref<Store> store, const std::string & installable);
|
||||
ref<Store> store, const std::string & installable);
|
||||
|
||||
virtual Strings getDefaultFlakeAttrPaths();
|
||||
|
||||
@@ -130,7 +127,7 @@ struct SourceExprCommand : virtual Args, MixFlakeOptions
|
||||
/**
|
||||
* Complete an installable from the given prefix.
|
||||
*/
|
||||
void completeInstallable(EvalState & state, AddCompletions & completions, std::string_view prefix);
|
||||
void completeInstallable(AddCompletions & completions, std::string_view prefix);
|
||||
|
||||
/**
|
||||
* Convenience wrapper around the underlying function to make setting the
|
||||
@@ -262,60 +259,31 @@ struct StorePathCommand : public StorePathsCommand
|
||||
/**
|
||||
* A helper class for registering \ref Command commands globally.
|
||||
*/
|
||||
struct CommandRegistry
|
||||
struct RegisterCommand
|
||||
{
|
||||
using CommandMap = std::map<
|
||||
std::vector<std::string>,
|
||||
std::function<ref<Command>(AsyncIoRoot & aio)>
|
||||
>;
|
||||
static CommandMap * commands;
|
||||
typedef std::map<std::vector<std::string>, std::function<ref<Command>()>> Commands;
|
||||
static Commands * commands;
|
||||
|
||||
static void add(std::vector<std::string> && name,
|
||||
std::function<ref<Command>(AsyncIoRoot & aio)> command)
|
||||
RegisterCommand(std::vector<std::string> && name,
|
||||
std::function<ref<Command>()> command)
|
||||
{
|
||||
if (!commands) {
|
||||
commands = new CommandMap;
|
||||
}
|
||||
if (!commands) commands = new Commands;
|
||||
commands->emplace(name, command);
|
||||
}
|
||||
|
||||
static nix::CommandMap getCommandsFor(const std::vector<std::string> & prefix);
|
||||
};
|
||||
|
||||
template<typename Base>
|
||||
class MixAio : public Base
|
||||
{
|
||||
private:
|
||||
AsyncIoRoot & aio_;
|
||||
|
||||
public:
|
||||
template<typename... Args>
|
||||
MixAio(AsyncIoRoot & aio, Args &&... args)
|
||||
: Base(std::forward<Args>(args)...)
|
||||
, aio_(aio)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncIoRoot & aio() override
|
||||
{
|
||||
return aio_;
|
||||
}
|
||||
static nix::Commands getCommandsFor(const std::vector<std::string> & prefix);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static void registerCommand(const std::string & name)
|
||||
static RegisterCommand registerCommand(const std::string & name)
|
||||
{
|
||||
CommandRegistry::add({name}, [](AsyncIoRoot & aio) {
|
||||
return make_ref<MixAio<T>>(aio);
|
||||
});
|
||||
return RegisterCommand({name}, [](){ return make_ref<T>(); });
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void registerCommand2(std::vector<std::string> && name)
|
||||
static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
||||
{
|
||||
CommandRegistry::add(std::move(name), [](AsyncIoRoot & aio) {
|
||||
return make_ref<MixAio<T>>(aio);
|
||||
});
|
||||
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
||||
}
|
||||
|
||||
struct MixProfile : virtual StoreCommand
|
||||
@@ -356,28 +324,24 @@ struct MixEnvironment : virtual Args {
|
||||
|
||||
void completeFlakeInputPath(
|
||||
AddCompletions & completions,
|
||||
EvalState & evalState,
|
||||
ref<EvalState> evalState,
|
||||
const std::vector<FlakeRef> & flakeRefs,
|
||||
std::string_view prefix);
|
||||
|
||||
void completeFlakeRef(
|
||||
AsyncIoRoot & aio, AddCompletions & completions, ref<Store> store, std::string_view prefix
|
||||
);
|
||||
void completeFlakeRef(AddCompletions & completions, ref<Store> store, std::string_view prefix);
|
||||
|
||||
void completeFlakeRefWithFragment(
|
||||
AddCompletions & completions,
|
||||
EvalState & evalState,
|
||||
ref<eval_cache::CachingEvaluator> evaluator,
|
||||
ref<eval_cache::CachingEvalState> evalState,
|
||||
flake::LockFlags lockFlags,
|
||||
Strings attrPathPrefixes,
|
||||
const Strings & defaultFlakeAttrPaths,
|
||||
std::string_view prefix);
|
||||
|
||||
kj::Promise<Result<void>> printClosureDiff(
|
||||
void printClosureDiff(
|
||||
ref<Store> store,
|
||||
const StorePath & beforePath,
|
||||
const StorePath & afterPath,
|
||||
bool json,
|
||||
std::string_view indent);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
#include "lix/libexpr/flake/flakeref.hh"
|
||||
#include "lix/libstore/store-api.hh"
|
||||
#include "lix/libcmd/command.hh"
|
||||
#include "lix/libutil/async.hh"
|
||||
#include "lix/libutil/regex.hh"
|
||||
|
||||
#include <regex>
|
||||
|
||||
namespace nix {
|
||||
|
||||
static std::regex const identifierRegex = regex::parse("^[A-Za-z_][A-Za-z0-9_'-]*$");
|
||||
static std::regex const identifierRegex("^[A-Za-z_][A-Za-z0-9_'-]*$");
|
||||
static void warnInvalidNixIdentifier(const std::string & name)
|
||||
{
|
||||
std::smatch match;
|
||||
@@ -156,7 +154,7 @@ MixEvalArgs::MixEvalArgs()
|
||||
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
|
||||
}},
|
||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||
completeFlakeRef(aio(), completions, aio().blockOn(openStore()), prefix);
|
||||
completeFlakeRef(completions, openStore(), prefix);
|
||||
}}
|
||||
});
|
||||
|
||||
@@ -173,15 +171,13 @@ MixEvalArgs::MixEvalArgs()
|
||||
});
|
||||
}
|
||||
|
||||
Bindings * MixEvalArgs::getAutoArgs(Evaluator & state)
|
||||
Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
|
||||
{
|
||||
auto res = state.buildBindings(autoArgs.size());
|
||||
for (auto & i : autoArgs) {
|
||||
auto v = state.mem.allocValue();
|
||||
if (i.second[0] == 'E')
|
||||
state.evalLazily(
|
||||
state.parseExprFromString(i.second.substr(1), CanonPath::fromCwd()), *v
|
||||
);
|
||||
state.mkThunk_(*v, state.parseExprFromString(i.second.substr(1), CanonPath::fromCwd()));
|
||||
else
|
||||
v->mkString(((std::string_view) i.second).substr(1));
|
||||
res.insert(state.symbols.create(i.first), v);
|
||||
@@ -189,35 +185,30 @@ Bindings * MixEvalArgs::getAutoArgs(Evaluator & state)
|
||||
return res.finish();
|
||||
}
|
||||
|
||||
kj::Promise<Result<EvalPaths::PathResult<SourcePath, ThrownError>>>
|
||||
lookupFileArg(Evaluator & state, std::string_view fileArg)
|
||||
try {
|
||||
SourcePath lookupFileArg(EvalState & state, std::string_view fileArg)
|
||||
{
|
||||
if (EvalSettings::isPseudoUrl(fileArg)) {
|
||||
auto const url = EvalSettings::resolvePseudoUrl(fileArg);
|
||||
auto const downloaded = TRY_AWAIT(fetchers::downloadTarball(
|
||||
auto const downloaded = fetchers::downloadTarball(
|
||||
state.store,
|
||||
url,
|
||||
/* name */ "source",
|
||||
/* locked */ false
|
||||
));
|
||||
);
|
||||
StorePath const storePath = downloaded.tree.storePath;
|
||||
co_return SourcePath(CanonPath(state.store->toRealPath(storePath)));
|
||||
return CanonPath(state.store->toRealPath(storePath));
|
||||
} else if (fileArg.starts_with("flake:")) {
|
||||
experimentalFeatureSettings.require(Xp::Flakes);
|
||||
static constexpr size_t FLAKE_LEN = std::string_view("flake:").size();
|
||||
auto flakeRef = parseFlakeRef(std::string(fileArg.substr(FLAKE_LEN)), {}, true, false);
|
||||
auto storePath = TRY_AWAIT(TRY_AWAIT(flakeRef.resolve(state.store)).fetchTree(state.store))
|
||||
.first.storePath;
|
||||
co_return SourcePath(CanonPath(state.store->toRealPath(storePath)));
|
||||
} else if (fileArg.size() > 2 && fileArg.at(0) == '<' && fileArg.at(fileArg.size() - 1) == '>')
|
||||
{
|
||||
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first.storePath;
|
||||
return CanonPath(state.store->toRealPath(storePath));
|
||||
} else if (fileArg.size() > 2 && fileArg.at(0) == '<' && fileArg.at(fileArg.size() - 1) == '>') {
|
||||
Path p(fileArg.substr(1, fileArg.size() - 2));
|
||||
co_return TRY_AWAIT(state.paths.findFile(p));
|
||||
return state.findFile(p);
|
||||
} else {
|
||||
co_return SourcePath(CanonPath::fromCwd(fileArg));
|
||||
return CanonPath::fromCwd(fileArg);
|
||||
}
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "lix/libexpr/eval-error.hh"
|
||||
#include "lix/libexpr/eval.hh"
|
||||
#include "lix/libutil/args.hh"
|
||||
#include "lix/libmain/common-args.hh"
|
||||
#include "lix/libexpr/search-path.hh"
|
||||
@@ -20,7 +18,7 @@ struct MixEvalArgs : virtual Args, virtual MixRepair
|
||||
|
||||
MixEvalArgs();
|
||||
|
||||
Bindings * getAutoArgs(Evaluator & state);
|
||||
Bindings * getAutoArgs(EvalState & state);
|
||||
|
||||
SearchPath searchPath;
|
||||
|
||||
@@ -50,7 +48,6 @@ private:
|
||||
*
|
||||
* @exception nix::ThrownError for failed search path lookup. Probably others.
|
||||
*/
|
||||
kj::Promise<Result<EvalPaths::PathResult<SourcePath, ThrownError>>>
|
||||
lookupFileArg(Evaluator & state, std::string_view fileArg);
|
||||
SourcePath lookupFileArg(EvalState & state, std::string_view fileArg);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace nix {
|
||||
|
||||
Strings editorFor(const SourcePath & file, uint32_t line)
|
||||
{
|
||||
auto path = file.getPhysicalPath();
|
||||
if (!path)
|
||||
throw Error("cannot open '%s' in an editor because it has no physical path", file);
|
||||
auto editor = getEnv("EDITOR").value_or("cat");
|
||||
auto args = tokenizeString<Strings>(editor);
|
||||
if (line > 0 && (
|
||||
@@ -15,7 +18,7 @@ Strings editorFor(const SourcePath & file, uint32_t line)
|
||||
editor.find("vim") != std::string::npos ||
|
||||
editor.find("kak") != std::string::npos))
|
||||
args.push_back(fmt("+%d", line));
|
||||
args.push_back(file.canonical().abs());
|
||||
args.push_back(path->abs());
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
#include "lix/libexpr/get-drvs.hh"
|
||||
#include "lix/libexpr/flake/flake.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
InstallableAttrPath::InstallableAttrPath(
|
||||
ref<eval_cache::CachingEvaluator> state,
|
||||
ref<eval_cache::CachingEvalState> state,
|
||||
SourceExprCommand & cmd,
|
||||
Value * v,
|
||||
const std::string & attrPath,
|
||||
@@ -22,42 +24,43 @@ InstallableAttrPath::InstallableAttrPath(
|
||||
, extendedOutputsSpec(std::move(extendedOutputsSpec))
|
||||
{ }
|
||||
|
||||
std::pair<Value *, PosIdx> InstallableAttrPath::toValue(EvalState & state)
|
||||
std::pair<Value *, PosIdx> InstallableAttrPath::toValue()
|
||||
{
|
||||
auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(*evaluator), **v);
|
||||
state.forceValue(*vRes, pos);
|
||||
auto [vRes, pos] = findAlongAttrPath(*state, attrPath, *cmd.getAutoArgs(*state), **v);
|
||||
state->forceValue(*vRes, pos);
|
||||
return {vRes, pos};
|
||||
}
|
||||
|
||||
DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths(EvalState & state)
|
||||
DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths()
|
||||
{
|
||||
auto [v, pos] = toValue(state);
|
||||
auto [v, pos] = toValue();
|
||||
|
||||
if (std::optional derivedPathWithInfo = trySinglePathToDerivedPaths(
|
||||
state, *v, pos, fmt("while evaluating the attribute '%s'", attrPath)
|
||||
))
|
||||
*v,
|
||||
pos,
|
||||
fmt("while evaluating the attribute '%s'", attrPath)))
|
||||
{
|
||||
return { *derivedPathWithInfo };
|
||||
}
|
||||
|
||||
Bindings & autoArgs = *cmd.getAutoArgs(*evaluator);
|
||||
Bindings & autoArgs = *cmd.getAutoArgs(*state);
|
||||
|
||||
DrvInfos drvInfos;
|
||||
getDerivations(state, *v, "", autoArgs, drvInfos, false);
|
||||
getDerivations(*state, *v, "", autoArgs, drvInfos, false);
|
||||
|
||||
// Backward compatibility hack: group results by drvPath. This
|
||||
// helps keep .all output together.
|
||||
std::map<StorePath, OutputsSpec> byDrvPath;
|
||||
|
||||
for (auto & drvInfo : drvInfos) {
|
||||
auto drvPath = drvInfo.queryDrvPath(state);
|
||||
auto drvPath = drvInfo.queryDrvPath();
|
||||
if (!drvPath)
|
||||
throw Error("'%s' is not a derivation", what());
|
||||
|
||||
auto newOutputs = std::visit(overloaded {
|
||||
[&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
|
||||
std::set<std::string> outputsToInstall;
|
||||
for (auto & output : drvInfo.queryOutputs(state, false, true))
|
||||
for (auto & output : drvInfo.queryOutputs(false, true))
|
||||
outputsToInstall.insert(output.first);
|
||||
return OutputsSpec::Names { std::move(outputsToInstall) };
|
||||
},
|
||||
@@ -90,7 +93,7 @@ DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths(EvalState & state)
|
||||
}
|
||||
|
||||
InstallableAttrPath InstallableAttrPath::parse(
|
||||
ref<eval_cache::CachingEvaluator> state,
|
||||
ref<eval_cache::CachingEvalState> state,
|
||||
SourceExprCommand & cmd,
|
||||
Value * v,
|
||||
std::string_view prefix,
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "lix/libcmd/common-eval-args.hh"
|
||||
#include "lix/libexpr/eval.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
class InstallableAttrPath : public InstallableValue
|
||||
@@ -18,7 +20,7 @@ class InstallableAttrPath : public InstallableValue
|
||||
ExtendedOutputsSpec extendedOutputsSpec;
|
||||
|
||||
InstallableAttrPath(
|
||||
ref<eval_cache::CachingEvaluator> state,
|
||||
ref<eval_cache::CachingEvalState> state,
|
||||
SourceExprCommand & cmd,
|
||||
Value * v,
|
||||
const std::string & attrPath,
|
||||
@@ -26,14 +28,14 @@ class InstallableAttrPath : public InstallableValue
|
||||
|
||||
std::string what() const override { return attrPath; };
|
||||
|
||||
std::pair<Value *, PosIdx> toValue(EvalState & state) override;
|
||||
std::pair<Value *, PosIdx> toValue() override;
|
||||
|
||||
DerivedPathsWithInfo toDerivedPaths(EvalState & state) override;
|
||||
DerivedPathsWithInfo toDerivedPaths() override;
|
||||
|
||||
public:
|
||||
|
||||
static InstallableAttrPath parse(
|
||||
ref<eval_cache::CachingEvaluator> state,
|
||||
ref<eval_cache::CachingEvalState> state,
|
||||
SourceExprCommand & cmd,
|
||||
Value * v,
|
||||
std::string_view prefix,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user