Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e07e4b281 | ||
|
|
5d058d81f1 | ||
|
|
531cc6593a | ||
|
|
7568cbe344 | ||
|
|
357e095a7b | ||
|
|
007c4a7f3a | ||
|
|
188ed75d54 |
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
- Thanks for your contribution!
|
- Thanks for your contribution!
|
||||||
- To remove the stale label, just leave a new comment.
|
- To remove the stale label, just leave a new comment.
|
||||||
- _How to find the right people to ping?_ → [`git blame`](https://git-scm.com/docs/git-blame) to the rescue! (or GitHub's history and blame buttons.)
|
- _How to find the right people to ping?_ → [`git blame`](https://git-scm.com/docs/git-blame) to the rescue! (or GitHub's history and blame buttons.)
|
||||||
- You can always ask for help on [our Discourse Forum](https://discourse.nixos.org/) or on [Matrix - #nix:nixos.org](https://matrix.to/#/#nix:nixos.org).
|
- You can always ask for help on [our Discourse Forum](https://discourse.nixos.org/) or on the [#nixos IRC channel](https://webchat.freenode.net/#nixos).
|
||||||
|
|
||||||
## Suggestions for PRs
|
## Suggestions for PRs
|
||||||
|
|
||||||
|
|||||||
@@ -1,76 +1,17 @@
|
|||||||
name: "Test"
|
name: "Test"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
needs: [check_cachix]
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
timeout-minutes: 60
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2.3.5
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- uses: cachix/install-nix-action@v14.1
|
|
||||||
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
|
||||||
- uses: cachix/cachix-action@v10
|
|
||||||
if: needs.check_cachix.outputs.secret == 'true'
|
|
||||||
with:
|
|
||||||
name: '${{ env.CACHIX_NAME }}'
|
|
||||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
|
||||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
|
||||||
- run: nix-build -A checks.$(nix-instantiate --eval -E '(builtins.currentSystem)')
|
|
||||||
|
|
||||||
check_cachix:
|
|
||||||
name: Cachix secret present for installer tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
secret: ${{ steps.secret.outputs.secret }}
|
|
||||||
steps:
|
|
||||||
- name: Check for Cachix secret
|
|
||||||
id: secret
|
|
||||||
env:
|
|
||||||
_CACHIX_SECRETS: ${{ secrets.CACHIX_SIGNING_KEY }}${{ secrets.CACHIX_AUTH_TOKEN }}
|
|
||||||
run: echo "::set-output name=secret::${{ env._CACHIX_SECRETS != '' }}"
|
|
||||||
|
|
||||||
installer:
|
|
||||||
needs: [tests, check_cachix]
|
|
||||||
if: github.event_name == 'push' && needs.check_cachix.outputs.secret == 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
installerURL: ${{ steps.prepare-installer.outputs.installerURL }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2.3.5
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
|
||||||
- uses: cachix/install-nix-action@v14.1
|
|
||||||
- uses: cachix/cachix-action@v10
|
|
||||||
with:
|
|
||||||
name: '${{ env.CACHIX_NAME }}'
|
|
||||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
|
||||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
|
||||||
- id: prepare-installer
|
|
||||||
run: scripts/prepare-installer-for-github-actions
|
|
||||||
|
|
||||||
installer_test:
|
|
||||||
needs: [installer, check_cachix]
|
|
||||||
if: github.event_name == 'push' && needs.check_cachix.outputs.secret == 'true'
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.3.5
|
- uses: actions/checkout@v2
|
||||||
- run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
|
|
||||||
- uses: cachix/install-nix-action@v14.1
|
|
||||||
with:
|
with:
|
||||||
install_url: '${{needs.installer.outputs.installerURL}}'
|
fetch-depth: 0
|
||||||
install_options: "--tarball-url-prefix https://${{ env.CACHIX_NAME }}.cachix.org/serve"
|
- uses: cachix/install-nix-action@v12
|
||||||
- run: nix-instantiate -E 'builtins.currentTime' --eval
|
#- run: nix flake check
|
||||||
|
- run: nix-build -A checks.$(if [[ `uname` = Linux ]]; then echo x86_64-linux; else echo x86_64-darwin; fi)
|
||||||
+4
-3
@@ -15,7 +15,6 @@ perl/Makefile.config
|
|||||||
/doc/manual/*.1
|
/doc/manual/*.1
|
||||||
/doc/manual/*.5
|
/doc/manual/*.5
|
||||||
/doc/manual/*.8
|
/doc/manual/*.8
|
||||||
/doc/manual/generated/*
|
|
||||||
/doc/manual/nix.json
|
/doc/manual/nix.json
|
||||||
/doc/manual/conf-file.json
|
/doc/manual/conf-file.json
|
||||||
/doc/manual/builtins.json
|
/doc/manual/builtins.json
|
||||||
@@ -40,7 +39,6 @@ perl/Makefile.config
|
|||||||
|
|
||||||
# /src/libstore/
|
# /src/libstore/
|
||||||
*.gen.*
|
*.gen.*
|
||||||
/src/libstore/tests/libstore-tests
|
|
||||||
|
|
||||||
# /src/libutil/
|
# /src/libutil/
|
||||||
/src/libutil/tests/libutil-tests
|
/src/libutil/tests/libutil-tests
|
||||||
@@ -58,6 +56,9 @@ perl/Makefile.config
|
|||||||
|
|
||||||
/src/nix-prefetch-url/nix-prefetch-url
|
/src/nix-prefetch-url/nix-prefetch-url
|
||||||
|
|
||||||
|
# /src/nix-daemon/
|
||||||
|
/src/nix-daemon/nix-daemon
|
||||||
|
|
||||||
/src/nix-collect-garbage/nix-collect-garbage
|
/src/nix-collect-garbage/nix-collect-garbage
|
||||||
|
|
||||||
# /src/nix-channel/
|
# /src/nix-channel/
|
||||||
@@ -75,12 +76,12 @@ perl/Makefile.config
|
|||||||
# /tests/
|
# /tests/
|
||||||
/tests/test-tmp
|
/tests/test-tmp
|
||||||
/tests/common.sh
|
/tests/common.sh
|
||||||
|
/tests/dummy
|
||||||
/tests/result*
|
/tests/result*
|
||||||
/tests/restricted-innocent
|
/tests/restricted-innocent
|
||||||
/tests/shell
|
/tests/shell
|
||||||
/tests/shell.drv
|
/tests/shell.drv
|
||||||
/tests/config.nix
|
/tests/config.nix
|
||||||
/tests/ca/config.nix
|
|
||||||
|
|
||||||
# /tests/lang/
|
# /tests/lang/
|
||||||
/tests/lang/*.out
|
/tests/lang/*.out
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ makefiles = \
|
|||||||
src/libutil/local.mk \
|
src/libutil/local.mk \
|
||||||
src/libutil/tests/local.mk \
|
src/libutil/tests/local.mk \
|
||||||
src/libstore/local.mk \
|
src/libstore/local.mk \
|
||||||
src/libstore/tests/local.mk \
|
|
||||||
src/libfetchers/local.mk \
|
src/libfetchers/local.mk \
|
||||||
src/libmain/local.mk \
|
src/libmain/local.mk \
|
||||||
src/libexpr/local.mk \
|
src/libexpr/local.mk \
|
||||||
@@ -13,8 +12,6 @@ makefiles = \
|
|||||||
src/resolve-system-dependencies/local.mk \
|
src/resolve-system-dependencies/local.mk \
|
||||||
scripts/local.mk \
|
scripts/local.mk \
|
||||||
misc/bash/local.mk \
|
misc/bash/local.mk \
|
||||||
misc/fish/local.mk \
|
|
||||||
misc/zsh/local.mk \
|
|
||||||
misc/systemd/local.mk \
|
misc/systemd/local.mk \
|
||||||
misc/launchd/local.mk \
|
misc/launchd/local.mk \
|
||||||
misc/upstart/local.mk \
|
misc/upstart/local.mk \
|
||||||
@@ -34,4 +31,4 @@ endif
|
|||||||
|
|
||||||
include mk/lib.mk
|
include mk/lib.mk
|
||||||
|
|
||||||
GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++17 -I src
|
GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++17
|
||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
HOST_OS = @host_os@
|
|
||||||
AR = @AR@
|
AR = @AR@
|
||||||
BDW_GC_LIBS = @BDW_GC_LIBS@
|
BDW_GC_LIBS = @BDW_GC_LIBS@
|
||||||
BOOST_LDFLAGS = @BOOST_LDFLAGS@
|
BOOST_LDFLAGS = @BOOST_LDFLAGS@
|
||||||
@@ -10,14 +9,13 @@ CXXFLAGS = @CXXFLAGS@
|
|||||||
EDITLINE_LIBS = @EDITLINE_LIBS@
|
EDITLINE_LIBS = @EDITLINE_LIBS@
|
||||||
ENABLE_S3 = @ENABLE_S3@
|
ENABLE_S3 = @ENABLE_S3@
|
||||||
GTEST_LIBS = @GTEST_LIBS@
|
GTEST_LIBS = @GTEST_LIBS@
|
||||||
HAVE_LIBCPUID = @HAVE_LIBCPUID@
|
|
||||||
HAVE_SECCOMP = @HAVE_SECCOMP@
|
HAVE_SECCOMP = @HAVE_SECCOMP@
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBARCHIVE_LIBS = @LIBARCHIVE_LIBS@
|
LIBARCHIVE_LIBS = @LIBARCHIVE_LIBS@
|
||||||
LIBBROTLI_LIBS = @LIBBROTLI_LIBS@
|
LIBBROTLI_LIBS = @LIBBROTLI_LIBS@
|
||||||
LIBCURL_LIBS = @LIBCURL_LIBS@
|
LIBCURL_LIBS = @LIBCURL_LIBS@
|
||||||
|
LIBLZMA_LIBS = @LIBLZMA_LIBS@
|
||||||
OPENSSL_LIBS = @OPENSSL_LIBS@
|
OPENSSL_LIBS = @OPENSSL_LIBS@
|
||||||
LIBSECCOMP_LIBS = @LIBSECCOMP_LIBS@
|
|
||||||
PACKAGE_NAME = @PACKAGE_NAME@
|
PACKAGE_NAME = @PACKAGE_NAME@
|
||||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
SHELL = @bash@
|
SHELL = @bash@
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ build nix from source with nix-build or how to get a development environment.
|
|||||||
- [Nix manual](https://nixos.org/nix/manual)
|
- [Nix manual](https://nixos.org/nix/manual)
|
||||||
- [Nix jobsets on hydra.nixos.org](https://hydra.nixos.org/project/nix)
|
- [Nix jobsets on hydra.nixos.org](https://hydra.nixos.org/project/nix)
|
||||||
- [NixOS Discourse](https://discourse.nixos.org/)
|
- [NixOS Discourse](https://discourse.nixos.org/)
|
||||||
- [Matrix - #nix:nixos.org](https://matrix.to/#/#nix:nixos.org)
|
- [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
||||||
- [IRC - #nixos on libera.chat](irc://irc.libera.chat/#nixos)
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
|
|
||||||
index 4b2c429..1fb4c52 100644
|
|
||||||
--- a/pthread_stop_world.c
|
|
||||||
+++ b/pthread_stop_world.c
|
|
||||||
@@ -673,6 +673,8 @@ GC_INNER void GC_push_all_stacks(void)
|
|
||||||
struct GC_traced_stack_sect_s *traced_stack_sect;
|
|
||||||
pthread_t self = pthread_self();
|
|
||||||
word total_size = 0;
|
|
||||||
+ size_t stack_limit;
|
|
||||||
+ pthread_attr_t pattr;
|
|
||||||
|
|
||||||
if (!EXPECT(GC_thr_initialized, TRUE))
|
|
||||||
GC_thr_init();
|
|
||||||
@@ -722,6 +724,31 @@ GC_INNER void GC_push_all_stacks(void)
|
|
||||||
hi = p->altstack + p->altstack_size;
|
|
||||||
/* FIXME: Need to scan the normal stack too, but how ? */
|
|
||||||
/* FIXME: Assume stack grows down */
|
|
||||||
+ } else {
|
|
||||||
+ if (pthread_getattr_np(p->id, &pattr)) {
|
|
||||||
+ ABORT("GC_push_all_stacks: pthread_getattr_np failed!");
|
|
||||||
+ }
|
|
||||||
+ if (pthread_attr_getstacksize(&pattr, &stack_limit)) {
|
|
||||||
+ ABORT("GC_push_all_stacks: pthread_attr_getstacksize failed!");
|
|
||||||
+ }
|
|
||||||
+ if (pthread_attr_destroy(&pattr)) {
|
|
||||||
+ ABORT("GC_push_all_stacks: pthread_attr_destroy failed!");
|
|
||||||
+ }
|
|
||||||
+ // When a thread goes into a coroutine, we lose its original sp until
|
|
||||||
+ // control flow returns to the thread.
|
|
||||||
+ // While in the coroutine, the sp points outside the thread stack,
|
|
||||||
+ // so we can detect this and push the entire thread stack instead,
|
|
||||||
+ // as an approximation.
|
|
||||||
+ // We assume that the coroutine has similarly added its entire stack.
|
|
||||||
+ // This could be made accurate by cooperating with the application
|
|
||||||
+ // via new functions and/or callbacks.
|
|
||||||
+ #ifndef STACK_GROWS_UP
|
|
||||||
+ if (lo >= hi || lo < hi - stack_limit) { // sp outside stack
|
|
||||||
+ lo = hi - stack_limit;
|
|
||||||
+ }
|
|
||||||
+ #else
|
|
||||||
+ #error "STACK_GROWS_UP not supported in boost_coroutine2 (as of june 2021), so we don't support it in Nix."
|
|
||||||
+ #endif
|
|
||||||
}
|
|
||||||
GC_push_all_stack_sections(lo, hi, traced_stack_sect);
|
|
||||||
# ifdef STACK_GROWS_UP
|
|
||||||
Vendored
+9
-11
@@ -1,8 +1,8 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Attempt to guess a canonical system name.
|
# Attempt to guess a canonical system name.
|
||||||
# Copyright 1992-2021 Free Software Foundation, Inc.
|
# Copyright 1992-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
timestamp='2021-01-25'
|
timestamp='2020-11-19'
|
||||||
|
|
||||||
# This file is free software; you can redistribute it and/or modify it
|
# This file is free software; you can redistribute it and/or modify it
|
||||||
# under the terms of the GNU General Public License as published by
|
# under the terms of the GNU General Public License as published by
|
||||||
@@ -50,7 +50,7 @@ version="\
|
|||||||
GNU config.guess ($timestamp)
|
GNU config.guess ($timestamp)
|
||||||
|
|
||||||
Originally written by Per Bothner.
|
Originally written by Per Bothner.
|
||||||
Copyright 1992-2021 Free Software Foundation, Inc.
|
Copyright 1992-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This is free software; see the source for copying conditions. There is NO
|
This is free software; see the source for copying conditions. There is NO
|
||||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||||
@@ -188,9 +188,10 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
|
|||||||
#
|
#
|
||||||
# Note: NetBSD doesn't particularly care about the vendor
|
# Note: NetBSD doesn't particularly care about the vendor
|
||||||
# portion of the name. We always set it to "unknown".
|
# portion of the name. We always set it to "unknown".
|
||||||
|
sysctl="sysctl -n hw.machine_arch"
|
||||||
UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \
|
UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \
|
||||||
/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
|
"/sbin/$sysctl" 2>/dev/null || \
|
||||||
/usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
|
"/usr/sbin/$sysctl" 2>/dev/null || \
|
||||||
echo unknown))
|
echo unknown))
|
||||||
case "$UNAME_MACHINE_ARCH" in
|
case "$UNAME_MACHINE_ARCH" in
|
||||||
aarch64eb) machine=aarch64_be-unknown ;;
|
aarch64eb) machine=aarch64_be-unknown ;;
|
||||||
@@ -995,9 +996,6 @@ EOF
|
|||||||
k1om:Linux:*:*)
|
k1om:Linux:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||||
exit ;;
|
exit ;;
|
||||||
loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
|
|
||||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
|
||||||
exit ;;
|
|
||||||
m32r*:Linux:*:*)
|
m32r*:Linux:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||||
exit ;;
|
exit ;;
|
||||||
@@ -1086,7 +1084,7 @@ EOF
|
|||||||
ppcle:Linux:*:*)
|
ppcle:Linux:*:*)
|
||||||
echo powerpcle-unknown-linux-"$LIBC"
|
echo powerpcle-unknown-linux-"$LIBC"
|
||||||
exit ;;
|
exit ;;
|
||||||
riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
|
riscv32:Linux:*:* | riscv64:Linux:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||||
exit ;;
|
exit ;;
|
||||||
s390:Linux:*:* | s390x:Linux:*:*)
|
s390:Linux:*:* | s390x:Linux:*:*)
|
||||||
@@ -1482,8 +1480,8 @@ EOF
|
|||||||
i*86:rdos:*:*)
|
i*86:rdos:*:*)
|
||||||
echo "$UNAME_MACHINE"-pc-rdos
|
echo "$UNAME_MACHINE"-pc-rdos
|
||||||
exit ;;
|
exit ;;
|
||||||
*:AROS:*:*)
|
i*86:AROS:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-aros
|
echo "$UNAME_MACHINE"-pc-aros
|
||||||
exit ;;
|
exit ;;
|
||||||
x86_64:VMkernel:*:*)
|
x86_64:VMkernel:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-esx
|
echo "$UNAME_MACHINE"-unknown-esx
|
||||||
|
|||||||
Vendored
+7
-13
@@ -1,8 +1,8 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Configuration validation subroutine script.
|
# Configuration validation subroutine script.
|
||||||
# Copyright 1992-2021 Free Software Foundation, Inc.
|
# Copyright 1992-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
timestamp='2021-01-08'
|
timestamp='2020-12-02'
|
||||||
|
|
||||||
# This file is free software; you can redistribute it and/or modify it
|
# This file is free software; you can redistribute it and/or modify it
|
||||||
# under the terms of the GNU General Public License as published by
|
# under the terms of the GNU General Public License as published by
|
||||||
@@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
|||||||
version="\
|
version="\
|
||||||
GNU config.sub ($timestamp)
|
GNU config.sub ($timestamp)
|
||||||
|
|
||||||
Copyright 1992-2021 Free Software Foundation, Inc.
|
Copyright 1992-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This is free software; see the source for copying conditions. There is NO
|
This is free software; see the source for copying conditions. There is NO
|
||||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||||
@@ -1185,7 +1185,6 @@ case $cpu-$vendor in
|
|||||||
| k1om \
|
| k1om \
|
||||||
| le32 | le64 \
|
| le32 | le64 \
|
||||||
| lm32 \
|
| lm32 \
|
||||||
| loongarch32 | loongarch64 | loongarchx32 \
|
|
||||||
| m32c | m32r | m32rle \
|
| m32c | m32r | m32rle \
|
||||||
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
|
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
|
||||||
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
|
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
|
||||||
@@ -1230,7 +1229,7 @@ case $cpu-$vendor in
|
|||||||
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
|
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
|
||||||
| pru \
|
| pru \
|
||||||
| pyramid \
|
| pyramid \
|
||||||
| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
|
| riscv | riscv32 | riscv64 \
|
||||||
| rl78 | romp | rs6000 | rx \
|
| rl78 | romp | rs6000 | rx \
|
||||||
| s390 | s390x \
|
| s390 | s390x \
|
||||||
| score \
|
| score \
|
||||||
@@ -1683,14 +1682,11 @@ fi
|
|||||||
|
|
||||||
# Now, validate our (potentially fixed-up) OS.
|
# Now, validate our (potentially fixed-up) OS.
|
||||||
case $os in
|
case $os in
|
||||||
# Sometimes we do "kernel-libc", so those need to count as OSes.
|
# Sometimes we do "kernel-abi", so those need to count as OSes.
|
||||||
musl* | newlib* | uclibc*)
|
musl* | newlib* | uclibc*)
|
||||||
;;
|
;;
|
||||||
# Likewise for "kernel-abi"
|
# Likewise for "kernel-libc"
|
||||||
eabi* | gnueabi*)
|
eabi | eabihf | gnueabi | gnueabihf)
|
||||||
;;
|
|
||||||
# VxWorks passes extra cpu info in the 4th filed.
|
|
||||||
simlinux | simwindows | spe)
|
|
||||||
;;
|
;;
|
||||||
# Now accept the basic system types.
|
# Now accept the basic system types.
|
||||||
# The portable systems comes first.
|
# The portable systems comes first.
|
||||||
@@ -1754,8 +1750,6 @@ case $kernel-$os in
|
|||||||
;;
|
;;
|
||||||
kfreebsd*-gnu* | kopensolaris*-gnu*)
|
kfreebsd*-gnu* | kopensolaris*-gnu*)
|
||||||
;;
|
;;
|
||||||
vxworks-simlinux | vxworks-simwindows | vxworks-spe)
|
|
||||||
;;
|
|
||||||
nto-qnx*)
|
nto-qnx*)
|
||||||
;;
|
;;
|
||||||
os2-emx)
|
os2-emx)
|
||||||
|
|||||||
+71
-47
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT([nix],[m4_esyscmd(bash -c "echo -n $(cat ./.version)$VERSION_SUFFIX")])
|
AC_INIT(nix, m4_esyscmd([bash -c "echo -n $(cat ./.version)$VERSION_SUFFIX"]))
|
||||||
AC_CONFIG_MACRO_DIRS([m4])
|
AC_CONFIG_MACRO_DIRS([m4])
|
||||||
AC_CONFIG_SRCDIR(README.md)
|
AC_CONFIG_SRCDIR(README.md)
|
||||||
AC_CONFIG_AUX_DIR(config)
|
AC_CONFIG_AUX_DIR(config)
|
||||||
@@ -9,7 +9,8 @@ AC_PROG_SED
|
|||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
AC_MSG_CHECKING([for the canonical Nix system name])
|
AC_MSG_CHECKING([for the canonical Nix system name])
|
||||||
|
|
||||||
AC_ARG_WITH(system, AS_HELP_STRING([--with-system=SYSTEM],[Platform identifier (e.g., `i686-linux').]),
|
AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
|
||||||
|
[Platform identifier (e.g., `i686-linux').]),
|
||||||
[system=$withval],
|
[system=$withval],
|
||||||
[case "$host_cpu" in
|
[case "$host_cpu" in
|
||||||
i*86)
|
i*86)
|
||||||
@@ -32,6 +33,14 @@ AC_ARG_WITH(system, AS_HELP_STRING([--with-system=SYSTEM],[Platform identifier (
|
|||||||
system="$machine_name-`echo $host_os | "$SED" -e's/@<:@0-9.@:>@*$//g'`";;
|
system="$machine_name-`echo $host_os | "$SED" -e's/@<:@0-9.@:>@*$//g'`";;
|
||||||
esac])
|
esac])
|
||||||
|
|
||||||
|
sys_name=$(uname -s | tr 'A-Z ' 'a-z_')
|
||||||
|
|
||||||
|
case $sys_name in
|
||||||
|
cygwin*)
|
||||||
|
sys_name=cygwin
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
AC_MSG_RESULT($system)
|
AC_MSG_RESULT($system)
|
||||||
AC_SUBST(system)
|
AC_SUBST(system)
|
||||||
AC_DEFINE_UNQUOTED(SYSTEM, ["$system"], [platform identifier ('cpu-os')])
|
AC_DEFINE_UNQUOTED(SYSTEM, ["$system"], [platform identifier ('cpu-os')])
|
||||||
@@ -55,12 +64,10 @@ AC_SYS_LARGEFILE
|
|||||||
|
|
||||||
# Solaris-specific stuff.
|
# Solaris-specific stuff.
|
||||||
AC_STRUCT_DIRENT_D_TYPE
|
AC_STRUCT_DIRENT_D_TYPE
|
||||||
case "$host_os" in
|
if test "$sys_name" = sunos; then
|
||||||
solaris*)
|
|
||||||
# Solaris requires -lsocket -lnsl for network functions
|
# Solaris requires -lsocket -lnsl for network functions
|
||||||
LDFLAGS="-lsocket -lnsl $LDFLAGS"
|
LIBS="-lsocket -lnsl $LIBS"
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
# Check for pubsetbuf.
|
# Check for pubsetbuf.
|
||||||
@@ -120,7 +127,8 @@ NEED_PROG(jq, jq)
|
|||||||
AC_SUBST(coreutils, [$(dirname $(type -p cat))])
|
AC_SUBST(coreutils, [$(dirname $(type -p cat))])
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_WITH(store-dir, AS_HELP_STRING([--with-store-dir=PATH],[path of the Nix store (defaults to /nix/store)]),
|
AC_ARG_WITH(store-dir, AC_HELP_STRING([--with-store-dir=PATH],
|
||||||
|
[path of the Nix store (defaults to /nix/store)]),
|
||||||
storedir=$withval, storedir='/nix/store')
|
storedir=$withval, storedir='/nix/store')
|
||||||
AC_SUBST(storedir)
|
AC_SUBST(storedir)
|
||||||
|
|
||||||
@@ -144,12 +152,13 @@ int main() {
|
|||||||
}]])], GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=no, GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=yes)
|
}]])], GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=no, GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=yes)
|
||||||
AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC)
|
AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC)
|
||||||
if test "x$GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC" = xyes; then
|
if test "x$GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC" = xyes; then
|
||||||
LDFLAGS="-latomic $LDFLAGS"
|
LIBS="-latomic $LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
AC_ARG_ENABLE(shared, AS_HELP_STRING([--enable-shared],[Build shared libraries for Nix [default=yes]]),
|
AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared],
|
||||||
|
[Build shared libraries for Nix [default=yes]]),
|
||||||
shared=$enableval, shared=yes)
|
shared=$enableval, shared=yes)
|
||||||
if test "$shared" = yes; then
|
if test "$shared" = yes; then
|
||||||
AC_SUBST(BUILD_SHARED_LIBS, 1, [Whether to build shared libraries.])
|
AC_SUBST(BUILD_SHARED_LIBS, 1, [Whether to build shared libraries.])
|
||||||
@@ -163,6 +172,11 @@ fi
|
|||||||
PKG_CHECK_MODULES([OPENSSL], [libcrypto], [CXXFLAGS="$OPENSSL_CFLAGS $CXXFLAGS"])
|
PKG_CHECK_MODULES([OPENSSL], [libcrypto], [CXXFLAGS="$OPENSSL_CFLAGS $CXXFLAGS"])
|
||||||
|
|
||||||
|
|
||||||
|
# Look for libbz2, a required dependency.
|
||||||
|
AC_CHECK_LIB([bz2], [BZ2_bzWriteOpen], [true],
|
||||||
|
[AC_MSG_ERROR([Nix requires libbz2, which is part of bzip2. See https://sourceware.org/bzip2/.])])
|
||||||
|
AC_CHECK_HEADERS([bzlib.h], [true],
|
||||||
|
[AC_MSG_ERROR([Nix requires libbz2, which is part of bzip2. See https://sourceware.org/bzip2/.])])
|
||||||
# Checks for libarchive
|
# Checks for libarchive
|
||||||
PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.1.2], [CXXFLAGS="$LIBARCHIVE_CFLAGS $CXXFLAGS"])
|
PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.1.2], [CXXFLAGS="$LIBARCHIVE_CFLAGS $CXXFLAGS"])
|
||||||
# Workaround until https://github.com/libarchive/libarchive/issues/1446 is fixed
|
# Workaround until https://github.com/libarchive/libarchive/issues/1446 is fixed
|
||||||
@@ -191,45 +205,45 @@ PKG_CHECK_MODULES([EDITLINE], [libeditline], [CXXFLAGS="$EDITLINE_CFLAGS $CXXFLA
|
|||||||
# Look for libsodium, an optional dependency.
|
# Look for libsodium, an optional dependency.
|
||||||
PKG_CHECK_MODULES([SODIUM], [libsodium], [CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"])
|
PKG_CHECK_MODULES([SODIUM], [libsodium], [CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"])
|
||||||
|
|
||||||
|
# Look for liblzma, a required dependency.
|
||||||
|
PKG_CHECK_MODULES([LIBLZMA], [liblzma], [CXXFLAGS="$LIBLZMA_CFLAGS $CXXFLAGS"])
|
||||||
|
AC_CHECK_LIB([lzma], [lzma_stream_encoder_mt],
|
||||||
|
[AC_DEFINE([HAVE_LZMA_MT], [1], [xz multithreaded compression support])])
|
||||||
|
|
||||||
|
# Look for zlib, a required dependency.
|
||||||
|
PKG_CHECK_MODULES([ZLIB], [zlib], [CXXFLAGS="$ZLIB_CFLAGS $CXXFLAGS"])
|
||||||
|
AC_CHECK_HEADER([zlib.h],[:],[AC_MSG_ERROR([could not find the zlib.h header])])
|
||||||
|
LDFLAGS="-lz $LDFLAGS"
|
||||||
|
|
||||||
# Look for libbrotli{enc,dec}.
|
# Look for libbrotli{enc,dec}.
|
||||||
PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec], [CXXFLAGS="$LIBBROTLI_CFLAGS $CXXFLAGS"])
|
PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec], [CXXFLAGS="$LIBBROTLI_CFLAGS $CXXFLAGS"])
|
||||||
|
|
||||||
# Look for libcpuid.
|
|
||||||
if test "$machine_name" = "x86_64"; then
|
|
||||||
PKG_CHECK_MODULES([LIBCPUID], [libcpuid], [CXXFLAGS="$LIBCPUID_CFLAGS $CXXFLAGS"])
|
|
||||||
have_libcpuid=1
|
|
||||||
AC_DEFINE([HAVE_LIBCPUID], [1], [Use libcpuid])
|
|
||||||
fi
|
|
||||||
AC_SUBST(HAVE_LIBCPUID, [$have_libcpuid])
|
|
||||||
|
|
||||||
|
|
||||||
# Look for libseccomp, required for Linux sandboxing.
|
# Look for libseccomp, required for Linux sandboxing.
|
||||||
case "$host_os" in
|
if test "$sys_name" = linux; then
|
||||||
linux*)
|
AC_ARG_ENABLE([seccomp-sandboxing],
|
||||||
AC_ARG_ENABLE([seccomp-sandboxing],
|
AC_HELP_STRING([--disable-seccomp-sandboxing],
|
||||||
AS_HELP_STRING([--disable-seccomp-sandboxing],[Don't build support for seccomp sandboxing (only recommended if your arch doesn't support libseccomp yet!)
|
[Don't build support for seccomp sandboxing (only recommended if your arch doesn't support libseccomp yet!)]
|
||||||
]))
|
))
|
||||||
if test "x$enable_seccomp_sandboxing" != "xno"; then
|
if test "x$enable_seccomp_sandboxing" != "xno"; then
|
||||||
PKG_CHECK_MODULES([LIBSECCOMP], [libseccomp],
|
PKG_CHECK_MODULES([LIBSECCOMP], [libseccomp],
|
||||||
[CXXFLAGS="$LIBSECCOMP_CFLAGS $CXXFLAGS"])
|
[CXXFLAGS="$LIBSECCOMP_CFLAGS $CXXFLAGS"])
|
||||||
have_seccomp=1
|
have_seccomp=1
|
||||||
AC_DEFINE([HAVE_SECCOMP], [1], [Whether seccomp is available and should be used for sandboxing.])
|
AC_DEFINE([HAVE_SECCOMP], [1], [Whether seccomp is available and should be used for sandboxing.])
|
||||||
else
|
else
|
||||||
have_seccomp=
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
have_seccomp=
|
have_seccomp=
|
||||||
;;
|
fi
|
||||||
esac
|
else
|
||||||
|
have_seccomp=
|
||||||
|
fi
|
||||||
AC_SUBST(HAVE_SECCOMP, [$have_seccomp])
|
AC_SUBST(HAVE_SECCOMP, [$have_seccomp])
|
||||||
|
|
||||||
|
|
||||||
# Look for aws-cpp-sdk-s3.
|
# Look for aws-cpp-sdk-s3.
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
AC_CHECK_HEADERS([aws/s3/S3Client.h],
|
AC_CHECK_HEADERS([aws/s3/S3Client.h],
|
||||||
[AC_DEFINE([ENABLE_S3], [1], [Whether to enable S3 support via aws-sdk-cpp.]) enable_s3=1],
|
[AC_DEFINE([ENABLE_S3], [1], [Whether to enable S3 support via aws-sdk-cpp.])
|
||||||
[AC_DEFINE([ENABLE_S3], [0], [Whether to enable S3 support via aws-sdk-cpp.]) enable_s3=])
|
enable_s3=1], [enable_s3=])
|
||||||
AC_SUBST(ENABLE_S3, [$enable_s3])
|
AC_SUBST(ENABLE_S3, [$enable_s3])
|
||||||
AC_LANG_POP(C++)
|
AC_LANG_POP(C++)
|
||||||
|
|
||||||
@@ -242,7 +256,8 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# Whether to use the Boehm garbage collector.
|
# Whether to use the Boehm garbage collector.
|
||||||
AC_ARG_ENABLE(gc, AS_HELP_STRING([--enable-gc],[enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=yes]]),
|
AC_ARG_ENABLE(gc, AC_HELP_STRING([--enable-gc],
|
||||||
|
[enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=yes]]),
|
||||||
gc=$enableval, gc=yes)
|
gc=$enableval, gc=yes)
|
||||||
if test "$gc" = yes; then
|
if test "$gc" = yes; then
|
||||||
PKG_CHECK_MODULES([BDW_GC], [bdw-gc])
|
PKG_CHECK_MODULES([BDW_GC], [bdw-gc])
|
||||||
@@ -256,12 +271,11 @@ PKG_CHECK_MODULES([GTEST], [gtest_main])
|
|||||||
|
|
||||||
|
|
||||||
# documentation generation switch
|
# documentation generation switch
|
||||||
AC_ARG_ENABLE(doc-gen, AS_HELP_STRING([--disable-doc-gen],[disable documentation generation]),
|
AC_ARG_ENABLE(doc-gen, AC_HELP_STRING([--disable-doc-gen],
|
||||||
|
[disable documentation generation]),
|
||||||
doc_generate=$enableval, doc_generate=yes)
|
doc_generate=$enableval, doc_generate=yes)
|
||||||
AC_SUBST(doc_generate)
|
AC_SUBST(doc_generate)
|
||||||
|
|
||||||
# Look for lowdown library.
|
|
||||||
PKG_CHECK_MODULES([LOWDOWN], [lowdown >= 0.8.0], [CXXFLAGS="$LOWDOWN_CFLAGS $CXXFLAGS"])
|
|
||||||
|
|
||||||
# Setuid installations.
|
# Setuid installations.
|
||||||
AC_CHECK_FUNCS([setresuid setreuid lchown])
|
AC_CHECK_FUNCS([setresuid setreuid lchown])
|
||||||
@@ -273,14 +287,24 @@ AC_CHECK_FUNCS([strsignal posix_fallocate sysconf])
|
|||||||
|
|
||||||
# This is needed if bzip2 is a static library, and the Nix libraries
|
# This is needed if bzip2 is a static library, and the Nix libraries
|
||||||
# are dynamic.
|
# are dynamic.
|
||||||
case "${host_os}" in
|
if test "$(uname)" = "Darwin"; then
|
||||||
darwin*)
|
|
||||||
LDFLAGS="-all_load $LDFLAGS"
|
LDFLAGS="-all_load $LDFLAGS"
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_WITH(sandbox-shell, AS_HELP_STRING([--with-sandbox-shell=PATH],[path of a statically-linked shell to use as /bin/sh in sandboxes]),
|
# Do we have GNU tar?
|
||||||
|
AC_MSG_CHECKING([if you have a recent GNU tar])
|
||||||
|
if $tar --version 2> /dev/null | grep -q GNU && tar cvf /dev/null --warning=no-timestamp ./config.log > /dev/null; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
tarFlags="--warning=no-timestamp"
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
AC_SUBST(tarFlags)
|
||||||
|
|
||||||
|
|
||||||
|
AC_ARG_WITH(sandbox-shell, AC_HELP_STRING([--with-sandbox-shell=PATH],
|
||||||
|
[path of a statically-linked shell to use as /bin/sh in sandboxes]),
|
||||||
sandbox_shell=$withval)
|
sandbox_shell=$withval)
|
||||||
AC_SUBST(sandbox_shell)
|
AC_SUBST(sandbox_shell)
|
||||||
|
|
||||||
@@ -295,6 +319,6 @@ done
|
|||||||
|
|
||||||
rm -f Makefile.config
|
rm -f Makefile.config
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADER([config.h])
|
||||||
AC_CONFIG_FILES([])
|
AC_CONFIG_FILES([])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
@@ -6,11 +6,9 @@ builtins:
|
|||||||
concatStrings (map
|
concatStrings (map
|
||||||
(name:
|
(name:
|
||||||
let builtin = builtins.${name}; in
|
let builtin = builtins.${name}; in
|
||||||
"<dt><code>${name} "
|
" - `builtins.${name}` " + concatStringsSep " " (map (s: "*${s}*") builtin.args)
|
||||||
+ concatStringsSep " " (map (s: "<var>${s}</var>") builtin.args)
|
+ " \n\n"
|
||||||
+ "</code></dt>"
|
+ concatStrings (map (s: " ${s}\n") (splitLines builtin.doc)) + "\n\n"
|
||||||
+ "<dd>\n\n"
|
|
||||||
+ builtin.doc
|
|
||||||
+ "\n\n</dd>"
|
|
||||||
)
|
)
|
||||||
(attrNames builtins))
|
(attrNames builtins))
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{ command, renderLinks ? false }:
|
command:
|
||||||
|
|
||||||
with builtins;
|
with builtins;
|
||||||
with import ./utils.nix;
|
with import ./utils.nix;
|
||||||
@@ -7,10 +7,7 @@ let
|
|||||||
|
|
||||||
showCommand =
|
showCommand =
|
||||||
{ command, def, filename }:
|
{ command, def, filename }:
|
||||||
''
|
"# Name\n\n"
|
||||||
**Warning**: This program is **experimental** and its interface is subject to change.
|
|
||||||
''
|
|
||||||
+ "# Name\n\n"
|
|
||||||
+ "`${command}` - ${def.description}\n\n"
|
+ "`${command}` - ${def.description}\n\n"
|
||||||
+ "# Synopsis\n\n"
|
+ "# Synopsis\n\n"
|
||||||
+ showSynopsis { inherit command; args = def.args; }
|
+ showSynopsis { inherit command; args = def.args; }
|
||||||
@@ -20,11 +17,7 @@ let
|
|||||||
categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues def.commands)));
|
categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues def.commands)));
|
||||||
listCommands = cmds:
|
listCommands = cmds:
|
||||||
concatStrings (map (name:
|
concatStrings (map (name:
|
||||||
"* "
|
"* [`${command} ${name}`](./${appendName filename name}.md) - ${cmds.${name}.description}\n")
|
||||||
+ (if renderLinks
|
|
||||||
then "[`${command} ${name}`](./${appendName filename name}.md)"
|
|
||||||
else "`${command} ${name}`")
|
|
||||||
+ " - ${cmds.${name}.description}\n")
|
|
||||||
(attrNames cmds));
|
(attrNames cmds));
|
||||||
in
|
in
|
||||||
"where *subcommand* is one of the following:\n\n"
|
"where *subcommand* is one of the following:\n\n"
|
||||||
@@ -93,7 +86,7 @@ let
|
|||||||
in
|
in
|
||||||
|
|
||||||
let
|
let
|
||||||
manpages = processCommand { filename = "nix"; command = "nix"; def = builtins.fromJSON command; };
|
manpages = processCommand { filename = "nix"; command = "nix"; def = command; };
|
||||||
summary = concatStrings (map (manpage: " - [${manpage.command}](command-ref/new-cli/${manpage.name})\n") manpages);
|
summary = concatStrings (map (manpage: " - [${manpage.command}](command-ref/new-cli/${manpage.name})\n") manpages);
|
||||||
in
|
in
|
||||||
(listToAttrs manpages) // { "SUMMARY.md" = summary; }
|
(listToAttrs manpages) // { "SUMMARY.md" = summary; }
|
||||||
File renamed without changes.
+13
-23
@@ -1,5 +1,7 @@
|
|||||||
ifeq ($(doc_generate),yes)
|
ifeq ($(doc_generate),yes)
|
||||||
|
|
||||||
|
MANUAL_SRCS := $(call rwildcard, $(d)/src, *.md)
|
||||||
|
|
||||||
# Generate man pages.
|
# Generate man pages.
|
||||||
man-pages := $(foreach n, \
|
man-pages := $(foreach n, \
|
||||||
nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 \
|
nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 \
|
||||||
@@ -23,19 +25,19 @@ nix-eval = $(dummy-env) $(bindir)/nix eval --experimental-features nix-command -
|
|||||||
$(d)/%.1: $(d)/src/command-ref/%.md
|
$(d)/%.1: $(d)/src/command-ref/%.md
|
||||||
@printf "Title: %s\n\n" "$$(basename $@ .1)" > $^.tmp
|
@printf "Title: %s\n\n" "$$(basename $@ .1)" > $^.tmp
|
||||||
@cat $^ >> $^.tmp
|
@cat $^ >> $^.tmp
|
||||||
$(trace-gen) lowdown -sT man -M section=1 $^.tmp -o $@
|
$(trace-gen) lowdown -sT man $^.tmp -o $@
|
||||||
@rm $^.tmp
|
@rm $^.tmp
|
||||||
|
|
||||||
$(d)/%.8: $(d)/src/command-ref/%.md
|
$(d)/%.8: $(d)/src/command-ref/%.md
|
||||||
@printf "Title: %s\n\n" "$$(basename $@ .8)" > $^.tmp
|
@printf "Title: %s\n\n" "$$(basename $@ .8)" > $^.tmp
|
||||||
@cat $^ >> $^.tmp
|
@cat $^ >> $^.tmp
|
||||||
$(trace-gen) lowdown -sT man -M section=8 $^.tmp -o $@
|
$(trace-gen) lowdown -sT man $^.tmp -o $@
|
||||||
@rm $^.tmp
|
@rm $^.tmp
|
||||||
|
|
||||||
$(d)/nix.conf.5: $(d)/src/command-ref/conf-file.md
|
$(d)/nix.conf.5: $(d)/src/command-ref/conf-file.md
|
||||||
@printf "Title: %s\n\n" "$$(basename $@ .5)" > $^.tmp
|
@printf "Title: %s\n\n" "$$(basename $@ .5)" > $^.tmp
|
||||||
@cat $^ >> $^.tmp
|
@cat $^ >> $^.tmp
|
||||||
$(trace-gen) lowdown -sT man -M section=5 $^.tmp -o $@
|
$(trace-gen) lowdown -sT man $^.tmp -o $@
|
||||||
@rm $^.tmp
|
@rm $^.tmp
|
||||||
|
|
||||||
$(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/command-ref/new-cli
|
$(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/command-ref/new-cli
|
||||||
@@ -44,7 +46,7 @@ $(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/command-ref/new-cli
|
|||||||
|
|
||||||
$(d)/src/command-ref/new-cli: $(d)/nix.json $(d)/generate-manpage.nix $(bindir)/nix
|
$(d)/src/command-ref/new-cli: $(d)/nix.json $(d)/generate-manpage.nix $(bindir)/nix
|
||||||
@rm -rf $@
|
@rm -rf $@
|
||||||
$(trace-gen) $(nix-eval) --write-to $@ --expr 'import doc/manual/generate-manpage.nix { command = builtins.readFile $<; renderLinks = true; }'
|
$(trace-gen) $(nix-eval) --write-to $@ --expr 'import doc/manual/generate-manpage.nix (builtins.fromJSON (builtins.readFile $<))'
|
||||||
|
|
||||||
$(d)/src/command-ref/conf-file.md: $(d)/conf-file.json $(d)/generate-options.nix $(d)/src/command-ref/conf-file-prefix.md $(bindir)/nix
|
$(d)/src/command-ref/conf-file.md: $(d)/conf-file.json $(d)/generate-options.nix $(d)/src/command-ref/conf-file-prefix.md $(bindir)/nix
|
||||||
@cat doc/manual/src/command-ref/conf-file-prefix.md > $@.tmp
|
@cat doc/manual/src/command-ref/conf-file-prefix.md > $@.tmp
|
||||||
@@ -62,7 +64,6 @@ $(d)/conf-file.json: $(bindir)/nix
|
|||||||
$(d)/src/expressions/builtins.md: $(d)/builtins.json $(d)/generate-builtins.nix $(d)/src/expressions/builtins-prefix.md $(bindir)/nix
|
$(d)/src/expressions/builtins.md: $(d)/builtins.json $(d)/generate-builtins.nix $(d)/src/expressions/builtins-prefix.md $(bindir)/nix
|
||||||
@cat doc/manual/src/expressions/builtins-prefix.md > $@.tmp
|
@cat doc/manual/src/expressions/builtins-prefix.md > $@.tmp
|
||||||
$(trace-gen) $(nix-eval) --expr 'import doc/manual/generate-builtins.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
|
$(trace-gen) $(nix-eval) --expr 'import doc/manual/generate-builtins.nix (builtins.fromJSON (builtins.readFile $<))' >> $@.tmp
|
||||||
@cat doc/manual/src/expressions/builtins-suffix.md >> $@.tmp
|
|
||||||
@mv $@.tmp $@
|
@mv $@.tmp $@
|
||||||
|
|
||||||
$(d)/builtins.json: $(bindir)/nix
|
$(d)/builtins.json: $(bindir)/nix
|
||||||
@@ -73,28 +74,17 @@ $(d)/builtins.json: $(bindir)/nix
|
|||||||
install: $(docdir)/manual/index.html
|
install: $(docdir)/manual/index.html
|
||||||
|
|
||||||
# Generate 'nix' manpages.
|
# Generate 'nix' manpages.
|
||||||
install: $(mandir)/man1/nix3-manpages
|
install: $(d)/src/command-ref/new-cli
|
||||||
man: doc/manual/generated/man1/nix3-manpages
|
|
||||||
all: doc/manual/generated/man1/nix3-manpages
|
|
||||||
|
|
||||||
$(mandir)/man1/nix3-manpages: doc/manual/generated/man1/nix3-manpages
|
|
||||||
@mkdir -p $(DESTDIR)$$(dirname $@)
|
|
||||||
$(trace-install) install -m 0644 $$(dirname $<)/* $(DESTDIR)$$(dirname $@)
|
|
||||||
|
|
||||||
doc/manual/generated/man1/nix3-manpages: $(d)/src/command-ref/new-cli
|
|
||||||
@mkdir -p $(DESTDIR)$$(dirname $@)
|
|
||||||
$(trace-gen) for i in doc/manual/src/command-ref/new-cli/*.md; do \
|
$(trace-gen) for i in doc/manual/src/command-ref/new-cli/*.md; do \
|
||||||
name=$$(basename $$i .md); \
|
name=$$(basename $$i .md); \
|
||||||
tmpFile=$$(mktemp); \
|
|
||||||
if [[ $$name = SUMMARY ]]; then continue; fi; \
|
if [[ $$name = SUMMARY ]]; then continue; fi; \
|
||||||
printf "Title: %s\n\n" "$$name" > $$tmpFile; \
|
printf "Title: %s\n\n" "$$name" > $$i.tmp; \
|
||||||
cat $$i >> $$tmpFile; \
|
cat $$i >> $$i.tmp; \
|
||||||
lowdown -sT man -M section=1 $$tmpFile -o $(DESTDIR)$$(dirname $@)/$$name.1; \
|
lowdown -sT man $$i.tmp -o $(mandir)/man1/$$name.1; \
|
||||||
rm $$tmpFile; \
|
|
||||||
done
|
done
|
||||||
@touch $@
|
|
||||||
|
|
||||||
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/command-ref/new-cli $(d)/src/command-ref/conf-file.md $(d)/src/expressions/builtins.md $(call rwildcard, $(d)/src, *.md)
|
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/command-ref/new-cli $(d)/src/command-ref/conf-file.md $(d)/src/expressions/builtins.md
|
||||||
$(trace-gen) RUST_LOG=warn mdbook build doc/manual -d $(DESTDIR)$(docdir)/manual
|
$(trace-gen) RUST_LOG=warn mdbook build doc/manual -d $(docdir)/manual
|
||||||
|
@cp doc/manual/highlight.pack.js $(docdir)/manual/highlight.js
|
||||||
|
|
||||||
endif
|
endif
|
||||||
@@ -70,8 +70,6 @@
|
|||||||
- [Hacking](contributing/hacking.md)
|
- [Hacking](contributing/hacking.md)
|
||||||
- [CLI guideline](contributing/cli-guideline.md)
|
- [CLI guideline](contributing/cli-guideline.md)
|
||||||
- [Release Notes](release-notes/release-notes.md)
|
- [Release Notes](release-notes/release-notes.md)
|
||||||
- [Release X.Y (202?-??-??)](release-notes/rl-next.md)
|
|
||||||
- [Release 2.4 (2021-11-01)](release-notes/rl-2.4.md)
|
|
||||||
- [Release 2.3 (2019-09-04)](release-notes/rl-2.3.md)
|
- [Release 2.3 (2019-09-04)](release-notes/rl-2.3.md)
|
||||||
- [Release 2.2 (2019-01-11)](release-notes/rl-2.2.md)
|
- [Release 2.2 (2019-01-11)](release-notes/rl-2.2.md)
|
||||||
- [Release 2.1 (2018-09-02)](release-notes/rl-2.1.md)
|
- [Release 2.1 (2018-09-02)](release-notes/rl-2.1.md)
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ Nix has two relevant settings with regards to how your CPU cores will
|
|||||||
be utilized: `cores` and `max-jobs`. This chapter will talk about what
|
be utilized: `cores` and `max-jobs`. This chapter will talk about what
|
||||||
they are, how they interact, and their configuration trade-offs.
|
they are, how they interact, and their configuration trade-offs.
|
||||||
|
|
||||||
- `max-jobs`\
|
- `max-jobs`
|
||||||
Dictates how many separate derivations will be built at the same
|
Dictates how many separate derivations will be built at the same
|
||||||
time. If you set this to zero, the local machine will do no
|
time. If you set this to zero, the local machine will do no
|
||||||
builds. Nix will still substitute from binary caches, and build
|
builds. Nix will still substitute from binary caches, and build
|
||||||
remotely if remote builders are configured.
|
remotely if remote builders are configured.
|
||||||
|
|
||||||
- `cores`\
|
- `cores`
|
||||||
Suggests how many cores each derivation should use. Similar to
|
Suggests how many cores each derivation should use. Similar to
|
||||||
`make -j`.
|
`make -j`.
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ then you need to ensure that the `PATH` of non-interactive login shells
|
|||||||
contains Nix.
|
contains Nix.
|
||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
>
|
>
|
||||||
> If you are building via the Nix daemon, it is the Nix daemon user
|
> If you are building via the Nix daemon, it is the Nix daemon user
|
||||||
> account (that is, `root`) that should have SSH access to the remote
|
> account (that is, `root`) that should have SSH access to the remote
|
||||||
> machine. If you can’t or don’t want to configure `root` to be able to
|
> machine. If you can’t or don’t want to configure `root` to be able to
|
||||||
@@ -52,7 +52,7 @@ example, the following command allows you to build a derivation for
|
|||||||
```console
|
```console
|
||||||
$ uname
|
$ uname
|
||||||
Linux
|
Linux
|
||||||
|
|
||||||
$ nix build \
|
$ nix build \
|
||||||
'(with import <nixpkgs> { system = "x86_64-darwin"; }; runCommand "foo" {} "uname > $out")' \
|
'(with import <nixpkgs> { system = "x86_64-darwin"; }; runCommand "foo" {} "uname > $out")' \
|
||||||
--builders 'ssh://mac x86_64-darwin'
|
--builders 'ssh://mac x86_64-darwin'
|
||||||
@@ -103,7 +103,7 @@ default, set it to `-`.
|
|||||||
```nix
|
```nix
|
||||||
requiredSystemFeatures = [ "kvm" ];
|
requiredSystemFeatures = [ "kvm" ];
|
||||||
```
|
```
|
||||||
|
|
||||||
will cause the build to be performed on a machine that has the `kvm`
|
will cause the build to be performed on a machine that has the `kvm`
|
||||||
feature.
|
feature.
|
||||||
|
|
||||||
@@ -112,10 +112,6 @@ default, set it to `-`.
|
|||||||
features appear in the derivation’s `requiredSystemFeatures`
|
features appear in the derivation’s `requiredSystemFeatures`
|
||||||
attribute..
|
attribute..
|
||||||
|
|
||||||
8. The (base64-encoded) public host key of the remote machine. If omitted, SSH
|
|
||||||
will use its regular known-hosts file. Specifically, the field is calculated
|
|
||||||
via `base64 -w0 /etc/ssh/ssh_host_ed25519_key.pub`.
|
|
||||||
|
|
||||||
For example, the machine specification
|
For example, the machine specification
|
||||||
|
|
||||||
nix@scratchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 1 kvm
|
nix@scratchy.labs.cs.uu.nl i686-linux /home/nix/.ssh/id_scratchy_auto 8 1 kvm
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ By default Nix reads settings from the following places:
|
|||||||
|
|
||||||
Otherwise it will look for `nix/nix.conf` files in `XDG_CONFIG_DIRS`
|
Otherwise it will look for `nix/nix.conf` files in `XDG_CONFIG_DIRS`
|
||||||
and `XDG_CONFIG_HOME`. If these are unset, it will look in
|
and `XDG_CONFIG_HOME`. If these are unset, it will look in
|
||||||
`$HOME/.config/nix/nix.conf`.
|
`$HOME/.config/nix.conf`.
|
||||||
|
|
||||||
- If `NIX_CONFIG` is set, its contents is treated as the contents of
|
- If `NIX_CONFIG` is set, its contents is treated as the contents of
|
||||||
a configuration file.
|
a configuration file.
|
||||||
|
|||||||
@@ -2,49 +2,45 @@
|
|||||||
|
|
||||||
Most Nix commands interpret the following environment variables:
|
Most Nix commands interpret the following environment variables:
|
||||||
|
|
||||||
- `IN_NIX_SHELL`\
|
- `IN_NIX_SHELL`
|
||||||
Indicator that tells if the current environment was set up by
|
Indicator that tells if the current environment was set up by
|
||||||
`nix-shell`. Since Nix 2.0 the values are `"pure"` and `"impure"`
|
`nix-shell`. Since Nix 2.0 the values are `"pure"` and `"impure"`
|
||||||
|
|
||||||
- `NIX_PATH`\
|
- `NIX_PATH`
|
||||||
A colon-separated list of directories used to look up Nix
|
A colon-separated list of directories used to look up Nix
|
||||||
expressions enclosed in angle brackets (i.e., `<path>`). For
|
expressions enclosed in angle brackets (i.e., `<path>`). For
|
||||||
instance, the value
|
instance, the value
|
||||||
|
|
||||||
/home/eelco/Dev:/etc/nixos
|
/home/eelco/Dev:/etc/nixos
|
||||||
|
|
||||||
will cause Nix to look for paths relative to `/home/eelco/Dev` and
|
will cause Nix to look for paths relative to `/home/eelco/Dev` and
|
||||||
`/etc/nixos`, in this order. It is also possible to match paths
|
`/etc/nixos`, in this order. It is also possible to match paths
|
||||||
against a prefix. For example, the value
|
against a prefix. For example, the value
|
||||||
|
|
||||||
nixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
|
nixpkgs=/home/eelco/Dev/nixpkgs-branch:/etc/nixos
|
||||||
|
|
||||||
will cause Nix to search for `<nixpkgs/path>` in
|
will cause Nix to search for `<nixpkgs/path>` in
|
||||||
`/home/eelco/Dev/nixpkgs-branch/path` and `/etc/nixos/nixpkgs/path`.
|
`/home/eelco/Dev/nixpkgs-branch/path` and `/etc/nixos/nixpkgs/path`.
|
||||||
|
|
||||||
If a path in the Nix search path starts with `http://` or
|
If a path in the Nix search path starts with `http://` or
|
||||||
`https://`, it is interpreted as the URL of a tarball that will be
|
`https://`, it is interpreted as the URL of a tarball that will be
|
||||||
downloaded and unpacked to a temporary location. The tarball must
|
downloaded and unpacked to a temporary location. The tarball must
|
||||||
consist of a single top-level directory. For example, setting
|
consist of a single top-level directory. For example, setting
|
||||||
`NIX_PATH` to
|
`NIX_PATH` to
|
||||||
|
|
||||||
|
nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-15.09.tar.gz
|
||||||
|
|
||||||
|
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
|
||||||
|
channel.
|
||||||
|
|
||||||
|
A following shorthand can be used to refer to the official channels:
|
||||||
|
|
||||||
|
nixpkgs=channel:nixos-15.09
|
||||||
|
|
||||||
|
The search path can be extended using the `-I` option, which takes
|
||||||
|
precedence over `NIX_PATH`.
|
||||||
|
|
||||||
nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
|
- `NIX_IGNORE_SYMLINK_STORE`
|
||||||
|
|
||||||
tells Nix to download and use the current contents of the
|
|
||||||
`master` branch in the `nixpkgs` repository.
|
|
||||||
|
|
||||||
The URLs of the tarballs from the official nixos.org channels (see
|
|
||||||
[the manual for `nix-channel`](nix-channel.md)) can be abbreviated
|
|
||||||
as `channel:<channel-name>`. For instance, the following two
|
|
||||||
values of `NIX_PATH` are equivalent:
|
|
||||||
|
|
||||||
nixpkgs=channel:nixos-21.05
|
|
||||||
nixpkgs=https://nixos.org/channels/nixos-21.05/nixexprs.tar.xz
|
|
||||||
|
|
||||||
The Nix search path can also be extended using the `-I` option to
|
|
||||||
many Nix commands, which takes precedence over `NIX_PATH`.
|
|
||||||
|
|
||||||
- `NIX_IGNORE_SYMLINK_STORE`\
|
|
||||||
Normally, the Nix store directory (typically `/nix/store`) is not
|
Normally, the Nix store directory (typically `/nix/store`) is not
|
||||||
allowed to contain any symlink components. This is to prevent
|
allowed to contain any symlink components. This is to prevent
|
||||||
“impure” builds. Builders sometimes “canonicalise” paths by
|
“impure” builds. Builders sometimes “canonicalise” paths by
|
||||||
@@ -54,7 +50,7 @@ Most Nix commands interpret the following environment variables:
|
|||||||
builds are deployed to machines where `/nix/store` resolves
|
builds are deployed to machines where `/nix/store` resolves
|
||||||
differently. If you are sure that you’re not going to do that, you
|
differently. If you are sure that you’re not going to do that, you
|
||||||
can set `NIX_IGNORE_SYMLINK_STORE` to `1`.
|
can set `NIX_IGNORE_SYMLINK_STORE` to `1`.
|
||||||
|
|
||||||
Note that if you’re symlinking the Nix store so that you can put it
|
Note that if you’re symlinking the Nix store so that you can put it
|
||||||
on another file system than the root file system, on Linux you’re
|
on another file system than the root file system, on Linux you’re
|
||||||
better off using `bind` mount points, e.g.,
|
better off using `bind` mount points, e.g.,
|
||||||
@@ -63,44 +59,44 @@ Most Nix commands interpret the following environment variables:
|
|||||||
$ mkdir /nix
|
$ mkdir /nix
|
||||||
$ mount -o bind /mnt/otherdisk/nix /nix
|
$ mount -o bind /mnt/otherdisk/nix /nix
|
||||||
```
|
```
|
||||||
|
|
||||||
Consult the mount 8 manual page for details.
|
Consult the mount 8 manual page for details.
|
||||||
|
|
||||||
- `NIX_STORE_DIR`\
|
- `NIX_STORE_DIR`
|
||||||
Overrides the location of the Nix store (default `prefix/store`).
|
Overrides the location of the Nix store (default `prefix/store`).
|
||||||
|
|
||||||
- `NIX_DATA_DIR`\
|
- `NIX_DATA_DIR`
|
||||||
Overrides the location of the Nix static data directory (default
|
Overrides the location of the Nix static data directory (default
|
||||||
`prefix/share`).
|
`prefix/share`).
|
||||||
|
|
||||||
- `NIX_LOG_DIR`\
|
- `NIX_LOG_DIR`
|
||||||
Overrides the location of the Nix log directory (default
|
Overrides the location of the Nix log directory (default
|
||||||
`prefix/var/log/nix`).
|
`prefix/var/log/nix`).
|
||||||
|
|
||||||
- `NIX_STATE_DIR`\
|
- `NIX_STATE_DIR`
|
||||||
Overrides the location of the Nix state directory (default
|
Overrides the location of the Nix state directory (default
|
||||||
`prefix/var/nix`).
|
`prefix/var/nix`).
|
||||||
|
|
||||||
- `NIX_CONF_DIR`\
|
- `NIX_CONF_DIR`
|
||||||
Overrides the location of the system Nix configuration directory
|
Overrides the location of the system Nix configuration directory
|
||||||
(default `prefix/etc/nix`).
|
(default `prefix/etc/nix`).
|
||||||
|
|
||||||
- `NIX_CONFIG`\
|
- `NIX_CONFIG`
|
||||||
Applies settings from Nix configuration from the environment.
|
Applies settings from Nix configuration from the environment.
|
||||||
The content is treated as if it was read from a Nix configuration file.
|
The content is treated as if it was read from a Nix configuration file.
|
||||||
Settings are separated by the newline character.
|
Settings are separated by the newline character.
|
||||||
|
|
||||||
- `NIX_USER_CONF_FILES`\
|
- `NIX_USER_CONF_FILES`
|
||||||
Overrides the location of the user Nix configuration files to load
|
Overrides the location of the user Nix configuration files to load
|
||||||
from (defaults to the XDG spec locations). The variable is treated
|
from (defaults to the XDG spec locations). The variable is treated
|
||||||
as a list separated by the `:` token.
|
as a list separated by the `:` token.
|
||||||
|
|
||||||
- `TMPDIR`\
|
- `TMPDIR`
|
||||||
Use the specified directory to store temporary files. In particular,
|
Use the specified directory to store temporary files. In particular,
|
||||||
this includes temporary build directories; these can take up
|
this includes temporary build directories; these can take up
|
||||||
substantial amounts of disk space. The default is `/tmp`.
|
substantial amounts of disk space. The default is `/tmp`.
|
||||||
|
|
||||||
- `NIX_REMOTE`\
|
- `NIX_REMOTE`
|
||||||
This variable should be set to `daemon` if you want to use the Nix
|
This variable should be set to `daemon` if you want to use the Nix
|
||||||
daemon to execute Nix operations. This is necessary in [multi-user
|
daemon to execute Nix operations. This is necessary in [multi-user
|
||||||
Nix installations](../installation/multi-user.md). If the Nix
|
Nix installations](../installation/multi-user.md). If the Nix
|
||||||
@@ -108,16 +104,16 @@ Most Nix commands interpret the following environment variables:
|
|||||||
should be set to `unix://path/to/socket`. Otherwise, it should be
|
should be set to `unix://path/to/socket`. Otherwise, it should be
|
||||||
left unset.
|
left unset.
|
||||||
|
|
||||||
- `NIX_SHOW_STATS`\
|
- `NIX_SHOW_STATS`
|
||||||
If set to `1`, Nix will print some evaluation statistics, such as
|
If set to `1`, Nix will print some evaluation statistics, such as
|
||||||
the number of values allocated.
|
the number of values allocated.
|
||||||
|
|
||||||
- `NIX_COUNT_CALLS`\
|
- `NIX_COUNT_CALLS`
|
||||||
If set to `1`, Nix will print how often functions were called during
|
If set to `1`, Nix will print how often functions were called during
|
||||||
Nix expression evaluation. This is useful for profiling your Nix
|
Nix expression evaluation. This is useful for profiling your Nix
|
||||||
expressions.
|
expressions.
|
||||||
|
|
||||||
- `GC_INITIAL_HEAP_SIZE`\
|
- `GC_INITIAL_HEAP_SIZE`
|
||||||
If Nix has been configured to use the Boehm garbage collector, this
|
If Nix has been configured to use the Boehm garbage collector, this
|
||||||
variable sets the initial size of the heap in bytes. It defaults to
|
variable sets the initial size of the heap in bytes. It defaults to
|
||||||
384 MiB. Setting it to a low value reduces memory consumption, but
|
384 MiB. Setting it to a low value reduces memory consumption, but
|
||||||
|
|||||||
@@ -47,16 +47,16 @@ All options not listed here are passed to `nix-store
|
|||||||
--realise`, except for `--arg` and `--attr` / `-A` which are passed to
|
--realise`, except for `--arg` and `--attr` / `-A` which are passed to
|
||||||
`nix-instantiate`.
|
`nix-instantiate`.
|
||||||
|
|
||||||
- `--no-out-link`\
|
- `--no-out-link`
|
||||||
Do not create a symlink to the output path. Note that as a result
|
Do not create a symlink to the output path. Note that as a result
|
||||||
the output does not become a root of the garbage collector, and so
|
the output does not become a root of the garbage collector, and so
|
||||||
might be deleted by `nix-store
|
might be deleted by `nix-store
|
||||||
--gc`.
|
--gc`.
|
||||||
|
|
||||||
- `--dry-run`\
|
- `--dry-run`
|
||||||
Show what store paths would be built or downloaded.
|
Show what store paths would be built or downloaded.
|
||||||
|
|
||||||
- `--out-link` / `-o` *outlink*\
|
- `--out-link` / `-o` *outlink*
|
||||||
Change the name of the symlink to the output path created from
|
Change the name of the symlink to the output path created from
|
||||||
`result` to *outlink*.
|
`result` to *outlink*.
|
||||||
|
|
||||||
|
|||||||
@@ -17,26 +17,26 @@ To see the list of official NixOS channels, visit
|
|||||||
|
|
||||||
This command has the following operations:
|
This command has the following operations:
|
||||||
|
|
||||||
- `--add` *url* \[*name*\]\
|
- `--add` *url* \[*name*\]
|
||||||
Adds a channel named *name* with URL *url* to the list of subscribed
|
Adds a channel named *name* with URL *url* to the list of subscribed
|
||||||
channels. If *name* is omitted, it defaults to the last component of
|
channels. If *name* is omitted, it defaults to the last component of
|
||||||
*url*, with the suffixes `-stable` or `-unstable` removed.
|
*url*, with the suffixes `-stable` or `-unstable` removed.
|
||||||
|
|
||||||
- `--remove` *name*\
|
- `--remove` *name*
|
||||||
Removes the channel named *name* from the list of subscribed
|
Removes the channel named *name* from the list of subscribed
|
||||||
channels.
|
channels.
|
||||||
|
|
||||||
- `--list`\
|
- `--list`
|
||||||
Prints the names and URLs of all subscribed channels on standard
|
Prints the names and URLs of all subscribed channels on standard
|
||||||
output.
|
output.
|
||||||
|
|
||||||
- `--update` \[*names*…\]\
|
- `--update` \[*names*…\]
|
||||||
Downloads the Nix expressions of all subscribed channels (or only
|
Downloads the Nix expressions of all subscribed channels (or only
|
||||||
those included in *names* if specified) and makes them the default
|
those included in *names* if specified) and makes them the default
|
||||||
for `nix-env` operations (by symlinking them from the directory
|
for `nix-env` operations (by symlinking them from the directory
|
||||||
`~/.nix-defexpr`).
|
`~/.nix-defexpr`).
|
||||||
|
|
||||||
- `--rollback` \[*generation*\]\
|
- `--rollback` \[*generation*\]
|
||||||
Reverts the previous call to `nix-channel
|
Reverts the previous call to `nix-channel
|
||||||
--update`. Optionally, you can specify a specific channel generation
|
--update`. Optionally, you can specify a specific channel generation
|
||||||
number to restore.
|
number to restore.
|
||||||
@@ -70,14 +70,14 @@ $ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
|
|||||||
|
|
||||||
# Files
|
# Files
|
||||||
|
|
||||||
- `/nix/var/nix/profiles/per-user/username/channels`\
|
- `/nix/var/nix/profiles/per-user/username/channels`
|
||||||
`nix-channel` uses a `nix-env` profile to keep track of previous
|
`nix-channel` uses a `nix-env` profile to keep track of previous
|
||||||
versions of the subscribed channels. Every time you run `nix-channel
|
versions of the subscribed channels. Every time you run `nix-channel
|
||||||
--update`, a new channel generation (that is, a symlink to the
|
--update`, a new channel generation (that is, a symlink to the
|
||||||
channel Nix expressions in the Nix store) is created. This enables
|
channel Nix expressions in the Nix store) is created. This enables
|
||||||
`nix-channel --rollback` to revert to previous versions.
|
`nix-channel --rollback` to revert to previous versions.
|
||||||
|
|
||||||
- `~/.nix-defexpr/channels`\
|
- `~/.nix-defexpr/channels`
|
||||||
This is a symlink to
|
This is a symlink to
|
||||||
`/nix/var/nix/profiles/per-user/username/channels`. It ensures that
|
`/nix/var/nix/profiles/per-user/username/channels`. It ensures that
|
||||||
`nix-env` can find your channels. In a multi-user installation, you
|
`nix-env` can find your channels. In a multi-user installation, you
|
||||||
@@ -89,7 +89,7 @@ $ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
|
|||||||
A channel URL should point to a directory containing the following
|
A channel URL should point to a directory containing the following
|
||||||
files:
|
files:
|
||||||
|
|
||||||
- `nixexprs.tar.xz`\
|
- `nixexprs.tar.xz`
|
||||||
A tarball containing Nix expressions and files referenced by them
|
A tarball containing Nix expressions and files referenced by them
|
||||||
(such as build scripts and patches). At the top level, the tarball
|
(such as build scripts and patches). At the top level, the tarball
|
||||||
should contain a single directory. That directory must contain a
|
should contain a single directory. That directory must contain a
|
||||||
|
|||||||
@@ -35,21 +35,21 @@ and second to send the dump of those paths. If this bothers you, use
|
|||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
- `--to`\
|
- `--to`
|
||||||
Copy the closure of _paths_ from the local Nix store to the Nix
|
Copy the closure of _paths_ from the local Nix store to the Nix
|
||||||
store on _machine_. This is the default.
|
store on _machine_. This is the default.
|
||||||
|
|
||||||
- `--from`\
|
- `--from`
|
||||||
Copy the closure of _paths_ from the Nix store on _machine_ to the
|
Copy the closure of _paths_ from the Nix store on _machine_ to the
|
||||||
local Nix store.
|
local Nix store.
|
||||||
|
|
||||||
- `--gzip`\
|
- `--gzip`
|
||||||
Enable compression of the SSH connection.
|
Enable compression of the SSH connection.
|
||||||
|
|
||||||
- `--include-outputs`\
|
- `--include-outputs`
|
||||||
Also copy the outputs of store derivations included in the closure.
|
Also copy the outputs of store derivations included in the closure.
|
||||||
|
|
||||||
- `--use-substitutes` / `-s`\
|
- `--use-substitutes` / `-s`
|
||||||
Attempt to download missing paths on the target machine using Nix’s
|
Attempt to download missing paths on the target machine using Nix’s
|
||||||
substitute mechanism. Any paths that cannot be substituted on the
|
substitute mechanism. Any paths that cannot be substituted on the
|
||||||
target are still copied normally from the source. This is useful,
|
target are still copied normally from the source. This is useful,
|
||||||
@@ -58,12 +58,12 @@ and second to send the dump of those paths. If this bothers you, use
|
|||||||
`nixos.org` (the default binary cache server) is
|
`nixos.org` (the default binary cache server) is
|
||||||
fast.
|
fast.
|
||||||
|
|
||||||
- `-v`\
|
- `-v`
|
||||||
Show verbose output.
|
Show verbose output.
|
||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
|
|
||||||
- `NIX_SSHOPTS`\
|
- `NIX_SSHOPTS`
|
||||||
Additional options to be passed to `ssh` on the command
|
Additional options to be passed to `ssh` on the command
|
||||||
line.
|
line.
|
||||||
|
|
||||||
|
|||||||
@@ -36,27 +36,27 @@ case-sensitive. The regular expression can optionally be followed by a
|
|||||||
dash and a version number; if omitted, any version of the package will
|
dash and a version number; if omitted, any version of the package will
|
||||||
match. Here are some examples:
|
match. Here are some examples:
|
||||||
|
|
||||||
- `firefox`\
|
- `firefox`
|
||||||
Matches the package name `firefox` and any version.
|
Matches the package name `firefox` and any version.
|
||||||
|
|
||||||
- `firefox-32.0`\
|
- `firefox-32.0`
|
||||||
Matches the package name `firefox` and version `32.0`.
|
Matches the package name `firefox` and version `32.0`.
|
||||||
|
|
||||||
- `gtk\\+`\
|
- `gtk\\+`
|
||||||
Matches the package name `gtk+`. The `+` character must be escaped
|
Matches the package name `gtk+`. The `+` character must be escaped
|
||||||
using a backslash to prevent it from being interpreted as a
|
using a backslash to prevent it from being interpreted as a
|
||||||
quantifier, and the backslash must be escaped in turn with another
|
quantifier, and the backslash must be escaped in turn with another
|
||||||
backslash to ensure that the shell passes it on.
|
backslash to ensure that the shell passes it on.
|
||||||
|
|
||||||
- `.\*`\
|
- `.\*`
|
||||||
Matches any package name. This is the default for most commands.
|
Matches any package name. This is the default for most commands.
|
||||||
|
|
||||||
- `'.*zip.*'`\
|
- `'.*zip.*'`
|
||||||
Matches any package name containing the string `zip`. Note the dots:
|
Matches any package name containing the string `zip`. Note the dots:
|
||||||
`'*zip*'` does not work, because in a regular expression, the
|
`'*zip*'` does not work, because in a regular expression, the
|
||||||
character `*` is interpreted as a quantifier.
|
character `*` is interpreted as a quantifier.
|
||||||
|
|
||||||
- `'.*(firefox|chromium).*'`\
|
- `'.*(firefox|chromium).*'`
|
||||||
Matches any package name containing the strings `firefox` or
|
Matches any package name containing the strings `firefox` or
|
||||||
`chromium`.
|
`chromium`.
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ This section lists the options that are common to all operations. These
|
|||||||
options are allowed for every subcommand, though they may not always
|
options are allowed for every subcommand, though they may not always
|
||||||
have an effect.
|
have an effect.
|
||||||
|
|
||||||
- `--file` / `-f` *path*\
|
- `--file` / `-f` *path*
|
||||||
Specifies the Nix expression (designated below as the *active Nix
|
Specifies the Nix expression (designated below as the *active Nix
|
||||||
expression*) used by the `--install`, `--upgrade`, and `--query
|
expression*) used by the `--install`, `--upgrade`, and `--query
|
||||||
--available` operations to obtain derivations. The default is
|
--available` operations to obtain derivations. The default is
|
||||||
@@ -77,13 +77,13 @@ have an effect.
|
|||||||
unpacked to a temporary location. The tarball must include a single
|
unpacked to a temporary location. The tarball must include a single
|
||||||
top-level directory containing at least a file named `default.nix`.
|
top-level directory containing at least a file named `default.nix`.
|
||||||
|
|
||||||
- `--profile` / `-p` *path*\
|
- `--profile` / `-p` *path*
|
||||||
Specifies the profile to be used by those operations that operate on
|
Specifies the profile to be used by those operations that operate on
|
||||||
a profile (designated below as the *active profile*). A profile is a
|
a profile (designated below as the *active profile*). A profile is a
|
||||||
sequence of user environments called *generations*, one of which is
|
sequence of user environments called *generations*, one of which is
|
||||||
the *current generation*.
|
the *current generation*.
|
||||||
|
|
||||||
- `--dry-run`\
|
- `--dry-run`
|
||||||
For the `--install`, `--upgrade`, `--uninstall`,
|
For the `--install`, `--upgrade`, `--uninstall`,
|
||||||
`--switch-generation`, `--delete-generations` and `--rollback`
|
`--switch-generation`, `--delete-generations` and `--rollback`
|
||||||
operations, this flag will cause `nix-env` to print what *would* be
|
operations, this flag will cause `nix-env` to print what *would* be
|
||||||
@@ -93,7 +93,7 @@ have an effect.
|
|||||||
[substituted](../glossary.md) (i.e., downloaded) and which paths
|
[substituted](../glossary.md) (i.e., downloaded) and which paths
|
||||||
will be built from source (because no substitute is available).
|
will be built from source (because no substitute is available).
|
||||||
|
|
||||||
- `--system-filter` *system*\
|
- `--system-filter` *system*
|
||||||
By default, operations such as `--query
|
By default, operations such as `--query
|
||||||
--available` show derivations matching any platform. This option
|
--available` show derivations matching any platform. This option
|
||||||
allows you to use derivations for the specified platform *system*.
|
allows you to use derivations for the specified platform *system*.
|
||||||
@@ -102,7 +102,7 @@ have an effect.
|
|||||||
|
|
||||||
# Files
|
# Files
|
||||||
|
|
||||||
- `~/.nix-defexpr`\
|
- `~/.nix-defexpr`
|
||||||
The source for the default Nix expressions used by the
|
The source for the default Nix expressions used by the
|
||||||
`--install`, `--upgrade`, and `--query --available` operations to
|
`--install`, `--upgrade`, and `--query --available` operations to
|
||||||
obtain derivations. The `--file` option may be used to override
|
obtain derivations. The `--file` option may be used to override
|
||||||
@@ -140,7 +140,7 @@ have an effect.
|
|||||||
The command `nix-channel` places symlinks to the downloaded Nix
|
The command `nix-channel` places symlinks to the downloaded Nix
|
||||||
expressions from each subscribed channel in this directory.
|
expressions from each subscribed channel in this directory.
|
||||||
|
|
||||||
- `~/.nix-profile`\
|
- `~/.nix-profile`
|
||||||
A symbolic link to the user's current profile. By default, this
|
A symbolic link to the user's current profile. By default, this
|
||||||
symlink points to `prefix/var/nix/profiles/default`. The `PATH`
|
symlink points to `prefix/var/nix/profiles/default`. The `PATH`
|
||||||
environment variable should include `~/.nix-profile/bin` for the
|
environment variable should include `~/.nix-profile/bin` for the
|
||||||
@@ -217,13 +217,13 @@ a number of possible ways:
|
|||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
- `--prebuilt-only` / `-b`\
|
- `--prebuilt-only` / `-b`
|
||||||
Use only derivations for which a substitute is registered, i.e.,
|
Use only derivations for which a substitute is registered, i.e.,
|
||||||
there is a pre-built binary available that can be downloaded in lieu
|
there is a pre-built binary available that can be downloaded in lieu
|
||||||
of building the derivation. Thus, no packages will be built from
|
of building the derivation. Thus, no packages will be built from
|
||||||
source.
|
source.
|
||||||
|
|
||||||
- `--preserve-installed`; `-P`\
|
- `--preserve-installed`; `-P`
|
||||||
Do not remove derivations with a name matching one of the
|
Do not remove derivations with a name matching one of the
|
||||||
derivations being installed. Usually, trying to have two versions of
|
derivations being installed. Usually, trying to have two versions of
|
||||||
the same package installed in the same generation of a profile will
|
the same package installed in the same generation of a profile will
|
||||||
@@ -231,7 +231,7 @@ a number of possible ways:
|
|||||||
clashes between the two versions. However, this is not the case for
|
clashes between the two versions. However, this is not the case for
|
||||||
all packages.
|
all packages.
|
||||||
|
|
||||||
- `--remove-all`; `-r`\
|
- `--remove-all`; `-r`
|
||||||
Remove all previously installed packages first. This is equivalent
|
Remove all previously installed packages first. This is equivalent
|
||||||
to running `nix-env -e '.*'` first, except that everything happens
|
to running `nix-env -e '.*'` first, except that everything happens
|
||||||
in a single transaction.
|
in a single transaction.
|
||||||
@@ -346,24 +346,24 @@ version is installed.
|
|||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
- `--lt`\
|
- `--lt`
|
||||||
Only upgrade a derivation to newer versions. This is the default.
|
Only upgrade a derivation to newer versions. This is the default.
|
||||||
|
|
||||||
- `--leq`\
|
- `--leq`
|
||||||
In addition to upgrading to newer versions, also “upgrade” to
|
In addition to upgrading to newer versions, also “upgrade” to
|
||||||
derivations that have the same version. Version are not a unique
|
derivations that have the same version. Version are not a unique
|
||||||
identification of a derivation, so there may be many derivations
|
identification of a derivation, so there may be many derivations
|
||||||
that have the same version. This flag may be useful to force
|
that have the same version. This flag may be useful to force
|
||||||
“synchronisation” between the installed and available derivations.
|
“synchronisation” between the installed and available derivations.
|
||||||
|
|
||||||
- `--eq`\
|
- `--eq`
|
||||||
*Only* “upgrade” to derivations that have the same version. This may
|
*Only* “upgrade” to derivations that have the same version. This may
|
||||||
not seem very useful, but it actually is, e.g., when there is a new
|
not seem very useful, but it actually is, e.g., when there is a new
|
||||||
release of Nixpkgs and you want to replace installed applications
|
release of Nixpkgs and you want to replace installed applications
|
||||||
with the same versions built against newer dependencies (to reduce
|
with the same versions built against newer dependencies (to reduce
|
||||||
the number of dependencies floating around on your system).
|
the number of dependencies floating around on your system).
|
||||||
|
|
||||||
- `--always`\
|
- `--always`
|
||||||
In addition to upgrading to newer versions, also “upgrade” to
|
In addition to upgrading to newer versions, also “upgrade” to
|
||||||
derivations that have the same or a lower version. I.e., derivations
|
derivations that have the same or a lower version. I.e., derivations
|
||||||
may actually be downgraded depending on what is available in the
|
may actually be downgraded depending on what is available in the
|
||||||
@@ -401,7 +401,7 @@ of a derivation `x` by looking at their respective `name` attributes.
|
|||||||
The names (e.g., `gcc-3.3.1` are split into two parts: the package name
|
The names (e.g., `gcc-3.3.1` are split into two parts: the package name
|
||||||
(`gcc`), and the version (`3.3.1`). The version part starts after the
|
(`gcc`), and the version (`3.3.1`). The version part starts after the
|
||||||
first dash not followed by a letter. `x` is considered an upgrade of `y`
|
first dash not followed by a letter. `x` is considered an upgrade of `y`
|
||||||
if their package names match, and the version of `y` is higher than that
|
if their package names match, and the version of `y` is higher that that
|
||||||
of `x`.
|
of `x`.
|
||||||
|
|
||||||
The versions are compared by splitting them into contiguous components
|
The versions are compared by splitting them into contiguous components
|
||||||
@@ -578,11 +578,11 @@ The derivations are sorted by their `name` attributes.
|
|||||||
The following flags specify the set of things on which the query
|
The following flags specify the set of things on which the query
|
||||||
operates.
|
operates.
|
||||||
|
|
||||||
- `--installed`\
|
- `--installed`
|
||||||
The query operates on the store paths that are installed in the
|
The query operates on the store paths that are installed in the
|
||||||
current generation of the active profile. This is the default.
|
current generation of the active profile. This is the default.
|
||||||
|
|
||||||
- `--available`; `-a`\
|
- `--available`; `-a`
|
||||||
The query operates on the derivations that are available in the
|
The query operates on the derivations that are available in the
|
||||||
active Nix expression.
|
active Nix expression.
|
||||||
|
|
||||||
@@ -593,24 +593,24 @@ selected derivations. Multiple flags may be specified, in which case the
|
|||||||
information is shown in the order given here. Note that the name of the
|
information is shown in the order given here. Note that the name of the
|
||||||
derivation is shown unless `--no-name` is specified.
|
derivation is shown unless `--no-name` is specified.
|
||||||
|
|
||||||
- `--xml`\
|
- `--xml`
|
||||||
Print the result in an XML representation suitable for automatic
|
Print the result in an XML representation suitable for automatic
|
||||||
processing by other tools. The root element is called `items`, which
|
processing by other tools. The root element is called `items`, which
|
||||||
contains a `item` element for each available or installed
|
contains a `item` element for each available or installed
|
||||||
derivation. The fields discussed below are all stored in attributes
|
derivation. The fields discussed below are all stored in attributes
|
||||||
of the `item` elements.
|
of the `item` elements.
|
||||||
|
|
||||||
- `--json`\
|
- `--json`
|
||||||
Print the result in a JSON representation suitable for automatic
|
Print the result in a JSON representation suitable for automatic
|
||||||
processing by other tools.
|
processing by other tools.
|
||||||
|
|
||||||
- `--prebuilt-only` / `-b`\
|
- `--prebuilt-only` / `-b`
|
||||||
Show only derivations for which a substitute is registered, i.e.,
|
Show only derivations for which a substitute is registered, i.e.,
|
||||||
there is a pre-built binary available that can be downloaded in lieu
|
there is a pre-built binary available that can be downloaded in lieu
|
||||||
of building the derivation. Thus, this shows all packages that
|
of building the derivation. Thus, this shows all packages that
|
||||||
probably can be installed quickly.
|
probably can be installed quickly.
|
||||||
|
|
||||||
- `--status`; `-s`\
|
- `--status`; `-s`
|
||||||
Print the *status* of the derivation. The status consists of three
|
Print the *status* of the derivation. The status consists of three
|
||||||
characters. The first is `I` or `-`, indicating whether the
|
characters. The first is `I` or `-`, indicating whether the
|
||||||
derivation is currently installed in the current generation of the
|
derivation is currently installed in the current generation of the
|
||||||
@@ -621,49 +621,49 @@ derivation is shown unless `--no-name` is specified.
|
|||||||
derivation to be built. The third is `S` or `-`, indicating whether
|
derivation to be built. The third is `S` or `-`, indicating whether
|
||||||
a substitute is available for the derivation.
|
a substitute is available for the derivation.
|
||||||
|
|
||||||
- `--attr-path`; `-P`\
|
- `--attr-path`; `-P`
|
||||||
Print the *attribute path* of the derivation, which can be used to
|
Print the *attribute path* of the derivation, which can be used to
|
||||||
unambiguously select it using the `--attr` option available in
|
unambiguously select it using the `--attr` option available in
|
||||||
commands that install derivations like `nix-env --install`. This
|
commands that install derivations like `nix-env --install`. This
|
||||||
option only works together with `--available`
|
option only works together with `--available`
|
||||||
|
|
||||||
- `--no-name`\
|
- `--no-name`
|
||||||
Suppress printing of the `name` attribute of each derivation.
|
Suppress printing of the `name` attribute of each derivation.
|
||||||
|
|
||||||
- `--compare-versions` / `-c`\
|
- `--compare-versions` / `-c`
|
||||||
Compare installed versions to available versions, or vice versa (if
|
Compare installed versions to available versions, or vice versa (if
|
||||||
`--available` is given). This is useful for quickly seeing whether
|
`--available` is given). This is useful for quickly seeing whether
|
||||||
upgrades for installed packages are available in a Nix expression. A
|
upgrades for installed packages are available in a Nix expression. A
|
||||||
column is added with the following meaning:
|
column is added with the following meaning:
|
||||||
|
|
||||||
- `<` *version*\
|
- `<` *version*
|
||||||
A newer version of the package is available or installed.
|
A newer version of the package is available or installed.
|
||||||
|
|
||||||
- `=` *version*\
|
- `=` *version*
|
||||||
At most the same version of the package is available or
|
At most the same version of the package is available or
|
||||||
installed.
|
installed.
|
||||||
|
|
||||||
- `>` *version*\
|
- `>` *version*
|
||||||
Only older versions of the package are available or installed.
|
Only older versions of the package are available or installed.
|
||||||
|
|
||||||
- `- ?`\
|
- `- ?`
|
||||||
No version of the package is available or installed.
|
No version of the package is available or installed.
|
||||||
|
|
||||||
- `--system`\
|
- `--system`
|
||||||
Print the `system` attribute of the derivation.
|
Print the `system` attribute of the derivation.
|
||||||
|
|
||||||
- `--drv-path`\
|
- `--drv-path`
|
||||||
Print the path of the store derivation.
|
Print the path of the store derivation.
|
||||||
|
|
||||||
- `--out-path`\
|
- `--out-path`
|
||||||
Print the output path of the derivation.
|
Print the output path of the derivation.
|
||||||
|
|
||||||
- `--description`\
|
- `--description`
|
||||||
Print a short (one-line) description of the derivation, if
|
Print a short (one-line) description of the derivation, if
|
||||||
available. The description is taken from the `meta.description`
|
available. The description is taken from the `meta.description`
|
||||||
attribute of the derivation.
|
attribute of the derivation.
|
||||||
|
|
||||||
- `--meta`\
|
- `--meta`
|
||||||
Print all of the meta-attributes of the derivation. This option is
|
Print all of the meta-attributes of the derivation. This option is
|
||||||
only available with `--xml` or `--json`.
|
only available with `--xml` or `--json`.
|
||||||
|
|
||||||
@@ -874,7 +874,7 @@ error: no generation older than the current (91) exists
|
|||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
|
|
||||||
- `NIX_PROFILE`\
|
- `NIX_PROFILE`
|
||||||
Location of the Nix profile. Defaults to the target of the symlink
|
Location of the Nix profile. Defaults to the target of the symlink
|
||||||
`~/.nix-profile`, if it exists, or `/nix/var/nix/profiles/default`
|
`~/.nix-profile`, if it exists, or `/nix/var/nix/profiles/default`
|
||||||
otherwise.
|
otherwise.
|
||||||
@@ -29,29 +29,29 @@ md5sum`.
|
|||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
- `--flat`\
|
- `--flat`
|
||||||
Print the cryptographic hash of the contents of each regular file
|
Print the cryptographic hash of the contents of each regular file
|
||||||
*path*. That is, do not compute the hash over the dump of *path*.
|
*path*. That is, do not compute the hash over the dump of *path*.
|
||||||
The result is identical to that produced by the GNU commands
|
The result is identical to that produced by the GNU commands
|
||||||
`md5sum` and `sha1sum`.
|
`md5sum` and `sha1sum`.
|
||||||
|
|
||||||
- `--base32`\
|
- `--base32`
|
||||||
Print the hash in a base-32 representation rather than hexadecimal.
|
Print the hash in a base-32 representation rather than hexadecimal.
|
||||||
This base-32 representation is more compact and can be used in Nix
|
This base-32 representation is more compact and can be used in Nix
|
||||||
expressions (such as in calls to `fetchurl`).
|
expressions (such as in calls to `fetchurl`).
|
||||||
|
|
||||||
- `--truncate`\
|
- `--truncate`
|
||||||
Truncate hashes longer than 160 bits (such as SHA-256) to 160 bits.
|
Truncate hashes longer than 160 bits (such as SHA-256) to 160 bits.
|
||||||
|
|
||||||
- `--type` *hashAlgo*\
|
- `--type` *hashAlgo*
|
||||||
Use the specified cryptographic hash algorithm, which can be one of
|
Use the specified cryptographic hash algorithm, which can be one of
|
||||||
`md5`, `sha1`, `sha256`, and `sha512`.
|
`md5`, `sha1`, `sha256`, and `sha512`.
|
||||||
|
|
||||||
- `--to-base16`\
|
- `--to-base16`
|
||||||
Don’t hash anything, but convert the base-32 hash representation
|
Don’t hash anything, but convert the base-32 hash representation
|
||||||
*hash* to hexadecimal.
|
*hash* to hexadecimal.
|
||||||
|
|
||||||
- `--to-base32`\
|
- `--to-base32`
|
||||||
Don’t hash anything, but convert the hexadecimal hash representation
|
Don’t hash anything, but convert the hexadecimal hash representation
|
||||||
*hash* to base-32.
|
*hash* to base-32.
|
||||||
|
|
||||||
|
|||||||
@@ -29,26 +29,26 @@ standard input.
|
|||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
- `--add-root` *path*\
|
- `--add-root` *path*
|
||||||
See the [corresponding option](nix-store.md) in `nix-store`.
|
See the [corresponding option](nix-store.md) in `nix-store`.
|
||||||
|
|
||||||
- `--parse`\
|
- `--parse`
|
||||||
Just parse the input files, and print their abstract syntax trees on
|
Just parse the input files, and print their abstract syntax trees on
|
||||||
standard output in ATerm format.
|
standard output in ATerm format.
|
||||||
|
|
||||||
- `--eval`\
|
- `--eval`
|
||||||
Just parse and evaluate the input files, and print the resulting
|
Just parse and evaluate the input files, and print the resulting
|
||||||
values on standard output. No instantiation of store derivations
|
values on standard output. No instantiation of store derivations
|
||||||
takes place.
|
takes place.
|
||||||
|
|
||||||
- `--find-file`\
|
- `--find-file`
|
||||||
Look up the given files in Nix’s search path (as specified by the
|
Look up the given files in Nix’s search path (as specified by the
|
||||||
`NIX_PATH` environment variable). If found, print the corresponding
|
`NIX_PATH` environment variable). If found, print the corresponding
|
||||||
absolute paths on standard output. For instance, if `NIX_PATH` is
|
absolute paths on standard output. For instance, if `NIX_PATH` is
|
||||||
`nixpkgs=/home/alice/nixpkgs`, then `nix-instantiate --find-file
|
`nixpkgs=/home/alice/nixpkgs`, then `nix-instantiate --find-file
|
||||||
nixpkgs/default.nix` will print `/home/alice/nixpkgs/default.nix`.
|
nixpkgs/default.nix` will print `/home/alice/nixpkgs/default.nix`.
|
||||||
|
|
||||||
- `--strict`\
|
- `--strict`
|
||||||
When used with `--eval`, recursively evaluate list elements and
|
When used with `--eval`, recursively evaluate list elements and
|
||||||
attributes. Normally, such sub-expressions are left unevaluated
|
attributes. Normally, such sub-expressions are left unevaluated
|
||||||
(since the Nix expression language is lazy).
|
(since the Nix expression language is lazy).
|
||||||
@@ -58,17 +58,17 @@ standard input.
|
|||||||
> This option can cause non-termination, because lazy data
|
> This option can cause non-termination, because lazy data
|
||||||
> structures can be infinitely large.
|
> structures can be infinitely large.
|
||||||
|
|
||||||
- `--json`\
|
- `--json`
|
||||||
When used with `--eval`, print the resulting value as an JSON
|
When used with `--eval`, print the resulting value as an JSON
|
||||||
representation of the abstract syntax tree rather than as an ATerm.
|
representation of the abstract syntax tree rather than as an ATerm.
|
||||||
|
|
||||||
- `--xml`\
|
- `--xml`
|
||||||
When used with `--eval`, print the resulting value as an XML
|
When used with `--eval`, print the resulting value as an XML
|
||||||
representation of the abstract syntax tree rather than as an ATerm.
|
representation of the abstract syntax tree rather than as an ATerm.
|
||||||
The schema is the same as that used by the [`toXML`
|
The schema is the same as that used by the [`toXML`
|
||||||
built-in](../expressions/builtins.md).
|
built-in](../expressions/builtins.md).
|
||||||
|
|
||||||
- `--read-write-mode`\
|
- `--read-write-mode`
|
||||||
When used with `--eval`, perform evaluation in read/write mode so
|
When used with `--eval`, perform evaluation in read/write mode so
|
||||||
nix language features that require it will still work (at the cost
|
nix language features that require it will still work (at the cost
|
||||||
of needing to do instantiation of every evaluated derivation). If
|
of needing to do instantiation of every evaluated derivation). If
|
||||||
|
|||||||
@@ -37,22 +37,22 @@ Nix store is also printed.
|
|||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
- `--type` *hashAlgo*\
|
- `--type` *hashAlgo*
|
||||||
Use the specified cryptographic hash algorithm, which can be one of
|
Use the specified cryptographic hash algorithm, which can be one of
|
||||||
`md5`, `sha1`, `sha256`, and `sha512`.
|
`md5`, `sha1`, `sha256`, and `sha512`.
|
||||||
|
|
||||||
- `--print-path`\
|
- `--print-path`
|
||||||
Print the store path of the downloaded file on standard output.
|
Print the store path of the downloaded file on standard output.
|
||||||
|
|
||||||
- `--unpack`\
|
- `--unpack`
|
||||||
Unpack the archive (which must be a tarball or zip file) and add the
|
Unpack the archive (which must be a tarball or zip file) and add the
|
||||||
result to the Nix store. The resulting hash can be used with
|
result to the Nix store. The resulting hash can be used with
|
||||||
functions such as Nixpkgs’s `fetchzip` or `fetchFromGitHub`.
|
functions such as Nixpkgs’s `fetchzip` or `fetchFromGitHub`.
|
||||||
|
|
||||||
- `--executable`\
|
- `--executable`
|
||||||
Set the executable bit on the downloaded file.
|
Set the executable bit on the downloaded file.
|
||||||
|
|
||||||
- `--name` *name*\
|
- `--name` *name*
|
||||||
Override the name of the file in the Nix store. By default, this is
|
Override the name of the file in the Nix store. By default, this is
|
||||||
`hash-basename`, where *basename* is the last component of *url*.
|
`hash-basename`, where *basename* is the last component of *url*.
|
||||||
Overriding the name is necessary when *basename* contains characters
|
Overriding the name is necessary when *basename* contains characters
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
[`--command` *cmd*]
|
[`--command` *cmd*]
|
||||||
[`--run` *cmd*]
|
[`--run` *cmd*]
|
||||||
[`--exclude` *regexp*]
|
[`--exclude` *regexp*]
|
||||||
[`--pure`]
|
[--pure]
|
||||||
[`--keep` *name*]
|
[--keep *name*]
|
||||||
{{`--packages` | `-p`} {*packages* | *expressions*} … | [*path*]}
|
{{`--packages` | `-p`} {*packages* | *expressions*} … | [*path*]}
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
@@ -54,7 +54,7 @@ All options not listed here are passed to `nix-store
|
|||||||
--realise`, except for `--arg` and `--attr` / `-A` which are passed to
|
--realise`, except for `--arg` and `--attr` / `-A` which are passed to
|
||||||
`nix-instantiate`.
|
`nix-instantiate`.
|
||||||
|
|
||||||
- `--command` *cmd*\
|
- `--command` *cmd*
|
||||||
In the environment of the derivation, run the shell command *cmd*.
|
In the environment of the derivation, run the shell command *cmd*.
|
||||||
This command is executed in an interactive shell. (Use `--run` to
|
This command is executed in an interactive shell. (Use `--run` to
|
||||||
use a non-interactive shell instead.) However, a call to `exit` is
|
use a non-interactive shell instead.) However, a call to `exit` is
|
||||||
@@ -64,34 +64,36 @@ All options not listed here are passed to `nix-store
|
|||||||
drop you into the interactive shell. This can be useful for doing
|
drop you into the interactive shell. This can be useful for doing
|
||||||
any additional initialisation.
|
any additional initialisation.
|
||||||
|
|
||||||
- `--run` *cmd*\
|
- `--run` *cmd*
|
||||||
Like `--command`, but executes the command in a non-interactive
|
Like `--command`, but executes the command in a non-interactive
|
||||||
shell. This means (among other things) that if you hit Ctrl-C while
|
shell. This means (among other things) that if you hit Ctrl-C while
|
||||||
the command is running, the shell exits.
|
the command is running, the shell exits.
|
||||||
|
|
||||||
- `--exclude` *regexp*\
|
- `--exclude` *regexp*
|
||||||
Do not build any dependencies whose store path matches the regular
|
Do not build any dependencies whose store path matches the regular
|
||||||
expression *regexp*. This option may be specified multiple times.
|
expression *regexp*. This option may be specified multiple times.
|
||||||
|
|
||||||
- `--pure`\
|
- `--pure`
|
||||||
If this flag is specified, the environment is almost entirely
|
If this flag is specified, the environment is almost entirely
|
||||||
cleared before the interactive shell is started, so you get an
|
cleared before the interactive shell is started, so you get an
|
||||||
environment that more closely corresponds to the “real” Nix build. A
|
environment that more closely corresponds to the “real” Nix build. A
|
||||||
few variables, in particular `HOME`, `USER` and `DISPLAY`, are
|
few variables, in particular `HOME`, `USER` and `DISPLAY`, are
|
||||||
retained.
|
retained. Note that (depending on your Bash
|
||||||
|
installation) `/etc/bashrc` is still sourced, so any variables set
|
||||||
|
there will affect the interactive shell.
|
||||||
|
|
||||||
- `--packages` / `-p` *packages*…\
|
- `--packages` / `-p` *packages*…
|
||||||
Set up an environment in which the specified packages are present.
|
Set up an environment in which the specified packages are present.
|
||||||
The command line arguments are interpreted as attribute names inside
|
The command line arguments are interpreted as attribute names inside
|
||||||
the Nix Packages collection. Thus, `nix-shell -p libjpeg openjdk`
|
the Nix Packages collection. Thus, `nix-shell -p libjpeg openjdk`
|
||||||
will start a shell in which the packages denoted by the attribute
|
will start a shell in which the packages denoted by the attribute
|
||||||
names `libjpeg` and `openjdk` are present.
|
names `libjpeg` and `openjdk` are present.
|
||||||
|
|
||||||
- `-i` *interpreter*\
|
- `-i` *interpreter*
|
||||||
The chained script interpreter to be invoked by `nix-shell`. Only
|
The chained script interpreter to be invoked by `nix-shell`. Only
|
||||||
applicable in `#!`-scripts (described below).
|
applicable in `#!`-scripts (described below).
|
||||||
|
|
||||||
- `--keep` *name*\
|
- `--keep` *name*
|
||||||
When a `--pure` shell is started, keep the listed environment
|
When a `--pure` shell is started, keep the listed environment
|
||||||
variables.
|
variables.
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ The following common options are supported:
|
|||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
|
|
||||||
- `NIX_BUILD_SHELL`\
|
- `NIX_BUILD_SHELL`
|
||||||
Shell used to start the interactive environment. Defaults to the
|
Shell used to start the interactive environment. Defaults to the
|
||||||
`bash` found in `PATH`.
|
`bash` found in `PATH`.
|
||||||
|
|
||||||
@@ -110,19 +112,13 @@ shell in which to build it:
|
|||||||
|
|
||||||
```console
|
```console
|
||||||
$ nix-shell '<nixpkgs>' -A pan
|
$ nix-shell '<nixpkgs>' -A pan
|
||||||
[nix-shell]$ eval ${unpackPhase:-unpackPhase}
|
[nix-shell]$ unpackPhase
|
||||||
[nix-shell]$ cd pan-*
|
[nix-shell]$ cd pan-*
|
||||||
[nix-shell]$ eval ${configurePhase:-configurePhase}
|
[nix-shell]$ configurePhase
|
||||||
[nix-shell]$ eval ${buildPhase:-buildPhase}
|
[nix-shell]$ buildPhase
|
||||||
[nix-shell]$ ./pan/gui/pan
|
[nix-shell]$ ./pan/gui/pan
|
||||||
```
|
```
|
||||||
|
|
||||||
The reason we use form `eval ${configurePhase:-configurePhase}` here is because
|
|
||||||
those packages that override these phases do so by exporting the overridden
|
|
||||||
values in the environment variable of the same name.
|
|
||||||
Here bash is being told to either evaluate the contents of 'configurePhase',
|
|
||||||
if it exists as a variable, otherwise evaluate the configurePhase function.
|
|
||||||
|
|
||||||
To clear the environment first, and do some additional automatic
|
To clear the environment first, and do some additional automatic
|
||||||
initialisation of the interactive shell:
|
initialisation of the interactive shell:
|
||||||
|
|
||||||
@@ -236,23 +232,22 @@ terraform apply
|
|||||||
> in a nix-shell shebang.
|
> in a nix-shell shebang.
|
||||||
|
|
||||||
Finally, using the merging of multiple nix-shell shebangs the following
|
Finally, using the merging of multiple nix-shell shebangs the following
|
||||||
Haskell script uses a specific branch of Nixpkgs/NixOS (the 20.03 stable
|
Haskell script uses a specific branch of Nixpkgs/NixOS (the 18.03 stable
|
||||||
branch):
|
branch):
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
#! /usr/bin/env nix-shell
|
#! /usr/bin/env nix-shell
|
||||||
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (ps: [ps.download-curl ps.tagsoup])"
|
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (ps: [ps.HTTP ps.tagsoup])"
|
||||||
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.03.tar.gz
|
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-18.03.tar.gz
|
||||||
|
|
||||||
import Network.Curl.Download
|
import Network.HTTP
|
||||||
import Text.HTML.TagSoup
|
import Text.HTML.TagSoup
|
||||||
import Data.Either
|
|
||||||
import Data.ByteString.Char8 (unpack)
|
|
||||||
|
|
||||||
-- Fetch nixos.org and print all hrefs.
|
-- Fetch nixos.org and print all hrefs.
|
||||||
main = do
|
main = do
|
||||||
resp <- openURI "https://nixos.org/"
|
resp <- Network.HTTP.simpleHTTP (getRequest "http://nixos.org/")
|
||||||
let tags = filter (isTagOpenName "a") $ parseTags $ unpack $ fromRight undefined resp
|
body <- getResponseBody resp
|
||||||
|
let tags = filter (isTagOpenName "a") $ parseTags body
|
||||||
let tags' = map (fromAttrib "href") tags
|
let tags' = map (fromAttrib "href") tags
|
||||||
mapM_ putStrLn $ filter (/= "") tags'
|
mapM_ putStrLn $ filter (/= "") tags'
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ This section lists the options that are common to all operations. These
|
|||||||
options are allowed for every subcommand, though they may not always
|
options are allowed for every subcommand, though they may not always
|
||||||
have an effect.
|
have an effect.
|
||||||
|
|
||||||
- `--add-root` *path*\
|
- `--add-root` *path*
|
||||||
Causes the result of a realisation (`--realise` and
|
Causes the result of a realisation (`--realise` and
|
||||||
`--force-realise`) to be registered as a root of the garbage
|
`--force-realise`) to be registered as a root of the garbage
|
||||||
collector. *path* will be created as a symlink to the resulting
|
collector. *path* will be created as a symlink to the resulting
|
||||||
@@ -79,22 +79,22 @@ paths. Realisation is a somewhat overloaded term:
|
|||||||
system). If the path is already valid, we are done immediately.
|
system). If the path is already valid, we are done immediately.
|
||||||
Otherwise, the path and any missing paths in its closure may be
|
Otherwise, the path and any missing paths in its closure may be
|
||||||
produced through substitutes. If there are no (successful)
|
produced through substitutes. If there are no (successful)
|
||||||
substitutes, realisation fails.
|
subsitutes, realisation fails.
|
||||||
|
|
||||||
The output path of each derivation is printed on standard output. (For
|
The output path of each derivation is printed on standard output. (For
|
||||||
non-derivations argument, the argument itself is printed.)
|
non-derivations argument, the argument itself is printed.)
|
||||||
|
|
||||||
The following flags are available:
|
The following flags are available:
|
||||||
|
|
||||||
- `--dry-run`\
|
- `--dry-run`
|
||||||
Print on standard error a description of what packages would be
|
Print on standard error a description of what packages would be
|
||||||
built or downloaded, without actually performing the operation.
|
built or downloaded, without actually performing the operation.
|
||||||
|
|
||||||
- `--ignore-unknown`\
|
- `--ignore-unknown`
|
||||||
If a non-derivation path does not have a substitute, then silently
|
If a non-derivation path does not have a substitute, then silently
|
||||||
ignore it.
|
ignore it.
|
||||||
|
|
||||||
- `--check`\
|
- `--check`
|
||||||
This option allows you to check whether a derivation is
|
This option allows you to check whether a derivation is
|
||||||
deterministic. It rebuilds the specified derivation and checks
|
deterministic. It rebuilds the specified derivation and checks
|
||||||
whether the result is bitwise-identical with the existing outputs,
|
whether the result is bitwise-identical with the existing outputs,
|
||||||
@@ -110,22 +110,22 @@ The following flags are available:
|
|||||||
|
|
||||||
Special exit codes:
|
Special exit codes:
|
||||||
|
|
||||||
- `100`\
|
- `100`
|
||||||
Generic build failure, the builder process returned with a non-zero
|
Generic build failure, the builder process returned with a non-zero
|
||||||
exit code.
|
exit code.
|
||||||
|
|
||||||
- `101`\
|
- `101`
|
||||||
Build timeout, the build was aborted because it did not complete
|
Build timeout, the build was aborted because it did not complete
|
||||||
within the specified `timeout`.
|
within the specified `timeout`.
|
||||||
|
|
||||||
- `102`\
|
- `102`
|
||||||
Hash mismatch, the build output was rejected because it does not
|
Hash mismatch, the build output was rejected because it does not
|
||||||
match the [`outputHash` attribute of the
|
match the [`outputHash` attribute of the
|
||||||
derivation](../expressions/advanced-attributes.md).
|
derivation](../expressions/advanced-attributes.md).
|
||||||
|
|
||||||
- `104`\
|
- `104`
|
||||||
Not deterministic, the build succeeded in check mode but the
|
Not deterministic, the build succeeded in check mode but the
|
||||||
resulting output is not binary reproducible.
|
resulting output is not binary reproducable.
|
||||||
|
|
||||||
With the `--keep-going` flag it's possible for multiple failures to
|
With the `--keep-going` flag it's possible for multiple failures to
|
||||||
occur, in this case the 1xx status codes are or combined using binary
|
occur, in this case the 1xx status codes are or combined using binary
|
||||||
@@ -170,7 +170,7 @@ access to a restricted ssh user.
|
|||||||
|
|
||||||
The following flags are available:
|
The following flags are available:
|
||||||
|
|
||||||
- `--write`\
|
- `--write`
|
||||||
Allow the connected client to request the realization of
|
Allow the connected client to request the realization of
|
||||||
derivations. In effect, this can be used to make the host act as a
|
derivations. In effect, this can be used to make the host act as a
|
||||||
remote builder.
|
remote builder.
|
||||||
@@ -200,18 +200,18 @@ reachable via file system references from a set of “roots”, are deleted.
|
|||||||
|
|
||||||
The following suboperations may be specified:
|
The following suboperations may be specified:
|
||||||
|
|
||||||
- `--print-roots`\
|
- `--print-roots`
|
||||||
This operation prints on standard output the set of roots used by
|
This operation prints on standard output the set of roots used by
|
||||||
the garbage collector.
|
the garbage collector.
|
||||||
|
|
||||||
- `--print-live`\
|
- `--print-live`
|
||||||
This operation prints on standard output the set of “live” store
|
This operation prints on standard output the set of “live” store
|
||||||
paths, which are all the store paths reachable from the roots. Live
|
paths, which are all the store paths reachable from the roots. Live
|
||||||
paths should never be deleted, since that would break consistency —
|
paths should never be deleted, since that would break consistency —
|
||||||
it would become possible that applications are installed that
|
it would become possible that applications are installed that
|
||||||
reference things that are no longer present in the store.
|
reference things that are no longer present in the store.
|
||||||
|
|
||||||
- `--print-dead`\
|
- `--print-dead`
|
||||||
This operation prints out on standard output the set of “dead” store
|
This operation prints out on standard output the set of “dead” store
|
||||||
paths, which is just the opposite of the set of live paths: any path
|
paths, which is just the opposite of the set of live paths: any path
|
||||||
in the store that is not live (with respect to the roots) is dead.
|
in the store that is not live (with respect to the roots) is dead.
|
||||||
@@ -219,7 +219,7 @@ The following suboperations may be specified:
|
|||||||
By default, all unreachable paths are deleted. The following options
|
By default, all unreachable paths are deleted. The following options
|
||||||
control what gets deleted and in what order:
|
control what gets deleted and in what order:
|
||||||
|
|
||||||
- `--max-freed` *bytes*\
|
- `--max-freed` *bytes*
|
||||||
Keep deleting paths until at least *bytes* bytes have been deleted,
|
Keep deleting paths until at least *bytes* bytes have been deleted,
|
||||||
then stop. The argument *bytes* can be followed by the
|
then stop. The argument *bytes* can be followed by the
|
||||||
multiplicative suffix `K`, `M`, `G` or `T`, denoting KiB, MiB, GiB
|
multiplicative suffix `K`, `M`, `G` or `T`, denoting KiB, MiB, GiB
|
||||||
@@ -300,22 +300,22 @@ symlink.
|
|||||||
|
|
||||||
## Common query options
|
## Common query options
|
||||||
|
|
||||||
- `--use-output`; `-u`\
|
- `--use-output`; `-u`
|
||||||
For each argument to the query that is a store derivation, apply the
|
For each argument to the query that is a store derivation, apply the
|
||||||
query to the output path of the derivation instead.
|
query to the output path of the derivation instead.
|
||||||
|
|
||||||
- `--force-realise`; `-f`\
|
- `--force-realise`; `-f`
|
||||||
Realise each argument to the query first (see [`nix-store
|
Realise each argument to the query first (see [`nix-store
|
||||||
--realise`](#operation---realise)).
|
--realise`](#operation---realise)).
|
||||||
|
|
||||||
## Queries
|
## Queries
|
||||||
|
|
||||||
- `--outputs`\
|
- `--outputs`
|
||||||
Prints out the [output paths](../glossary.md) of the store
|
Prints out the [output paths](../glossary.md) of the store
|
||||||
derivations *paths*. These are the paths that will be produced when
|
derivations *paths*. These are the paths that will be produced when
|
||||||
the derivation is built.
|
the derivation is built.
|
||||||
|
|
||||||
- `--requisites`; `-R`\
|
- `--requisites`; `-R`
|
||||||
Prints out the [closure](../glossary.md) of the store path *paths*.
|
Prints out the [closure](../glossary.md) of the store path *paths*.
|
||||||
|
|
||||||
This query has one option:
|
This query has one option:
|
||||||
@@ -332,31 +332,31 @@ symlink.
|
|||||||
dependencies) is obtained by distributing the closure of a store
|
dependencies) is obtained by distributing the closure of a store
|
||||||
derivation and specifying the option `--include-outputs`.
|
derivation and specifying the option `--include-outputs`.
|
||||||
|
|
||||||
- `--references`\
|
- `--references`
|
||||||
Prints the set of [references](../glossary.md) of the store paths
|
Prints the set of [references](../glossary.md) of the store paths
|
||||||
*paths*, that is, their immediate dependencies. (For *all*
|
*paths*, that is, their immediate dependencies. (For *all*
|
||||||
dependencies, use `--requisites`.)
|
dependencies, use `--requisites`.)
|
||||||
|
|
||||||
- `--referrers`\
|
- `--referrers`
|
||||||
Prints the set of *referrers* of the store paths *paths*, that is,
|
Prints the set of *referrers* of the store paths *paths*, that is,
|
||||||
the store paths currently existing in the Nix store that refer to
|
the store paths currently existing in the Nix store that refer to
|
||||||
one of *paths*. Note that contrary to the references, the set of
|
one of *paths*. Note that contrary to the references, the set of
|
||||||
referrers is not constant; it can change as store paths are added or
|
referrers is not constant; it can change as store paths are added or
|
||||||
removed.
|
removed.
|
||||||
|
|
||||||
- `--referrers-closure`\
|
- `--referrers-closure`
|
||||||
Prints the closure of the set of store paths *paths* under the
|
Prints the closure of the set of store paths *paths* under the
|
||||||
referrers relation; that is, all store paths that directly or
|
referrers relation; that is, all store paths that directly or
|
||||||
indirectly refer to one of *paths*. These are all the path currently
|
indirectly refer to one of *paths*. These are all the path currently
|
||||||
in the Nix store that are dependent on *paths*.
|
in the Nix store that are dependent on *paths*.
|
||||||
|
|
||||||
- `--deriver`; `-d`\
|
- `--deriver`; `-d`
|
||||||
Prints the [deriver](../glossary.md) of the store paths *paths*. If
|
Prints the [deriver](../glossary.md) of the store paths *paths*. If
|
||||||
the path has no deriver (e.g., if it is a source file), or if the
|
the path has no deriver (e.g., if it is a source file), or if the
|
||||||
deriver is not known (e.g., in the case of a binary-only
|
deriver is not known (e.g., in the case of a binary-only
|
||||||
deployment), the string `unknown-deriver` is printed.
|
deployment), the string `unknown-deriver` is printed.
|
||||||
|
|
||||||
- `--graph`\
|
- `--graph`
|
||||||
Prints the references graph of the store paths *paths* in the format
|
Prints the references graph of the store paths *paths* in the format
|
||||||
of the `dot` tool of AT\&T's [Graphviz
|
of the `dot` tool of AT\&T's [Graphviz
|
||||||
package](http://www.graphviz.org/). This can be used to visualise
|
package](http://www.graphviz.org/). This can be used to visualise
|
||||||
@@ -364,39 +364,39 @@ symlink.
|
|||||||
this to a store derivation. To obtain a runtime dependency graph,
|
this to a store derivation. To obtain a runtime dependency graph,
|
||||||
apply it to an output path.
|
apply it to an output path.
|
||||||
|
|
||||||
- `--tree`\
|
- `--tree`
|
||||||
Prints the references graph of the store paths *paths* as a nested
|
Prints the references graph of the store paths *paths* as a nested
|
||||||
ASCII tree. References are ordered by descending closure size; this
|
ASCII tree. References are ordered by descending closure size; this
|
||||||
tends to flatten the tree, making it more readable. The query only
|
tends to flatten the tree, making it more readable. The query only
|
||||||
recurses into a store path when it is first encountered; this
|
recurses into a store path when it is first encountered; this
|
||||||
prevents a blowup of the tree representation of the graph.
|
prevents a blowup of the tree representation of the graph.
|
||||||
|
|
||||||
- `--graphml`\
|
- `--graphml`
|
||||||
Prints the references graph of the store paths *paths* in the
|
Prints the references graph of the store paths *paths* in the
|
||||||
[GraphML](http://graphml.graphdrawing.org/) file format. This can be
|
[GraphML](http://graphml.graphdrawing.org/) file format. This can be
|
||||||
used to visualise dependency graphs. To obtain a build-time
|
used to visualise dependency graphs. To obtain a build-time
|
||||||
dependency graph, apply this to a store derivation. To obtain a
|
dependency graph, apply this to a store derivation. To obtain a
|
||||||
runtime dependency graph, apply it to an output path.
|
runtime dependency graph, apply it to an output path.
|
||||||
|
|
||||||
- `--binding` *name*; `-b` *name*\
|
- `--binding` *name*; `-b` *name*
|
||||||
Prints the value of the attribute *name* (i.e., environment
|
Prints the value of the attribute *name* (i.e., environment
|
||||||
variable) of the store derivations *paths*. It is an error for a
|
variable) of the store derivations *paths*. It is an error for a
|
||||||
derivation to not have the specified attribute.
|
derivation to not have the specified attribute.
|
||||||
|
|
||||||
- `--hash`\
|
- `--hash`
|
||||||
Prints the SHA-256 hash of the contents of the store paths *paths*
|
Prints the SHA-256 hash of the contents of the store paths *paths*
|
||||||
(that is, the hash of the output of `nix-store --dump` on the given
|
(that is, the hash of the output of `nix-store --dump` on the given
|
||||||
paths). Since the hash is stored in the Nix database, this is a fast
|
paths). Since the hash is stored in the Nix database, this is a fast
|
||||||
operation.
|
operation.
|
||||||
|
|
||||||
- `--size`\
|
- `--size`
|
||||||
Prints the size in bytes of the contents of the store paths *paths*
|
Prints the size in bytes of the contents of the store paths *paths*
|
||||||
— to be precise, the size of the output of `nix-store --dump` on
|
— to be precise, the size of the output of `nix-store --dump` on
|
||||||
the given paths. Note that the actual disk space required by the
|
the given paths. Note that the actual disk space required by the
|
||||||
store paths may be higher, especially on filesystems with large
|
store paths may be higher, especially on filesystems with large
|
||||||
cluster sizes.
|
cluster sizes.
|
||||||
|
|
||||||
- `--roots`\
|
- `--roots`
|
||||||
Prints the garbage collector roots that point, directly or
|
Prints the garbage collector roots that point, directly or
|
||||||
indirectly, at the store paths *paths*.
|
indirectly, at the store paths *paths*.
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ public url or broke since the download expression was written.
|
|||||||
|
|
||||||
This operation has the following options:
|
This operation has the following options:
|
||||||
|
|
||||||
- `--recursive`\
|
- `--recursive`
|
||||||
Use recursive instead of flat hashing mode, used when adding
|
Use recursive instead of flat hashing mode, used when adding
|
||||||
directories to the store.
|
directories to the store.
|
||||||
|
|
||||||
@@ -540,14 +540,14 @@ being modified by non-Nix tools, or of bugs in Nix itself.
|
|||||||
|
|
||||||
This operation has the following options:
|
This operation has the following options:
|
||||||
|
|
||||||
- `--check-contents`\
|
- `--check-contents`
|
||||||
Checks that the contents of every valid store path has not been
|
Checks that the contents of every valid store path has not been
|
||||||
altered by computing a SHA-256 hash of the contents and comparing it
|
altered by computing a SHA-256 hash of the contents and comparing it
|
||||||
with the hash stored in the Nix database at build time. Paths that
|
with the hash stored in the Nix database at build time. Paths that
|
||||||
have been modified are printed out. For large stores,
|
have been modified are printed out. For large stores,
|
||||||
`--check-contents` is obviously quite slow.
|
`--check-contents` is obviously quite slow.
|
||||||
|
|
||||||
- `--repair`\
|
- `--repair`
|
||||||
If any valid path is missing from the store, or (if
|
If any valid path is missing from the store, or (if
|
||||||
`--check-contents` is given) the contents of a valid path has been
|
`--check-contents` is given) the contents of a valid path has been
|
||||||
modified, then try to repair the path by redownloading it. See
|
modified, then try to repair the path by redownloading it. See
|
||||||
|
|||||||
@@ -2,56 +2,56 @@
|
|||||||
|
|
||||||
Most Nix commands accept the following command-line options:
|
Most Nix commands accept the following command-line options:
|
||||||
|
|
||||||
- `--help`\
|
- `--help`
|
||||||
Prints out a summary of the command syntax and exits.
|
Prints out a summary of the command syntax and exits.
|
||||||
|
|
||||||
- `--version`\
|
- `--version`
|
||||||
Prints out the Nix version number on standard output and exits.
|
Prints out the Nix version number on standard output and exits.
|
||||||
|
|
||||||
- `--verbose` / `-v`\
|
- `--verbose` / `-v`
|
||||||
Increases the level of verbosity of diagnostic messages printed on
|
Increases the level of verbosity of diagnostic messages printed on
|
||||||
standard error. For each Nix operation, the information printed on
|
standard error. For each Nix operation, the information printed on
|
||||||
standard output is well-defined; any diagnostic information is
|
standard output is well-defined; any diagnostic information is
|
||||||
printed on standard error, never on standard output.
|
printed on standard error, never on standard output.
|
||||||
|
|
||||||
This option may be specified repeatedly. Currently, the following
|
This option may be specified repeatedly. Currently, the following
|
||||||
verbosity levels exist:
|
verbosity levels exist:
|
||||||
|
|
||||||
- 0\
|
- 0
|
||||||
“Errors only”: only print messages explaining why the Nix
|
“Errors only”: only print messages explaining why the Nix
|
||||||
invocation failed.
|
invocation failed.
|
||||||
|
|
||||||
- 1\
|
- 1
|
||||||
“Informational”: print *useful* messages about what Nix is
|
“Informational”: print *useful* messages about what Nix is
|
||||||
doing. This is the default.
|
doing. This is the default.
|
||||||
|
|
||||||
- 2\
|
- 2
|
||||||
“Talkative”: print more informational messages.
|
“Talkative”: print more informational messages.
|
||||||
|
|
||||||
- 3\
|
- 3
|
||||||
“Chatty”: print even more informational messages.
|
“Chatty”: print even more informational messages.
|
||||||
|
|
||||||
- 4\
|
- 4
|
||||||
“Debug”: print debug information.
|
“Debug”: print debug information.
|
||||||
|
|
||||||
- 5\
|
- 5
|
||||||
“Vomit”: print vast amounts of debug information.
|
“Vomit”: print vast amounts of debug information.
|
||||||
|
|
||||||
- `--quiet`\
|
- `--quiet`
|
||||||
Decreases the level of verbosity of diagnostic messages printed on
|
Decreases the level of verbosity of diagnostic messages printed on
|
||||||
standard error. This is the inverse option to `-v` / `--verbose`.
|
standard error. This is the inverse option to `-v` / `--verbose`.
|
||||||
|
|
||||||
This option may be specified repeatedly. See the previous verbosity
|
This option may be specified repeatedly. See the previous verbosity
|
||||||
levels list.
|
levels list.
|
||||||
|
|
||||||
- `--log-format` *format*\
|
- `--log-format` *format*
|
||||||
This option can be used to change the output of the log format, with
|
This option can be used to change the output of the log format, with
|
||||||
*format* being one of:
|
*format* being one of:
|
||||||
|
|
||||||
- raw\
|
- raw
|
||||||
This is the raw format, as outputted by nix-build.
|
This is the raw format, as outputted by nix-build.
|
||||||
|
|
||||||
- internal-json\
|
- internal-json
|
||||||
Outputs the logs in a structured manner.
|
Outputs the logs in a structured manner.
|
||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
@@ -60,30 +60,30 @@ Most Nix commands accept the following command-line options:
|
|||||||
> the error-messages (namely of the `msg`-field) can change
|
> the error-messages (namely of the `msg`-field) can change
|
||||||
> between releases.
|
> between releases.
|
||||||
|
|
||||||
- bar\
|
- bar
|
||||||
Only display a progress bar during the builds.
|
Only display a progress bar during the builds.
|
||||||
|
|
||||||
- bar-with-logs\
|
- bar-with-logs
|
||||||
Display the raw logs, with the progress bar at the bottom.
|
Display the raw logs, with the progress bar at the bottom.
|
||||||
|
|
||||||
- `--no-build-output` / `-Q`\
|
- `--no-build-output` / `-Q`
|
||||||
By default, output written by builders to standard output and
|
By default, output written by builders to standard output and
|
||||||
standard error is echoed to the Nix command's standard error. This
|
standard error is echoed to the Nix command's standard error. This
|
||||||
option suppresses this behaviour. Note that the builder's standard
|
option suppresses this behaviour. Note that the builder's standard
|
||||||
output and error are always written to a log file in
|
output and error are always written to a log file in
|
||||||
`prefix/nix/var/log/nix`.
|
`prefix/nix/var/log/nix`.
|
||||||
|
|
||||||
- `--max-jobs` / `-j` *number*\
|
- `--max-jobs` / `-j` *number*
|
||||||
Sets the maximum number of build jobs that Nix will perform in
|
Sets the maximum number of build jobs that Nix will perform in
|
||||||
parallel to the specified number. Specify `auto` to use the number
|
parallel to the specified number. Specify `auto` to use the number
|
||||||
of CPUs in the system. The default is specified by the `max-jobs`
|
of CPUs in the system. The default is specified by the `max-jobs`
|
||||||
configuration setting, which itself defaults to `1`. A higher
|
configuration setting, which itself defaults to `1`. A higher
|
||||||
value is useful on SMP systems or to exploit I/O latency.
|
value is useful on SMP systems or to exploit I/O latency.
|
||||||
|
|
||||||
Setting it to `0` disallows building on the local machine, which is
|
Setting it to `0` disallows building on the local machine, which is
|
||||||
useful when you want builds to happen only on remote builders.
|
useful when you want builds to happen only on remote builders.
|
||||||
|
|
||||||
- `--cores`\
|
- `--cores`
|
||||||
Sets the value of the `NIX_BUILD_CORES` environment variable in
|
Sets the value of the `NIX_BUILD_CORES` environment variable in
|
||||||
the invocation of builders. Builders can use this variable at
|
the invocation of builders. Builders can use this variable at
|
||||||
their discretion to control the maximum amount of parallelism. For
|
their discretion to control the maximum amount of parallelism. For
|
||||||
@@ -94,18 +94,18 @@ Most Nix commands accept the following command-line options:
|
|||||||
means that the builder should use all available CPU cores in the
|
means that the builder should use all available CPU cores in the
|
||||||
system.
|
system.
|
||||||
|
|
||||||
- `--max-silent-time`\
|
- `--max-silent-time`
|
||||||
Sets the maximum number of seconds that a builder can go without
|
Sets the maximum number of seconds that a builder can go without
|
||||||
producing any data on standard output or standard error. The
|
producing any data on standard output or standard error. The
|
||||||
default is specified by the `max-silent-time` configuration
|
default is specified by the `max-silent-time` configuration
|
||||||
setting. `0` means no time-out.
|
setting. `0` means no time-out.
|
||||||
|
|
||||||
- `--timeout`\
|
- `--timeout`
|
||||||
Sets the maximum number of seconds that a builder can run. The
|
Sets the maximum number of seconds that a builder can run. The
|
||||||
default is specified by the `timeout` configuration setting. `0`
|
default is specified by the `timeout` configuration setting. `0`
|
||||||
means no timeout.
|
means no timeout.
|
||||||
|
|
||||||
- `--keep-going` / `-k`\
|
- `--keep-going` / `-k`
|
||||||
Keep going in case of failed builds, to the greatest extent
|
Keep going in case of failed builds, to the greatest extent
|
||||||
possible. That is, if building an input of some derivation fails,
|
possible. That is, if building an input of some derivation fails,
|
||||||
Nix will still build the other inputs, but not the derivation
|
Nix will still build the other inputs, but not the derivation
|
||||||
@@ -113,17 +113,17 @@ Most Nix commands accept the following command-line options:
|
|||||||
for builds of substitutes), possibly killing builds in progress (in
|
for builds of substitutes), possibly killing builds in progress (in
|
||||||
case of parallel or distributed builds).
|
case of parallel or distributed builds).
|
||||||
|
|
||||||
- `--keep-failed` / `-K`\
|
- `--keep-failed` / `-K`
|
||||||
Specifies that in case of a build failure, the temporary directory
|
Specifies that in case of a build failure, the temporary directory
|
||||||
(usually in `/tmp`) in which the build takes place should not be
|
(usually in `/tmp`) in which the build takes place should not be
|
||||||
deleted. The path of the build directory is printed as an
|
deleted. The path of the build directory is printed as an
|
||||||
informational message.
|
informational message.
|
||||||
|
|
||||||
- `--fallback`\
|
- `--fallback`
|
||||||
Whenever Nix attempts to build a derivation for which substitutes
|
Whenever Nix attempts to build a derivation for which substitutes
|
||||||
are known for each output path, but realising the output paths
|
are known for each output path, but realising the output paths
|
||||||
through the substitutes fails, fall back on building the derivation.
|
through the substitutes fails, fall back on building the derivation.
|
||||||
|
|
||||||
The most common scenario in which this is useful is when we have
|
The most common scenario in which this is useful is when we have
|
||||||
registered substitutes in order to perform binary distribution from,
|
registered substitutes in order to perform binary distribution from,
|
||||||
say, a network repository. If the repository is down, the
|
say, a network repository. If the repository is down, the
|
||||||
@@ -134,12 +134,21 @@ Most Nix commands accept the following command-line options:
|
|||||||
failure in obtaining the substitutes to lead to a full build from
|
failure in obtaining the substitutes to lead to a full build from
|
||||||
source (with the related consumption of resources).
|
source (with the related consumption of resources).
|
||||||
|
|
||||||
- `--readonly-mode`\
|
- `--no-build-hook`
|
||||||
|
Disables the build hook mechanism. This allows to ignore remote
|
||||||
|
builders if they are setup on the machine.
|
||||||
|
|
||||||
|
It's useful in cases where the bandwidth between the client and the
|
||||||
|
remote builder is too low. In that case it can take more time to
|
||||||
|
upload the sources to the remote builder and fetch back the result
|
||||||
|
than to do the computation locally.
|
||||||
|
|
||||||
|
- `--readonly-mode`
|
||||||
When this option is used, no attempt is made to open the Nix
|
When this option is used, no attempt is made to open the Nix
|
||||||
database. Most Nix operations do need database access, so those
|
database. Most Nix operations do need database access, so those
|
||||||
operations will fail.
|
operations will fail.
|
||||||
|
|
||||||
- `--arg` *name* *value*\
|
- `--arg` *name* *value*
|
||||||
This option is accepted by `nix-env`, `nix-instantiate`,
|
This option is accepted by `nix-env`, `nix-instantiate`,
|
||||||
`nix-shell` and `nix-build`. When evaluating Nix expressions, the
|
`nix-shell` and `nix-build`. When evaluating Nix expressions, the
|
||||||
expression evaluator will automatically try to call functions that
|
expression evaluator will automatically try to call functions that
|
||||||
@@ -151,7 +160,7 @@ Most Nix commands accept the following command-line options:
|
|||||||
override a default value). That is, if the evaluator encounters a
|
override a default value). That is, if the evaluator encounters a
|
||||||
function with an argument named *name*, it will call it with value
|
function with an argument named *name*, it will call it with value
|
||||||
*value*.
|
*value*.
|
||||||
|
|
||||||
For instance, the top-level `default.nix` in Nixpkgs is actually a
|
For instance, the top-level `default.nix` in Nixpkgs is actually a
|
||||||
function:
|
function:
|
||||||
|
|
||||||
@@ -161,7 +170,7 @@ Most Nix commands accept the following command-line options:
|
|||||||
...
|
...
|
||||||
}: ...
|
}: ...
|
||||||
```
|
```
|
||||||
|
|
||||||
So if you call this Nix expression (e.g., when you do `nix-env -i
|
So if you call this Nix expression (e.g., when you do `nix-env -i
|
||||||
pkgname`), the function will be called automatically using the
|
pkgname`), the function will be called automatically using the
|
||||||
value [`builtins.currentSystem`](../expressions/builtins.md) for
|
value [`builtins.currentSystem`](../expressions/builtins.md) for
|
||||||
@@ -170,13 +179,13 @@ Most Nix commands accept the following command-line options:
|
|||||||
since the argument is a Nix string literal, you have to escape the
|
since the argument is a Nix string literal, you have to escape the
|
||||||
quotes.)
|
quotes.)
|
||||||
|
|
||||||
- `--argstr` *name* *value*\
|
- `--argstr` *name* *value*
|
||||||
This option is like `--arg`, only the value is not a Nix
|
This option is like `--arg`, only the value is not a Nix
|
||||||
expression but a string. So instead of `--arg system
|
expression but a string. So instead of `--arg system
|
||||||
\"i686-linux\"` (the outer quotes are to keep the shell happy) you
|
\"i686-linux\"` (the outer quotes are to keep the shell happy) you
|
||||||
can say `--argstr system i686-linux`.
|
can say `--argstr system i686-linux`.
|
||||||
|
|
||||||
- `--attr` / `-A` *attrPath*\
|
- `--attr` / `-A` *attrPath*
|
||||||
Select an attribute from the top-level Nix expression being
|
Select an attribute from the top-level Nix expression being
|
||||||
evaluated. (`nix-env`, `nix-instantiate`, `nix-build` and
|
evaluated. (`nix-env`, `nix-instantiate`, `nix-build` and
|
||||||
`nix-shell` only.) The *attribute path* *attrPath* is a sequence
|
`nix-shell` only.) The *attribute path* *attrPath* is a sequence
|
||||||
@@ -185,34 +194,34 @@ Most Nix commands accept the following command-line options:
|
|||||||
would cause the expression `e.xorg.xorgserver` to be used. See
|
would cause the expression `e.xorg.xorgserver` to be used. See
|
||||||
[`nix-env --install`](nix-env.md#operation---install) for some
|
[`nix-env --install`](nix-env.md#operation---install) for some
|
||||||
concrete examples.
|
concrete examples.
|
||||||
|
|
||||||
In addition to attribute names, you can also specify array indices.
|
In addition to attribute names, you can also specify array indices.
|
||||||
For instance, the attribute path `foo.3.bar` selects the `bar`
|
For instance, the attribute path `foo.3.bar` selects the `bar`
|
||||||
attribute of the fourth element of the array in the `foo` attribute
|
attribute of the fourth element of the array in the `foo` attribute
|
||||||
of the top-level expression.
|
of the top-level expression.
|
||||||
|
|
||||||
- `--expr` / `-E`\
|
- `--expr` / `-E`
|
||||||
Interpret the command line arguments as a list of Nix expressions to
|
Interpret the command line arguments as a list of Nix expressions to
|
||||||
be parsed and evaluated, rather than as a list of file names of Nix
|
be parsed and evaluated, rather than as a list of file names of Nix
|
||||||
expressions. (`nix-instantiate`, `nix-build` and `nix-shell` only.)
|
expressions. (`nix-instantiate`, `nix-build` and `nix-shell` only.)
|
||||||
|
|
||||||
For `nix-shell`, this option is commonly used to give you a shell in
|
For `nix-shell`, this option is commonly used to give you a shell in
|
||||||
which you can build the packages returned by the expression. If you
|
which you can build the packages returned by the expression. If you
|
||||||
want to get a shell which contain the *built* packages ready for
|
want to get a shell which contain the *built* packages ready for
|
||||||
use, give your expression to the `nix-shell -p` convenience flag
|
use, give your expression to the `nix-shell -p` convenience flag
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
- `-I` *path*\
|
- `-I` *path*
|
||||||
Add a path to the Nix expression search path. This option may be
|
Add a path to the Nix expression search path. This option may be
|
||||||
given multiple times. See the `NIX_PATH` environment variable for
|
given multiple times. See the `NIX_PATH` environment variable for
|
||||||
information on the semantics of the Nix search path. Paths added
|
information on the semantics of the Nix search path. Paths added
|
||||||
through `-I` take precedence over `NIX_PATH`.
|
through `-I` take precedence over `NIX_PATH`.
|
||||||
|
|
||||||
- `--option` *name* *value*\
|
- `--option` *name* *value*
|
||||||
Set the Nix configuration option *name* to *value*. This overrides
|
Set the Nix configuration option *name* to *value*. This overrides
|
||||||
settings in the Nix configuration file (see nix.conf5).
|
settings in the Nix configuration file (see nix.conf5).
|
||||||
|
|
||||||
- `--repair`\
|
- `--repair`
|
||||||
Fix corrupted or missing store paths by redownloading or rebuilding
|
Fix corrupted or missing store paths by redownloading or rebuilding
|
||||||
them. Note that this is slow because it requires computing a
|
them. Note that this is slow because it requires computing a
|
||||||
cryptographic hash of the contents of every path in the closure of
|
cryptographic hash of the contents of every path in the closure of
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
Purpose of this document is to provide a clear direction to **help design
|
Purpose of this document is to provide a clear direction to **help design
|
||||||
delightful command line** experience. This document contains guidelines to
|
delightful command line** experience. This document contain guidelines to
|
||||||
follow to ensure a consistent and approachable user experience.
|
follow to ensure a consistent and approachable user experience.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
@@ -115,7 +115,7 @@ The rules are:
|
|||||||
|
|
||||||
- Help is shown by using `--help` or `help` command (eg `nix` `--``help` or
|
- Help is shown by using `--help` or `help` command (eg `nix` `--``help` or
|
||||||
`nix help`).
|
`nix help`).
|
||||||
- For non-COMMANDs (eg. `nix` `--``help` and `nix store` `--``help`) we **show
|
- For non-COMMANDs (eg. `nix` `--``help` and `nix store` `--``help`) we **show
|
||||||
a summary** of most common use cases. Summary is presented on the STDOUT
|
a summary** of most common use cases. Summary is presented on the STDOUT
|
||||||
without any use of PAGER.
|
without any use of PAGER.
|
||||||
- For COMMANDs (eg. `nix init` `--``help` or `nix help init`) we display the
|
- For COMMANDs (eg. `nix init` `--``help` or `nix help init`) we display the
|
||||||
@@ -230,8 +230,8 @@ Now **Learn** part of the output is where you educate users. You should only
|
|||||||
show it when you know that a build will take some time and not annoy users of
|
show it when you know that a build will take some time and not annoy users of
|
||||||
the builds that take only few seconds.
|
the builds that take only few seconds.
|
||||||
|
|
||||||
Every feature like this should go through an intensive review and testing to
|
Every feature like this should go though a intensive review and testing to
|
||||||
collect as much feedback as possible and to fine tune every little detail. If
|
collect as much a feedback as possible and to fine tune every little detail. If
|
||||||
done right this can be an awesome features beginners and advance users will
|
done right this can be an awesome features beginners and advance users will
|
||||||
love, but if not done perfectly it will annoy users and leave bad impression.
|
love, but if not done perfectly it will annoy users and leave bad impression.
|
||||||
|
|
||||||
@@ -272,11 +272,11 @@ not know which `ARGUMENTS` and `OPTIONS` are required or which values are
|
|||||||
possible for those options.
|
possible for those options.
|
||||||
|
|
||||||
In cases, the user might not provide the input or they provide wrong input,
|
In cases, the user might not provide the input or they provide wrong input,
|
||||||
rather than show the error, prompt a user with an option to find and select
|
rather then show the error, prompt a user with an option to find and select
|
||||||
correct input (see examples).
|
correct input (see examples).
|
||||||
|
|
||||||
Prompting is of course not required when TTY is not attached to STDIN. This
|
Prompting is of course not required when TTY is not attached to STDIN. This
|
||||||
would mean that scripts won't need to handle prompt, but rather handle errors.
|
would mean that scripts wont need to handle prompt, but rather handle errors.
|
||||||
|
|
||||||
A place to use prompt and provide user with interactive select
|
A place to use prompt and provide user with interactive select
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ going to happen.
|
|||||||
```shell
|
```shell
|
||||||
$ nix build --option substitutors https://cache.example.org
|
$ nix build --option substitutors https://cache.example.org
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Warning! A security related question needs to be answered.
|
Warning! A security related question need to be answered.
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
The following substitutors will be used to in `my-project`:
|
The following substitutors will be used to in `my-project`:
|
||||||
- https://cache.example.org
|
- https://cache.example.org
|
||||||
@@ -311,14 +311,14 @@ $ nix build --option substitutors https://cache.example.org
|
|||||||
|
|
||||||
# Output
|
# Output
|
||||||
|
|
||||||
Terminal output can be quite limiting in many ways. Which should force us to
|
Terminal output can be quite limiting in many ways. Which should forces us to
|
||||||
think about the experience even more. As with every design the output is a
|
think about the experience even more. As with every design the output is a
|
||||||
compromise between being terse and being verbose, between showing help to
|
compromise between being terse and being verbose, between showing help to
|
||||||
beginners and annoying advance users. For this it is important that we know
|
beginners and annoying advance users. For this it is important that we know
|
||||||
what are the priorities.
|
what are the priorities.
|
||||||
|
|
||||||
Nix command line should be first and foremost written with beginners in mind.
|
Nix command line should be first and foremost written with beginners in mind.
|
||||||
But users won't stay beginners for long and what was once useful might quickly
|
But users wont stay beginners for long and what was once useful might quickly
|
||||||
become annoying. There is no golden rule that we can give in this guideline
|
become annoying. There is no golden rule that we can give in this guideline
|
||||||
that would make it easier how to draw a line and find best compromise.
|
that would make it easier how to draw a line and find best compromise.
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ can, with a few key strokes, be changed into and advance introspection tool.
|
|||||||
|
|
||||||
### Progress
|
### Progress
|
||||||
|
|
||||||
For longer running commands we should provide and overview the progress.
|
For longer running commands we should provide and overview of the progress.
|
||||||
This is shown best in `nix build` example:
|
This is shown best in `nix build` example:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -553,7 +553,7 @@ going to happen.
|
|||||||
```shell
|
```shell
|
||||||
$ nix build --option substitutors https://cache.example.org
|
$ nix build --option substitutors https://cache.example.org
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Warning! A security related question needs to be answered.
|
Warning! A security related question need to be answered.
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
The following substitutors will be used to in `my-project`:
|
The following substitutors will be used to in `my-project`:
|
||||||
- https://cache.example.org
|
- https://cache.example.org
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
Derivations can declare some infrequently used optional attributes.
|
Derivations can declare some infrequently used optional attributes.
|
||||||
|
|
||||||
- `allowedReferences`\
|
- `allowedReferences`
|
||||||
The optional attribute `allowedReferences` specifies a list of legal
|
The optional attribute `allowedReferences` specifies a list of legal
|
||||||
references (dependencies) of the output of the builder. For example,
|
references (dependencies) of the output of the builder. For example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
allowedReferences = [];
|
allowedReferences = [];
|
||||||
```
|
```
|
||||||
|
|
||||||
enforces that the output of a derivation cannot have any runtime
|
enforces that the output of a derivation cannot have any runtime
|
||||||
dependencies on its inputs. To allow an output to have a runtime
|
dependencies on its inputs. To allow an output to have a runtime
|
||||||
dependency on itself, use `"out"` as a list item. This is used in
|
dependency on itself, use `"out"` as a list item. This is used in
|
||||||
@@ -17,45 +17,45 @@ Derivations can declare some infrequently used optional attributes.
|
|||||||
booting Linux don’t have accidental dependencies on other paths in
|
booting Linux don’t have accidental dependencies on other paths in
|
||||||
the Nix store.
|
the Nix store.
|
||||||
|
|
||||||
- `allowedRequisites`\
|
- `allowedRequisites`
|
||||||
This attribute is similar to `allowedReferences`, but it specifies
|
This attribute is similar to `allowedReferences`, but it specifies
|
||||||
the legal requisites of the whole closure, so all the dependencies
|
the legal requisites of the whole closure, so all the dependencies
|
||||||
recursively. For example,
|
recursively. For example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
allowedRequisites = [ foobar ];
|
allowedRequisites = [ foobar ];
|
||||||
```
|
```
|
||||||
|
|
||||||
enforces that the output of a derivation cannot have any other
|
enforces that the output of a derivation cannot have any other
|
||||||
runtime dependency than `foobar`, and in addition it enforces that
|
runtime dependency than `foobar`, and in addition it enforces that
|
||||||
`foobar` itself doesn't introduce any other dependency itself.
|
`foobar` itself doesn't introduce any other dependency itself.
|
||||||
|
|
||||||
- `disallowedReferences`\
|
- `disallowedReferences`
|
||||||
The optional attribute `disallowedReferences` specifies a list of
|
The optional attribute `disallowedReferences` specifies a list of
|
||||||
illegal references (dependencies) of the output of the builder. For
|
illegal references (dependencies) of the output of the builder. For
|
||||||
example,
|
example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
disallowedReferences = [ foo ];
|
disallowedReferences = [ foo ];
|
||||||
```
|
```
|
||||||
|
|
||||||
enforces that the output of a derivation cannot have a direct
|
enforces that the output of a derivation cannot have a direct
|
||||||
runtime dependencies on the derivation `foo`.
|
runtime dependencies on the derivation `foo`.
|
||||||
|
|
||||||
- `disallowedRequisites`\
|
- `disallowedRequisites`
|
||||||
This attribute is similar to `disallowedReferences`, but it
|
This attribute is similar to `disallowedReferences`, but it
|
||||||
specifies illegal requisites for the whole closure, so all the
|
specifies illegal requisites for the whole closure, so all the
|
||||||
dependencies recursively. For example,
|
dependencies recursively. For example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
disallowedRequisites = [ foobar ];
|
disallowedRequisites = [ foobar ];
|
||||||
```
|
```
|
||||||
|
|
||||||
enforces that the output of a derivation cannot have any runtime
|
enforces that the output of a derivation cannot have any runtime
|
||||||
dependency on `foobar` or any other derivation depending recursively
|
dependency on `foobar` or any other derivation depending recursively
|
||||||
on `foobar`.
|
on `foobar`.
|
||||||
|
|
||||||
- `exportReferencesGraph`\
|
- `exportReferencesGraph`
|
||||||
This attribute allows builders access to the references graph of
|
This attribute allows builders access to the references graph of
|
||||||
their inputs. The attribute is a list of inputs in the Nix store
|
their inputs. The attribute is a list of inputs in the Nix store
|
||||||
whose references graph the builder needs to know. The value of
|
whose references graph the builder needs to know. The value of
|
||||||
@@ -65,17 +65,17 @@ Derivations can declare some infrequently used optional attributes.
|
|||||||
files have the format used by `nix-store --register-validity`
|
files have the format used by `nix-store --register-validity`
|
||||||
(with the deriver fields left empty). For example, when the
|
(with the deriver fields left empty). For example, when the
|
||||||
following derivation is built:
|
following derivation is built:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
derivation {
|
derivation {
|
||||||
...
|
...
|
||||||
exportReferencesGraph = [ "libfoo-graph" libfoo ];
|
exportReferencesGraph = [ "libfoo-graph" libfoo ];
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
the references graph of `libfoo` is placed in the file
|
the references graph of `libfoo` is placed in the file
|
||||||
`libfoo-graph` in the temporary build directory.
|
`libfoo-graph` in the temporary build directory.
|
||||||
|
|
||||||
`exportReferencesGraph` is useful for builders that want to do
|
`exportReferencesGraph` is useful for builders that want to do
|
||||||
something with the closure of a store path. Examples include the
|
something with the closure of a store path. Examples include the
|
||||||
builders in NixOS that generate the initial ramdisk for booting
|
builders in NixOS that generate the initial ramdisk for booting
|
||||||
@@ -84,66 +84,66 @@ Derivations can declare some infrequently used optional attributes.
|
|||||||
with a Nix store containing the closure of a bootable NixOS
|
with a Nix store containing the closure of a bootable NixOS
|
||||||
configuration).
|
configuration).
|
||||||
|
|
||||||
- `impureEnvVars`\
|
- `impureEnvVars`
|
||||||
This attribute allows you to specify a list of environment variables
|
This attribute allows you to specify a list of environment variables
|
||||||
that should be passed from the environment of the calling user to
|
that should be passed from the environment of the calling user to
|
||||||
the builder. Usually, the environment is cleared completely when the
|
the builder. Usually, the environment is cleared completely when the
|
||||||
builder is executed, but with this attribute you can allow specific
|
builder is executed, but with this attribute you can allow specific
|
||||||
environment variables to be passed unmodified. For example,
|
environment variables to be passed unmodified. For example,
|
||||||
`fetchurl` in Nixpkgs has the line
|
`fetchurl` in Nixpkgs has the line
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
impureEnvVars = [ "http_proxy" "https_proxy" ... ];
|
impureEnvVars = [ "http_proxy" "https_proxy" ... ];
|
||||||
```
|
```
|
||||||
|
|
||||||
to make it use the proxy server configuration specified by the user
|
to make it use the proxy server configuration specified by the user
|
||||||
in the environment variables `http_proxy` and friends.
|
in the environment variables `http_proxy` and friends.
|
||||||
|
|
||||||
This attribute is only allowed in *fixed-output derivations* (see
|
This attribute is only allowed in *fixed-output derivations* (see
|
||||||
below), where impurities such as these are okay since (the hash
|
below), where impurities such as these are okay since (the hash
|
||||||
of) the output is known in advance. It is ignored for all other
|
of) the output is known in advance. It is ignored for all other
|
||||||
derivations.
|
derivations.
|
||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
>
|
>
|
||||||
> `impureEnvVars` implementation takes environment variables from
|
> `impureEnvVars` implementation takes environment variables from
|
||||||
> the current builder process. When a daemon is building its
|
> the current builder process. When a daemon is building its
|
||||||
> environmental variables are used. Without the daemon, the
|
> environmental variables are used. Without the daemon, the
|
||||||
> environmental variables come from the environment of the
|
> environmental variables come from the environment of the
|
||||||
> `nix-build`.
|
> `nix-build`.
|
||||||
|
|
||||||
- `outputHash`; `outputHashAlgo`; `outputHashMode`\
|
- `outputHash`; `outputHashAlgo`; `outputHashMode`
|
||||||
These attributes declare that the derivation is a so-called
|
These attributes declare that the derivation is a so-called
|
||||||
*fixed-output derivation*, which means that a cryptographic hash of
|
*fixed-output derivation*, which means that a cryptographic hash of
|
||||||
the output is already known in advance. When the build of a
|
the output is already known in advance. When the build of a
|
||||||
fixed-output derivation finishes, Nix computes the cryptographic
|
fixed-output derivation finishes, Nix computes the cryptographic
|
||||||
hash of the output and compares it to the hash declared with these
|
hash of the output and compares it to the hash declared with these
|
||||||
attributes. If there is a mismatch, the build fails.
|
attributes. If there is a mismatch, the build fails.
|
||||||
|
|
||||||
The rationale for fixed-output derivations is derivations such as
|
The rationale for fixed-output derivations is derivations such as
|
||||||
those produced by the `fetchurl` function. This function downloads a
|
those produced by the `fetchurl` function. This function downloads a
|
||||||
file from a given URL. To ensure that the downloaded file has not
|
file from a given URL. To ensure that the downloaded file has not
|
||||||
been modified, the caller must also specify a cryptographic hash of
|
been modified, the caller must also specify a cryptographic hash of
|
||||||
the file. For example,
|
the file. For example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
fetchurl {
|
fetchurl {
|
||||||
url = "http://ftp.gnu.org/pub/gnu/hello/hello-2.1.1.tar.gz";
|
url = "http://ftp.gnu.org/pub/gnu/hello/hello-2.1.1.tar.gz";
|
||||||
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
|
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
It sometimes happens that the URL of the file changes, e.g., because
|
It sometimes happens that the URL of the file changes, e.g., because
|
||||||
servers are reorganised or no longer available. We then must update
|
servers are reorganised or no longer available. We then must update
|
||||||
the call to `fetchurl`, e.g.,
|
the call to `fetchurl`, e.g.,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
fetchurl {
|
fetchurl {
|
||||||
url = "ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz";
|
url = "ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz";
|
||||||
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
|
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If a `fetchurl` derivation was treated like a normal derivation, the
|
If a `fetchurl` derivation was treated like a normal derivation, the
|
||||||
output paths of the derivation and *all derivations depending on it*
|
output paths of the derivation and *all derivations depending on it*
|
||||||
would change. For instance, if we were to change the URL of the
|
would change. For instance, if we were to change the URL of the
|
||||||
@@ -151,16 +151,16 @@ Derivations can declare some infrequently used optional attributes.
|
|||||||
other packages depend) massive rebuilds would be needed. This is
|
other packages depend) massive rebuilds would be needed. This is
|
||||||
unfortunate for a change which we know cannot have a real effect as
|
unfortunate for a change which we know cannot have a real effect as
|
||||||
it propagates upwards through the dependency graph.
|
it propagates upwards through the dependency graph.
|
||||||
|
|
||||||
For fixed-output derivations, on the other hand, the name of the
|
For fixed-output derivations, on the other hand, the name of the
|
||||||
output path only depends on the `outputHash*` and `name` attributes,
|
output path only depends on the `outputHash*` and `name` attributes,
|
||||||
while all other attributes are ignored for the purpose of computing
|
while all other attributes are ignored for the purpose of computing
|
||||||
the output path. (The `name` attribute is included because it is
|
the output path. (The `name` attribute is included because it is
|
||||||
part of the path.)
|
part of the path.)
|
||||||
|
|
||||||
As an example, here is the (simplified) Nix expression for
|
As an example, here is the (simplified) Nix expression for
|
||||||
`fetchurl`:
|
`fetchurl`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ stdenv, curl }: # The curl program is used for downloading.
|
{ stdenv, curl }: # The curl program is used for downloading.
|
||||||
|
|
||||||
@@ -180,51 +180,43 @@ Derivations can declare some infrequently used optional attributes.
|
|||||||
inherit url;
|
inherit url;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The `outputHashAlgo` attribute specifies the hash algorithm used to
|
The `outputHashAlgo` attribute specifies the hash algorithm used to
|
||||||
compute the hash. It can currently be `"sha1"`, `"sha256"` or
|
compute the hash. It can currently be `"sha1"`, `"sha256"` or
|
||||||
`"sha512"`.
|
`"sha512"`.
|
||||||
|
|
||||||
The `outputHashMode` attribute determines how the hash is computed.
|
The `outputHashMode` attribute determines how the hash is computed.
|
||||||
It must be one of the following two values:
|
It must be one of the following two values:
|
||||||
|
|
||||||
- `"flat"`\
|
- `"flat"`
|
||||||
The output must be a non-executable regular file. If it isn’t,
|
The output must be a non-executable regular file. If it isn’t,
|
||||||
the build fails. The hash is simply computed over the contents
|
the build fails. The hash is simply computed over the contents
|
||||||
of that file (so it’s equal to what Unix commands like
|
of that file (so it’s equal to what Unix commands like
|
||||||
`sha256sum` or `sha1sum` produce).
|
`sha256sum` or `sha1sum` produce).
|
||||||
|
|
||||||
This is the default.
|
This is the default.
|
||||||
|
|
||||||
- `"recursive"`\
|
- `"recursive"`
|
||||||
The hash is computed over the NAR archive dump of the output
|
The hash is computed over the NAR archive dump of the output
|
||||||
(i.e., the result of [`nix-store
|
(i.e., the result of [`nix-store
|
||||||
--dump`](../command-ref/nix-store.md#operation---dump)). In
|
--dump`](../command-ref/nix-store.md#operation---dump)). In
|
||||||
this case, the output can be anything, including a directory
|
this case, the output can be anything, including a directory
|
||||||
tree.
|
tree.
|
||||||
|
|
||||||
The `outputHash` attribute, finally, must be a string containing
|
The `outputHash` attribute, finally, must be a string containing
|
||||||
the hash in either hexadecimal or base-32 notation. (See the
|
the hash in either hexadecimal or base-32 notation. (See the
|
||||||
[`nix-hash` command](../command-ref/nix-hash.md) for information
|
[`nix-hash` command](../command-ref/nix-hash.md) for information
|
||||||
about converting to and from base-32 notation.)
|
about converting to and from base-32 notation.)
|
||||||
|
|
||||||
- `__contentAddressed`
|
|
||||||
If this **experimental** attribute is set to true, then the derivation
|
|
||||||
outputs will be stored in a content-addressed location rather than the
|
|
||||||
traditional input-addressed one.
|
|
||||||
This only has an effect if the `ca-derivation` experimental feature is enabled.
|
|
||||||
|
|
||||||
Setting this attribute also requires setting `outputHashMode` and `outputHashAlgo` like for *fixed-output derivations* (see above).
|
|
||||||
|
|
||||||
- `passAsFile`\
|
- `passAsFile`
|
||||||
A list of names of attributes that should be passed via files rather
|
A list of names of attributes that should be passed via files rather
|
||||||
than environment variables. For example, if you have
|
than environment variables. For example, if you have
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
passAsFile = ["big"];
|
passAsFile = ["big"];
|
||||||
big = "a very long string";
|
big = "a very long string";
|
||||||
```
|
```
|
||||||
|
|
||||||
then when the builder runs, the environment variable `bigPath`
|
then when the builder runs, the environment variable `bigPath`
|
||||||
will contain the absolute path to a temporary file containing `a
|
will contain the absolute path to a temporary file containing `a
|
||||||
very long string`. That is, for any attribute *x* listed in
|
very long string`. That is, for any attribute *x* listed in
|
||||||
@@ -234,22 +226,22 @@ Derivations can declare some infrequently used optional attributes.
|
|||||||
builder, since most operating systems impose a limit on the size
|
builder, since most operating systems impose a limit on the size
|
||||||
of the environment (typically, a few hundred kilobyte).
|
of the environment (typically, a few hundred kilobyte).
|
||||||
|
|
||||||
- `preferLocalBuild`\
|
- `preferLocalBuild`
|
||||||
If this attribute is set to `true` and [distributed building is
|
If this attribute is set to `true` and [distributed building is
|
||||||
enabled](../advanced-topics/distributed-builds.md), then, if
|
enabled](../advanced-topics/distributed-builds.md), then, if
|
||||||
possible, the derivation will be built locally instead of forwarded
|
possible, the derivaton will be built locally instead of forwarded
|
||||||
to a remote machine. This is appropriate for trivial builders
|
to a remote machine. This is appropriate for trivial builders
|
||||||
where the cost of doing a download or remote build would exceed
|
where the cost of doing a download or remote build would exceed
|
||||||
the cost of building locally.
|
the cost of building locally.
|
||||||
|
|
||||||
- `allowSubstitutes`\
|
- `allowSubstitutes`
|
||||||
If this attribute is set to `false`, then Nix will always build this
|
If this attribute is set to `false`, then Nix will always build this
|
||||||
derivation; it will not try to substitute its outputs. This is
|
derivation; it will not try to substitute its outputs. This is
|
||||||
useful for very trivial derivations (such as `writeText` in Nixpkgs)
|
useful for very trivial derivations (such as `writeText` in Nixpkgs)
|
||||||
that are cheaper to build than to substitute from a binary cache.
|
that are cheaper to build than to substitute from a binary cache.
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
> You need to have a builder configured which satisfies the
|
> You need to have a builder configured which satisfies the
|
||||||
> derivation’s `system` attribute, since the derivation cannot be
|
> derivation’s `system` attribute, since the derivation cannot be
|
||||||
> substituted. Thus it is usually a good idea to align `system` with
|
> substituted. Thus it is usually a good idea to align `system` with
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Here are the constants built into the Nix expression evaluator:
|
Here are the constants built into the Nix expression evaluator:
|
||||||
|
|
||||||
- `builtins`\
|
- `builtins`
|
||||||
The set `builtins` contains all the built-in functions and values.
|
The set `builtins` contains all the built-in functions and values.
|
||||||
You can use `builtins` to test for the availability of features in
|
You can use `builtins` to test for the availability of features in
|
||||||
the Nix installation, e.g.,
|
the Nix installation, e.g.,
|
||||||
@@ -14,7 +14,7 @@ Here are the constants built into the Nix expression evaluator:
|
|||||||
This allows a Nix expression to fall back gracefully on older Nix
|
This allows a Nix expression to fall back gracefully on older Nix
|
||||||
installations that don’t have the desired built-in function.
|
installations that don’t have the desired built-in function.
|
||||||
|
|
||||||
- `builtins.currentSystem`\
|
- `builtins.currentSystem`
|
||||||
The built-in value `currentSystem` evaluates to the Nix platform
|
The built-in value `currentSystem` evaluates to the Nix platform
|
||||||
identifier for the Nix installation on which the expression is being
|
identifier for the Nix installation on which the expression is being
|
||||||
evaluated, such as `"i686-linux"` or `"x86_64-darwin"`.
|
evaluated, such as `"i686-linux"` or `"x86_64-darwin"`.
|
||||||
@@ -9,8 +9,7 @@ scope. Instead, you can access them through the `builtins` built-in
|
|||||||
value, which is a set that contains all built-in functions and values.
|
value, which is a set that contains all built-in functions and values.
|
||||||
For instance, `derivation` is also available as `builtins.derivation`.
|
For instance, `derivation` is also available as `builtins.derivation`.
|
||||||
|
|
||||||
<dl>
|
- `derivation` *attrs*; `builtins.derivation` *attrs*
|
||||||
<dt><code>derivation <var>attrs</var></code>;
|
|
||||||
<code>builtins.derivation <var>attrs</var></code></dt>
|
`derivation` is described in [its own section](derivations.md).
|
||||||
<dd><p><var>derivation</var> in described in
|
|
||||||
<a href="derivations.md">its own section</a>.</p></dd>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
</dl>
|
|
||||||
@@ -26,7 +26,7 @@ elements (referenced from the figure by number):
|
|||||||
called with three arguments: `stdenv`, `fetchurl`, and `perl`. They
|
called with three arguments: `stdenv`, `fetchurl`, and `perl`. They
|
||||||
are needed to build Hello, but we don't know how to build them here;
|
are needed to build Hello, but we don't know how to build them here;
|
||||||
that's why they are function arguments. `stdenv` is a package that
|
that's why they are function arguments. `stdenv` is a package that
|
||||||
is used by almost all Nix Packages; it provides a
|
is used by almost all Nix Packages packages; it provides a
|
||||||
“standard” environment consisting of the things you would expect
|
“standard” environment consisting of the things you would expect
|
||||||
in a basic Unix environment: a C/C++ compiler (GCC, to be precise),
|
in a basic Unix environment: a C/C++ compiler (GCC, to be precise),
|
||||||
the Bash shell, fundamental Unix tools such as `cp`, `grep`, `tar`,
|
the Bash shell, fundamental Unix tools such as `cp`, `grep`, `tar`,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ Nix has the following basic data types:
|
|||||||
the start of each line. To be precise, it strips from each line a
|
the start of each line. To be precise, it strips from each line a
|
||||||
number of spaces equal to the minimal indentation of the string as a
|
number of spaces equal to the minimal indentation of the string as a
|
||||||
whole (disregarding the indentation of empty lines). For instance,
|
whole (disregarding the indentation of empty lines). For instance,
|
||||||
the first and second line are indented two spaces, while the third
|
the first and second line are indented two space, while the third
|
||||||
line is indented four spaces. Thus, two spaces are stripped from
|
line is indented four spaces. Thus, two spaces are stripped from
|
||||||
each line, so the resulting string is
|
each line, so the resulting string is
|
||||||
|
|
||||||
@@ -139,13 +139,6 @@ Nix has the following basic data types:
|
|||||||
environment variable `NIX_PATH` will be searched for the given file
|
environment variable `NIX_PATH` will be searched for the given file
|
||||||
or directory name.
|
or directory name.
|
||||||
|
|
||||||
Antiquotation is supported in any paths except those in angle brackets.
|
|
||||||
`./${foo}-${bar}.nix` is a more convenient way of writing
|
|
||||||
`./. + "/" + foo + "-" + bar + ".nix"` or `./. + "/${foo}-${bar}.nix"`. At
|
|
||||||
least one slash must appear *before* any antiquotations for this to be
|
|
||||||
recognized as a path. `a.${foo}/b.${bar}` is a syntactically valid division
|
|
||||||
operation. `./a.${foo}/b.${bar}` is a path.
|
|
||||||
|
|
||||||
- *Booleans* with values `true` and `false`.
|
- *Booleans* with values `true` and `false`.
|
||||||
|
|
||||||
- The null value, denoted as `null`.
|
- The null value, denoted as `null`.
|
||||||
|
|||||||
+16
-16
@@ -1,48 +1,48 @@
|
|||||||
# Glossary
|
# Glossary
|
||||||
|
|
||||||
- derivation\
|
- derivation
|
||||||
A description of a build action. The result of a derivation is a
|
A description of a build action. The result of a derivation is a
|
||||||
store object. Derivations are typically specified in Nix expressions
|
store object. Derivations are typically specified in Nix expressions
|
||||||
using the [`derivation` primitive](expressions/derivations.md). These are
|
using the [`derivation` primitive](expressions/derivations.md). These are
|
||||||
translated into low-level *store derivations* (implicitly by
|
translated into low-level *store derivations* (implicitly by
|
||||||
`nix-env` and `nix-build`, or explicitly by `nix-instantiate`).
|
`nix-env` and `nix-build`, or explicitly by `nix-instantiate`).
|
||||||
|
|
||||||
- store\
|
- store
|
||||||
The location in the file system where store objects live. Typically
|
The location in the file system where store objects live. Typically
|
||||||
`/nix/store`.
|
`/nix/store`.
|
||||||
|
|
||||||
- store path\
|
- store path
|
||||||
The location in the file system of a store object, i.e., an
|
The location in the file system of a store object, i.e., an
|
||||||
immediate child of the Nix store directory.
|
immediate child of the Nix store directory.
|
||||||
|
|
||||||
- store object\
|
- store object
|
||||||
A file that is an immediate child of the Nix store directory. These
|
A file that is an immediate child of the Nix store directory. These
|
||||||
can be regular files, but also entire directory trees. Store objects
|
can be regular files, but also entire directory trees. Store objects
|
||||||
can be sources (objects copied from outside of the store),
|
can be sources (objects copied from outside of the store),
|
||||||
derivation outputs (objects produced by running a build action), or
|
derivation outputs (objects produced by running a build action), or
|
||||||
derivations (files describing a build action).
|
derivations (files describing a build action).
|
||||||
|
|
||||||
- substitute\
|
- substitute
|
||||||
A substitute is a command invocation stored in the Nix database that
|
A substitute is a command invocation stored in the Nix database that
|
||||||
describes how to build a store object, bypassing the normal build
|
describes how to build a store object, bypassing the normal build
|
||||||
mechanism (i.e., derivations). Typically, the substitute builds the
|
mechanism (i.e., derivations). Typically, the substitute builds the
|
||||||
store object by downloading a pre-built version of the store object
|
store object by downloading a pre-built version of the store object
|
||||||
from some server.
|
from some server.
|
||||||
|
|
||||||
- purity\
|
- purity
|
||||||
The assumption that equal Nix derivations when run always produce
|
The assumption that equal Nix derivations when run always produce
|
||||||
the same output. This cannot be guaranteed in general (e.g., a
|
the same output. This cannot be guaranteed in general (e.g., a
|
||||||
builder can rely on external inputs such as the network or the
|
builder can rely on external inputs such as the network or the
|
||||||
system time) but the Nix model assumes it.
|
system time) but the Nix model assumes it.
|
||||||
|
|
||||||
- Nix expression\
|
- Nix expression
|
||||||
A high-level description of software packages and compositions
|
A high-level description of software packages and compositions
|
||||||
thereof. Deploying software using Nix entails writing Nix
|
thereof. Deploying software using Nix entails writing Nix
|
||||||
expressions for your packages. Nix expressions are translated to
|
expressions for your packages. Nix expressions are translated to
|
||||||
derivations that are stored in the Nix store. These derivations can
|
derivations that are stored in the Nix store. These derivations can
|
||||||
then be built.
|
then be built.
|
||||||
|
|
||||||
- reference\
|
- reference
|
||||||
A store path `P` is said to have a reference to a store path `Q` if
|
A store path `P` is said to have a reference to a store path `Q` if
|
||||||
the store object at `P` contains the path `Q` somewhere. The
|
the store object at `P` contains the path `Q` somewhere. The
|
||||||
*references* of a store path are the set of store paths to which it
|
*references* of a store path are the set of store paths to which it
|
||||||
@@ -52,11 +52,11 @@
|
|||||||
output paths), whereas an output path only references other output
|
output paths), whereas an output path only references other output
|
||||||
paths.
|
paths.
|
||||||
|
|
||||||
- reachable\
|
- reachable
|
||||||
A store path `Q` is reachable from another store path `P` if `Q`
|
A store path `Q` is reachable from another store path `P` if `Q`
|
||||||
is in the *closure* of the *references* relation.
|
is in the *closure* of the *references* relation.
|
||||||
|
|
||||||
- closure\
|
- closure
|
||||||
The closure of a store path is the set of store paths that are
|
The closure of a store path is the set of store paths that are
|
||||||
directly or indirectly “reachable” from that store path; that is,
|
directly or indirectly “reachable” from that store path; that is,
|
||||||
it’s the closure of the path under the *references* relation. For
|
it’s the closure of the path under the *references* relation. For
|
||||||
@@ -71,29 +71,29 @@
|
|||||||
to path `Q`, then `Q` is in the closure of `P`. Further, if `Q`
|
to path `Q`, then `Q` is in the closure of `P`. Further, if `Q`
|
||||||
references `R` then `R` is also in the closure of `P`.
|
references `R` then `R` is also in the closure of `P`.
|
||||||
|
|
||||||
- output path\
|
- output path
|
||||||
A store path produced by a derivation.
|
A store path produced by a derivation.
|
||||||
|
|
||||||
- deriver\
|
- deriver
|
||||||
The deriver of an *output path* is the store
|
The deriver of an *output path* is the store
|
||||||
derivation that built it.
|
derivation that built it.
|
||||||
|
|
||||||
- validity\
|
- validity
|
||||||
A store path is considered *valid* if it exists in the file system,
|
A store path is considered *valid* if it exists in the file system,
|
||||||
is listed in the Nix database as being valid, and if all paths in
|
is listed in the Nix database as being valid, and if all paths in
|
||||||
its closure are also valid.
|
its closure are also valid.
|
||||||
|
|
||||||
- user environment\
|
- user environment
|
||||||
An automatically generated store object that consists of a set of
|
An automatically generated store object that consists of a set of
|
||||||
symlinks to “active” applications, i.e., other store paths. These
|
symlinks to “active” applications, i.e., other store paths. These
|
||||||
are generated automatically by
|
are generated automatically by
|
||||||
[`nix-env`](command-ref/nix-env.md). See *profiles*.
|
[`nix-env`](command-ref/nix-env.md). See *profiles*.
|
||||||
|
|
||||||
- profile\
|
- profile
|
||||||
A symlink to the current *user environment* of a user, e.g.,
|
A symlink to the current *user environment* of a user, e.g.,
|
||||||
`/nix/var/nix/profiles/default`.
|
`/nix/var/nix/profiles/default`.
|
||||||
|
|
||||||
- NAR\
|
- NAR
|
||||||
A *N*ix *AR*chive. This is a serialisation of a path in the Nix
|
A *N*ix *AR*chive. This is a serialisation of a path in the Nix
|
||||||
store. It can contain regular files, directories and symbolic
|
store. It can contain regular files, directories and symbolic
|
||||||
links. NARs are generated and unpacked using `nix-store --dump`
|
links. NARs are generated and unpacked using `nix-store --dump`
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Building Nix from Source
|
# Building Nix from Source
|
||||||
|
|
||||||
After cloning Nix's Git repository, issue the following commands:
|
After unpacking or checking out the Nix sources, issue the following
|
||||||
|
commands:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ ./bootstrap.sh
|
|
||||||
$ ./configure options...
|
$ ./configure options...
|
||||||
$ make
|
$ make
|
||||||
$ make install
|
$ make install
|
||||||
@@ -11,6 +11,13 @@ $ make install
|
|||||||
|
|
||||||
Nix requires GNU Make so you may need to invoke `gmake` instead.
|
Nix requires GNU Make so you may need to invoke `gmake` instead.
|
||||||
|
|
||||||
|
When building from the Git repository, these should be preceded by the
|
||||||
|
command:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./bootstrap.sh
|
||||||
|
```
|
||||||
|
|
||||||
The installation path can be specified by passing the `--prefix=prefix`
|
The installation path can be specified by passing the `--prefix=prefix`
|
||||||
to `configure`. The default installation directory is `/usr/local`. You
|
to `configure`. The default installation directory is `/usr/local`. You
|
||||||
can change this to any location you like. You must have write permission
|
can change this to any location you like. You must have write permission
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export NIX_SSL_CERT_FILE=/etc/ssl/my-certificate-bundle.crt
|
|||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
> You must not add the export and then do the install, as the Nix
|
> You must not add the export and then do the install, as the Nix
|
||||||
> installer will detect the presence of Nix configuration, and abort.
|
> installer will detect the presense of Nix configuration, and abort.
|
||||||
|
|
||||||
## `NIX_SSL_CERT_FILE` with macOS and the Nix daemon
|
## `NIX_SSL_CERT_FILE` with macOS and the Nix daemon
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,18 @@
|
|||||||
# Installing a Binary Distribution
|
# Installing a Binary Distribution
|
||||||
|
|
||||||
The easiest way to install Nix is to run the following command:
|
If you are using Linux or macOS versions up to 10.14 (Mojave), the
|
||||||
|
easiest way to install Nix is to run the following command:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ sh <(curl -L https://nixos.org/nix/install)
|
$ sh <(curl -L https://nixos.org/nix/install)
|
||||||
```
|
```
|
||||||
|
|
||||||
This will run the installer interactively (causing it to explain what
|
If you're using macOS 10.15 (Catalina) or newer, consult [the macOS
|
||||||
it is doing more explicitly), and perform the default "type" of install
|
installation instructions](#macos-installation) before installing.
|
||||||
for your platform:
|
|
||||||
- single-user on Linux
|
|
||||||
- multi-user on macOS
|
|
||||||
|
|
||||||
> **Notes on read-only filesystem root in macOS 10.15 Catalina +**
|
As of Nix 2.1.0, the Nix installer will always default to creating a
|
||||||
>
|
single-user installation, however opting in to the multi-user
|
||||||
> - It took some time to support this cleanly. You may see posts,
|
installation is highly recommended.
|
||||||
> examples, and tutorials using obsolete workarounds.
|
|
||||||
> - Supporting it cleanly made macOS installs too complex to qualify
|
|
||||||
> as single-user, so this type is no longer supported on macOS.
|
|
||||||
|
|
||||||
We recommend the multi-user install if it supports your platform and
|
|
||||||
you can authenticate with `sudo`.
|
|
||||||
|
|
||||||
# Single User Installation
|
# Single User Installation
|
||||||
|
|
||||||
@@ -58,9 +50,9 @@ $ rm -rf /nix
|
|||||||
The multi-user Nix installation creates system users, and a system
|
The multi-user Nix installation creates system users, and a system
|
||||||
service for the Nix daemon.
|
service for the Nix daemon.
|
||||||
|
|
||||||
**Supported Systems**
|
- Linux running systemd, with SELinux disabled
|
||||||
- Linux running systemd, with SELinux disabled
|
|
||||||
- macOS
|
- macOS
|
||||||
|
|
||||||
You can instruct the installer to perform a multi-user installation on
|
You can instruct the installer to perform a multi-user installation on
|
||||||
your system:
|
your system:
|
||||||
@@ -104,28 +96,165 @@ sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
|||||||
There may also be references to Nix in `/etc/profile`, `/etc/bashrc`,
|
There may also be references to Nix in `/etc/profile`, `/etc/bashrc`,
|
||||||
and `/etc/zshrc` which you may remove.
|
and `/etc/zshrc` which you may remove.
|
||||||
|
|
||||||
# macOS Installation <a name="sect-macos-installation-change-store-prefix"></a><a name="sect-macos-installation-encrypted-volume"></a><a name="sect-macos-installation-symlink"></a><a name="sect-macos-installation-recommended-notes"></a>
|
# macOS Installation
|
||||||
<!-- Note: anchors above to catch permalinks to old explanations -->
|
|
||||||
|
|
||||||
We believe we have ironed out how to cleanly support the read-only root
|
Starting with macOS 10.15 (Catalina), the root filesystem is read-only.
|
||||||
on modern macOS. New installs will do this automatically, and you can
|
This means `/nix` can no longer live on your system volume, and that
|
||||||
also re-run a new installer to convert your existing setup.
|
you'll need a workaround to install Nix.
|
||||||
|
|
||||||
This section previously detailed the situation, options, and trade-offs,
|
The recommended approach, which creates an unencrypted APFS volume for
|
||||||
but it now only outlines what the installer does. You don't need to know
|
your Nix store and a "synthetic" empty directory to mount it over at
|
||||||
this to run the installer, but it may help if you run into trouble:
|
`/nix`, is least likely to impair Nix or your system.
|
||||||
|
|
||||||
- create a new APFS volume for your Nix store
|
> **Note**
|
||||||
- update `/etc/synthetic.conf` to direct macOS to create a "synthetic"
|
>
|
||||||
empty root directory to mount your volume
|
> With all separate-volume approaches, it's possible something on your
|
||||||
- specify mount options for the volume in `/etc/fstab`
|
> system (particularly daemons/services and restored apps) may need
|
||||||
- if you have FileVault enabled
|
> access to your Nix store before the volume is mounted. Adding
|
||||||
- generate an encryption password
|
> additional encryption makes this more likely.
|
||||||
- put it in your system Keychain
|
|
||||||
- use it to encrypt the volume
|
If you're using a recent Mac with a [T2
|
||||||
- create a system LaunchDaemon to mount this volume early enough in the
|
chip](https://www.apple.com/euro/mac/shared/docs/Apple_T2_Security_Chip_Overview.pdf),
|
||||||
boot process to avoid problems loading or restoring any programs that
|
your drive will still be encrypted at rest (in which case "unencrypted"
|
||||||
need access to your Nix store
|
is a bit of a misnomer). To use this approach, just install Nix with:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't like the sound of this, you'll want to weigh the other
|
||||||
|
approaches and tradeoffs detailed in this section.
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
>
|
||||||
|
> All of the known workarounds have drawbacks, but we hope better
|
||||||
|
> solutions will be available in the future. Some that we have our eye
|
||||||
|
> on are:
|
||||||
|
>
|
||||||
|
> 1. A true firmlink would enable the Nix store to live on the primary
|
||||||
|
> data volume without the build problems caused by the symlink
|
||||||
|
> approach. End users cannot currently create true firmlinks.
|
||||||
|
>
|
||||||
|
> 2. If the Nix store volume shared FileVault encryption with the
|
||||||
|
> primary data volume (probably by using the same volume group and
|
||||||
|
> role), FileVault encryption could be easily supported by the
|
||||||
|
> installer without requiring manual setup by each user.
|
||||||
|
|
||||||
|
## Change the Nix store path prefix
|
||||||
|
|
||||||
|
Changing the default prefix for the Nix store is a simple approach which
|
||||||
|
enables you to leave it on your root volume, where it can take full
|
||||||
|
advantage of FileVault encryption if enabled. Unfortunately, this
|
||||||
|
approach also opts your device out of some benefits that are enabled by
|
||||||
|
using the same prefix across systems:
|
||||||
|
|
||||||
|
- Your system won't be able to take advantage of the binary cache
|
||||||
|
(unless someone is able to stand up and support duplicate caching
|
||||||
|
infrastructure), which means you'll spend more time waiting for
|
||||||
|
builds.
|
||||||
|
|
||||||
|
- It's harder to build and deploy packages to Linux systems.
|
||||||
|
|
||||||
|
It would also possible (and often requested) to just apply this change
|
||||||
|
ecosystem-wide, but it's an intrusive process that has side effects we
|
||||||
|
want to avoid for now.
|
||||||
|
|
||||||
|
## Use a separate encrypted volume
|
||||||
|
|
||||||
|
If you like, you can also add encryption to the recommended approach
|
||||||
|
taken by the installer. You can do this by pre-creating an encrypted
|
||||||
|
volume before you run the installer--or you can run the installer and
|
||||||
|
encrypt the volume it creates later.
|
||||||
|
|
||||||
|
In either case, adding encryption to a second volume isn't quite as
|
||||||
|
simple as enabling FileVault for your boot volume. Before you dive in,
|
||||||
|
there are a few things to weigh:
|
||||||
|
|
||||||
|
1. The additional volume won't be encrypted with your existing
|
||||||
|
FileVault key, so you'll need another mechanism to decrypt the
|
||||||
|
volume.
|
||||||
|
|
||||||
|
2. You can store the password in Keychain to automatically decrypt the
|
||||||
|
volume on boot--but it'll have to wait on Keychain and may not mount
|
||||||
|
before your GUI apps restore. If any of your launchd agents or apps
|
||||||
|
depend on Nix-installed software (for example, if you use a
|
||||||
|
Nix-installed login shell), the restore may fail or break.
|
||||||
|
|
||||||
|
On a case-by-case basis, you may be able to work around this problem
|
||||||
|
by using `wait4path` to block execution until your executable is
|
||||||
|
available.
|
||||||
|
|
||||||
|
It's also possible to decrypt and mount the volume earlier with a
|
||||||
|
login hook--but this mechanism appears to be deprecated and its
|
||||||
|
future is unclear.
|
||||||
|
|
||||||
|
3. You can hard-code the password in the clear, so that your store
|
||||||
|
volume can be decrypted before Keychain is available.
|
||||||
|
|
||||||
|
If you are comfortable navigating these tradeoffs, you can encrypt the
|
||||||
|
volume with something along the lines of:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ diskutil apfs enableFileVault /nix -user disk
|
||||||
|
```
|
||||||
|
|
||||||
|
## Symlink the Nix store to a custom location
|
||||||
|
|
||||||
|
Another simple approach is using `/etc/synthetic.conf` to symlink the
|
||||||
|
Nix store to the data volume. This option also enables your store to
|
||||||
|
share any configured FileVault encryption. Unfortunately, builds that
|
||||||
|
resolve the symlink may leak the canonical path or even fail.
|
||||||
|
|
||||||
|
Because of these downsides, we can't recommend this approach.
|
||||||
|
|
||||||
|
## Notes on the recommended approach
|
||||||
|
|
||||||
|
This section goes into a little more detail on the recommended approach.
|
||||||
|
You don't need to understand it to run the installer, but it can serve
|
||||||
|
as a helpful reference if you run into trouble.
|
||||||
|
|
||||||
|
1. In order to compose user-writable locations into the new read-only
|
||||||
|
system root, Apple introduced a new concept called `firmlinks`,
|
||||||
|
which it describes as a "bi-directional wormhole" between two
|
||||||
|
filesystems. You can see the current firmlinks in
|
||||||
|
`/usr/share/firmlinks`. Unfortunately, firmlinks aren't (currently?)
|
||||||
|
user-configurable.
|
||||||
|
|
||||||
|
For special cases like NFS mount points or package manager roots,
|
||||||
|
[synthetic.conf(5)](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man5/synthetic.conf.5.html)
|
||||||
|
supports limited user-controlled file-creation (of symlinks, and
|
||||||
|
synthetic empty directories) at `/`. To create a synthetic empty
|
||||||
|
directory for mounting at `/nix`, add the following line to
|
||||||
|
`/etc/synthetic.conf` (create it if necessary):
|
||||||
|
|
||||||
|
nix
|
||||||
|
|
||||||
|
2. This configuration is applied at boot time, but you can use
|
||||||
|
`apfs.util` to trigger creation (not deletion) of new entries
|
||||||
|
without a reboot:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Create the new APFS volume with diskutil:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ sudo diskutil apfs addVolume diskX APFS 'Nix Store' -mountpoint /nix
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Using `vifs`, add the new mount to `/etc/fstab`. If it doesn't
|
||||||
|
already have other entries, it should look something like:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Warning - this file should only be modified with vifs(8)
|
||||||
|
#
|
||||||
|
# Failure to do so is unsupported and may be destructive.
|
||||||
|
#
|
||||||
|
LABEL=Nix\040Store /nix apfs rw,nobrowse
|
||||||
|
|
||||||
|
The nobrowse setting will keep Spotlight from indexing this volume,
|
||||||
|
and keep it from showing up on your desktop.
|
||||||
|
|
||||||
# Installing a pinned Nix version from a URL
|
# Installing a pinned Nix version from a URL
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Installing Nix from Source
|
# Installing Nix from Source
|
||||||
|
|
||||||
If no binary package is available or if you want to hack on Nix, you
|
If no binary package is available, you can download and compile a source
|
||||||
can build Nix from its Git repository.
|
distribution.
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
# Obtaining the Source
|
# Obtaining a Source Distribution
|
||||||
|
|
||||||
The most recent sources of Nix can be obtained from its [Git
|
The source tarball of the most recent stable release can be downloaded
|
||||||
repository](https://github.com/NixOS/nix). For example, the following
|
from the [Nix homepage](http://nixos.org/nix/download.html). You can
|
||||||
command will check out the latest revision into a directory called
|
also grab the [most recent development
|
||||||
`nix`:
|
release](http://hydra.nixos.org/job/nix/master/release/latest-finished#tabs-constituents).
|
||||||
|
|
||||||
|
Alternatively, the most recent sources of Nix can be obtained from its
|
||||||
|
[Git repository](https://github.com/NixOS/nix). For example, the
|
||||||
|
following command will check out the latest revision into a directory
|
||||||
|
called `nix`:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ git clone https://github.com/NixOS/nix
|
$ git clone https://github.com/NixOS/nix
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
- GNU Autoconf (<https://www.gnu.org/software/autoconf/>) and the
|
- GNU Autoconf (<https://www.gnu.org/software/autoconf/>) and the
|
||||||
autoconf-archive macro collection
|
autoconf-archive macro collection
|
||||||
(<https://www.gnu.org/software/autoconf-archive/>). These are
|
(<https://www.gnu.org/software/autoconf-archive/>). These are only
|
||||||
needed to run the bootstrap script.
|
needed to run the bootstrap script, and are not necessary if your
|
||||||
|
source distribution came with a pre-built `./configure` script.
|
||||||
|
|
||||||
- GNU Make.
|
- GNU Make.
|
||||||
|
|
||||||
@@ -25,6 +26,15 @@
|
|||||||
available for download from the official repository
|
available for download from the official repository
|
||||||
<https://github.com/google/brotli>.
|
<https://github.com/google/brotli>.
|
||||||
|
|
||||||
|
- The bzip2 compressor program and the `libbz2` library. Thus you must
|
||||||
|
have bzip2 installed, including development headers and libraries.
|
||||||
|
If your distribution does not provide these, you can obtain bzip2
|
||||||
|
from
|
||||||
|
<https://sourceware.org/bzip2/>.
|
||||||
|
|
||||||
|
- `liblzma`, which is provided by XZ Utils. If your distribution does
|
||||||
|
not provide this, you can get it from <https://tukaani.org/xz/>.
|
||||||
|
|
||||||
- cURL and its library. If your distribution does not provide it, you
|
- cURL and its library. If your distribution does not provide it, you
|
||||||
can get it from <https://curl.haxx.se/>.
|
can get it from <https://curl.haxx.se/>.
|
||||||
|
|
||||||
@@ -51,7 +61,8 @@
|
|||||||
you need version 2.5.35, which is available on
|
you need version 2.5.35, which is available on
|
||||||
[SourceForge](http://lex.sourceforge.net/). Slightly older versions
|
[SourceForge](http://lex.sourceforge.net/). Slightly older versions
|
||||||
may also work, but ancient versions like the ubiquitous 2.5.4a
|
may also work, but ancient versions like the ubiquitous 2.5.4a
|
||||||
won't.
|
won't. Note that these are only required if you modify the parser or
|
||||||
|
when you are building from the Git repository.
|
||||||
|
|
||||||
- The `libseccomp` is used to provide syscall filtering on Linux. This
|
- The `libseccomp` is used to provide syscall filtering on Linux. This
|
||||||
is an optional dependency and can be disabled passing a
|
is an optional dependency and can be disabled passing a
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ $ nix-env --install firefox
|
|||||||
|
|
||||||
_could_ cause quite a bit of build activity, as not only Firefox but
|
_could_ cause quite a bit of build activity, as not only Firefox but
|
||||||
also all its dependencies (all the way up to the C library and the
|
also all its dependencies (all the way up to the C library and the
|
||||||
compiler) would have to be built, at least if they are not already in the
|
compiler) would have to built, at least if they are not already in the
|
||||||
Nix store. This is a _source deployment model_. For most users,
|
Nix store. This is a _source deployment model_. For most users,
|
||||||
building from source is not very pleasant as it takes far too long.
|
building from source is not very pleasant as it takes far too long.
|
||||||
However, Nix can automatically skip building from source and instead
|
However, Nix can automatically skip building from source and instead
|
||||||
|
|||||||
@@ -7,17 +7,17 @@ cache mechanism that Nix usually uses to fetch prebuilt binaries from
|
|||||||
|
|
||||||
The following options can be specified as URL parameters to the S3 URL:
|
The following options can be specified as URL parameters to the S3 URL:
|
||||||
|
|
||||||
- `profile`\
|
- `profile`
|
||||||
The name of the AWS configuration profile to use. By default Nix
|
The name of the AWS configuration profile to use. By default Nix
|
||||||
will use the `default` profile.
|
will use the `default` profile.
|
||||||
|
|
||||||
- `region`\
|
- `region`
|
||||||
The region of the S3 bucket. `us–east-1` by default.
|
The region of the S3 bucket. `us–east-1` by default.
|
||||||
|
|
||||||
If your bucket is not in `us–east-1`, you should always explicitly
|
If your bucket is not in `us–east-1`, you should always explicitly
|
||||||
specify the region parameter.
|
specify the region parameter.
|
||||||
|
|
||||||
- `endpoint`\
|
- `endpoint`
|
||||||
The URL to your S3-compatible service, for when not using Amazon S3.
|
The URL to your S3-compatible service, for when not using Amazon S3.
|
||||||
Do not specify this value if you're using Amazon S3.
|
Do not specify this value if you're using Amazon S3.
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ The following options can be specified as URL parameters to the S3 URL:
|
|||||||
> This endpoint must support HTTPS and will use path-based
|
> This endpoint must support HTTPS and will use path-based
|
||||||
> addressing instead of virtual host based addressing.
|
> addressing instead of virtual host based addressing.
|
||||||
|
|
||||||
- `scheme`\
|
- `scheme`
|
||||||
The scheme used for S3 requests, `https` (default) or `http`. This
|
The scheme used for S3 requests, `https` (default) or `http`. This
|
||||||
option allows you to disable HTTPS for binary caches which don't
|
option allows you to disable HTTPS for binary caches which don't
|
||||||
support it.
|
support it.
|
||||||
|
|||||||
@@ -1,539 +0,0 @@
|
|||||||
# Release 2.4 (2021-11-01)
|
|
||||||
|
|
||||||
This is the first release in more than two years and is the result of
|
|
||||||
more than 2800 commits from 195 contributors since release 2.3.
|
|
||||||
|
|
||||||
## Highlights
|
|
||||||
|
|
||||||
* Nix's **error messages** have been improved a lot. For instance,
|
|
||||||
evaluation errors now point out the location of the error:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ nix build
|
|
||||||
error: undefined variable 'bzip3'
|
|
||||||
|
|
||||||
at /nix/store/449lv242z0zsgwv95a8124xi11sp419f-source/flake.nix:88:13:
|
|
||||||
|
|
||||||
87| [ curl
|
|
||||||
88| bzip3 xz brotli editline
|
|
||||||
| ^
|
|
||||||
89| openssl sqlite
|
|
||||||
```
|
|
||||||
|
|
||||||
* The **`nix` command** has seen a lot of work and is now almost at
|
|
||||||
feature parity with the old command-line interface (the `nix-*`
|
|
||||||
commands). It aims to be [more modern, consistent and pleasant to
|
|
||||||
use](../contributing/cli-guideline.md) than the old CLI. It is still
|
|
||||||
marked as experimental but its interface should not change much
|
|
||||||
anymore in future releases.
|
|
||||||
|
|
||||||
* **Flakes** are a new format to package Nix-based projects in a more
|
|
||||||
discoverable, composable, consistent and reproducible way. A flake
|
|
||||||
is just a repository or tarball containing a file named `flake.nix`
|
|
||||||
that specifies dependencies on other flakes and returns any Nix
|
|
||||||
assets such as packages, Nixpkgs overlays, NixOS modules or CI
|
|
||||||
tests. The new `nix` CLI is primarily based around flakes; for
|
|
||||||
example, a command like `nix run nixpkgs#hello` runs the `hello`
|
|
||||||
application from the `nixpkgs` flake.
|
|
||||||
|
|
||||||
Flakes are currently marked as experimental. For an introduction,
|
|
||||||
see [this blog
|
|
||||||
post](https://www.tweag.io/blog/2020-05-25-flakes/). For detailed
|
|
||||||
information about flake syntax and semantics, see the [`nix flake`
|
|
||||||
manual page](../command-ref/new-cli/nix3-flake.md).
|
|
||||||
|
|
||||||
* Nix's store can now be **content-addressed**, meaning that the hash
|
|
||||||
component of a store path is the hash of the path's
|
|
||||||
contents. Previously Nix could only build **input-addressed** store
|
|
||||||
paths, where the hash is computed from the derivation dependency
|
|
||||||
graph. Content-addressing allows deduplication, early cutoff in
|
|
||||||
build systems, and unprivileged closure copying. This is still [an
|
|
||||||
experimental
|
|
||||||
feature](https://discourse.nixos.org/t/content-addressed-nix-call-for-testers/12881).
|
|
||||||
|
|
||||||
* The Nix manual has been converted into Markdown, making it easier to
|
|
||||||
contribute. In addition, every `nix` subcommand now has a manual
|
|
||||||
page, documenting every option.
|
|
||||||
|
|
||||||
* A new setting that allows **experimental features** to be enabled
|
|
||||||
selectively. This allows us to merge unstable features into Nix more
|
|
||||||
quickly and do more frequent releases.
|
|
||||||
|
|
||||||
## Other features
|
|
||||||
|
|
||||||
* There are many new `nix` subcommands:
|
|
||||||
|
|
||||||
- `nix develop` is intended to replace `nix-shell`. It has a number
|
|
||||||
of new features:
|
|
||||||
|
|
||||||
* It automatically sets the output environment variables (such as
|
|
||||||
`$out`) to writable locations (such as `./outputs/out`).
|
|
||||||
|
|
||||||
* It can store the environment in a profile. This is useful for
|
|
||||||
offline work.
|
|
||||||
|
|
||||||
* It can run specific phases directly. For instance, `nix develop
|
|
||||||
--build` runs `buildPhase`.
|
|
||||||
|
|
||||||
- It allows dependencies in the Nix store to be "redirected" to
|
|
||||||
arbitrary directories using the `--redirect` flag. This is
|
|
||||||
useful if you want to hack on a package *and* some of its
|
|
||||||
dependencies at the same time.
|
|
||||||
|
|
||||||
- `nix print-dev-env` prints the environment variables and bash
|
|
||||||
functions defined by a derivation. This is useful for users of
|
|
||||||
other shells than bash (especially with `--json`).
|
|
||||||
|
|
||||||
- `nix shell` was previously named `nix run` and is intended to
|
|
||||||
replace `nix-shell -p`, but without the `stdenv` overhead. It
|
|
||||||
simply starts a shell where some packages have been added to
|
|
||||||
`$PATH`.
|
|
||||||
|
|
||||||
- `nix run` (not to be confused with the old subcommand that has
|
|
||||||
been renamed to `nix shell`) runs an "app", a flake output that
|
|
||||||
specifies a command to run, or an eponymous program from a
|
|
||||||
package. For example, `nix run nixpkgs#hello` runs the `hello`
|
|
||||||
program from the `hello` package in `nixpkgs`.
|
|
||||||
|
|
||||||
- `nix flake` is the container for flake-related operations, such as
|
|
||||||
creating a new flake, querying the contents of a flake or updating
|
|
||||||
flake lock files.
|
|
||||||
|
|
||||||
- `nix registry` allows you to query and update the flake registry,
|
|
||||||
which maps identifiers such as `nixpkgs` to concrete flake URLs.
|
|
||||||
|
|
||||||
- `nix profile` is intended to replace `nix-env`. Its main advantage
|
|
||||||
is that it keeps track of the provenance of installed packages
|
|
||||||
(e.g. exactly which flake version a package came from). It also
|
|
||||||
has some helpful subcommands:
|
|
||||||
|
|
||||||
* `nix profile history` shows what packages were added, upgraded
|
|
||||||
or removed between each version of a profile.
|
|
||||||
|
|
||||||
* `nix profile diff-closures` shows the changes between the
|
|
||||||
closures of each version of a profile. This allows you to
|
|
||||||
discover the addition or removal of dependencies or size
|
|
||||||
changes.
|
|
||||||
|
|
||||||
**Warning**: after a profile has been updated using `nix profile`,
|
|
||||||
it is no longer usable with `nix-env`.
|
|
||||||
|
|
||||||
- `nix store diff-closures` shows the differences between the
|
|
||||||
closures of two store paths in terms of the versions and sizes of
|
|
||||||
dependencies in the closures.
|
|
||||||
|
|
||||||
- `nix store make-content-addressable` rewrites an arbitrary closure
|
|
||||||
to make it content-addressed. Such paths can be copied into other
|
|
||||||
stores without requiring signatures.
|
|
||||||
|
|
||||||
- `nix bundle` uses the [`nix-bundle`
|
|
||||||
program](https://github.com/matthewbauer/nix-bundle) to convert a
|
|
||||||
closure into a self-extracting executable.
|
|
||||||
|
|
||||||
- Various other replacements for the old CLI, e.g. `nix store gc`,
|
|
||||||
`nix store delete`, `nix store repair`, `nix nar dump-path`, `nix
|
|
||||||
store prefetch-file`, `nix store prefetch-tarball`, `nix key` and
|
|
||||||
`nix daemon`.
|
|
||||||
|
|
||||||
* Nix now has an **evaluation cache** for flake outputs. For example,
|
|
||||||
a second invocation of the command `nix run nixpkgs#firefox` will
|
|
||||||
not need to evaluate the `firefox` attribute because it's already in
|
|
||||||
the evaluation cache. This is made possible by the hermetic
|
|
||||||
evaluation model of flakes.
|
|
||||||
|
|
||||||
* The new `--offline` flag disables substituters and causes all
|
|
||||||
locally cached tarballs and repositories to be considered
|
|
||||||
up-to-date.
|
|
||||||
|
|
||||||
* The new `--refresh` flag causes all locally cached tarballs and
|
|
||||||
repositories to be considered out-of-date.
|
|
||||||
|
|
||||||
* Many `nix` subcommands now have a `--json` option to produce
|
|
||||||
machine-readable output.
|
|
||||||
|
|
||||||
* `nix repl` has a new `:doc` command to show documentation about
|
|
||||||
builtin functions (e.g. `:doc builtins.map`).
|
|
||||||
|
|
||||||
* Binary cache stores now have an option `index-debug-info` to create
|
|
||||||
an index of DWARF debuginfo files for use by
|
|
||||||
[`dwarffs`](https://github.com/edolstra/dwarffs).
|
|
||||||
|
|
||||||
* To support flakes, Nix now has an extensible mechanism for fetching
|
|
||||||
source trees. Currently it has the following backends:
|
|
||||||
|
|
||||||
* Git repositories
|
|
||||||
|
|
||||||
* Mercurial repositories
|
|
||||||
|
|
||||||
* GitHub and GitLab repositories (an optimisation for faster
|
|
||||||
fetching than Git)
|
|
||||||
|
|
||||||
* Tarballs
|
|
||||||
|
|
||||||
* Arbitrary directories
|
|
||||||
|
|
||||||
The fetcher infrastructure is exposed via flake input specifications
|
|
||||||
and via the `fetchTree` built-in.
|
|
||||||
|
|
||||||
* **Languages changes**: the only new language feature is that you can
|
|
||||||
now have antiquotations in paths, e.g. `./${foo}` instead of `./. +
|
|
||||||
foo`.
|
|
||||||
|
|
||||||
* **New built-in functions**:
|
|
||||||
|
|
||||||
- `builtins.fetchTree` allows fetching a source tree using any
|
|
||||||
backends supported by the fetcher infrastructure. It subsumes the
|
|
||||||
functionality of existing built-ins like `fetchGit`,
|
|
||||||
`fetchMercurial` and `fetchTarball`.
|
|
||||||
|
|
||||||
- `builtins.getFlake` fetches a flake and returns its output
|
|
||||||
attributes. This function should not be used inside flakes! Use
|
|
||||||
flake inputs instead.
|
|
||||||
|
|
||||||
- `builtins.floor` and `builtins.ceil` round a floating-point number
|
|
||||||
down and up, respectively.
|
|
||||||
|
|
||||||
* Experimental support for recursive Nix. This means that Nix
|
|
||||||
derivations can now call Nix to build other derivations. This is not
|
|
||||||
in a stable state yet and not well
|
|
||||||
[documented](https://github.com/NixOS/nix/commit/c4d7c76b641d82b2696fef73ce0ac160043c18da).
|
|
||||||
|
|
||||||
* The new experimental feature `no-url-literals` disables URL
|
|
||||||
literals. This helps to implement [RFC
|
|
||||||
45](https://github.com/NixOS/rfcs/pull/45).
|
|
||||||
|
|
||||||
* Nix now uses `libarchive` to decompress and unpack tarballs and zip
|
|
||||||
files, so `tar` is no longer required.
|
|
||||||
|
|
||||||
* The priority of substituters can now be overridden using the
|
|
||||||
`priority` substituter setting (e.g. `--substituters
|
|
||||||
'http://cache.nixos.org?priority=100 daemon?priority=10'`).
|
|
||||||
|
|
||||||
* `nix edit` now supports non-derivation attributes, e.g. `nix edit
|
|
||||||
.#nixosConfigurations.bla`.
|
|
||||||
|
|
||||||
* The `nix` command now provides command line completion for `bash`,
|
|
||||||
`zsh` and `fish`. Since the support for getting completions is built
|
|
||||||
into `nix`, it's easy to add support for other shells.
|
|
||||||
|
|
||||||
* The new `--log-format` flag selects what Nix's output looks like. It
|
|
||||||
defaults to a terse progress indicator. There is a new
|
|
||||||
`internal-json` output format for use by other programs.
|
|
||||||
|
|
||||||
* `nix eval` has a new `--apply` flag that applies a function to the
|
|
||||||
evaluation result.
|
|
||||||
|
|
||||||
* `nix eval` has a new `--write-to` flag that allows it to write a
|
|
||||||
nested attribute set of string leaves to a corresponding directory
|
|
||||||
tree.
|
|
||||||
|
|
||||||
* Memory improvements: many operations that add paths to the store or
|
|
||||||
copy paths between stores now run in constant memory.
|
|
||||||
|
|
||||||
* Many `nix` commands now support the flag `--derivation` to operate
|
|
||||||
on a `.drv` file itself instead of its outputs.
|
|
||||||
|
|
||||||
* There is a new store called `dummy://` that does not support
|
|
||||||
building or adding paths. This is useful if you want to use the Nix
|
|
||||||
evaluator but don't have a Nix store.
|
|
||||||
|
|
||||||
* The `ssh-ng://` store now allows substituting paths on the remote,
|
|
||||||
as `ssh://` already did.
|
|
||||||
|
|
||||||
* When auto-calling a function with an ellipsis, all arguments are now
|
|
||||||
passed.
|
|
||||||
|
|
||||||
* New `nix-shell` features:
|
|
||||||
|
|
||||||
- It preserves the `PS1` environment variable if
|
|
||||||
`NIX_SHELL_PRESERVE_PROMPT` is set.
|
|
||||||
|
|
||||||
- With `-p`, it passes any `--arg`s as Nixpkgs arguments.
|
|
||||||
|
|
||||||
- Support for structured attributes.
|
|
||||||
|
|
||||||
* `nix-prefetch-url` has a new `--executable` flag.
|
|
||||||
|
|
||||||
* On `x86_64` systems, [`x86_64` microarchitecture
|
|
||||||
levels](https://lwn.net/Articles/844831/) are mapped to additional
|
|
||||||
system types (e.g. `x86_64-v1-linux`).
|
|
||||||
|
|
||||||
* The new `--eval-store` flag allows you to use a different store for
|
|
||||||
evaluation than for building or storing the build result. This is
|
|
||||||
primarily useful when you want to query whether something exists in
|
|
||||||
a read-only store, such as a binary cache:
|
|
||||||
|
|
||||||
```
|
|
||||||
# nix path-info --json --store https://cache.nixos.org \
|
|
||||||
--eval-store auto nixpkgs#hello
|
|
||||||
```
|
|
||||||
|
|
||||||
(Here `auto` indicates the local store.)
|
|
||||||
|
|
||||||
* The Nix daemon has a new low-latency mechanism for copying
|
|
||||||
closures. This is useful when building on remote stores such as
|
|
||||||
`ssh-ng://`.
|
|
||||||
|
|
||||||
* Plugins can now register `nix` subcommands.
|
|
||||||
|
|
||||||
## Incompatible changes
|
|
||||||
|
|
||||||
* The `nix` command is now marked as an experimental feature. This
|
|
||||||
means that you need to add
|
|
||||||
|
|
||||||
```
|
|
||||||
experimental-features = nix-command
|
|
||||||
```
|
|
||||||
|
|
||||||
to your `nix.conf` if you want to use it, or pass
|
|
||||||
`--extra-experimental-features nix-command` on the command line.
|
|
||||||
|
|
||||||
* The `nix` command no longer has a syntax for referring to packages
|
|
||||||
in a channel. This means that the following no longer works:
|
|
||||||
|
|
||||||
```console
|
|
||||||
nix build nixpkgs.hello # Nix 2.3
|
|
||||||
```
|
|
||||||
|
|
||||||
Instead, you can either use the `#` syntax to select a package from
|
|
||||||
a flake, e.g.
|
|
||||||
|
|
||||||
```console
|
|
||||||
nix build nixpkgs#hello
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, if you want to use the `nixpkgs` channel in the `NIX_PATH`
|
|
||||||
environment variable:
|
|
||||||
|
|
||||||
```console
|
|
||||||
nix build -f '<nixpkgs>' hello
|
|
||||||
```
|
|
||||||
|
|
||||||
* The old `nix run` has been renamed to `nix shell`, while there is a
|
|
||||||
new `nix run` that runs a default command. So instead of
|
|
||||||
|
|
||||||
```console
|
|
||||||
nix run nixpkgs.hello -c hello # Nix 2.3
|
|
||||||
```
|
|
||||||
|
|
||||||
you should use
|
|
||||||
|
|
||||||
```console
|
|
||||||
nix shell nixpkgs#hello -c hello
|
|
||||||
```
|
|
||||||
|
|
||||||
or just
|
|
||||||
|
|
||||||
```console
|
|
||||||
nix run nixpkgs#hello
|
|
||||||
```
|
|
||||||
|
|
||||||
if the command you want to run has the same name as the package.
|
|
||||||
|
|
||||||
* It is now an error to modify the `plugin-files` setting via a
|
|
||||||
command-line flag that appears after the first non-flag argument to
|
|
||||||
any command, including a subcommand to `nix`. For example,
|
|
||||||
`nix-instantiate default.nix --plugin-files ""` must now become
|
|
||||||
`nix-instantiate --plugin-files "" default.nix`.
|
|
||||||
|
|
||||||
* We no longer release source tarballs. If you want to build from
|
|
||||||
source, please build from the tags in the Git repository.
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
This release has contributions from
|
|
||||||
Adam Höse,
|
|
||||||
Albert Safin,
|
|
||||||
Alex Kovar,
|
|
||||||
Alex Zero,
|
|
||||||
Alexander Bantyev,
|
|
||||||
Alexandre Esteves,
|
|
||||||
Alyssa Ross,
|
|
||||||
Anatole Lucet,
|
|
||||||
Anders Kaseorg,
|
|
||||||
Andreas Rammhold,
|
|
||||||
Antoine Eiche,
|
|
||||||
Antoine Martin,
|
|
||||||
Arnout Engelen,
|
|
||||||
Arthur Gautier,
|
|
||||||
aszlig,
|
|
||||||
Ben Burdette,
|
|
||||||
Benjamin Hipple,
|
|
||||||
Bernardo Meurer,
|
|
||||||
Björn Gohla,
|
|
||||||
Bjørn Forsman,
|
|
||||||
Bob van der Linden,
|
|
||||||
Brian Leung,
|
|
||||||
Brian McKenna,
|
|
||||||
Brian Wignall,
|
|
||||||
Bruce Toll,
|
|
||||||
Bryan Richter,
|
|
||||||
Calle Rosenquist,
|
|
||||||
Calvin Loncaric,
|
|
||||||
Carlo Nucera,
|
|
||||||
Carlos D'Agostino,
|
|
||||||
Chaz Schlarp,
|
|
||||||
Christian Höppner,
|
|
||||||
Christian Kampka,
|
|
||||||
Chua Hou,
|
|
||||||
Chuck,
|
|
||||||
Cole Helbling,
|
|
||||||
Daiderd Jordan,
|
|
||||||
Dan Callahan,
|
|
||||||
Dani,
|
|
||||||
Daniel Fitzpatrick,
|
|
||||||
Danila Fedorin,
|
|
||||||
Daniël de Kok,
|
|
||||||
Danny Bautista,
|
|
||||||
DavHau,
|
|
||||||
David McFarland,
|
|
||||||
Dima,
|
|
||||||
Domen Kožar,
|
|
||||||
Dominik Schrempf,
|
|
||||||
Dominique Martinet,
|
|
||||||
dramforever,
|
|
||||||
Dustin DeWeese,
|
|
||||||
edef,
|
|
||||||
Eelco Dolstra,
|
|
||||||
Emilio Karakey,
|
|
||||||
Emily,
|
|
||||||
Eric Culp,
|
|
||||||
Ersin Akinci,
|
|
||||||
Fabian Möller,
|
|
||||||
Farid Zakaria,
|
|
||||||
Federico Pellegrin,
|
|
||||||
Finn Behrens,
|
|
||||||
Florian Franzen,
|
|
||||||
Félix Baylac-Jacqué,
|
|
||||||
Gabriel Gonzalez,
|
|
||||||
Geoff Reedy,
|
|
||||||
Georges Dubus,
|
|
||||||
Graham Christensen,
|
|
||||||
Greg Hale,
|
|
||||||
Greg Price,
|
|
||||||
Gregor Kleen,
|
|
||||||
Gregory Hale,
|
|
||||||
Griffin Smith,
|
|
||||||
Guillaume Bouchard,
|
|
||||||
Harald van Dijk,
|
|
||||||
illustris,
|
|
||||||
Ivan Zvonimir Horvat,
|
|
||||||
Jade,
|
|
||||||
Jake Waksbaum,
|
|
||||||
jakobrs,
|
|
||||||
James Ottaway,
|
|
||||||
Jan Tojnar,
|
|
||||||
Janne Heß,
|
|
||||||
Jaroslavas Pocepko,
|
|
||||||
Jarrett Keifer,
|
|
||||||
Jeremy Schlatter,
|
|
||||||
Joachim Breitner,
|
|
||||||
Joe Hermaszewski,
|
|
||||||
Joe Pea,
|
|
||||||
John Ericson,
|
|
||||||
Jonathan Ringer,
|
|
||||||
Josef Kemetmüller,
|
|
||||||
Joseph Lucas,
|
|
||||||
Jude Taylor,
|
|
||||||
Julian Stecklina,
|
|
||||||
Julien Tanguy,
|
|
||||||
Jörg Thalheim,
|
|
||||||
Kai Wohlfahrt,
|
|
||||||
keke,
|
|
||||||
Keshav Kini,
|
|
||||||
Kevin Quick,
|
|
||||||
Kevin Stock,
|
|
||||||
Kjetil Orbekk,
|
|
||||||
Krzysztof Gogolewski,
|
|
||||||
kvtb,
|
|
||||||
Lars Mühmel,
|
|
||||||
Leonhard Markert,
|
|
||||||
Lily Ballard,
|
|
||||||
Linus Heckemann,
|
|
||||||
Lorenzo Manacorda,
|
|
||||||
Lucas Desgouilles,
|
|
||||||
Lucas Franceschino,
|
|
||||||
Lucas Hoffmann,
|
|
||||||
Luke Granger-Brown,
|
|
||||||
Madeline Haraj,
|
|
||||||
Marwan Aljubeh,
|
|
||||||
Mat Marini,
|
|
||||||
Mateusz Piotrowski,
|
|
||||||
Matthew Bauer,
|
|
||||||
Matthew Kenigsberg,
|
|
||||||
Mauricio Scheffer,
|
|
||||||
Maximilian Bosch,
|
|
||||||
Michael Adler,
|
|
||||||
Michael Bishop,
|
|
||||||
Michael Fellinger,
|
|
||||||
Michael Forney,
|
|
||||||
Michael Reilly,
|
|
||||||
mlatus,
|
|
||||||
Mykola Orliuk,
|
|
||||||
Nathan van Doorn,
|
|
||||||
Naïm Favier,
|
|
||||||
ng0,
|
|
||||||
Nick Van den Broeck,
|
|
||||||
Nicolas Stig124 Formichella,
|
|
||||||
Niels Egberts,
|
|
||||||
Niklas Hambüchen,
|
|
||||||
Nikola Knezevic,
|
|
||||||
oxalica,
|
|
||||||
p01arst0rm,
|
|
||||||
Pamplemousse,
|
|
||||||
Patrick Hilhorst,
|
|
||||||
Paul Opiyo,
|
|
||||||
Pavol Rusnak,
|
|
||||||
Peter Kolloch,
|
|
||||||
Philipp Bartsch,
|
|
||||||
Philipp Middendorf,
|
|
||||||
Piotr Szubiakowski,
|
|
||||||
Profpatsch,
|
|
||||||
Puck Meerburg,
|
|
||||||
Ricardo M. Correia,
|
|
||||||
Rickard Nilsson,
|
|
||||||
Robert Hensing,
|
|
||||||
Robin Gloster,
|
|
||||||
Rodrigo,
|
|
||||||
Rok Garbas,
|
|
||||||
Ronnie Ebrin,
|
|
||||||
Rovanion Luckey,
|
|
||||||
Ryan Burns,
|
|
||||||
Ryan Mulligan,
|
|
||||||
Ryne Everett,
|
|
||||||
Sam Doshi,
|
|
||||||
Sam Lidder,
|
|
||||||
Samir Talwar,
|
|
||||||
Samuel Dionne-Riel,
|
|
||||||
Sebastian Ullrich,
|
|
||||||
Sergei Trofimovich,
|
|
||||||
Sevan Janiyan,
|
|
||||||
Shao Cheng,
|
|
||||||
Shea Levy,
|
|
||||||
Silvan Mosberger,
|
|
||||||
Stefan Frijters,
|
|
||||||
Stefan Jaax,
|
|
||||||
sternenseemann,
|
|
||||||
Steven Shaw,
|
|
||||||
Stéphan Kochen,
|
|
||||||
SuperSandro2000,
|
|
||||||
Suraj Barkale,
|
|
||||||
Taeer Bar-Yam,
|
|
||||||
Thomas Churchman,
|
|
||||||
Théophane Hufschmitt,
|
|
||||||
Timothy DeHerrera,
|
|
||||||
Timothy Klim,
|
|
||||||
Tobias Möst,
|
|
||||||
Tobias Pflug,
|
|
||||||
Tom Bereknyei,
|
|
||||||
Travis A. Everett,
|
|
||||||
Ujjwal Jain,
|
|
||||||
Vladimír Čunát,
|
|
||||||
Wil Taylor,
|
|
||||||
Will Dietz,
|
|
||||||
Yaroslav Bolyukin,
|
|
||||||
Yestin L. Harrison,
|
|
||||||
YI,
|
|
||||||
Yorick van Pelt,
|
|
||||||
Yuriy Taraday and
|
|
||||||
zimbatm.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Release 2.5 (2021-XX-XX)
|
|
||||||
|
|
||||||
* Binary cache stores now have a setting `compression-level`.
|
|
||||||
|
|
||||||
* `nix develop` now has a flag `--unpack` to run `unpackPhase`.
|
|
||||||
Generated
+4
-21
@@ -1,39 +1,22 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"lowdown-src": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1633514407,
|
|
||||||
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
|
|
||||||
"owner": "kristapsdz",
|
|
||||||
"repo": "lowdown",
|
|
||||||
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "kristapsdz",
|
|
||||||
"repo": "lowdown",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1632864508,
|
"lastModified": 1602702596,
|
||||||
"narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=",
|
"narHash": "sha256-fqJ4UgOb4ZUnCDIapDb4gCrtAah5Rnr2/At3IzMitig=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "82891b5e2c2359d7e58d08849e4c89511ab94234",
|
"rev": "ad0d20345219790533ebe06571f82ed6b034db31",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-21.05-small",
|
"ref": "nixos-20.09-small",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"lowdown-src": "lowdown-src",
|
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
description = "The purely functional package manager";
|
description = "The purely functional package manager";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-21.05-small";
|
inputs.nixpkgs.url = "nixpkgs/nixos-20.09-small";
|
||||||
inputs.lowdown-src = { url = "github:kristapsdz/lowdown"; flake = false; };
|
#inputs.lowdown-src = { url = "github:kristapsdz/lowdown"; flake = false; };
|
||||||
|
|
||||||
outputs = { self, nixpkgs, lowdown-src }:
|
outputs = { self, nixpkgs }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
@@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ];
|
linux64BitSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
linuxSystems = linux64BitSystems ++ [ "i686-linux" ];
|
linuxSystems = linux64BitSystems ++ [ "i686-linux" ];
|
||||||
systems = linuxSystems ++ [ "x86_64-darwin" "aarch64-darwin" ];
|
systems = linuxSystems ++ [ "x86_64-darwin" ];
|
||||||
|
|
||||||
crossSystems = [ "armv6l-linux" "armv7l-linux" ];
|
|
||||||
|
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||||
|
|
||||||
@@ -61,7 +59,6 @@
|
|||||||
|
|
||||||
configureFlags =
|
configureFlags =
|
||||||
lib.optionals stdenv.isLinux [
|
lib.optionals stdenv.isLinux [
|
||||||
"--with-boost=${boost}/lib"
|
|
||||||
"--with-sandbox-shell=${sh}/bin/busybox"
|
"--with-sandbox-shell=${sh}/bin/busybox"
|
||||||
"LDFLAGS=-fuse-ld=gold"
|
"LDFLAGS=-fuse-ld=gold"
|
||||||
];
|
];
|
||||||
@@ -71,7 +68,7 @@
|
|||||||
[
|
[
|
||||||
buildPackages.bison
|
buildPackages.bison
|
||||||
buildPackages.flex
|
buildPackages.flex
|
||||||
(lib.getBin buildPackages.lowdown-nix)
|
(lib.getBin buildPackages.lowdown)
|
||||||
buildPackages.mdbook
|
buildPackages.mdbook
|
||||||
buildPackages.autoconf-archive
|
buildPackages.autoconf-archive
|
||||||
buildPackages.autoreconfHook
|
buildPackages.autoreconfHook
|
||||||
@@ -79,23 +76,22 @@
|
|||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
buildPackages.git
|
buildPackages.git
|
||||||
buildPackages.mercurial # FIXME: remove? only needed for tests
|
buildPackages.mercurial
|
||||||
buildPackages.jq
|
buildPackages.jq
|
||||||
]
|
];
|
||||||
++ lib.optionals stdenv.hostPlatform.isLinux [(buildPackages.util-linuxMinimal or buildPackages.utillinuxMinimal)];
|
|
||||||
|
|
||||||
buildDeps =
|
buildDeps =
|
||||||
[ curl
|
[ curl
|
||||||
bzip2 xz brotli editline
|
bzip2 xz brotli zlib editline
|
||||||
openssl sqlite
|
openssl sqlite
|
||||||
libarchive
|
libarchive
|
||||||
boost
|
boost
|
||||||
lowdown-nix
|
nlohmann_json
|
||||||
|
lowdown
|
||||||
gmock
|
gmock
|
||||||
]
|
]
|
||||||
++ lib.optionals stdenv.isLinux [libseccomp]
|
++ lib.optionals stdenv.isLinux [libseccomp utillinuxMinimal]
|
||||||
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
|
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium;
|
||||||
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid;
|
|
||||||
|
|
||||||
awsDeps = lib.optional (stdenv.isLinux || stdenv.isDarwin)
|
awsDeps = lib.optional (stdenv.isLinux || stdenv.isDarwin)
|
||||||
(aws-sdk-cpp.override {
|
(aws-sdk-cpp.override {
|
||||||
@@ -104,13 +100,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
propagatedDeps =
|
propagatedDeps =
|
||||||
[ ((boehmgc.override {
|
[ (boehmgc.override { enableLargeConfig = true; })
|
||||||
enableLargeConfig = true;
|
|
||||||
}).overrideAttrs(o: {
|
|
||||||
patches = (o.patches or []) ++ [
|
|
||||||
./boehmgc-coroutine-sp-fallback.diff
|
|
||||||
];
|
|
||||||
}))
|
|
||||||
];
|
];
|
||||||
|
|
||||||
perlDeps =
|
perlDeps =
|
||||||
@@ -119,153 +109,12 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
installScriptFor = systems:
|
|
||||||
with nixpkgsFor.x86_64-linux;
|
|
||||||
runCommand "installer-script"
|
|
||||||
{ buildInputs = [ nix ];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
mkdir -p $out/nix-support
|
|
||||||
|
|
||||||
# Converts /nix/store/50p3qk8k...-nix-2.4pre20201102_550e11f/bin/nix to 50p3qk8k.../bin/nix.
|
|
||||||
tarballPath() {
|
|
||||||
# Remove the store prefix
|
|
||||||
local path=''${1#${builtins.storeDir}/}
|
|
||||||
# Get the path relative to the derivation root
|
|
||||||
local rest=''${path#*/}
|
|
||||||
# Get the derivation hash
|
|
||||||
local drvHash=''${path%%-*}
|
|
||||||
echo "$drvHash/$rest"
|
|
||||||
}
|
|
||||||
|
|
||||||
substitute ${./scripts/install.in} $out/install \
|
|
||||||
${pkgs.lib.concatMapStrings
|
|
||||||
(system: let
|
|
||||||
tarball = if builtins.elem system crossSystems then self.hydraJobs.binaryTarballCross.x86_64-linux.${system} else self.hydraJobs.binaryTarball.${system};
|
|
||||||
in '' \
|
|
||||||
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${tarball}/*.tar.xz) \
|
|
||||||
--replace '@tarballPath_${system}@' $(tarballPath ${tarball}/*.tar.xz) \
|
|
||||||
''
|
|
||||||
)
|
|
||||||
systems
|
|
||||||
} --replace '@nixVersion@' ${version}
|
|
||||||
|
|
||||||
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
|
||||||
'';
|
|
||||||
|
|
||||||
testNixVersions = pkgs: client: daemon: with commonDeps pkgs; with pkgs.lib; pkgs.stdenv.mkDerivation {
|
|
||||||
NIX_DAEMON_PACKAGE = daemon;
|
|
||||||
NIX_CLIENT_PACKAGE = client;
|
|
||||||
name =
|
|
||||||
"nix-tests"
|
|
||||||
+ optionalString
|
|
||||||
(versionAtLeast daemon.version "2.4pre20211005" &&
|
|
||||||
versionAtLeast client.version "2.4pre20211005")
|
|
||||||
"-${client.version}-against-${daemon.version}";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = self;
|
|
||||||
|
|
||||||
VERSION_SUFFIX = versionSuffix;
|
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildDeps;
|
|
||||||
buildInputs = buildDeps ++ awsDeps;
|
|
||||||
propagatedBuildInputs = propagatedDeps;
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
dontBuild = true;
|
|
||||||
doInstallCheck = true;
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
installCheckPhase = "make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES";
|
|
||||||
};
|
|
||||||
|
|
||||||
binaryTarball = buildPackages: nix: pkgs: let
|
|
||||||
inherit (pkgs) cacert;
|
|
||||||
installerClosureInfo = buildPackages.closureInfo { rootPaths = [ nix cacert ]; };
|
|
||||||
in
|
|
||||||
|
|
||||||
buildPackages.runCommand "nix-binary-tarball-${version}"
|
|
||||||
{ #nativeBuildInputs = lib.optional (system != "aarch64-linux") shellcheck;
|
|
||||||
meta.description = "Distribution-independent Nix bootstrap binaries for ${pkgs.system}";
|
|
||||||
}
|
|
||||||
''
|
|
||||||
cp ${installerClosureInfo}/registration $TMPDIR/reginfo
|
|
||||||
cp ${./scripts/create-darwin-volume.sh} $TMPDIR/create-darwin-volume.sh
|
|
||||||
substitute ${./scripts/install-nix-from-closure.sh} $TMPDIR/install \
|
|
||||||
--subst-var-by nix ${nix} \
|
|
||||||
--subst-var-by cacert ${cacert}
|
|
||||||
|
|
||||||
substitute ${./scripts/install-darwin-multi-user.sh} $TMPDIR/install-darwin-multi-user.sh \
|
|
||||||
--subst-var-by nix ${nix} \
|
|
||||||
--subst-var-by cacert ${cacert}
|
|
||||||
substitute ${./scripts/install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \
|
|
||||||
--subst-var-by nix ${nix} \
|
|
||||||
--subst-var-by cacert ${cacert}
|
|
||||||
substitute ${./scripts/install-multi-user.sh} $TMPDIR/install-multi-user \
|
|
||||||
--subst-var-by nix ${nix} \
|
|
||||||
--subst-var-by cacert ${cacert}
|
|
||||||
|
|
||||||
if type -p shellcheck; then
|
|
||||||
# SC1090: Don't worry about not being able to find
|
|
||||||
# $nix/etc/profile.d/nix.sh
|
|
||||||
shellcheck --exclude SC1090 $TMPDIR/install
|
|
||||||
shellcheck $TMPDIR/create-darwin-volume.sh
|
|
||||||
shellcheck $TMPDIR/install-darwin-multi-user.sh
|
|
||||||
shellcheck $TMPDIR/install-systemd-multi-user.sh
|
|
||||||
|
|
||||||
# SC1091: Don't panic about not being able to source
|
|
||||||
# /etc/profile
|
|
||||||
# SC2002: Ignore "useless cat" "error", when loading
|
|
||||||
# .reginfo, as the cat is a much cleaner
|
|
||||||
# implementation, even though it is "useless"
|
|
||||||
# SC2116: Allow ROOT_HOME=$(echo ~root) for resolving
|
|
||||||
# root's home directory
|
|
||||||
shellcheck --external-sources \
|
|
||||||
--exclude SC1091,SC2002,SC2116 $TMPDIR/install-multi-user
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod +x $TMPDIR/install
|
|
||||||
chmod +x $TMPDIR/create-darwin-volume.sh
|
|
||||||
chmod +x $TMPDIR/install-darwin-multi-user.sh
|
|
||||||
chmod +x $TMPDIR/install-systemd-multi-user.sh
|
|
||||||
chmod +x $TMPDIR/install-multi-user
|
|
||||||
dir=nix-${version}-${pkgs.system}
|
|
||||||
fn=$out/$dir.tar.xz
|
|
||||||
mkdir -p $out/nix-support
|
|
||||||
echo "file binary-dist $fn" >> $out/nix-support/hydra-build-products
|
|
||||||
tar cvfJ $fn \
|
|
||||||
--owner=0 --group=0 --mode=u+rw,uga+r \
|
|
||||||
--absolute-names \
|
|
||||||
--hard-dereference \
|
|
||||||
--transform "s,$TMPDIR/install,$dir/install," \
|
|
||||||
--transform "s,$TMPDIR/create-darwin-volume.sh,$dir/create-darwin-volume.sh," \
|
|
||||||
--transform "s,$TMPDIR/reginfo,$dir/.reginfo," \
|
|
||||||
--transform "s,$NIX_STORE,$dir/store,S" \
|
|
||||||
$TMPDIR/install \
|
|
||||||
$TMPDIR/create-darwin-volume.sh \
|
|
||||||
$TMPDIR/install-darwin-multi-user.sh \
|
|
||||||
$TMPDIR/install-systemd-multi-user.sh \
|
|
||||||
$TMPDIR/install-multi-user \
|
|
||||||
$TMPDIR/reginfo \
|
|
||||||
$(cat ${installerClosureInfo}/store-paths)
|
|
||||||
'';
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
# A Nixpkgs overlay that overrides the 'nix' and
|
# A Nixpkgs overlay that overrides the 'nix' and
|
||||||
# 'nix.perl-bindings' packages.
|
# 'nix.perl-bindings' packages.
|
||||||
overlay = final: prev: {
|
overlay = final: prev: {
|
||||||
|
|
||||||
nixStable = prev.nix;
|
|
||||||
|
|
||||||
# Forward from the previous stage as we don’t want it to pick the lowdown override
|
|
||||||
nixUnstable = prev.nixUnstable;
|
|
||||||
|
|
||||||
nix = with final; with commonDeps pkgs; stdenv.mkDerivation {
|
nix = with final; with commonDeps pkgs; stdenv.mkDerivation {
|
||||||
name = "nix-${version}";
|
name = "nix-${version}";
|
||||||
inherit version;
|
inherit version;
|
||||||
@@ -315,8 +164,6 @@
|
|||||||
|
|
||||||
separateDebugInfo = true;
|
separateDebugInfo = true;
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
passthru.perl-bindings = with final; stdenv.mkDerivation {
|
passthru.perl-bindings = with final; stdenv.mkDerivation {
|
||||||
name = "nix-perl-${version}";
|
name = "nix-perl-${version}";
|
||||||
|
|
||||||
@@ -335,9 +182,9 @@
|
|||||||
xz
|
xz
|
||||||
pkgs.perl
|
pkgs.perl
|
||||||
boost
|
boost
|
||||||
|
nlohmann_json
|
||||||
]
|
]
|
||||||
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
|
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium;
|
||||||
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
|
|
||||||
|
|
||||||
configureFlags = ''
|
configureFlags = ''
|
||||||
--with-dbi=${perlPackages.DBI}/${pkgs.perl.libPrefix}
|
--with-dbi=${perlPackages.DBI}/${pkgs.perl.libPrefix}
|
||||||
@@ -351,17 +198,22 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lowdown-nix = with final; stdenv.mkDerivation rec {
|
lowdown = with final; stdenv.mkDerivation rec {
|
||||||
name = "lowdown-0.9.0";
|
name = "lowdown-0.8.0";
|
||||||
|
|
||||||
src = lowdown-src;
|
src = fetchurl {
|
||||||
|
url = "https://kristaps.bsd.lv/lowdown/snapshots/${name}.tar.gz";
|
||||||
|
hash = "sha512-U9WeGoInT9vrawwa57t6u9dEdRge4/P+0wLxmQyOL9nhzOEUU2FRz2Be9H0dCjYE7p2v3vCXIYk40M+jjULATw==";
|
||||||
|
};
|
||||||
|
|
||||||
|
#src = lowdown-src;
|
||||||
|
|
||||||
outputs = [ "out" "bin" "dev" ];
|
outputs = [ "out" "bin" "dev" ];
|
||||||
|
|
||||||
nativeBuildInputs = [ buildPackages.which ];
|
nativeBuildInputs = [ which ];
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase =
|
||||||
${if (stdenv.isDarwin && stdenv.isAarch64) then "echo \"HAVE_SANDBOX_INIT=false\" > configure.local" else ""}
|
''
|
||||||
./configure \
|
./configure \
|
||||||
PREFIX=${placeholder "dev"} \
|
PREFIX=${placeholder "dev"} \
|
||||||
BINDIR=${placeholder "bin"}/bin
|
BINDIR=${placeholder "bin"}/bin
|
||||||
@@ -377,33 +229,124 @@
|
|||||||
|
|
||||||
buildStatic = nixpkgs.lib.genAttrs linux64BitSystems (system: self.packages.${system}.nix-static);
|
buildStatic = nixpkgs.lib.genAttrs linux64BitSystems (system: self.packages.${system}.nix-static);
|
||||||
|
|
||||||
buildCross = nixpkgs.lib.genAttrs crossSystems (crossSystem:
|
|
||||||
nixpkgs.lib.genAttrs ["x86_64-linux"] (system: self.packages.${system}."nix-${crossSystem}"));
|
|
||||||
|
|
||||||
# Perl bindings for various platforms.
|
# Perl bindings for various platforms.
|
||||||
perlBindings = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix.perl-bindings);
|
perlBindings = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix.perl-bindings);
|
||||||
|
|
||||||
# Binary tarball for various platforms, containing a Nix store
|
# Binary tarball for various platforms, containing a Nix store
|
||||||
# with the closure of 'nix' package, and the second half of
|
# with the closure of 'nix' package, and the second half of
|
||||||
# the installation script.
|
# the installation script.
|
||||||
binaryTarball = nixpkgs.lib.genAttrs systems (system: binaryTarball nixpkgsFor.${system} nixpkgsFor.${system}.nix nixpkgsFor.${system});
|
binaryTarball = nixpkgs.lib.genAttrs systems (system:
|
||||||
|
|
||||||
binaryTarballCross = nixpkgs.lib.genAttrs ["x86_64-linux"] (system: builtins.listToAttrs (map (crossSystem: {
|
with nixpkgsFor.${system};
|
||||||
name = crossSystem;
|
|
||||||
value = let
|
let
|
||||||
nixpkgsCross = import nixpkgs {
|
installerClosureInfo = closureInfo { rootPaths = [ nix cacert ]; };
|
||||||
inherit system crossSystem;
|
in
|
||||||
overlays = [ self.overlay ];
|
|
||||||
};
|
runCommand "nix-binary-tarball-${version}"
|
||||||
in binaryTarball nixpkgsFor.${system} self.packages.${system}."nix-${crossSystem}" nixpkgsCross;
|
{ #nativeBuildInputs = lib.optional (system != "aarch64-linux") shellcheck;
|
||||||
}) crossSystems));
|
meta.description = "Distribution-independent Nix bootstrap binaries for ${system}";
|
||||||
|
}
|
||||||
|
''
|
||||||
|
cp ${installerClosureInfo}/registration $TMPDIR/reginfo
|
||||||
|
cp ${./scripts/create-darwin-volume.sh} $TMPDIR/create-darwin-volume.sh
|
||||||
|
substitute ${./scripts/install-nix-from-closure.sh} $TMPDIR/install \
|
||||||
|
--subst-var-by nix ${nix} \
|
||||||
|
--subst-var-by cacert ${cacert}
|
||||||
|
|
||||||
|
substitute ${./scripts/install-darwin-multi-user.sh} $TMPDIR/install-darwin-multi-user.sh \
|
||||||
|
--subst-var-by nix ${nix} \
|
||||||
|
--subst-var-by cacert ${cacert}
|
||||||
|
substitute ${./scripts/install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \
|
||||||
|
--subst-var-by nix ${nix} \
|
||||||
|
--subst-var-by cacert ${cacert}
|
||||||
|
substitute ${./scripts/install-multi-user.sh} $TMPDIR/install-multi-user \
|
||||||
|
--subst-var-by nix ${nix} \
|
||||||
|
--subst-var-by cacert ${cacert}
|
||||||
|
|
||||||
|
if type -p shellcheck; then
|
||||||
|
# SC1090: Don't worry about not being able to find
|
||||||
|
# $nix/etc/profile.d/nix.sh
|
||||||
|
shellcheck --exclude SC1090 $TMPDIR/install
|
||||||
|
shellcheck $TMPDIR/create-darwin-volume.sh
|
||||||
|
shellcheck $TMPDIR/install-darwin-multi-user.sh
|
||||||
|
shellcheck $TMPDIR/install-systemd-multi-user.sh
|
||||||
|
|
||||||
|
# SC1091: Don't panic about not being able to source
|
||||||
|
# /etc/profile
|
||||||
|
# SC2002: Ignore "useless cat" "error", when loading
|
||||||
|
# .reginfo, as the cat is a much cleaner
|
||||||
|
# implementation, even though it is "useless"
|
||||||
|
# SC2116: Allow ROOT_HOME=$(echo ~root) for resolving
|
||||||
|
# root's home directory
|
||||||
|
shellcheck --external-sources \
|
||||||
|
--exclude SC1091,SC2002,SC2116 $TMPDIR/install-multi-user
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod +x $TMPDIR/install
|
||||||
|
chmod +x $TMPDIR/create-darwin-volume.sh
|
||||||
|
chmod +x $TMPDIR/install-darwin-multi-user.sh
|
||||||
|
chmod +x $TMPDIR/install-systemd-multi-user.sh
|
||||||
|
chmod +x $TMPDIR/install-multi-user
|
||||||
|
dir=nix-${version}-${system}
|
||||||
|
fn=$out/$dir.tar.xz
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
echo "file binary-dist $fn" >> $out/nix-support/hydra-build-products
|
||||||
|
tar cvfJ $fn \
|
||||||
|
--owner=0 --group=0 --mode=u+rw,uga+r \
|
||||||
|
--absolute-names \
|
||||||
|
--hard-dereference \
|
||||||
|
--transform "s,$TMPDIR/install,$dir/install," \
|
||||||
|
--transform "s,$TMPDIR/create-darwin-volume.sh,$dir/create-darwin-volume.sh," \
|
||||||
|
--transform "s,$TMPDIR/reginfo,$dir/.reginfo," \
|
||||||
|
--transform "s,$NIX_STORE,$dir/store,S" \
|
||||||
|
$TMPDIR/install \
|
||||||
|
$TMPDIR/create-darwin-volume.sh \
|
||||||
|
$TMPDIR/install-darwin-multi-user.sh \
|
||||||
|
$TMPDIR/install-systemd-multi-user.sh \
|
||||||
|
$TMPDIR/install-multi-user \
|
||||||
|
$TMPDIR/reginfo \
|
||||||
|
$(cat ${installerClosureInfo}/store-paths)
|
||||||
|
'');
|
||||||
|
|
||||||
# The first half of the installation script. This is uploaded
|
# The first half of the installation script. This is uploaded
|
||||||
# to https://nixos.org/nix/install. It downloads the binary
|
# to https://nixos.org/nix/install. It downloads the binary
|
||||||
# tarball for the user's system and calls the second half of the
|
# tarball for the user's system and calls the second half of the
|
||||||
# installation script.
|
# installation script.
|
||||||
installerScript = installScriptFor [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" "armv6l-linux" "armv7l-linux" ];
|
installerScript =
|
||||||
installerScriptForGHA = installScriptFor [ "x86_64-linux" "x86_64-darwin" "armv6l-linux" "armv7l-linux"];
|
with nixpkgsFor.x86_64-linux;
|
||||||
|
runCommand "installer-script"
|
||||||
|
{ buildInputs = [ nix ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
|
||||||
|
# Converts /nix/store/50p3qk8kka9dl6wyq40vydq945k0j3kv-nix-2.4pre20201102_550e11f/bin/nix
|
||||||
|
# To 50p3qk8kka9dl6wyq40vydq945k0j3kv/bin/nix
|
||||||
|
tarballPath() {
|
||||||
|
# Remove the store prefix
|
||||||
|
local path=''${1#${builtins.storeDir}/}
|
||||||
|
# Get the path relative to the derivation root
|
||||||
|
local rest=''${path#*/}
|
||||||
|
# Get the derivation hash
|
||||||
|
local drvHash=''${path%%-*}
|
||||||
|
echo "$drvHash/$rest"
|
||||||
|
}
|
||||||
|
|
||||||
|
substitute ${./scripts/install.in} $out/install \
|
||||||
|
${pkgs.lib.concatMapStrings
|
||||||
|
(system:
|
||||||
|
'' \
|
||||||
|
--replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \
|
||||||
|
--replace '@tarballPath_${system}@' $(tarballPath ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \
|
||||||
|
''
|
||||||
|
)
|
||||||
|
[ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ]
|
||||||
|
} \
|
||||||
|
--replace '@nixVersion@' ${version}
|
||||||
|
|
||||||
|
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
||||||
|
'';
|
||||||
|
|
||||||
# Line coverage analysis.
|
# Line coverage analysis.
|
||||||
coverage =
|
coverage =
|
||||||
@@ -445,12 +388,6 @@
|
|||||||
inherit (self) overlay;
|
inherit (self) overlay;
|
||||||
};
|
};
|
||||||
|
|
||||||
tests.nssPreload = (import ./tests/nss-preload.nix rec {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
inherit nixpkgs;
|
|
||||||
inherit (self) overlay;
|
|
||||||
});
|
|
||||||
|
|
||||||
tests.githubFlakes = (import ./tests/github-flakes.nix rec {
|
tests.githubFlakes = (import ./tests/github-flakes.nix rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
inherit nixpkgs;
|
inherit nixpkgs;
|
||||||
@@ -489,31 +426,16 @@
|
|||||||
'';
|
'';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
installTests = forAllSystems (system:
|
|
||||||
let pkgs = nixpkgsFor.${system}; in
|
|
||||||
pkgs.runCommand "install-tests" {
|
|
||||||
againstSelf = testNixVersions pkgs pkgs.nix pkgs.pkgs.nix;
|
|
||||||
againstCurrentUnstable =
|
|
||||||
# FIXME: temporarily disable this on macOS because of #3605.
|
|
||||||
if system == "x86_64-linux"
|
|
||||||
then testNixVersions pkgs pkgs.nix pkgs.nixUnstable
|
|
||||||
else null;
|
|
||||||
# Disabled because the latest stable version doesn't handle
|
|
||||||
# `NIX_DAEMON_SOCKET_PATH` which is required for the tests to work
|
|
||||||
# againstLatestStable = testNixVersions pkgs pkgs.nix pkgs.nixStable;
|
|
||||||
} "touch $out");
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = forAllSystems (system: {
|
checks = forAllSystems (system: {
|
||||||
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
||||||
perlBindings = self.hydraJobs.perlBindings.${system};
|
perlBindings = self.hydraJobs.perlBindings.${system};
|
||||||
installTests = self.hydraJobs.installTests.${system};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
packages = forAllSystems (system: {
|
packages = forAllSystems (system: {
|
||||||
inherit (nixpkgsFor.${system}) nix;
|
inherit (nixpkgsFor.${system}) nix;
|
||||||
} // (nixpkgs.lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
} // nixpkgs.lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
||||||
nix-static = let
|
nix-static = let
|
||||||
nixpkgs = nixpkgsFor.${system}.pkgsStatic;
|
nixpkgs = nixpkgsFor.${system}.pkgsStatic;
|
||||||
in with commonDeps nixpkgs; nixpkgs.stdenv.mkDerivation {
|
in with commonDeps nixpkgs; nixpkgs.stdenv.mkDerivation {
|
||||||
@@ -549,51 +471,8 @@
|
|||||||
installCheckFlags = "sysconfdir=$(out)/etc";
|
installCheckFlags = "sysconfdir=$(out)/etc";
|
||||||
|
|
||||||
stripAllList = ["bin"];
|
stripAllList = ["bin"];
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
hardeningDisable = [ "pie" ];
|
|
||||||
};
|
};
|
||||||
} // builtins.listToAttrs (map (crossSystem: {
|
});
|
||||||
name = "nix-${crossSystem}";
|
|
||||||
value = let
|
|
||||||
nixpkgsCross = import nixpkgs {
|
|
||||||
inherit system crossSystem;
|
|
||||||
overlays = [ self.overlay ];
|
|
||||||
};
|
|
||||||
in with commonDeps nixpkgsCross; nixpkgsCross.stdenv.mkDerivation {
|
|
||||||
name = "nix-${version}";
|
|
||||||
|
|
||||||
src = self;
|
|
||||||
|
|
||||||
VERSION_SUFFIX = versionSuffix;
|
|
||||||
|
|
||||||
outputs = [ "out" "dev" "doc" ];
|
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildDeps;
|
|
||||||
buildInputs = buildDeps ++ propagatedDeps;
|
|
||||||
|
|
||||||
configureFlags = [ "--sysconfdir=/etc" "--disable-doc-gen" ];
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
makeFlags = "profiledir=$(out)/etc/profile.d";
|
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
installFlags = "sysconfdir=$(out)/etc";
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
mkdir -p $doc/nix-support
|
|
||||||
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
|
||||||
mkdir -p $out/nix-support
|
|
||||||
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
|
||||||
'';
|
|
||||||
|
|
||||||
doInstallCheck = true;
|
|
||||||
installCheckFlags = "sysconfdir=$(out)/etc";
|
|
||||||
};
|
|
||||||
}) crossSystems)));
|
|
||||||
|
|
||||||
defaultPackage = forAllSystems (system: self.packages.${system}.nix);
|
defaultPackage = forAllSystems (system: self.packages.${system}.nix);
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ my $nixpkgsDir = "/home/eelco/Dev/nixpkgs-pristine";
|
|||||||
|
|
||||||
my $TMPDIR = $ENV{'TMPDIR'} // "/tmp";
|
my $TMPDIR = $ENV{'TMPDIR'} // "/tmp";
|
||||||
|
|
||||||
my $isLatest = ($ENV{'IS_LATEST'} // "") eq "1";
|
|
||||||
|
|
||||||
# FIXME: cut&paste from nixos-channel-scripts.
|
# FIXME: cut&paste from nixos-channel-scripts.
|
||||||
sub fetch {
|
sub fetch {
|
||||||
my ($url, $type) = @_;
|
my ($url, $type) = @_;
|
||||||
@@ -37,18 +35,16 @@ sub fetch {
|
|||||||
my $evalUrl = "https://hydra.nixos.org/eval/$evalId";
|
my $evalUrl = "https://hydra.nixos.org/eval/$evalId";
|
||||||
my $evalInfo = decode_json(fetch($evalUrl, 'application/json'));
|
my $evalInfo = decode_json(fetch($evalUrl, 'application/json'));
|
||||||
#print Dumper($evalInfo);
|
#print Dumper($evalInfo);
|
||||||
my $flakeUrl = $evalInfo->{flake} or die;
|
|
||||||
my $flakeInfo = decode_json(`nix flake metadata --json "$flakeUrl"` or die);
|
|
||||||
my $nixRev = $flakeInfo->{revision} or die;
|
|
||||||
|
|
||||||
my $buildInfo = decode_json(fetch("$evalUrl/job/build.x86_64-linux", 'application/json'));
|
my $nixRev = $evalInfo->{jobsetevalinputs}->{nix}->{revision} or die;
|
||||||
#print Dumper($buildInfo);
|
|
||||||
|
|
||||||
my $releaseName = $buildInfo->{nixname};
|
my $tarballInfo = decode_json(fetch("$evalUrl/job/tarball", 'application/json'));
|
||||||
|
|
||||||
|
my $releaseName = $tarballInfo->{releasename};
|
||||||
$releaseName =~ /nix-(.*)$/ or die;
|
$releaseName =~ /nix-(.*)$/ or die;
|
||||||
my $version = $1;
|
my $version = $1;
|
||||||
|
|
||||||
print STDERR "Flake URL is $flakeUrl, Nix revision is $nixRev, version is $version\n";
|
print STDERR "Nix revision is $nixRev, version is $version\n";
|
||||||
|
|
||||||
my $releaseDir = "nix/$releaseName";
|
my $releaseDir = "nix/$releaseName";
|
||||||
|
|
||||||
@@ -87,12 +83,12 @@ sub downloadFile {
|
|||||||
|
|
||||||
if (!-e $tmpFile) {
|
if (!-e $tmpFile) {
|
||||||
print STDERR "downloading $srcFile to $tmpFile...\n";
|
print STDERR "downloading $srcFile to $tmpFile...\n";
|
||||||
system("NIX_REMOTE=https://cache.nixos.org/ nix store cat '$srcFile' > '$tmpFile'") == 0
|
system("NIX_REMOTE=https://cache.nixos.org/ nix cat-store '$srcFile' > '$tmpFile'") == 0
|
||||||
or die "unable to fetch $srcFile\n";
|
or die "unable to fetch $srcFile\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $sha256_expected = $buildInfo->{buildproducts}->{$productNr}->{sha256hash} or die;
|
my $sha256_expected = $buildInfo->{buildproducts}->{$productNr}->{sha256hash} or die;
|
||||||
my $sha256_actual = `nix hash file --base16 --type sha256 '$tmpFile'`;
|
my $sha256_actual = `nix hash-file --base16 --type sha256 '$tmpFile'`;
|
||||||
chomp $sha256_actual;
|
chomp $sha256_actual;
|
||||||
if ($sha256_expected ne $sha256_actual) {
|
if ($sha256_expected ne $sha256_actual) {
|
||||||
print STDERR "file $tmpFile is corrupt, got $sha256_actual, expected $sha256_expected\n";
|
print STDERR "file $tmpFile is corrupt, got $sha256_actual, expected $sha256_expected\n";
|
||||||
@@ -108,13 +104,12 @@ sub downloadFile {
|
|||||||
return $sha256_expected;
|
return $sha256_expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadFile("tarball", "2"); # .tar.bz2
|
||||||
|
my $tarballHash = downloadFile("tarball", "3"); # .tar.xz
|
||||||
downloadFile("binaryTarball.i686-linux", "1");
|
downloadFile("binaryTarball.i686-linux", "1");
|
||||||
downloadFile("binaryTarball.x86_64-linux", "1");
|
downloadFile("binaryTarball.x86_64-linux", "1");
|
||||||
downloadFile("binaryTarball.aarch64-linux", "1");
|
downloadFile("binaryTarball.aarch64-linux", "1");
|
||||||
downloadFile("binaryTarball.x86_64-darwin", "1");
|
downloadFile("binaryTarball.x86_64-darwin", "1");
|
||||||
downloadFile("binaryTarball.aarch64-darwin", "1");
|
|
||||||
downloadFile("binaryTarballCross.x86_64-linux.armv6l-linux", "1");
|
|
||||||
downloadFile("binaryTarballCross.x86_64-linux.armv7l-linux", "1");
|
|
||||||
downloadFile("installerScript", "1");
|
downloadFile("installerScript", "1");
|
||||||
|
|
||||||
for my $fn (glob "$tmpDir/*") {
|
for my $fn (glob "$tmpDir/*") {
|
||||||
@@ -136,38 +131,53 @@ for my $fn (glob "$tmpDir/*") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update nix-fallback-paths.nix.
|
exit if $version =~ /pre/;
|
||||||
if ($isLatest) {
|
|
||||||
system("cd $nixpkgsDir && git pull") == 0 or die;
|
|
||||||
|
|
||||||
sub getStorePath {
|
# Update Nixpkgs in a very hacky way.
|
||||||
my ($jobName) = @_;
|
system("cd $nixpkgsDir && git pull") == 0 or die;
|
||||||
my $buildInfo = decode_json(fetch("$evalUrl/job/$jobName", 'application/json'));
|
my $oldName = `nix-instantiate --eval $nixpkgsDir -A nix.name`; chomp $oldName;
|
||||||
return $buildInfo->{buildoutputs}->{out}->{path} or die "cannot get store path for '$jobName'";
|
my $oldHash = `nix-instantiate --eval $nixpkgsDir -A nix.src.outputHash`; chomp $oldHash;
|
||||||
|
print STDERR "old stable version in Nixpkgs = $oldName / $oldHash\n";
|
||||||
|
|
||||||
|
my $fn = "$nixpkgsDir/pkgs/tools/package-management/nix/default.nix";
|
||||||
|
my $oldFile = read_file($fn);
|
||||||
|
$oldFile =~ s/$oldName/"$releaseName"/g;
|
||||||
|
$oldFile =~ s/$oldHash/"$tarballHash"/g;
|
||||||
|
write_file($fn, $oldFile);
|
||||||
|
|
||||||
|
$oldName =~ s/nix-//g;
|
||||||
|
$oldName =~ s/"//g;
|
||||||
|
|
||||||
|
sub getStorePath {
|
||||||
|
my ($jobName) = @_;
|
||||||
|
my $buildInfo = decode_json(fetch("$evalUrl/job/$jobName", 'application/json'));
|
||||||
|
for my $product (values %{$buildInfo->{buildproducts}}) {
|
||||||
|
next unless $product->{type} eq "nix-build";
|
||||||
|
next if $product->{path} =~ /[a-z]+$/;
|
||||||
|
return $product->{path};
|
||||||
}
|
}
|
||||||
|
die;
|
||||||
write_file("$nixpkgsDir/nixos/modules/installer/tools/nix-fallback-paths.nix",
|
|
||||||
"{\n" .
|
|
||||||
" x86_64-linux = \"" . getStorePath("build.x86_64-linux") . "\";\n" .
|
|
||||||
" i686-linux = \"" . getStorePath("build.i686-linux") . "\";\n" .
|
|
||||||
" aarch64-linux = \"" . getStorePath("build.aarch64-linux") . "\";\n" .
|
|
||||||
" x86_64-darwin = \"" . getStorePath("build.x86_64-darwin") . "\";\n" .
|
|
||||||
" aarch64-darwin = \"" . getStorePath("build.aarch64-darwin") . "\";\n" .
|
|
||||||
"}\n");
|
|
||||||
|
|
||||||
system("cd $nixpkgsDir && git commit -a -m 'nix-fallback-paths.nix: Update to $version'") == 0 or die;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_file("$nixpkgsDir/nixos/modules/installer/tools/nix-fallback-paths.nix",
|
||||||
|
"{\n" .
|
||||||
|
" x86_64-linux = \"" . getStorePath("build.x86_64-linux") . "\";\n" .
|
||||||
|
" i686-linux = \"" . getStorePath("build.i686-linux") . "\";\n" .
|
||||||
|
" aarch64-linux = \"" . getStorePath("build.aarch64-linux") . "\";\n" .
|
||||||
|
" x86_64-darwin = \"" . getStorePath("build.x86_64-darwin") . "\";\n" .
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
system("cd $nixpkgsDir && git commit -a -m 'nix: $oldName -> $version'") == 0 or die;
|
||||||
|
|
||||||
# Update the "latest" symlink.
|
# Update the "latest" symlink.
|
||||||
$channelsBucket->add_key(
|
$channelsBucket->add_key(
|
||||||
"nix-latest/install", "",
|
"nix-latest/install", "",
|
||||||
{ "x-amz-website-redirect-location" => "https://releases.nixos.org/$releaseDir/install" })
|
{ "x-amz-website-redirect-location" => "https://releases.nixos.org/$releaseDir/install" })
|
||||||
or die $channelsBucket->err . ": " . $channelsBucket->errstr
|
or die $channelsBucket->err . ": " . $channelsBucket->errstr;
|
||||||
if $isLatest;
|
|
||||||
|
|
||||||
# Tag the release in Git.
|
# Tag the release in Git.
|
||||||
chdir("/home/eelco/Dev/nix-pristine") or die;
|
chdir("/home/eelco/Dev/nix-pristine") or die;
|
||||||
system("git remote update origin") == 0 or die;
|
system("git remote update origin") == 0 or die;
|
||||||
system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 0 or die;
|
system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 0 or die;
|
||||||
system("git push --tags") == 0 or die;
|
system("git push --tags") == 0 or die;
|
||||||
system("git push --force-with-lease origin $nixRev:refs/heads/latest-release") == 0 or die if $isLatest;
|
system("git push --force-with-lease origin $nixRev:refs/heads/latest-release") == 0 or die;
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
function _nix_complete
|
|
||||||
# Get the current command up to a cursor.
|
|
||||||
# - Behaves correctly even with pipes and nested in commands like env.
|
|
||||||
# - TODO: Returns the command verbatim (does not interpolate variables).
|
|
||||||
# That might not be optimal for arguments like -f.
|
|
||||||
set -l nix_args (commandline --current-process --tokenize --cut-at-cursor)
|
|
||||||
# --cut-at-cursor with --tokenize removes the current token so we need to add it separately.
|
|
||||||
# https://github.com/fish-shell/fish-shell/issues/7375
|
|
||||||
# Can be an empty string.
|
|
||||||
set -l current_token (commandline --current-token --cut-at-cursor)
|
|
||||||
|
|
||||||
# Nix wants the index of the argv item to complete but the $nix_args variable
|
|
||||||
# also contains the program name (argv[0]) so we would need to subtract 1.
|
|
||||||
# But the variable also misses the current token so it cancels out.
|
|
||||||
set -l nix_arg_to_complete (count $nix_args)
|
|
||||||
|
|
||||||
env NIX_GET_COMPLETIONS=$nix_arg_to_complete $nix_args $current_token
|
|
||||||
end
|
|
||||||
|
|
||||||
function _nix_accepts_files
|
|
||||||
set -l response (_nix_complete)
|
|
||||||
# First line is either filenames or no-filenames.
|
|
||||||
test $response[1] = 'filenames'
|
|
||||||
end
|
|
||||||
|
|
||||||
function _nix
|
|
||||||
set -l response (_nix_complete)
|
|
||||||
# Skip the first line since it handled by _nix_accepts_files.
|
|
||||||
# Tail lines each contain a command followed by a tab character and, optionally, a description.
|
|
||||||
# This is also the format fish expects.
|
|
||||||
string collect -- $response[2..-1]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Disable file path completion if paths do not belong in the current context.
|
|
||||||
complete --command nix --condition 'not _nix_accepts_files' --no-files
|
|
||||||
|
|
||||||
complete --command nix --arguments '(_nix)'
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
$(eval $(call install-file-as, $(d)/completion.fish, $(datarootdir)/fish/vendor_completions.d/nix.fish, 0644))
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
ifdef HOST_DARWIN
|
ifeq ($(OS), Darwin)
|
||||||
|
|
||||||
$(eval $(call install-data-in, $(d)/org.nixos.nix-daemon.plist, $(prefix)/Library/LaunchDaemons))
|
$(eval $(call install-data-in, $(d)/org.nixos.nix-daemon.plist, $(prefix)/Library/LaunchDaemons))
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<array>
|
<array>
|
||||||
<string>/bin/sh</string>
|
<string>/bin/sh</string>
|
||||||
<string>-c</string>
|
<string>-c</string>
|
||||||
<string>/bin/wait4path /nix/var/nix/profiles/default/bin/nix-daemon && exec /nix/var/nix/profiles/default/bin/nix-daemon</string>
|
<string>/bin/wait4path /nix/var/nix/profiles/default/bin/nix-daemon && /nix/var/nix/profiles/default/bin/nix-daemon</string>
|
||||||
</array>
|
</array>
|
||||||
<key>StandardErrorPath</key>
|
<key>StandardErrorPath</key>
|
||||||
<string>/var/log/nix-daemon.log</string>
|
<string>/var/log/nix-daemon.log</string>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ifdef HOST_LINUX
|
ifeq ($(OS), Linux)
|
||||||
|
|
||||||
$(foreach n, nix-daemon.socket nix-daemon.service, $(eval $(call install-file-in, $(d)/$(n), $(prefix)/lib/systemd/system, 0644)))
|
$(foreach n, nix-daemon.socket nix-daemon.service, $(eval $(call install-file-in, $(d)/$(n), $(prefix)/lib/systemd/system, 0644)))
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ifdef HOST_LINUX
|
ifeq ($(OS), Linux)
|
||||||
|
|
||||||
$(foreach n, nix-daemon.conf, $(eval $(call install-file-in, $(d)/$(n), $(sysconfdir)/init, 0644)))
|
$(foreach n, nix-daemon.conf, $(eval $(call install-file-in, $(d)/$(n), $(sysconfdir)/init, 0644)))
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#compdef nix
|
|
||||||
|
|
||||||
function _nix() {
|
function _nix() {
|
||||||
local ifs_bk="$IFS"
|
local ifs_bk="$IFS"
|
||||||
local input=("${(Q)words[@]}")
|
local input=("${(Q)words[@]}")
|
||||||
@@ -20,4 +18,4 @@ function _nix() {
|
|||||||
_describe 'nix' suggestions
|
_describe 'nix' suggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
_nix "$@"
|
compdef _nix nix
|
||||||
@@ -1 +0,0 @@
|
|||||||
$(eval $(call install-file-as, $(d)/completion.zsh, $(datarootdir)/zsh/site-functions/_nix, 0644))
|
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
define build-jar
|
||||||
|
|
||||||
|
$(1)_NAME ?= $(1)
|
||||||
|
|
||||||
|
_d := $$(strip $$($(1)_DIR))
|
||||||
|
|
||||||
|
$(1)_PATH := $$(_d)/$$($(1)_NAME).jar
|
||||||
|
|
||||||
|
$(1)_TMPDIR := $$(_d)/.$$($(1)_NAME).jar.tmp
|
||||||
|
|
||||||
|
_jars := $$(foreach jar, $$($(1)_JARS), $$($$(jar)_PATH))
|
||||||
|
|
||||||
|
$$($(1)_PATH): $$($(1)_SOURCES) $$(_jars) $$($(1)_EXTRA_DEPS)| $$($(1)_ORDER_AFTER)
|
||||||
|
@rm -rf $$($(1)_TMPDIR)
|
||||||
|
@mkdir -p $$($(1)_TMPDIR)
|
||||||
|
$$(trace-javac) javac $(GLOBAL_JAVACFLAGS) $$($(1)_JAVACFLAGS) -d $$($(1)_TMPDIR) \
|
||||||
|
$$(foreach fn, $$($(1)_SOURCES), '$$(fn)') \
|
||||||
|
-cp "$$(subst $$(space),,$$(foreach jar,$$($(1)_JARS),$$($$(jar)_PATH):))$$$$CLASSPATH"
|
||||||
|
@echo -e '$$(subst $$(newline),\n,$$($(1)_MANIFEST))' > $$($(1)_PATH).manifest
|
||||||
|
$$(trace-jar) jar cfm $$($(1)_PATH) $$($(1)_PATH).manifest -C $$($(1)_TMPDIR) .
|
||||||
|
@rm $$($(1)_PATH).manifest
|
||||||
|
@rm -rf $$($(1)_TMPDIR)
|
||||||
|
|
||||||
|
$(1)_INSTALL_DIR ?= $$(jardir)
|
||||||
|
|
||||||
|
$(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).jar
|
||||||
|
|
||||||
|
$$(eval $$(call install-file-as, $$($(1)_PATH), $$($(1)_INSTALL_PATH), 0644))
|
||||||
|
|
||||||
|
install: $$($(1)_INSTALL_PATH)
|
||||||
|
|
||||||
|
jars-list += $$($(1)_PATH)
|
||||||
|
|
||||||
|
clean-files += $$($(1)_PATH)
|
||||||
|
|
||||||
|
endef
|
||||||
@@ -10,25 +10,8 @@ bin-scripts :=
|
|||||||
noinst-scripts :=
|
noinst-scripts :=
|
||||||
man-pages :=
|
man-pages :=
|
||||||
install-tests :=
|
install-tests :=
|
||||||
|
OS = $(shell uname -s)
|
||||||
|
|
||||||
ifdef HOST_OS
|
|
||||||
HOST_KERNEL = $(firstword $(subst -, ,$(HOST_OS)))
|
|
||||||
ifeq ($(HOST_KERNEL), cygwin)
|
|
||||||
HOST_CYGWIN = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst darwin%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_DARWIN = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst freebsd%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_FREEBSD = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(HOST_KERNEL), linux)
|
|
||||||
HOST_LINUX = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst solaris%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_SOLARIS = 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Hack to define a literal space.
|
# Hack to define a literal space.
|
||||||
space :=
|
space :=
|
||||||
@@ -48,6 +31,7 @@ libdir ?= $(prefix)/lib
|
|||||||
bindir ?= $(prefix)/bin
|
bindir ?= $(prefix)/bin
|
||||||
libexecdir ?= $(prefix)/libexec
|
libexecdir ?= $(prefix)/libexec
|
||||||
datadir ?= $(prefix)/share
|
datadir ?= $(prefix)/share
|
||||||
|
jardir ?= $(datadir)/java
|
||||||
localstatedir ?= $(prefix)/var
|
localstatedir ?= $(prefix)/var
|
||||||
sysconfdir ?= $(prefix)/etc
|
sysconfdir ?= $(prefix)/etc
|
||||||
mandir ?= $(prefix)/share/man
|
mandir ?= $(prefix)/share/man
|
||||||
@@ -67,16 +51,16 @@ endif
|
|||||||
BUILD_SHARED_LIBS ?= 1
|
BUILD_SHARED_LIBS ?= 1
|
||||||
|
|
||||||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||||
ifdef HOST_CYGWIN
|
ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
||||||
GLOBAL_CFLAGS += -U__STRICT_ANSI__ -D_GNU_SOURCE
|
GLOBAL_CFLAGS += -U__STRICT_ANSI__ -D_GNU_SOURCE
|
||||||
GLOBAL_CXXFLAGS += -U__STRICT_ANSI__ -D_GNU_SOURCE
|
GLOBAL_CXXFLAGS += -U__STRICT_ANSI__ -D_GNU_SOURCE
|
||||||
else
|
else
|
||||||
GLOBAL_CFLAGS += -fPIC
|
GLOBAL_CFLAGS += -fPIC
|
||||||
GLOBAL_CXXFLAGS += -fPIC
|
GLOBAL_CXXFLAGS += -fPIC
|
||||||
endif
|
endif
|
||||||
ifndef HOST_DARWIN
|
ifneq ($(OS), Darwin)
|
||||||
ifndef HOST_SOLARIS
|
ifneq ($(OS), SunOS)
|
||||||
ifndef HOST_FREEBSD
|
ifneq ($(OS), FreeBSD)
|
||||||
GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
|
GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -90,6 +74,7 @@ BUILD_DEBUG ?= 1
|
|||||||
ifeq ($(BUILD_DEBUG), 1)
|
ifeq ($(BUILD_DEBUG), 1)
|
||||||
GLOBAL_CFLAGS += -g
|
GLOBAL_CFLAGS += -g
|
||||||
GLOBAL_CXXFLAGS += -g
|
GLOBAL_CXXFLAGS += -g
|
||||||
|
GLOBAL_JAVACFLAGS += -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
@@ -99,6 +84,7 @@ include mk/clean.mk
|
|||||||
include mk/install.mk
|
include mk/install.mk
|
||||||
include mk/libraries.mk
|
include mk/libraries.mk
|
||||||
include mk/programs.mk
|
include mk/programs.mk
|
||||||
|
include mk/jars.mk
|
||||||
include mk/patterns.mk
|
include mk/patterns.mk
|
||||||
include mk/templates.mk
|
include mk/templates.mk
|
||||||
include mk/tests.mk
|
include mk/tests.mk
|
||||||
@@ -116,6 +102,7 @@ $(foreach mf, $(makefiles), $(eval $(call include-sub-makefile, $(mf))))
|
|||||||
# Instantiate stuff.
|
# Instantiate stuff.
|
||||||
$(foreach lib, $(libraries), $(eval $(call build-library,$(lib))))
|
$(foreach lib, $(libraries), $(eval $(call build-library,$(lib))))
|
||||||
$(foreach prog, $(programs), $(eval $(call build-program,$(prog))))
|
$(foreach prog, $(programs), $(eval $(call build-program,$(prog))))
|
||||||
|
$(foreach jar, $(jars), $(eval $(call build-jar,$(jar))))
|
||||||
$(foreach script, $(bin-scripts), $(eval $(call install-program-in,$(script),$(bindir))))
|
$(foreach script, $(bin-scripts), $(eval $(call install-program-in,$(script),$(bindir))))
|
||||||
$(foreach script, $(bin-scripts), $(eval programs-list += $(script)))
|
$(foreach script, $(bin-scripts), $(eval programs-list += $(script)))
|
||||||
$(foreach script, $(noinst-scripts), $(eval programs-list += $(script)))
|
$(foreach script, $(noinst-scripts), $(eval programs-list += $(script)))
|
||||||
@@ -126,7 +113,7 @@ $(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/
|
|||||||
|
|
||||||
.PHONY: default all man help
|
.PHONY: default all man help
|
||||||
|
|
||||||
all: $(programs-list) $(libs-list) $(man-pages)
|
all: $(programs-list) $(libs-list) $(jars-list) $(man-pages)
|
||||||
|
|
||||||
man: $(man-pages)
|
man: $(man-pages)
|
||||||
|
|
||||||
@@ -150,6 +137,12 @@ ifdef libs-list
|
|||||||
@echo "The following libraries can be built:"
|
@echo "The following libraries can be built:"
|
||||||
@echo ""
|
@echo ""
|
||||||
@for i in $(libs-list); do echo " $$i"; done
|
@for i in $(libs-list); do echo " $$i"; done
|
||||||
|
endif
|
||||||
|
ifdef jars-list
|
||||||
|
@echo ""
|
||||||
|
@echo "The following JARs can be built:"
|
||||||
|
@echo ""
|
||||||
|
@for i in $(jars-list); do echo " $$i"; done
|
||||||
endif
|
endif
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "The following variables control the build:"
|
@echo "The following variables control the build:"
|
||||||
@@ -160,5 +153,4 @@ endif
|
|||||||
@echo " CFLAGS: Flags for the C compiler"
|
@echo " CFLAGS: Flags for the C compiler"
|
||||||
@echo " CXX ($(CXX)): C++ compiler to be used"
|
@echo " CXX ($(CXX)): C++ compiler to be used"
|
||||||
@echo " CXXFLAGS: Flags for the C++ compiler"
|
@echo " CXXFLAGS: Flags for the C++ compiler"
|
||||||
@echo " CPPFLAGS: C preprocessor flags, used for both CC and CXX"
|
|
||||||
@$(print-var-help)
|
@$(print-var-help)
|
||||||
+11
-11
@@ -1,9 +1,9 @@
|
|||||||
libs-list :=
|
libs-list :=
|
||||||
|
|
||||||
ifdef HOST_DARWIN
|
ifeq ($(OS), Darwin)
|
||||||
SO_EXT = dylib
|
SO_EXT = dylib
|
||||||
else
|
else
|
||||||
ifdef HOST_CYGWIN
|
ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
||||||
SO_EXT = dll
|
SO_EXT = dll
|
||||||
else
|
else
|
||||||
SO_EXT = so
|
SO_EXT = so
|
||||||
@@ -59,7 +59,7 @@ define build-library
|
|||||||
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
|
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
|
||||||
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
|
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
|
||||||
|
|
||||||
ifdef HOST_CYGWIN
|
ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
||||||
$(1)_INSTALL_DIR ?= $$(bindir)
|
$(1)_INSTALL_DIR ?= $$(bindir)
|
||||||
else
|
else
|
||||||
$(1)_INSTALL_DIR ?= $$(libdir)
|
$(1)_INSTALL_DIR ?= $$(libdir)
|
||||||
@@ -73,18 +73,18 @@ define build-library
|
|||||||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||||
|
|
||||||
ifdef $(1)_ALLOW_UNDEFINED
|
ifdef $(1)_ALLOW_UNDEFINED
|
||||||
ifdef HOST_DARWIN
|
ifeq ($(OS), Darwin)
|
||||||
$(1)_LDFLAGS += -undefined suppress -flat_namespace
|
$(1)_LDFLAGS += -undefined suppress -flat_namespace
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
ifndef HOST_DARWIN
|
ifneq ($(OS), Darwin)
|
||||||
ifndef HOST_CYGWIN
|
ifneq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
||||||
$(1)_LDFLAGS += -Wl,-z,defs
|
$(1)_LDFLAGS += -Wl,-z,defs
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef HOST_DARWIN
|
ifneq ($(OS), Darwin)
|
||||||
$(1)_LDFLAGS += -Wl,-soname=$$($(1)_NAME).$(SO_EXT)
|
$(1)_LDFLAGS += -Wl,-soname=$$($(1)_NAME).$(SO_EXT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ define build-library
|
|||||||
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
|
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
|
||||||
$$(trace-ld) $(CXX) -o $$(abspath $$@) -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$($(1)_LDFLAGS_UNINSTALLED)
|
$$(trace-ld) $(CXX) -o $$(abspath $$@) -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$($(1)_LDFLAGS_UNINSTALLED)
|
||||||
|
|
||||||
ifndef HOST_DARWIN
|
ifneq ($(OS), Darwin)
|
||||||
$(1)_LDFLAGS_USE += -Wl,-rpath,$$(abspath $$(_d))
|
$(1)_LDFLAGS_USE += -Wl,-rpath,$$(abspath $$(_d))
|
||||||
endif
|
endif
|
||||||
$(1)_LDFLAGS_USE += -L$$(_d) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
$(1)_LDFLAGS_USE += -L$$(_d) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
||||||
@@ -108,7 +108,7 @@ define build-library
|
|||||||
$$(trace-ld) $(CXX) -o $$@ -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
$$(trace-ld) $(CXX) -o $$@ -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
||||||
|
|
||||||
$(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
$(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
|
||||||
ifndef HOST_DARWIN
|
ifneq ($(OS), Darwin)
|
||||||
ifeq ($(SET_RPATH_TO_LIBS), 1)
|
ifeq ($(SET_RPATH_TO_LIBS), 1)
|
||||||
$(1)_LDFLAGS_USE_INSTALLED += -Wl,-rpath,$$($(1)_INSTALL_DIR)
|
$(1)_LDFLAGS_USE_INSTALLED += -Wl,-rpath,$$($(1)_INSTALL_DIR)
|
||||||
else
|
else
|
||||||
@@ -125,8 +125,8 @@ define build-library
|
|||||||
$(1)_PATH := $$(_d)/$$($(1)_NAME).a
|
$(1)_PATH := $$(_d)/$$($(1)_NAME).a
|
||||||
|
|
||||||
$$($(1)_PATH): $$($(1)_OBJS) | $$(_d)/
|
$$($(1)_PATH): $$($(1)_OBJS) | $$(_d)/
|
||||||
$$(trace-ld) $(LD) -Ur -o $$(_d)/$$($(1)_NAME).o $$?
|
$(trace-ld) $(LD) -Ur -o $$(_d)/$$($(1)_NAME).o $$?
|
||||||
$$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o
|
$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o
|
||||||
|
|
||||||
$(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)
|
$(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
$(buildprefix)%.o: %.cc
|
$(buildprefix)%.o: %.cc
|
||||||
@mkdir -p "$(dir $@)"
|
@mkdir -p "$(dir $@)"
|
||||||
$(trace-cxx) $(CXX) -o $@ -c $< $(CPPFLAGS) $(GLOBAL_CXXFLAGS_PCH) $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP
|
$(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS_PCH) $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP
|
||||||
|
|
||||||
$(buildprefix)%.o: %.cpp
|
$(buildprefix)%.o: %.cpp
|
||||||
@mkdir -p "$(dir $@)"
|
@mkdir -p "$(dir $@)"
|
||||||
$(trace-cxx) $(CXX) -o $@ -c $< $(CPPFLAGS) $(GLOBAL_CXXFLAGS_PCH) $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP
|
$(trace-cxx) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS_PCH) $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP
|
||||||
|
|
||||||
$(buildprefix)%.o: %.c
|
$(buildprefix)%.o: %.c
|
||||||
@mkdir -p "$(dir $@)"
|
@mkdir -p "$(dir $@)"
|
||||||
$(trace-cc) $(CC) -o $@ -c $< $(CPPFLAGS) $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP
|
$(trace-cc) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP
|
||||||
+1
-1
@@ -14,7 +14,7 @@ if [ -t 1 ]; then
|
|||||||
yellow="[33;1m"
|
yellow="[33;1m"
|
||||||
normal="[m"
|
normal="[m"
|
||||||
fi
|
fi
|
||||||
(cd tests && env ${TESTS_ENVIRONMENT} init.sh 2>/dev/null > /dev/null)
|
(cd $(dirname $1) && env ${TESTS_ENVIRONMENT} init.sh 2>/dev/null > /dev/null)
|
||||||
log="$(cd $(dirname $1) && env ${TESTS_ENVIRONMENT} $(basename $1) 2>&1)"
|
log="$(cd $(dirname $1) && env ${TESTS_ENVIRONMENT} $(basename $1) 2>&1)"
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
|
|||||||
+1
-5
@@ -8,12 +8,8 @@ define run-install-test
|
|||||||
|
|
||||||
.PHONY: $1.test
|
.PHONY: $1.test
|
||||||
$1.test: $1 $(test-deps)
|
$1.test: $1 $(test-deps)
|
||||||
@env TEST_NAME=$(basename $1) TESTS_ENVIRONMENT="$(tests-environment)" mk/run_test.sh $1 < /dev/null
|
@env TEST_NAME=$(notdir $(basename $1)) TESTS_ENVIRONMENT="$(tests-environment)" mk/run_test.sh $1 < /dev/null
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
.PHONY: check installcheck
|
.PHONY: check installcheck
|
||||||
|
|
||||||
print-top-help += \
|
|
||||||
echo " check: Run unit tests"; \
|
|
||||||
echo " installcheck: Run functional tests";
|
|
||||||
@@ -8,6 +8,8 @@ ifeq ($(V), 0)
|
|||||||
trace-ld = @echo " LD " $@;
|
trace-ld = @echo " LD " $@;
|
||||||
trace-ar = @echo " AR " $@;
|
trace-ar = @echo " AR " $@;
|
||||||
trace-install = @echo " INST " $@;
|
trace-install = @echo " INST " $@;
|
||||||
|
trace-javac = @echo " JAVAC " $@;
|
||||||
|
trace-jar = @echo " JAR " $@;
|
||||||
trace-mkdir = @echo " MKDIR " $@;
|
trace-mkdir = @echo " MKDIR " $@;
|
||||||
trace-test = @echo " TEST " $@;
|
trace-test = @echo " TEST " $@;
|
||||||
|
|
||||||
|
|||||||
+5
-10
@@ -8,15 +8,10 @@ endif
|
|||||||
|
|
||||||
libnixrust_PATH := $(d)/target/$(RUST_DIR)/libnixrust.$(SO_EXT)
|
libnixrust_PATH := $(d)/target/$(RUST_DIR)/libnixrust.$(SO_EXT)
|
||||||
libnixrust_INSTALL_PATH := $(libdir)/libnixrust.$(SO_EXT)
|
libnixrust_INSTALL_PATH := $(libdir)/libnixrust.$(SO_EXT)
|
||||||
libnixrust_LDFLAGS_USE := -L$(d)/target/$(RUST_DIR) -lnixrust
|
libnixrust_LDFLAGS_USE := -L$(d)/target/$(RUST_DIR) -lnixrust -ldl
|
||||||
libnixrust_LDFLAGS_USE_INSTALLED := -L$(libdir) -lnixrust
|
libnixrust_LDFLAGS_USE_INSTALLED := -L$(libdir) -lnixrust -ldl
|
||||||
|
|
||||||
ifdef HOST_LINUX
|
ifeq ($(OS), Darwin)
|
||||||
libnixrust_LDFLAGS_USE += -ldl
|
|
||||||
libnixrust_LDFLAGS_USE_INSTALLED += -ldl
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef HOST_DARWIN
|
|
||||||
libnixrust_BUILD_FLAGS = NIX_LDFLAGS="-undefined dynamic_lookup"
|
libnixrust_BUILD_FLAGS = NIX_LDFLAGS="-undefined dynamic_lookup"
|
||||||
else
|
else
|
||||||
libnixrust_LDFLAGS_USE += -Wl,-rpath,$(abspath $(d)/target/$(RUST_DIR))
|
libnixrust_LDFLAGS_USE += -Wl,-rpath,$(abspath $(d)/target/$(RUST_DIR))
|
||||||
@@ -31,7 +26,7 @@ $(libnixrust_PATH): $(call rwildcard, $(d)/src, *.rs) $(d)/Cargo.toml
|
|||||||
|
|
||||||
$(libnixrust_INSTALL_PATH): $(libnixrust_PATH)
|
$(libnixrust_INSTALL_PATH): $(libnixrust_PATH)
|
||||||
$(target-gen) cp $^ $@
|
$(target-gen) cp $^ $@
|
||||||
ifdef HOST_DARWIN
|
ifeq ($(OS), Darwin)
|
||||||
install_name_tool -id $@ $@
|
install_name_tool -id $@ $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -40,7 +35,7 @@ clean: clean-rust
|
|||||||
clean-rust:
|
clean-rust:
|
||||||
$(suppress) rm -rfv nix-rust/target
|
$(suppress) rm -rfv nix-rust/target
|
||||||
|
|
||||||
ifndef HOST_DARWIN
|
ifneq ($(OS), Darwin)
|
||||||
check: rust-tests
|
check: rust-tests
|
||||||
|
|
||||||
rust-tests:
|
rust-tests:
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
makefiles = local.mk
|
makefiles = local.mk
|
||||||
|
|
||||||
GLOBAL_CXXFLAGS += -g -Wall -std=c++17 -I ../src
|
GLOBAL_CXXFLAGS += -g -Wall -std=c++17
|
||||||
|
|
||||||
-include Makefile.config
|
-include Makefile.config
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
HOST_OS = @host_os@
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
CXX = @CXX@
|
CXX = @CXX@
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ CXXFLAGS=
|
|||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
|
||||||
AC_CANONICAL_HOST
|
|
||||||
|
|
||||||
# Use 64-bit file system calls so that we can support files > 2 GiB.
|
# Use 64-bit file system calls so that we can support files > 2 GiB.
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ our @EXPORT = qw(
|
|||||||
derivationFromPath
|
derivationFromPath
|
||||||
addTempRoot
|
addTempRoot
|
||||||
getBinDir getStoreDir
|
getBinDir getStoreDir
|
||||||
queryRawRealisation
|
|
||||||
);
|
);
|
||||||
|
|
||||||
our $VERSION = '0.15';
|
our $VERSION = '0.15';
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include "crypto.hh"
|
#include "crypto.hh"
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
@@ -121,18 +120,6 @@ SV * queryPathInfo(char * path, int base32)
|
|||||||
croak("%s", e.what());
|
croak("%s", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
SV * queryRawRealisation(char * outputId)
|
|
||||||
PPCODE:
|
|
||||||
try {
|
|
||||||
auto realisation = store()->queryRealisation(DrvOutput::parse(outputId));
|
|
||||||
if (realisation)
|
|
||||||
XPUSHs(sv_2mortal(newSVpv(realisation->toJSON().dump().c_str(), 0)));
|
|
||||||
else
|
|
||||||
XPUSHs(sv_2mortal(newSVpv("", 0)));
|
|
||||||
} catch (Error & e) {
|
|
||||||
croak("%s", e.what());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SV * queryPathFromHashPart(char * hashPart)
|
SV * queryPathFromHashPart(char * hashPart)
|
||||||
PPCODE:
|
PPCODE:
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ Store_CXXFLAGS = \
|
|||||||
|
|
||||||
Store_LDFLAGS := $(SODIUM_LIBS) $(NIX_LIBS)
|
Store_LDFLAGS := $(SODIUM_LIBS) $(NIX_LIBS)
|
||||||
|
|
||||||
ifdef HOST_CYGWIN
|
ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
|
||||||
archlib = $(shell perl -E 'use Config; print $$Config{archlib};')
|
archlib = $(shell perl -E 'use Config; print $$Config{archlib};')
|
||||||
libperl = $(shell perl -E 'use Config; print $$Config{libperl};')
|
libperl = $(shell perl -E 'use Config; print $$Config{libperl};')
|
||||||
Store_LDFLAGS += $(shell find ${archlib} -name ${libperl})
|
Store_LDFLAGS += $(shell find ${archlib} -name ${libperl})
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
((NEW_NIX_FIRST_BUILD_UID=301))
|
|
||||||
|
|
||||||
id_available(){
|
|
||||||
dscl . list /Users UniqueID | grep -E '\b'$1'\b' >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
change_nixbld_names_and_ids(){
|
|
||||||
local name uid next_id
|
|
||||||
((next_id=NEW_NIX_FIRST_BUILD_UID))
|
|
||||||
echo "Attempting to migrate nixbld users."
|
|
||||||
echo "Each user should change from nixbld# to _nixbld#"
|
|
||||||
echo "and their IDs relocated to $next_id+"
|
|
||||||
while read -r name uid; do
|
|
||||||
echo " Checking $name (uid: $uid)"
|
|
||||||
# iterate for a clean ID
|
|
||||||
while id_available "$next_id"; do
|
|
||||||
((next_id++))
|
|
||||||
if ((next_id >= 400)); then
|
|
||||||
echo "We've hit UID 400 without placing all of your users :("
|
|
||||||
echo "You should use the commands in this script as a starting"
|
|
||||||
echo "point to review your UID-space and manually move the"
|
|
||||||
echo "remaining users (or delete them, if you don't need them)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $name == _* ]]; then
|
|
||||||
echo " It looks like $name has already been renamed--skipping."
|
|
||||||
else
|
|
||||||
# first 3 are cleanup, it's OK if they aren't here
|
|
||||||
sudo dscl . delete /Users/$name dsAttrTypeNative:_writers_passwd &>/dev/null || true
|
|
||||||
sudo dscl . change /Users/$name NFSHomeDirectory "/private/var/empty 1" "/var/empty" &>/dev/null || true
|
|
||||||
# remove existing user from group
|
|
||||||
sudo dseditgroup -o edit -t user -d $name nixbld || true
|
|
||||||
sudo dscl . change /Users/$name UniqueID $uid $next_id
|
|
||||||
sudo dscl . change /Users/$name RecordName $name _$name
|
|
||||||
# add renamed user to group
|
|
||||||
sudo dseditgroup -o edit -t user -a _$name nixbld
|
|
||||||
echo " $name migrated to _$name (uid: $next_id)"
|
|
||||||
fi
|
|
||||||
done < <(dscl . list /Users UniqueID | grep nixbld | sort -n -k2)
|
|
||||||
}
|
|
||||||
|
|
||||||
change_nixbld_names_and_ids
|
|
||||||
+113
-788
@@ -1,262 +1,33 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
set -eu
|
set -e
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
# I'm a little agnostic on the choices, but supporting a wide
|
root_disk() {
|
||||||
# slate of uses for now, including:
|
diskutil info -plist /
|
||||||
# - import-only: `. create-darwin-volume.sh no-main[ ...]`
|
}
|
||||||
# - legacy: `./create-darwin-volume.sh` or `. create-darwin-volume.sh`
|
|
||||||
# (both will run main())
|
|
||||||
# - external alt-routine: `./create-darwin-volume.sh no-main func[ ...]`
|
|
||||||
if [ "${1-}" = "no-main" ]; then
|
|
||||||
shift
|
|
||||||
readonly _CREATE_VOLUME_NO_MAIN=1
|
|
||||||
else
|
|
||||||
readonly _CREATE_VOLUME_NO_MAIN=0
|
|
||||||
# declare some things we expect to inherit from install-multi-user
|
|
||||||
# I don't love this (because it's a bit of a kludge).
|
|
||||||
#
|
|
||||||
# CAUTION: (Dec 19 2020)
|
|
||||||
# This is a stopgap. It doesn't cover the full slate of
|
|
||||||
# identifiers we inherit--just those necessary to:
|
|
||||||
# - avoid breaking direct invocations of this script (here/now)
|
|
||||||
# - avoid hard-to-reverse structural changes before the call to rm
|
|
||||||
# single-user support is verified
|
|
||||||
#
|
|
||||||
# In the near-mid term, I (personally) think we should:
|
|
||||||
# - decide to deprecate the direct call and add a notice
|
|
||||||
# - fold all of this into install-darwin-multi-user.sh
|
|
||||||
# - intentionally remove the old direct-invocation form (kill the
|
|
||||||
# routine, replace this script w/ deprecation notice and a note
|
|
||||||
# on the remove-after date)
|
|
||||||
#
|
|
||||||
readonly NIX_ROOT="${NIX_ROOT:-/nix}"
|
|
||||||
|
|
||||||
_sudo() {
|
# i.e., "disk1"
|
||||||
shift # throw away the 'explanation'
|
|
||||||
/usr/bin/sudo "$@"
|
|
||||||
}
|
|
||||||
failure() {
|
|
||||||
if [ "$*" = "" ]; then
|
|
||||||
cat
|
|
||||||
else
|
|
||||||
echo "$@"
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
task() {
|
|
||||||
echo "$@"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# usually "disk1"
|
|
||||||
root_disk_identifier() {
|
root_disk_identifier() {
|
||||||
# For performance (~10ms vs 280ms) I'm parsing 'diskX' from stat output
|
diskutil info -plist / | xmllint --xpath "/plist/dict/key[text()='ParentWholeDisk']/following-sibling::string[1]/text()" -
|
||||||
# (~diskXsY)--but I'm retaining the more-semantic approach since
|
|
||||||
# it documents intent better.
|
|
||||||
# /usr/sbin/diskutil info -plist / | xmllint --xpath "/plist/dict/key[text()='ParentWholeDisk']/following-sibling::string[1]/text()" -
|
|
||||||
#
|
|
||||||
local special_device
|
|
||||||
special_device="$(/usr/bin/stat -f "%Sd" /)"
|
|
||||||
echo "${special_device%s[0-9]*}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# make it easy to play w/ 'Case-sensitive APFS'
|
find_nix_volume() {
|
||||||
readonly NIX_VOLUME_FS="${NIX_VOLUME_FS:-APFS}"
|
diskutil apfs list -plist "$1" | xmllint --xpath "(/plist/dict/array/dict/key[text()='Volumes']/following-sibling::array/dict/key[text()='Name']/following-sibling::string[starts-with(translate(text(),'N','n'),'nix')]/text())[1]" - 2>/dev/null || true
|
||||||
readonly NIX_VOLUME_LABEL="${NIX_VOLUME_LABEL:-Nix Store}"
|
|
||||||
# Strongly assuming we'll make a volume on the device / is on
|
|
||||||
# But you can override NIX_VOLUME_USE_DISK to create it on some other device
|
|
||||||
readonly NIX_VOLUME_USE_DISK="${NIX_VOLUME_USE_DISK:-$(root_disk_identifier)}"
|
|
||||||
NIX_VOLUME_USE_SPECIAL="${NIX_VOLUME_USE_SPECIAL:-}"
|
|
||||||
NIX_VOLUME_USE_UUID="${NIX_VOLUME_USE_UUID:-}"
|
|
||||||
readonly NIX_VOLUME_MOUNTD_DEST="${NIX_VOLUME_MOUNTD_DEST:-/Library/LaunchDaemons/org.nixos.darwin-store.plist}"
|
|
||||||
|
|
||||||
if /usr/bin/fdesetup isactive >/dev/null; then
|
|
||||||
test_filevault_in_use() { return 0; }
|
|
||||||
# no readonly; we may modify if user refuses from cure_volume
|
|
||||||
NIX_VOLUME_DO_ENCRYPT="${NIX_VOLUME_DO_ENCRYPT:-1}"
|
|
||||||
else
|
|
||||||
test_filevault_in_use() { return 1; }
|
|
||||||
NIX_VOLUME_DO_ENCRYPT="${NIX_VOLUME_DO_ENCRYPT:-0}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
should_encrypt_volume() {
|
|
||||||
test_filevault_in_use && (( NIX_VOLUME_DO_ENCRYPT == 1 ))
|
|
||||||
}
|
|
||||||
|
|
||||||
substep() {
|
|
||||||
printf " %s\n" "" "- $1" "" "${@:2}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
volumes_labeled() {
|
|
||||||
local label="$1"
|
|
||||||
xsltproc --novalid --stringparam label "$label" - <(/usr/sbin/ioreg -ra -c "AppleAPFSVolume") <<'EOF'
|
|
||||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
|
||||||
<xsl:output method="text"/>
|
|
||||||
<xsl:template match="/">
|
|
||||||
<xsl:apply-templates select="/plist/array/dict/key[text()='IORegistryEntryName']/following-sibling::*[1][text()=$label]/.."/>
|
|
||||||
</xsl:template>
|
|
||||||
<xsl:template match="dict">
|
|
||||||
<xsl:apply-templates match="string" select="key[text()='BSD Name']/following-sibling::*[1]"/>
|
|
||||||
<xsl:text>=</xsl:text>
|
|
||||||
<xsl:apply-templates match="string" select="key[text()='UUID']/following-sibling::*[1]"/>
|
|
||||||
<xsl:text>
</xsl:text>
|
|
||||||
</xsl:template>
|
|
||||||
</xsl:stylesheet>
|
|
||||||
EOF
|
|
||||||
# I cut label out of the extracted values, but here it is for reference:
|
|
||||||
# <xsl:apply-templates match="string" select="key[text()='IORegistryEntryName']/following-sibling::*[1]"/>
|
|
||||||
# <xsl:text>=</xsl:text>
|
|
||||||
}
|
|
||||||
|
|
||||||
right_disk() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
[[ "$volume_special" == "$NIX_VOLUME_USE_DISK"s* ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
right_volume() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
# if set, it must match; otherwise ensure it's on the right disk
|
|
||||||
if [ -z "$NIX_VOLUME_USE_SPECIAL" ]; then
|
|
||||||
if right_disk "$volume_special"; then
|
|
||||||
NIX_VOLUME_USE_SPECIAL="$volume_special" # latch on
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
[ "$volume_special" = "$NIX_VOLUME_USE_SPECIAL" ]
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
right_uuid() {
|
|
||||||
local volume_uuid="$1"
|
|
||||||
# if set, it must match; otherwise allow
|
|
||||||
if [ -z "$NIX_VOLUME_USE_UUID" ]; then
|
|
||||||
NIX_VOLUME_USE_UUID="$volume_uuid" # latch on
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
[ "$volume_uuid" = "$NIX_VOLUME_USE_UUID" ]
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cure_volumes() {
|
|
||||||
local found volume special uuid
|
|
||||||
# loop just in case they have more than one volume
|
|
||||||
# (nothing stops you from doing this)
|
|
||||||
for volume in $(volumes_labeled "$NIX_VOLUME_LABEL"); do
|
|
||||||
# CAUTION: this could (maybe) be a more normal read
|
|
||||||
# loop like:
|
|
||||||
# while IFS== read -r special uuid; do
|
|
||||||
# # ...
|
|
||||||
# done <<<"$(volumes_labeled "$NIX_VOLUME_LABEL")"
|
|
||||||
#
|
|
||||||
# I did it with for to skirt a problem with the obvious
|
|
||||||
# pattern replacing stdin and causing user prompts
|
|
||||||
# inside (which also use read and access stdin) to skip
|
|
||||||
#
|
|
||||||
# If there's an existing encrypted volume we can't find
|
|
||||||
# in keychain, the user never gets prompted to delete
|
|
||||||
# the volume, and the install fails.
|
|
||||||
#
|
|
||||||
# If you change this, a human needs to test a very
|
|
||||||
# specific scenario: you already have an encrypted
|
|
||||||
# Nix Store volume, and have deleted its credential
|
|
||||||
# from keychain. Ensure the script asks you if it can
|
|
||||||
# delete the volume, and then prompts for your sudo
|
|
||||||
# password to confirm.
|
|
||||||
#
|
|
||||||
# shellcheck disable=SC1097
|
|
||||||
IFS== read -r special uuid <<< "$volume"
|
|
||||||
# take the first one that's on the right disk
|
|
||||||
if [ -z "${found:-}" ]; then
|
|
||||||
if right_volume "$special" && right_uuid "$uuid"; then
|
|
||||||
cure_volume "$special" "$uuid"
|
|
||||||
found="${special} (${uuid})"
|
|
||||||
else
|
|
||||||
warning <<EOF
|
|
||||||
Ignoring ${special} (${uuid}) because I am looking for:
|
|
||||||
disk=${NIX_VOLUME_USE_DISK} special=${NIX_VOLUME_USE_SPECIAL:-${NIX_VOLUME_USE_DISK}sX} uuid=${NIX_VOLUME_USE_UUID:-any}
|
|
||||||
EOF
|
|
||||||
# TODO: give chance to delete if ! headless?
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warning <<EOF
|
|
||||||
Ignoring ${special} (${uuid}), already found target: $found
|
|
||||||
EOF
|
|
||||||
# TODO reminder? I feel like I want one
|
|
||||||
# idiom that reminds some warnings, or warns
|
|
||||||
# some reminders?
|
|
||||||
# TODO: if ! headless, chance to delete?
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ -z "${found:-}" ]; then
|
|
||||||
readonly NIX_VOLUME_USE_SPECIAL NIX_VOLUME_USE_UUID
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
volume_encrypted() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
# Trying to match the first line of output; known first lines:
|
|
||||||
# No cryptographic users for <special>
|
|
||||||
# Cryptographic user for <special> (1 found)
|
|
||||||
# Cryptographic users for <special> (2 found)
|
|
||||||
/usr/sbin/diskutil apfs listCryptoUsers -plist "$volume_special" | /usr/bin/grep -q APFSCryptoUserUUID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fstab() {
|
test_fstab() {
|
||||||
/usr/bin/grep -q "$NIX_ROOT apfs rw" /etc/fstab 2>/dev/null
|
grep -q "/nix apfs rw" /etc/fstab 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
test_nix_root_is_symlink() {
|
test_nix_symlink() {
|
||||||
[ -L "$NIX_ROOT" ]
|
[ -L "/nix" ] || grep -q "^nix." /etc/synthetic.conf 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
test_synthetic_conf_either(){
|
test_synthetic_conf() {
|
||||||
/usr/bin/grep -qE "^${NIX_ROOT:1}($|\t.{3,}$)" /etc/synthetic.conf 2>/dev/null
|
grep -q "^nix$" /etc/synthetic.conf 2>/dev/null
|
||||||
}
|
|
||||||
|
|
||||||
test_synthetic_conf_mountable() {
|
|
||||||
/usr/bin/grep -q "^${NIX_ROOT:1}$" /etc/synthetic.conf 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
test_synthetic_conf_symlinked() {
|
|
||||||
/usr/bin/grep -qE "^${NIX_ROOT:1}\t.{3,}$" /etc/synthetic.conf 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
test_nix_volume_mountd_installed() {
|
|
||||||
test -e "$NIX_VOLUME_MOUNTD_DEST"
|
|
||||||
}
|
|
||||||
|
|
||||||
# current volume password
|
|
||||||
test_keychain_by_uuid() {
|
|
||||||
local volume_uuid="$1"
|
|
||||||
# Note: doesn't need sudo just to check; doesn't output pw
|
|
||||||
security find-generic-password -s "$volume_uuid" &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
get_volume_pass() {
|
|
||||||
local volume_uuid="$1"
|
|
||||||
_sudo \
|
|
||||||
"to confirm keychain has a password that unlocks this volume" \
|
|
||||||
security find-generic-password -s "$volume_uuid" -w
|
|
||||||
}
|
|
||||||
|
|
||||||
verify_volume_pass() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
local volume_uuid="$2"
|
|
||||||
/usr/sbin/diskutil apfs unlockVolume "$volume_special" -verify -stdinpassphrase -user "$volume_uuid"
|
|
||||||
}
|
|
||||||
|
|
||||||
volume_pass_works() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
local volume_uuid="$2"
|
|
||||||
get_volume_pass "$volume_uuid" | verify_volume_pass "$volume_special" "$volume_uuid"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the paths defined in synthetic.conf, saving us a reboot.
|
# Create the paths defined in synthetic.conf, saving us a reboot.
|
||||||
create_synthetic_objects() {
|
create_synthetic_objects(){
|
||||||
# Big Sur takes away the -B flag we were using and replaces it
|
# Big Sur takes away the -B flag we were using and replaces it
|
||||||
# with a -t flag that appears to do the same thing (but they
|
# with a -t flag that appears to do the same thing (but they
|
||||||
# don't behave exactly the same way in terms of return values).
|
# don't behave exactly the same way in terms of return values).
|
||||||
@@ -270,575 +41,129 @@ create_synthetic_objects() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_nix() {
|
test_nix() {
|
||||||
test -d "$NIX_ROOT"
|
test -d "/nix"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_voldaemon() {
|
test_t2_chip_present(){
|
||||||
test -f "$NIX_VOLUME_MOUNTD_DEST"
|
# Use xartutil to see if system has a t2 chip.
|
||||||
}
|
|
||||||
|
|
||||||
generate_mount_command() {
|
|
||||||
local cmd_type="$1" # encrypted|unencrypted
|
|
||||||
local volume_uuid mountpoint cmd=()
|
|
||||||
printf -v volume_uuid "%q" "$2"
|
|
||||||
printf -v mountpoint "%q" "$NIX_ROOT"
|
|
||||||
|
|
||||||
case "$cmd_type" in
|
|
||||||
encrypted)
|
|
||||||
cmd=(/bin/sh -c "/usr/bin/security find-generic-password -s '$volume_uuid' -w | /usr/sbin/diskutil apfs unlockVolume '$volume_uuid' -mountpoint '$mountpoint' -stdinpassphrase");;
|
|
||||||
unencrypted)
|
|
||||||
cmd=(/usr/sbin/diskutil mount -mountPoint "$mountpoint" "$volume_uuid");;
|
|
||||||
*)
|
|
||||||
failure "Invalid first arg $cmd_type to generate_mount_command";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
printf " <string>%s</string>\n" "${cmd[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
generate_mount_daemon() {
|
|
||||||
local cmd_type="$1" # encrypted|unencrypted
|
|
||||||
local volume_uuid="$2"
|
|
||||||
cat <<EOF
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>RunAtLoad</key>
|
|
||||||
<true/>
|
|
||||||
<key>Label</key>
|
|
||||||
<string>org.nixos.darwin-store</string>
|
|
||||||
<key>ProgramArguments</key>
|
|
||||||
<array>
|
|
||||||
$(generate_mount_command "$cmd_type" "$volume_uuid")
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
_eat_bootout_err() {
|
|
||||||
/usr/bin/grep -v "Boot-out failed: 36: Operation now in progress"
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO: remove with --uninstall?
|
|
||||||
uninstall_launch_daemon_directions() {
|
|
||||||
local daemon_label="$1" # i.e., org.nixos.blah-blah
|
|
||||||
local daemon_plist="$2" # abspath
|
|
||||||
substep "Uninstall LaunchDaemon $daemon_label" \
|
|
||||||
" sudo launchctl bootout system/$daemon_label" \
|
|
||||||
" sudo rm $daemon_plist"
|
|
||||||
}
|
|
||||||
|
|
||||||
uninstall_launch_daemon_prompt() {
|
|
||||||
local daemon_label="$1" # i.e., org.nixos.blah-blah
|
|
||||||
local daemon_plist="$2" # abspath
|
|
||||||
local reason_for_daemon="$3"
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
The installer adds a LaunchDaemon to $reason_for_daemon: $daemon_label
|
|
||||||
EOF
|
|
||||||
if ui_confirm "Can I remove it?"; then
|
|
||||||
_sudo "to terminate the daemon" \
|
|
||||||
launchctl bootout "system/$daemon_label" 2> >(_eat_bootout_err >&2) || true
|
|
||||||
# this can "fail" with a message like:
|
|
||||||
# Boot-out failed: 36: Operation now in progress
|
|
||||||
_sudo "to remove the daemon definition" rm "$daemon_plist"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
nix_volume_mountd_uninstall_directions() {
|
|
||||||
uninstall_launch_daemon_directions "org.nixos.darwin-store" \
|
|
||||||
"$NIX_VOLUME_MOUNTD_DEST"
|
|
||||||
}
|
|
||||||
|
|
||||||
nix_volume_mountd_uninstall_prompt() {
|
|
||||||
uninstall_launch_daemon_prompt "org.nixos.darwin-store" \
|
|
||||||
"$NIX_VOLUME_MOUNTD_DEST" \
|
|
||||||
"mount your Nix volume"
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO: move nix_daemon to install-darwin-multi-user if/when uninstall_launch_daemon_prompt moves up to install-multi-user
|
|
||||||
nix_daemon_uninstall_prompt() {
|
|
||||||
uninstall_launch_daemon_prompt "org.nixos.nix-daemon" \
|
|
||||||
"$NIX_DAEMON_DEST" \
|
|
||||||
"run the nix-daemon"
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO: remove with --uninstall?
|
|
||||||
nix_daemon_uninstall_directions() {
|
|
||||||
uninstall_launch_daemon_directions "org.nixos.nix-daemon" \
|
|
||||||
"$NIX_DAEMON_DEST"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: remove with --uninstall?
|
|
||||||
synthetic_conf_uninstall_directions() {
|
|
||||||
# :1 to strip leading slash
|
|
||||||
substep "Remove ${NIX_ROOT:1} from /etc/synthetic.conf" \
|
|
||||||
" If nix is the only entry: sudo rm /etc/synthetic.conf" \
|
|
||||||
" Otherwise: sudo /usr/bin/sed -i '' -e '/^${NIX_ROOT:1}$/d' /etc/synthetic.conf"
|
|
||||||
}
|
|
||||||
|
|
||||||
synthetic_conf_uninstall_prompt() {
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
During install, I add '${NIX_ROOT:1}' to /etc/synthetic.conf, which instructs
|
|
||||||
macOS to create an empty root directory for mounting the Nix volume.
|
|
||||||
EOF
|
|
||||||
# make the edit to a copy
|
|
||||||
/usr/bin/grep -vE "^${NIX_ROOT:1}($|\t.{3,}$)" /etc/synthetic.conf > "$SCRATCH/synthetic.conf.edit"
|
|
||||||
|
|
||||||
if test_synthetic_conf_symlinked; then
|
|
||||||
warning <<EOF
|
|
||||||
|
|
||||||
/etc/synthetic.conf already contains a line instructing your system
|
|
||||||
to make '${NIX_ROOT}' as a symlink:
|
|
||||||
$(/usr/bin/grep -nE "^${NIX_ROOT:1}\t.{3,}$" /etc/synthetic.conf)
|
|
||||||
|
|
||||||
This may mean your system has/had a non-standard Nix install.
|
|
||||||
|
|
||||||
The volume-creation process in this installer is *not* compatible
|
|
||||||
with a symlinked store, so I'll have to remove this instruction to
|
|
||||||
continue.
|
|
||||||
|
|
||||||
If you want/need to keep this instruction, answer 'n' to abort.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ask to rm if this left the file empty aside from comments, else edit
|
|
||||||
if /usr/bin/diff -q <(:) <(/usr/bin/grep -v "^#" "$SCRATCH/synthetic.conf.edit") &>/dev/null; then
|
|
||||||
if confirm_rm "/etc/synthetic.conf"; then
|
|
||||||
if test_nix_root_is_symlink; then
|
|
||||||
failure >&2 <<EOF
|
|
||||||
I removed /etc/synthetic.conf, but $NIX_ROOT is already a symlink
|
|
||||||
(-> $(readlink "$NIX_ROOT")). The system should remove it when you reboot.
|
|
||||||
Once you've rebooted, run the installer again.
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if confirm_edit "$SCRATCH/synthetic.conf.edit" "/etc/synthetic.conf"; then
|
|
||||||
if test_nix_root_is_symlink; then
|
|
||||||
failure >&2 <<EOF
|
|
||||||
I edited Nix out of /etc/synthetic.conf, but $NIX_ROOT is already a symlink
|
|
||||||
(-> $(readlink "$NIX_ROOT")). The system should remove it when you reboot.
|
|
||||||
Once you've rebooted, run the installer again.
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# fallback instructions
|
|
||||||
echo "Manually remove nix from /etc/synthetic.conf"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
add_nix_vol_fstab_line() {
|
|
||||||
local uuid="$1"
|
|
||||||
# shellcheck disable=SC1003,SC2026
|
|
||||||
local escaped_mountpoint="${NIX_ROOT/ /'\\\'040}"
|
|
||||||
shift
|
|
||||||
EDITOR="/usr/bin/ex" _sudo "to add nix to fstab" "$@" <<EOF
|
|
||||||
:a
|
|
||||||
UUID=$uuid $escaped_mountpoint apfs rw,noauto,nobrowse,suid,owners
|
|
||||||
.
|
|
||||||
:x
|
|
||||||
EOF
|
|
||||||
# TODO: preserving my notes on suid,owners above until resolved
|
|
||||||
# There *may* be some issue regarding volume ownership, see nix#3156
|
|
||||||
#
|
#
|
||||||
# It seems like the cheapest fix is adding "suid,owners" to fstab, but:
|
# This isn't well-documented on its own; until it is,
|
||||||
# - We don't have much info on this condition yet
|
# let's keep track of knowledge/assumptions.
|
||||||
# - I'm not certain if these cause other problems?
|
|
||||||
# - There's a "chown" component some people claim to need to fix this
|
|
||||||
# that I don't understand yet
|
|
||||||
# (Note however that I've had to add a chown step to handle
|
|
||||||
# single->multi-user reinstalls, which may cover this)
|
|
||||||
#
|
#
|
||||||
# I'm not sure if it's safe to approach this way?
|
# Warnings:
|
||||||
|
# - Don't search "xart" if porn will cause you trouble :)
|
||||||
|
# - Other xartutil flags do dangerous things. Don't run them
|
||||||
|
# naively. If you must, search "xartutil" first.
|
||||||
#
|
#
|
||||||
# I think I think the most-proper way to test for it is:
|
# Assumptions:
|
||||||
# diskutil info -plist "$NIX_VOLUME_LABEL" | xmllint --xpath "(/plist/dict/key[text()='GlobalPermissionsEnabled'])/following-sibling::*[1][name()='true']" -; echo $?
|
# - the "xART session seeds recovery utility"
|
||||||
#
|
# appears to interact with xartstorageremoted
|
||||||
# There's also `sudo /usr/sbin/vsdbutil -c /path` (which is much faster, but is also
|
# - `sudo xartutil --list` lists xART sessions
|
||||||
# deprecated and needs minor parsing).
|
# and their seeds and exits 0 if successful. If
|
||||||
#
|
# not, it exits 1 and prints an error such as:
|
||||||
# If no one finds a problem with doing so, I think the simplest approach
|
# xartutil: ERROR: No supported link to the SEP present
|
||||||
# is to just eagerly set this. I found a few imperative approaches:
|
# - xART sessions/seeds are present when a T2 chip is
|
||||||
# (diskutil enableOwnership, ~100ms), a cheap one (/usr/sbin/vsdbutil -a, ~40-50ms),
|
# (and not, otherwise)
|
||||||
# a very cheap one (append the internal format to /var/db/volinfo.database).
|
# - the presence of a T2 chip means a newly-created
|
||||||
#
|
# volume on the primary drive will be
|
||||||
# But vsdbutil's deprecation notice suggests using fstab, so I want to
|
# encrypted at rest
|
||||||
# give that a whirl first.
|
# - all together: `sudo xartutil --list`
|
||||||
#
|
# should exit 0 if a new Nix Store volume will
|
||||||
# TODO: when this is workable, poke infinisil about reproducing the issue
|
# be encrypted at rest, and exit 1 if not.
|
||||||
# and confirming this fix?
|
sudo xartutil --list >/dev/null 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_nix_vol_fstab_line() {
|
test_filevault_in_use() {
|
||||||
# TODO: I'm scaffolding this to handle the new nix volumes
|
fdesetup isactive >/dev/null
|
||||||
# but it might be nice to generalize a smidge further to
|
|
||||||
# go ahead and set up a pattern for curing "old" things
|
|
||||||
# we no longer do?
|
|
||||||
EDITOR="/usr/bin/patch" _sudo "to cut nix from fstab" "$@" < <(/usr/bin/diff /etc/fstab <(/usr/bin/grep -v "$NIX_ROOT apfs rw" /etc/fstab))
|
|
||||||
# leaving some parts out of the grep; people may fiddle this a little?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: hope to remove with --uninstall
|
# use after error msg for conditions we don't understand
|
||||||
fstab_uninstall_directions() {
|
suggest_report_error(){
|
||||||
substep "Remove ${NIX_ROOT} from /etc/fstab" \
|
# ex "error: something sad happened :(" >&2
|
||||||
" If nix is the only entry: sudo rm /etc/fstab" \
|
echo " please report this @ https://github.com/nixos/nix/issues" >&2
|
||||||
" Otherwise, run 'sudo /usr/sbin/vifs' to remove the nix line"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fstab_uninstall_prompt() {
|
main() {
|
||||||
cat <<EOF
|
(
|
||||||
During install, I add '${NIX_ROOT}' to /etc/fstab so that macOS knows what
|
echo ""
|
||||||
mount options to use for the Nix volume.
|
echo " ------------------------------------------------------------------ "
|
||||||
EOF
|
echo " | This installer will create a volume for the nix store and |"
|
||||||
cp /etc/fstab "$SCRATCH/fstab.edit"
|
echo " | configure it to mount at /nix. Follow these steps to uninstall. |"
|
||||||
# technically doesn't need the _sudo path, but throwing away the
|
echo " ------------------------------------------------------------------ "
|
||||||
# output is probably better than mostly-duplicating the code...
|
echo ""
|
||||||
delete_nix_vol_fstab_line patch "$SCRATCH/fstab.edit" &>/dev/null
|
echo " 1. Remove the entry from fstab using 'sudo vifs'"
|
||||||
|
echo " 2. Destroy the data volume using 'diskutil apfs deleteVolume'"
|
||||||
|
echo " 3. Remove the 'nix' line from /etc/synthetic.conf or the file"
|
||||||
|
echo ""
|
||||||
|
) >&2
|
||||||
|
|
||||||
# if the patch test edit, minus comment lines, is equal to empty (:)
|
if test_nix_symlink; then
|
||||||
if /usr/bin/diff -q <(:) <(/usr/bin/grep -v "^#" "$SCRATCH/fstab.edit") &>/dev/null; then
|
echo "error: /nix is a symlink, please remove it and make sure it's not in synthetic.conf (in which case a reboot is required)" >&2
|
||||||
# this edit would leave it empty; propose deleting it
|
echo " /nix -> $(readlink "/nix")" >&2
|
||||||
if confirm_rm "/etc/fstab"; then
|
exit 2
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "Remove nix from /etc/fstab (or remove the file)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "I might be able to help you make this edit. Here's the diff:"
|
|
||||||
if ! _diff "/etc/fstab" "$SCRATCH/fstab.edit" && ui_confirm "Does the change above look right?"; then
|
|
||||||
delete_nix_vol_fstab_line /usr/sbin/vifs
|
|
||||||
else
|
|
||||||
echo "Remove nix from /etc/fstab (or remove the file)"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_volume() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
_sudo "to unmount the Nix volume" \
|
|
||||||
/usr/sbin/diskutil unmount force "$volume_special" || true # might not be mounted
|
|
||||||
_sudo "to delete the Nix volume" \
|
|
||||||
/usr/sbin/diskutil apfs deleteVolume "$volume_special"
|
|
||||||
}
|
|
||||||
|
|
||||||
# aspiration: robust enough to both fix problems
|
|
||||||
# *and* update older darwin volumes
|
|
||||||
cure_volume() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
local volume_uuid="$2"
|
|
||||||
header "Found existing Nix volume"
|
|
||||||
row " special" "$volume_special"
|
|
||||||
row " uuid" "$volume_uuid"
|
|
||||||
|
|
||||||
if volume_encrypted "$volume_special"; then
|
|
||||||
row "encrypted" "yes"
|
|
||||||
if volume_pass_works "$volume_special" "$volume_uuid"; then
|
|
||||||
NIX_VOLUME_DO_ENCRYPT=0
|
|
||||||
ok "Found a working decryption password in keychain :)"
|
|
||||||
echo ""
|
|
||||||
else
|
|
||||||
# - this is a volume we made, and
|
|
||||||
# - the user encrypted it on their own
|
|
||||||
# - something deleted the credential
|
|
||||||
# - this is an old or BYO volume and the pw
|
|
||||||
# just isn't somewhere we can find it.
|
|
||||||
#
|
|
||||||
# We're going to explain why we're freaking out
|
|
||||||
# and prompt them to either delete the volume
|
|
||||||
# (requiring a sudo auth), or abort to fix
|
|
||||||
warning <<EOF
|
|
||||||
|
|
||||||
This volume is encrypted, but I don't see a password to decrypt it.
|
|
||||||
The quick fix is to let me delete this volume and make you a new one.
|
|
||||||
If that's okay, enter your (sudo) password to continue. If not, you
|
|
||||||
can ensure the decryption password is in your system keychain with a
|
|
||||||
"Where" (service) field set to this volume's UUID:
|
|
||||||
$volume_uuid
|
|
||||||
EOF
|
|
||||||
if password_confirm "delete this volume"; then
|
|
||||||
remove_volume "$volume_special"
|
|
||||||
else
|
|
||||||
# TODO: this is a good design case for a warn-and
|
|
||||||
# remind idiom...
|
|
||||||
failure <<EOF
|
|
||||||
Your Nix volume is encrypted, but I couldn't find its password. Either:
|
|
||||||
- Delete or rename the volume out of the way
|
|
||||||
- Ensure its decryption password is in the system keychain with a
|
|
||||||
"Where" (service) field set to this volume's UUID:
|
|
||||||
$volume_uuid
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif test_filevault_in_use; then
|
|
||||||
row "encrypted" "no"
|
|
||||||
warning <<EOF
|
|
||||||
FileVault is on, but your $NIX_VOLUME_LABEL volume isn't encrypted.
|
|
||||||
EOF
|
|
||||||
# if we're interactive, give them a chance to
|
|
||||||
# encrypt the volume. If not, /shrug
|
|
||||||
if ! headless && (( NIX_VOLUME_DO_ENCRYPT == 1 )); then
|
|
||||||
if ui_confirm "Should I encrypt it and add the decryption key to your keychain?"; then
|
|
||||||
encrypt_volume "$volume_uuid" "$NIX_VOLUME_LABEL"
|
|
||||||
NIX_VOLUME_DO_ENCRYPT=0
|
|
||||||
else
|
|
||||||
NIX_VOLUME_DO_ENCRYPT=0
|
|
||||||
reminder "FileVault is on, but your $NIX_VOLUME_LABEL volume isn't encrypted."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
row "encrypted" "no"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_volume_artifacts() {
|
|
||||||
if test_synthetic_conf_either; then
|
|
||||||
# NIX_ROOT is in synthetic.conf
|
|
||||||
if synthetic_conf_uninstall_prompt; then
|
|
||||||
# TODO: moot until we tackle uninstall, but when we're
|
|
||||||
# actually uninstalling, we should issue:
|
|
||||||
# reminder "macOS will clean up the empty mount-point directory at $NIX_ROOT on reboot."
|
|
||||||
:
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test_fstab; then
|
|
||||||
fstab_uninstall_prompt
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test_nix_volume_mountd_installed; then
|
if ! test_synthetic_conf; then
|
||||||
nix_volume_mountd_uninstall_prompt
|
echo "Configuring /etc/synthetic.conf..." >&2
|
||||||
|
echo nix | sudo tee -a /etc/synthetic.conf
|
||||||
|
if ! test_synthetic_conf; then
|
||||||
|
echo "error: failed to configure synthetic.conf;" >&2
|
||||||
|
suggest_report_error
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
setup_synthetic_conf() {
|
if ! test_nix; then
|
||||||
if test_nix_root_is_symlink; then
|
echo "Creating mountpoint for /nix..." >&2
|
||||||
if ! test_synthetic_conf_symlinked; then
|
create_synthetic_objects # the ones we defined in synthetic.conf
|
||||||
failure >&2 <<EOF
|
|
||||||
error: $NIX_ROOT is a symlink (-> $(readlink "$NIX_ROOT")).
|
|
||||||
Please remove it. If nix is in /etc/synthetic.conf, remove it and reboot.
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if ! test_synthetic_conf_mountable; then
|
|
||||||
task "Configuring /etc/synthetic.conf to make a mount-point at $NIX_ROOT" >&2
|
|
||||||
# technically /etc/synthetic.d/nix is supported in Big Sur+
|
|
||||||
# but handling both takes even more code...
|
|
||||||
_sudo "to add Nix to /etc/synthetic.conf" \
|
|
||||||
/usr/bin/ex /etc/synthetic.conf <<EOF
|
|
||||||
:a
|
|
||||||
${NIX_ROOT:1}
|
|
||||||
.
|
|
||||||
:x
|
|
||||||
EOF
|
|
||||||
if ! test_synthetic_conf_mountable; then
|
|
||||||
failure "error: failed to configure synthetic.conf" >&2
|
|
||||||
fi
|
|
||||||
create_synthetic_objects
|
|
||||||
if ! test_nix; then
|
if ! test_nix; then
|
||||||
failure >&2 <<EOF
|
sudo mkdir -p /nix 2>/dev/null || true
|
||||||
error: failed to bootstrap $NIX_ROOT
|
fi
|
||||||
If you enabled FileVault after booting, this is likely a known issue
|
if ! test_nix; then
|
||||||
with macOS that you'll have to reboot to fix. If you didn't enable FV,
|
echo "error: failed to bootstrap /nix; if a reboot doesn't help," >&2
|
||||||
though, please open an issue describing how the system that you see
|
suggest_report_error
|
||||||
this error on was set up.
|
exit 1
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
setup_fstab() {
|
disk="$(root_disk_identifier)"
|
||||||
local volume_uuid="$1"
|
volume=$(find_nix_volume "$disk")
|
||||||
# fstab used to be responsible for mounting the volume. Now the last
|
if [ -z "$volume" ]; then
|
||||||
# step adds a LaunchDaemon responsible for mounting. This is technically
|
echo "Creating a Nix Store volume..." >&2
|
||||||
# redundant for mounting, but diskutil appears to pick up mount options
|
|
||||||
# from fstab (and diskutil's support for specifying them directly is not
|
|
||||||
# consistent across versions/subcommands).
|
|
||||||
if ! test_fstab; then
|
|
||||||
task "Configuring /etc/fstab to specify volume mount options" >&2
|
|
||||||
add_nix_vol_fstab_line "$volume_uuid" /usr/sbin/vifs
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
encrypt_volume() {
|
if test_filevault_in_use; then
|
||||||
local volume_uuid="$1"
|
# TODO: Not sure if it's in-scope now, but `diskutil apfs list`
|
||||||
local volume_label="$2"
|
# shows both filevault and encrypted at rest status, and it
|
||||||
local password
|
# may be the more semantic way to test for this? It'll show
|
||||||
# Note: mount/unmount are late additions to support the right order
|
# `FileVault: No (Encrypted at rest)`
|
||||||
# of operations for creating the volume and then baking its uuid into
|
# `FileVault: No`
|
||||||
# other artifacts; not as well-trod wrt to potential errors, race
|
# `FileVault: Yes (Unlocked)`
|
||||||
# conditions, etc.
|
# and so on.
|
||||||
|
if test_t2_chip_present; then
|
||||||
|
echo "warning: boot volume is FileVault-encrypted, but the Nix store volume" >&2
|
||||||
|
echo " is only encrypted at rest." >&2
|
||||||
|
echo " See https://nixos.org/nix/manual/#sect-macos-installation" >&2
|
||||||
|
else
|
||||||
|
echo "error: refusing to create Nix store volume because the boot volume is" >&2
|
||||||
|
echo " FileVault encrypted, but encryption-at-rest is not available." >&2
|
||||||
|
echo " Manually create a volume for the store and re-run this script." >&2
|
||||||
|
echo " See https://nixos.org/nix/manual/#sect-macos-installation" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
/usr/sbin/diskutil mount "$volume_label"
|
sudo diskutil apfs addVolume "$disk" APFS 'Nix Store' -mountpoint /nix
|
||||||
|
volume="Nix Store"
|
||||||
password="$(/usr/bin/xxd -l 32 -p -c 256 /dev/random)"
|
|
||||||
_sudo "to add your Nix volume's password to Keychain" \
|
|
||||||
/usr/bin/security -i <<EOF
|
|
||||||
add-generic-password -a "$volume_label" -s "$volume_uuid" -l "$volume_label encryption password" -D "Encrypted volume password" -j "Added automatically by the Nix installer for use by $NIX_VOLUME_MOUNTD_DEST" -w "$password" -T /System/Library/CoreServices/APFSUserAgent -T /System/Library/CoreServices/CSUserAgent -T /usr/bin/security "/Library/Keychains/System.keychain"
|
|
||||||
EOF
|
|
||||||
builtin printf "%s" "$password" | _sudo "to encrypt your Nix volume" \
|
|
||||||
/usr/sbin/diskutil apfs encryptVolume "$volume_label" -user disk -stdinpassphrase
|
|
||||||
|
|
||||||
/usr/sbin/diskutil unmount force "$volume_label"
|
|
||||||
}
|
|
||||||
|
|
||||||
create_volume() {
|
|
||||||
# Notes:
|
|
||||||
# 1) using `-nomount` instead of `-mountpoint "$NIX_ROOT"` to get
|
|
||||||
# its UUID and set mount opts in fstab before first mount
|
|
||||||
#
|
|
||||||
# 2) system is in some sense less secure than user keychain... (it's
|
|
||||||
# possible to read the password for decrypting the keychain) but
|
|
||||||
# the user keychain appears to be available too late. As far as I
|
|
||||||
# can tell, the file with this password (/var/db/SystemKey) is
|
|
||||||
# inside the FileVault envelope. If that isn't true, it may make
|
|
||||||
# sense to store the password inside the envelope?
|
|
||||||
#
|
|
||||||
# 3) At some point it would be ideal to have a small binary to serve
|
|
||||||
# as the daemon itself, and for it to replace /usr/bin/security here.
|
|
||||||
#
|
|
||||||
# 4) *UserAgent exemptions should let the system seamlessly supply the
|
|
||||||
# password if noauto is removed from fstab entry. This is intentional;
|
|
||||||
# the user will hopefully look for help if the volume stops mounting,
|
|
||||||
# rather than failing over into subtle race-condition problems.
|
|
||||||
#
|
|
||||||
# 5) If we ever get users griping about not having space to do
|
|
||||||
# anything useful with Nix, it is possibly to specify
|
|
||||||
# `-reserve 10g` or something, which will fail w/o that much
|
|
||||||
#
|
|
||||||
# 6) getting special w/ awk may be fragile, but doing it to:
|
|
||||||
# - save time over running slow diskutil commands
|
|
||||||
# - skirt risk we grab wrong volume if multiple match
|
|
||||||
_sudo "to create a new APFS volume '$NIX_VOLUME_LABEL' on $NIX_VOLUME_USE_DISK" \
|
|
||||||
/usr/sbin/diskutil apfs addVolume "$NIX_VOLUME_USE_DISK" "$NIX_VOLUME_FS" "$NIX_VOLUME_LABEL" -nomount | /usr/bin/awk '/Created new APFS Volume/ {print $5}'
|
|
||||||
}
|
|
||||||
|
|
||||||
volume_uuid_from_special() {
|
|
||||||
local volume_special="$1" # (i.e., disk1s7)
|
|
||||||
# For reasons I won't pretend to fathom, this returns 253 when it works
|
|
||||||
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -k "$volume_special" || true
|
|
||||||
}
|
|
||||||
|
|
||||||
# this sometimes clears immediately, and AFAIK clears
|
|
||||||
# within about 1s. diskutil info on an unmounted path
|
|
||||||
# fails in around 50-100ms and a match takes about
|
|
||||||
# 250-300ms. I suspect it's usually ~250-750ms
|
|
||||||
await_volume() {
|
|
||||||
# caution: this could, in theory, get stuck
|
|
||||||
until /usr/sbin/diskutil info "$NIX_ROOT" &>/dev/null; do
|
|
||||||
:
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_volume() {
|
|
||||||
local use_special use_uuid profile_packages
|
|
||||||
task "Creating a Nix volume" >&2
|
|
||||||
|
|
||||||
use_special="${NIX_VOLUME_USE_SPECIAL:-$(create_volume)}"
|
|
||||||
|
|
||||||
use_uuid=${NIX_VOLUME_USE_UUID:-$(volume_uuid_from_special "$use_special")}
|
|
||||||
|
|
||||||
setup_fstab "$use_uuid"
|
|
||||||
|
|
||||||
if should_encrypt_volume; then
|
|
||||||
encrypt_volume "$use_uuid" "$NIX_VOLUME_LABEL"
|
|
||||||
setup_volume_daemon "encrypted" "$use_uuid"
|
|
||||||
# TODO: might be able to save ~60ms by caching or setting
|
|
||||||
# this somewhere rather than re-checking here.
|
|
||||||
elif volume_encrypted "$use_special"; then
|
|
||||||
setup_volume_daemon "encrypted" "$use_uuid"
|
|
||||||
else
|
else
|
||||||
setup_volume_daemon "unencrypted" "$use_uuid"
|
echo "Using existing '$volume' volume" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
await_volume
|
if ! test_fstab; then
|
||||||
|
echo "Configuring /etc/fstab..." >&2
|
||||||
if [ "$(/usr/sbin/diskutil info -plist "$NIX_ROOT" | xmllint --xpath "(/plist/dict/key[text()='GlobalPermissionsEnabled'])/following-sibling::*[1]" -)" = "<false/>" ]; then
|
label=$(echo "$volume" | sed 's/ /\\040/g')
|
||||||
_sudo "to set enableOwnership (enabling users to own files)" \
|
# shellcheck disable=SC2209
|
||||||
/usr/sbin/diskutil enableOwnership "$NIX_ROOT"
|
printf "\$a\nLABEL=%s /nix apfs rw,nobrowse\n.\nwq\n" "$label" | EDITOR=ed sudo vifs
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: below is a vague kludge for now; I just don't know
|
|
||||||
# what if any safe action there is to take here. Also, the
|
|
||||||
# reminder isn't very helpful.
|
|
||||||
# I'm less sure where this belongs, but it also wants mounted, pre-install
|
|
||||||
if type -p nix-env; then
|
|
||||||
profile_packages="$(nix-env --query --installed)"
|
|
||||||
# TODO: can probably do below faster w/ read
|
|
||||||
# intentionally unquoted string to eat whitespace in wc output
|
|
||||||
# shellcheck disable=SC2046,SC2059
|
|
||||||
if ! [ $(printf "$profile_packages" | /usr/bin/wc -l) = "0" ]; then
|
|
||||||
reminder <<EOF
|
|
||||||
Nix now supports only multi-user installs on Darwin/macOS, and your user's
|
|
||||||
Nix profile has some packages in it. These packages may obscure those in the
|
|
||||||
default profile, including the Nix this installer will add. You should
|
|
||||||
review these packages:
|
|
||||||
$profile_packages
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_volume_daemon() {
|
|
||||||
local cmd_type="$1" # encrypted|unencrypted
|
|
||||||
local volume_uuid="$2"
|
|
||||||
if ! test_voldaemon; then
|
|
||||||
task "Configuring LaunchDaemon to mount '$NIX_VOLUME_LABEL'" >&2
|
|
||||||
_sudo "to install the Nix volume mounter" /usr/bin/ex "$NIX_VOLUME_MOUNTD_DEST" <<EOF
|
|
||||||
:a
|
|
||||||
$(generate_mount_daemon "$cmd_type" "$volume_uuid")
|
|
||||||
.
|
|
||||||
:x
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# TODO: should probably alert the user if this is disabled?
|
|
||||||
_sudo "to launch the Nix volume mounter" \
|
|
||||||
launchctl bootstrap system "$NIX_VOLUME_MOUNTD_DEST" || true
|
|
||||||
# TODO: confirm whether kickstart is necessesary?
|
|
||||||
# I feel a little superstitous, but it can guard
|
|
||||||
# against multiple problems (doesn't start, old
|
|
||||||
# version still running for some reason...)
|
|
||||||
_sudo "to launch the Nix volume mounter" \
|
|
||||||
launchctl kickstart -k system/org.nixos.darwin-store
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_darwin_volume() {
|
main "$@"
|
||||||
setup_synthetic_conf
|
|
||||||
setup_volume
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$_CREATE_VOLUME_NO_MAIN" = 1 ]; then
|
|
||||||
if [ -n "$*" ]; then
|
|
||||||
"$@" # expose functions in case we want multiple routines?
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# no reason to pay for bash to process this
|
|
||||||
main() {
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo " ------------------------------------------------------------------ "
|
|
||||||
echo " | This installer will create a volume for the nix store and |"
|
|
||||||
echo " | configure it to mount at $NIX_ROOT. Follow these steps to uninstall. |"
|
|
||||||
echo " ------------------------------------------------------------------ "
|
|
||||||
echo ""
|
|
||||||
echo " 1. Remove the entry from fstab using 'sudo /usr/sbin/vifs'"
|
|
||||||
echo " 2. Run 'sudo launchctl bootout system/org.nixos.darwin-store'"
|
|
||||||
echo " 3. Remove $NIX_VOLUME_MOUNTD_DEST"
|
|
||||||
echo " 4. Destroy the data volume using '/usr/sbin/diskutil apfs deleteVolume'"
|
|
||||||
echo " 5. Remove the 'nix' line from /etc/synthetic.conf (or the file)"
|
|
||||||
echo ""
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
setup_darwin_volume
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
fi
|
|
||||||
@@ -3,110 +3,57 @@
|
|||||||
set -eu
|
set -eu
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
readonly NIX_DAEMON_DEST=/Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
readonly PLIST_DEST=/Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
||||||
# create by default; set 0 to DIY, use a symlink, etc.
|
|
||||||
readonly NIX_VOLUME_CREATE=${NIX_VOLUME_CREATE:-1} # now default
|
|
||||||
NIX_FIRST_BUILD_UID="301"
|
|
||||||
NIX_BUILD_USER_NAME_TEMPLATE="_nixbld%d"
|
|
||||||
|
|
||||||
# caution: may update times on / if not run as normal non-root user
|
|
||||||
read_only_root() {
|
|
||||||
# this touch command ~should~ always produce an error
|
|
||||||
# as of this change I confirmed /usr/bin/touch emits:
|
|
||||||
# "touch: /: Operation not permitted" Monterey
|
|
||||||
# "touch: /: Read-only file system" Catalina+ and Big Sur
|
|
||||||
# "touch: /: Permission denied" Mojave
|
|
||||||
# (not matching prefix for compat w/ coreutils touch in case using
|
|
||||||
# an explicit path causes problems; its prefix differs)
|
|
||||||
case "$(/usr/bin/touch / 2>&1)" in
|
|
||||||
*"Read-only file system") # Catalina, Big Sur
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*"Operation not permitted") # Monterey
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Avoiding the slow semantic way to get this information (~330ms vs ~8ms)
|
|
||||||
# unless using touch causes problems. Just in case, that approach is:
|
|
||||||
# diskutil info -plist / | <find the Writable or WritableVolume keys>, i.e.
|
|
||||||
# diskutil info -plist / | xmllint --xpath "name(/plist/dict/key[text()='Writable']/following-sibling::*[1])" -
|
|
||||||
}
|
|
||||||
|
|
||||||
if read_only_root && [ "$NIX_VOLUME_CREATE" = 1 ]; then
|
|
||||||
should_create_volume() { return 0; }
|
|
||||||
else
|
|
||||||
should_create_volume() { return 1; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
# shellcheck source=./create-darwin-volume.sh
|
|
||||||
. "$EXTRACTED_NIX_PATH/create-darwin-volume.sh" "no-main"
|
|
||||||
|
|
||||||
dsclattr() {
|
dsclattr() {
|
||||||
/usr/bin/dscl . -read "$1" \
|
/usr/bin/dscl . -read "$1" \
|
||||||
| /usr/bin/awk "/$2/ { print \$2 }"
|
| awk "/$2/ { print \$2 }"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_nix_daemon_installed() {
|
poly_validate_assumptions() {
|
||||||
test -e "$NIX_DAEMON_DEST"
|
if [ "$(uname -s)" != "Darwin" ]; then
|
||||||
}
|
failure "This script is for use with macOS!"
|
||||||
|
|
||||||
poly_cure_artifacts() {
|
|
||||||
if should_create_volume; then
|
|
||||||
task "Fixing any leftover Nix volume state"
|
|
||||||
cat <<EOF
|
|
||||||
Before I try to install, I'll check for any existing Nix volume config
|
|
||||||
and ask for your permission to remove it (so that the installer can
|
|
||||||
start fresh). I'll also ask for permission to fix any issues I spot.
|
|
||||||
EOF
|
|
||||||
cure_volumes
|
|
||||||
remove_volume_artifacts
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_service_installed_check() {
|
poly_service_installed_check() {
|
||||||
if should_create_volume; then
|
[ -e "$PLIST_DEST" ]
|
||||||
test_nix_daemon_installed || test_nix_volume_mountd_installed
|
|
||||||
else
|
|
||||||
test_nix_daemon_installed
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_service_uninstall_directions() {
|
poly_service_uninstall_directions() {
|
||||||
echo "$1. Remove macOS-specific components:"
|
cat <<EOF
|
||||||
if should_create_volume && test_nix_volume_mountd_installed; then
|
$1. Delete $PLIST_DEST
|
||||||
nix_volume_mountd_uninstall_directions
|
|
||||||
fi
|
sudo launchctl unload $PLIST_DEST
|
||||||
if test_nix_daemon_installed; then
|
sudo rm $PLIST_DEST
|
||||||
nix_daemon_uninstall_directions
|
|
||||||
fi
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_service_setup_note() {
|
poly_service_setup_note() {
|
||||||
if should_create_volume; then
|
cat <<EOF
|
||||||
echo " - create a Nix volume and a LaunchDaemon to mount it"
|
- load and start a LaunchDaemon (at $PLIST_DEST) for nix-daemon
|
||||||
fi
|
|
||||||
echo " - create a LaunchDaemon (at $NIX_DAEMON_DEST) for nix-daemon"
|
EOF
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_extra_try_me_commands() {
|
poly_extra_try_me_commands(){
|
||||||
:
|
:
|
||||||
|
}
|
||||||
|
poly_extra_setup_instructions(){
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_configure_nix_daemon_service() {
|
poly_configure_nix_daemon_service() {
|
||||||
task "Setting up the nix-daemon LaunchDaemon"
|
|
||||||
_sudo "to set up the nix-daemon as a LaunchDaemon" \
|
_sudo "to set up the nix-daemon as a LaunchDaemon" \
|
||||||
/bin/cp -f "/nix/var/nix/profiles/default$NIX_DAEMON_DEST" "$NIX_DAEMON_DEST"
|
cp -f "/nix/var/nix/profiles/default$PLIST_DEST" "$PLIST_DEST"
|
||||||
|
|
||||||
_sudo "to load the LaunchDaemon plist for nix-daemon" \
|
_sudo "to load the LaunchDaemon plist for nix-daemon" \
|
||||||
launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
|
||||||
|
|
||||||
_sudo "to start the nix-daemon" \
|
_sudo "to start the nix-daemon" \
|
||||||
launchctl kickstart -k system/org.nixos.nix-daemon
|
launchctl start org.nixos.nix-daemon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_group_exists() {
|
poly_group_exists() {
|
||||||
@@ -147,8 +94,6 @@ poly_user_home_get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
poly_user_home_set() {
|
poly_user_home_set() {
|
||||||
# This can trigger a permission prompt now:
|
|
||||||
# "Terminal" would like to administer your computer. Administration can include modifying passwords, networking, and system settings.
|
|
||||||
_sudo "in order to give $1 a safe home directory" \
|
_sudo "in order to give $1 a safe home directory" \
|
||||||
/usr/bin/dscl . -create "/Users/$1" "NFSHomeDirectory" "$2"
|
/usr/bin/dscl . -create "/Users/$1" "NFSHomeDirectory" "$2"
|
||||||
}
|
}
|
||||||
@@ -174,7 +119,7 @@ poly_user_shell_set() {
|
|||||||
poly_user_in_group_check() {
|
poly_user_in_group_check() {
|
||||||
username=$1
|
username=$1
|
||||||
group=$2
|
group=$2
|
||||||
/usr/sbin/dseditgroup -o checkmember -m "$username" "$group" > /dev/null 2>&1
|
dseditgroup -o checkmember -m "$username" "$group" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_user_in_group_set() {
|
poly_user_in_group_set() {
|
||||||
@@ -204,21 +149,3 @@ poly_create_build_user() {
|
|||||||
/usr/bin/dscl . create "/Users/$username" \
|
/usr/bin/dscl . create "/Users/$username" \
|
||||||
UniqueID "${uid}"
|
UniqueID "${uid}"
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_prepare_to_install() {
|
|
||||||
if should_create_volume; then
|
|
||||||
header "Preparing a Nix volume"
|
|
||||||
# intentional indent below to match task indent
|
|
||||||
cat <<EOF
|
|
||||||
Nix traditionally stores its data in the root directory $NIX_ROOT, but
|
|
||||||
macOS now (starting in 10.15 Catalina) has a read-only root directory.
|
|
||||||
To support Nix, I will create a volume and configure macOS to mount it
|
|
||||||
at $NIX_ROOT.
|
|
||||||
EOF
|
|
||||||
setup_darwin_volume
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$(diskutil info -plist /nix | xmllint --xpath "(/plist/dict/key[text()='GlobalPermissionsEnabled'])/following-sibling::*[1]" -)" = "<false/>" ]; then
|
|
||||||
failure "This script needs a /nix volume with global permissions! This may require running sudo diskutil enableOwnership /nix."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
+71
-250
@@ -25,15 +25,13 @@ readonly RED='\033[31m'
|
|||||||
readonly NIX_USER_COUNT=${NIX_USER_COUNT:-32}
|
readonly NIX_USER_COUNT=${NIX_USER_COUNT:-32}
|
||||||
readonly NIX_BUILD_GROUP_ID="30000"
|
readonly NIX_BUILD_GROUP_ID="30000"
|
||||||
readonly NIX_BUILD_GROUP_NAME="nixbld"
|
readonly NIX_BUILD_GROUP_NAME="nixbld"
|
||||||
# darwin installer needs to override these
|
readonly NIX_FIRST_BUILD_UID="30001"
|
||||||
NIX_FIRST_BUILD_UID="30001"
|
|
||||||
NIX_BUILD_USER_NAME_TEMPLATE="nixbld%d"
|
|
||||||
# Please don't change this. We don't support it, because the
|
# Please don't change this. We don't support it, because the
|
||||||
# default shell profile that comes with Nix doesn't support it.
|
# default shell profile that comes with Nix doesn't support it.
|
||||||
readonly NIX_ROOT="/nix"
|
readonly NIX_ROOT="/nix"
|
||||||
readonly NIX_EXTRA_CONF=${NIX_EXTRA_CONF:-}
|
readonly NIX_EXTRA_CONF=${NIX_EXTRA_CONF:-}
|
||||||
|
|
||||||
readonly PROFILE_TARGETS=("/etc/bashrc" "/etc/profile.d/nix.sh" "/etc/zshrc" "/etc/bash.bashrc" "/etc/zsh/zshrc")
|
readonly PROFILE_TARGETS=("/etc/bashrc" "/etc/profile.d/nix.sh" "/etc/zshenv")
|
||||||
readonly PROFILE_BACKUP_SUFFIX=".backup-before-nix"
|
readonly PROFILE_BACKUP_SUFFIX=".backup-before-nix"
|
||||||
readonly PROFILE_NIX_FILE="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
|
readonly PROFILE_NIX_FILE="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
|
||||||
|
|
||||||
@@ -43,7 +41,7 @@ readonly NIX_INSTALLED_CACERT="@cacert@"
|
|||||||
#readonly NIX_INSTALLED_CACERT="/nix/store/7dxhzymvy330i28ii676fl1pqwcahv2f-nss-cacert-3.49.2"
|
#readonly NIX_INSTALLED_CACERT="/nix/store/7dxhzymvy330i28ii676fl1pqwcahv2f-nss-cacert-3.49.2"
|
||||||
readonly EXTRACTED_NIX_PATH="$(dirname "$0")"
|
readonly EXTRACTED_NIX_PATH="$(dirname "$0")"
|
||||||
|
|
||||||
readonly ROOT_HOME=~root
|
readonly ROOT_HOME=$(echo ~root)
|
||||||
|
|
||||||
if [ -t 0 ]; then
|
if [ -t 0 ]; then
|
||||||
readonly IS_HEADLESS='no'
|
readonly IS_HEADLESS='no'
|
||||||
@@ -59,19 +57,14 @@ headless() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_us() {
|
contactme() {
|
||||||
echo "You can open an issue at https://github.com/nixos/nix/issues"
|
|
||||||
echo ""
|
|
||||||
echo "Or feel free to contact the team:"
|
|
||||||
echo " - Matrix: #nix:nixos.org"
|
|
||||||
echo " - IRC: in #nixos on irc.libera.chat"
|
|
||||||
echo " - twitter: @nixos_org"
|
|
||||||
echo " - forum: https://discourse.nixos.org"
|
|
||||||
}
|
|
||||||
get_help() {
|
|
||||||
echo "We'd love to help if you need it."
|
echo "We'd love to help if you need it."
|
||||||
echo ""
|
echo ""
|
||||||
contact_us
|
echo "If you can, open an issue at https://github.com/nixos/nix/issues"
|
||||||
|
echo ""
|
||||||
|
echo "Or feel free to contact the team,"
|
||||||
|
echo " - on IRC #nixos on irc.freenode.net"
|
||||||
|
echo " - on twitter @nixos_org"
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall_directions() {
|
uninstall_directions() {
|
||||||
@@ -107,10 +100,11 @@ $step. Delete the files Nix added to your system:
|
|||||||
and that is it.
|
and that is it.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_user_for_core() {
|
nix_user_for_core() {
|
||||||
printf "$NIX_BUILD_USER_NAME_TEMPLATE" "$1"
|
printf "nixbld%d" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_uid_for_core() {
|
nix_uid_for_core() {
|
||||||
@@ -174,7 +168,7 @@ failure() {
|
|||||||
header "oh no!"
|
header "oh no!"
|
||||||
_textout "$RED" "$@"
|
_textout "$RED" "$@"
|
||||||
echo ""
|
echo ""
|
||||||
_textout "$RED" "$(get_help)"
|
_textout "$RED" "$(contactme)"
|
||||||
trap finish_cleanup EXIT
|
trap finish_cleanup EXIT
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -205,95 +199,6 @@ ui_confirm() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
printf -v _UNCHANGED_GRP_FMT "%b" $'\033[2m%='"$ESC" # "dim"
|
|
||||||
# bold+invert+red and bold+invert+green just for the +/- below
|
|
||||||
# red/green foreground for rest of the line
|
|
||||||
printf -v _OLD_LINE_FMT "%b" $'\033[1;7;31m-'"$ESC ${RED}%L${ESC}"
|
|
||||||
printf -v _NEW_LINE_FMT "%b" $'\033[1;7;32m+'"$ESC ${GREEN}%L${ESC}"
|
|
||||||
|
|
||||||
_diff() {
|
|
||||||
# simple colorized diff comatible w/ pre `--color` versions
|
|
||||||
diff --unchanged-group-format="$_UNCHANGED_GRP_FMT" --old-line-format="$_OLD_LINE_FMT" --new-line-format="$_NEW_LINE_FMT" --unchanged-line-format=" %L" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
confirm_rm() {
|
|
||||||
local path="$1"
|
|
||||||
if ui_confirm "Can I remove $path?"; then
|
|
||||||
_sudo "to remove $path" rm "$path"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
confirm_edit() {
|
|
||||||
local path="$1"
|
|
||||||
local edit_path="$2"
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
Nix isn't the only thing in $path,
|
|
||||||
but I think I know how to edit it out.
|
|
||||||
Here's the diff:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# could technically test the diff, but caller should do it
|
|
||||||
_diff "$path" "$edit_path"
|
|
||||||
if ui_confirm "Does the change above look right?"; then
|
|
||||||
_sudo "remove nix from $path" cp "$edit_path" "$path"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_SERIOUS_BUSINESS="${RED}%s:${ESC} "
|
|
||||||
password_confirm() {
|
|
||||||
local do_something_consequential="$1"
|
|
||||||
if ui_confirm "Can I $do_something_consequential?"; then
|
|
||||||
# shellcheck disable=SC2059
|
|
||||||
sudo -kv --prompt="$(printf "${_SERIOUS_BUSINESS}" "Enter your password to $do_something_consequential")"
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Support accumulating reminders over the course of a run and showing
|
|
||||||
# them at the end. An example where this helps: the installer changes
|
|
||||||
# something, but it won't work without a reboot. If you tell the user
|
|
||||||
# when you do it, they may miss it in the stream. The value of the
|
|
||||||
# setting isn't enough to decide whether to message because you only
|
|
||||||
# need to message if you *changed* it.
|
|
||||||
|
|
||||||
# reminders stored in array delimited by empty entry; if ! headless,
|
|
||||||
# user is asked to confirm after each delimiter.
|
|
||||||
_reminders=()
|
|
||||||
((_remind_num=1))
|
|
||||||
|
|
||||||
remind() {
|
|
||||||
# (( arithmetic expression ))
|
|
||||||
if (( _remind_num > 1 )); then
|
|
||||||
header "Reminders"
|
|
||||||
for line in "${_reminders[@]}"; do
|
|
||||||
echo "$line"
|
|
||||||
if ! headless && [ "${#line}" = 0 ]; then
|
|
||||||
if read -r -p "Press enter/return to acknowledge."; then
|
|
||||||
printf $'\033[A\33[2K\r'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
reminder() {
|
|
||||||
printf -v label "${BLUE}[ %d ]${ESC}" "$_remind_num"
|
|
||||||
_reminders+=("$label")
|
|
||||||
if [[ "$*" = "" ]]; then
|
|
||||||
while read -r line; do
|
|
||||||
_reminders+=("$line")
|
|
||||||
done
|
|
||||||
else
|
|
||||||
# this expands each arg to an array entry (and each entry will
|
|
||||||
# ultimately be a separate line in the output)
|
|
||||||
_reminders+=("$@")
|
|
||||||
fi
|
|
||||||
_reminders+=("")
|
|
||||||
((_remind_num++))
|
|
||||||
}
|
|
||||||
|
|
||||||
__sudo() {
|
__sudo() {
|
||||||
local expl="$1"
|
local expl="$1"
|
||||||
local cmd="$2"
|
local cmd="$2"
|
||||||
@@ -314,18 +219,18 @@ _sudo() {
|
|||||||
local expl="$1"
|
local expl="$1"
|
||||||
shift
|
shift
|
||||||
if ! headless; then
|
if ! headless; then
|
||||||
__sudo "$expl" "$*" >&2
|
__sudo "$expl" "$*"
|
||||||
fi
|
fi
|
||||||
sudo "$@"
|
sudo "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
readonly SCRATCH=$(mktemp -d "${TMPDIR:-/tmp/}tmp.XXXXXXXXXX")
|
readonly SCRATCH=$(mktemp -d -t tmp.XXXXXXXXXX)
|
||||||
finish_cleanup() {
|
function finish_cleanup {
|
||||||
rm -rf "$SCRATCH"
|
rm -rf "$SCRATCH"
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_fail() {
|
function finish_fail {
|
||||||
finish_cleanup
|
finish_cleanup
|
||||||
|
|
||||||
failure <<EOF
|
failure <<EOF
|
||||||
@@ -337,46 +242,45 @@ EOF
|
|||||||
}
|
}
|
||||||
trap finish_fail EXIT
|
trap finish_fail EXIT
|
||||||
|
|
||||||
finish_success() {
|
channel_update_failed=0
|
||||||
|
function finish_success {
|
||||||
|
finish_cleanup
|
||||||
|
|
||||||
ok "Alright! We're done!"
|
ok "Alright! We're done!"
|
||||||
|
if [ "x$channel_update_failed" = x1 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "But fetching the nixpkgs channel failed. (Are you offline?)"
|
||||||
|
echo "To try again later, run \"sudo -i nix-channel --update nixpkgs\"."
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
|
Before Nix will work in your existing shells, you'll need to close
|
||||||
|
them and open them again. Other than that, you should be ready to go.
|
||||||
|
|
||||||
Try it! Open a new terminal, and type:
|
Try it! Open a new terminal, and type:
|
||||||
$(poly_extra_try_me_commands)
|
$(poly_extra_try_me_commands)
|
||||||
$ nix-shell -p nix-info --run "nix-info -m"
|
$ nix-shell -p nix-info --run "nix-info -m"
|
||||||
|
$(poly_extra_setup_instructions)
|
||||||
|
Thank you for using this installer. If you have any feedback, don't
|
||||||
|
hesitate:
|
||||||
|
|
||||||
Thank you for using this installer. If you have any feedback or need
|
$(contactme)
|
||||||
help, don't hesitate:
|
|
||||||
|
|
||||||
$(contact_us)
|
|
||||||
EOF
|
EOF
|
||||||
remind
|
|
||||||
finish_cleanup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_uninstall_success() {
|
|
||||||
ok "Alright! Nix should be removed!"
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
If you spot anything this uninstaller missed or have feedback,
|
|
||||||
don't hesitate:
|
|
||||||
|
|
||||||
$(contact_us)
|
|
||||||
EOF
|
|
||||||
remind
|
|
||||||
finish_cleanup
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_nix_artifacts() {
|
|
||||||
failure "Not implemented yet"
|
|
||||||
}
|
|
||||||
|
|
||||||
cure_artifacts() {
|
|
||||||
poly_cure_artifacts
|
|
||||||
# remove_nix_artifacts (LATER)
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_starting_assumptions() {
|
validate_starting_assumptions() {
|
||||||
|
poly_validate_assumptions
|
||||||
|
|
||||||
|
if [ $EUID -eq 0 ]; then
|
||||||
|
failure <<EOF
|
||||||
|
Please do not run this script with root privileges. We will call sudo
|
||||||
|
when we need to.
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
if type nix-env 2> /dev/null >&2; then
|
if type nix-env 2> /dev/null >&2; then
|
||||||
warning <<EOF
|
warning <<EOF
|
||||||
Nix already appears to be installed. This installer may run into issues.
|
Nix already appears to be installed. This installer may run into issues.
|
||||||
@@ -538,46 +442,18 @@ create_build_users() {
|
|||||||
|
|
||||||
create_directories() {
|
create_directories() {
|
||||||
# FIXME: remove all of this because it duplicates LocalStore::LocalStore().
|
# FIXME: remove all of this because it duplicates LocalStore::LocalStore().
|
||||||
task "Setting up the basic directory structure"
|
|
||||||
if [ -d "$NIX_ROOT" ]; then
|
|
||||||
# if /nix already exists, take ownership
|
|
||||||
#
|
|
||||||
# Caution: notes below are macOS-y
|
|
||||||
# This is a bit of a goldilocks zone for taking ownership
|
|
||||||
# if there are already files on the volume; the volume is
|
|
||||||
# now mounted, but we haven't added a bunch of new files
|
|
||||||
|
|
||||||
# this is probably a bit slow; I've been seeing 3.3-4s even
|
|
||||||
# when promptly installed over a fresh single-user install.
|
|
||||||
# In case anyone's aware of a shortcut.
|
|
||||||
# `|| true`: .Trashes errors w/o full disk perm
|
|
||||||
|
|
||||||
# rumor per #4488 that macOS 11.2 may not have
|
|
||||||
# sbin on path, and that's where chown is, but
|
|
||||||
# since this bit is cross-platform:
|
|
||||||
# - first try with `command -vp` to try and find
|
|
||||||
# chown in the usual places
|
|
||||||
# - fall back on `command -v` which would find
|
|
||||||
# any chown on path
|
|
||||||
# if we don't find one, the command is already
|
|
||||||
# hiding behind || true, and the general state
|
|
||||||
# should be one the user can repair once they
|
|
||||||
# figure out where chown is...
|
|
||||||
local get_chr_own="$(command -vp chown)"
|
|
||||||
if [[ -z "$get_chr_own" ]]; then
|
|
||||||
get_chr_own="$(command -v chown)"
|
|
||||||
fi
|
|
||||||
_sudo "to take root ownership of existing Nix store files" \
|
|
||||||
"$get_chr_own" -R "root:$NIX_BUILD_GROUP_NAME" "$NIX_ROOT" || true
|
|
||||||
fi
|
|
||||||
_sudo "to make the basic directory structure of Nix (part 1)" \
|
_sudo "to make the basic directory structure of Nix (part 1)" \
|
||||||
install -dv -m 0755 /nix /nix/var /nix/var/log /nix/var/log/nix /nix/var/log/nix/drvs /nix/var/nix{,/db,/gcroots,/profiles,/temproots,/userpool} /nix/var/nix/{gcroots,profiles}/per-user
|
mkdir -pv -m 0755 /nix /nix/var /nix/var/log /nix/var/log/nix /nix/var/log/nix/drvs /nix/var/nix{,/db,/gcroots,/profiles,/temproots,/userpool} /nix/var/nix/{gcroots,profiles}/per-user
|
||||||
|
|
||||||
_sudo "to make the basic directory structure of Nix (part 2)" \
|
_sudo "to make the basic directory structure of Nix (part 2)" \
|
||||||
install -dv -g "$NIX_BUILD_GROUP_NAME" -m 1775 /nix/store
|
mkdir -pv -m 1775 /nix/store
|
||||||
|
|
||||||
|
_sudo "to make the basic directory structure of Nix (part 3)" \
|
||||||
|
chgrp "$NIX_BUILD_GROUP_NAME" /nix/store
|
||||||
|
|
||||||
_sudo "to place the default nix daemon configuration (part 1)" \
|
_sudo "to place the default nix daemon configuration (part 1)" \
|
||||||
install -dv -m 0555 /etc/nix
|
mkdir -pv -m 0555 /etc/nix
|
||||||
}
|
}
|
||||||
|
|
||||||
place_channel_configuration() {
|
place_channel_configuration() {
|
||||||
@@ -597,9 +473,9 @@ This installation tool will set up your computer with the Nix package
|
|||||||
manager. This will happen in a few stages:
|
manager. This will happen in a few stages:
|
||||||
|
|
||||||
1. Make sure your computer doesn't already have Nix. If it does, I
|
1. Make sure your computer doesn't already have Nix. If it does, I
|
||||||
will show you instructions on how to clean up your old install.
|
will show you instructions on how to clean up your old one.
|
||||||
|
|
||||||
2. Show you what I am going to install and where. Then I will ask
|
2. Show you what we are going to install and where. Then we will ask
|
||||||
if you are ready to continue.
|
if you are ready to continue.
|
||||||
|
|
||||||
3. Create the system users and groups that the Nix daemon uses to run
|
3. Create the system users and groups that the Nix daemon uses to run
|
||||||
@@ -614,14 +490,14 @@ manager. This will happen in a few stages:
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if ui_confirm "Would you like to see a more detailed list of what I will do?"; then
|
if ui_confirm "Would you like to see a more detailed list of what we will do?"; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
I will:
|
We will:
|
||||||
|
|
||||||
- make sure your computer doesn't already have Nix files
|
- make sure your computer doesn't already have Nix files
|
||||||
(if it does, I will tell you how to clean them up.)
|
(if it does, I will tell you how to clean them up.)
|
||||||
- create local users (see the list above for the users I'll make)
|
- create local users (see the list above for the users we'll make)
|
||||||
- create a local group ($NIX_BUILD_GROUP_NAME)
|
- create a local group ($NIX_BUILD_GROUP_NAME)
|
||||||
- install Nix in to $NIX_ROOT
|
- install Nix in to $NIX_ROOT
|
||||||
- create a configuration file in /etc/nix
|
- create a configuration file in /etc/nix
|
||||||
@@ -656,7 +532,7 @@ run in a headless fashion, like this:
|
|||||||
|
|
||||||
$ curl -L https://nixos.org/nix/install | sh
|
$ curl -L https://nixos.org/nix/install | sh
|
||||||
|
|
||||||
or maybe in a CI pipeline. Because of that, I'm going to skip the
|
or maybe in a CI pipeline. Because of that, we're going to skip the
|
||||||
verbose output in the interest of brevity.
|
verbose output in the interest of brevity.
|
||||||
|
|
||||||
If you would like to
|
If you would like to
|
||||||
@@ -670,7 +546,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
This script is going to call sudo a lot. Every time I do, it'll
|
This script is going to call sudo a lot. Every time we do, it'll
|
||||||
output exactly what it'll do, and why.
|
output exactly what it'll do, and why.
|
||||||
|
|
||||||
Just like this:
|
Just like this:
|
||||||
@@ -682,29 +558,25 @@ EOF
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
This might look scary, but everything can be undone by running just a
|
This might look scary, but everything can be undone by running just a
|
||||||
few commands. I used to ask you to confirm each time sudo ran, but it
|
few commands. We used to ask you to confirm each time sudo ran, but it
|
||||||
was too many times. Instead, I'll just ask you this one time:
|
was too many times. Instead, I'll just ask you this one time:
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
if ui_confirm "Can I use sudo?"; then
|
if ui_confirm "Can we use sudo?"; then
|
||||||
ok "Yay! Thanks! Let's get going!"
|
ok "Yay! Thanks! Let's get going!"
|
||||||
else
|
else
|
||||||
failure <<EOF
|
failure <<EOF
|
||||||
That is okay, but I can't install.
|
That is okay, but we can't install.
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_from_extracted_nix() {
|
install_from_extracted_nix() {
|
||||||
task "Installing Nix"
|
|
||||||
(
|
(
|
||||||
cd "$EXTRACTED_NIX_PATH"
|
cd "$EXTRACTED_NIX_PATH"
|
||||||
|
|
||||||
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
|
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
|
||||||
cp -RLp ./store/* "$NIX_ROOT/store/"
|
rsync -rlpt --chmod=-w ./store/* "$NIX_ROOT/store/"
|
||||||
|
|
||||||
_sudo "to make the new store non-writable at $NIX_ROOT/store" \
|
|
||||||
chmod -R ugo-w "$NIX_ROOT/store/"
|
|
||||||
|
|
||||||
if [ -d "$NIX_INSTALLED_NIX" ]; then
|
if [ -d "$NIX_INSTALLED_NIX" ]; then
|
||||||
echo " Alright! We have our first nix at $NIX_INSTALLED_NIX"
|
echo " Alright! We have our first nix at $NIX_INSTALLED_NIX"
|
||||||
@@ -715,8 +587,9 @@ $NIX_INSTALLED_NIX.
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_sudo "to load data for the first time in to the Nix Database" \
|
cat ./.reginfo \
|
||||||
"$NIX_INSTALLED_NIX/bin/nix-store" --load-db < ./.reginfo
|
| _sudo "to load data for the first time in to the Nix Database" \
|
||||||
|
"$NIX_INSTALLED_NIX/bin/nix-store" --load-db
|
||||||
|
|
||||||
echo " Just finished getting the nix database ready."
|
echo " Just finished getting the nix database ready."
|
||||||
)
|
)
|
||||||
@@ -735,7 +608,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure_shell_profile() {
|
configure_shell_profile() {
|
||||||
task "Setting up shell profiles: ${PROFILE_TARGETS[*]}"
|
|
||||||
for profile_target in "${PROFILE_TARGETS[@]}"; do
|
for profile_target in "${PROFILE_TARGETS[@]}"; do
|
||||||
if [ -e "$profile_target" ]; then
|
if [ -e "$profile_target" ]; then
|
||||||
_sudo "to back up your current $profile_target to $profile_target$PROFILE_BACKUP_SUFFIX" \
|
_sudo "to back up your current $profile_target to $profile_target$PROFILE_BACKUP_SUFFIX" \
|
||||||
@@ -755,27 +627,14 @@ configure_shell_profile() {
|
|||||||
tee -a "$profile_target"
|
tee -a "$profile_target"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# TODO: should we suggest '. $PROFILE_NIX_FILE'? It would get them on
|
|
||||||
# their way less disruptively, but a counter-argument is that they won't
|
|
||||||
# immediately notice if something didn't get set up right?
|
|
||||||
reminder "Nix won't work in active shell sessions until you restart them."
|
|
||||||
}
|
|
||||||
|
|
||||||
cert_in_store() {
|
|
||||||
# in a subshell
|
|
||||||
# - change into the cert-file dir
|
|
||||||
# - get the phyiscal pwd
|
|
||||||
# and test if this path is in the Nix store
|
|
||||||
[[ "$(cd -- "$(dirname "$NIX_SSL_CERT_FILE")" && exec pwd -P)" == "$NIX_ROOT/store/"* ]]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_default_profile() {
|
setup_default_profile() {
|
||||||
task "Setting up the default profile"
|
_sudo "to installing a bootstrapping Nix in to the default Profile" \
|
||||||
_sudo "to install a bootstrapping Nix in to the default profile" \
|
|
||||||
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_NIX"
|
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_NIX"
|
||||||
|
|
||||||
if [ -z "${NIX_SSL_CERT_FILE:-}" ] || ! [ -f "${NIX_SSL_CERT_FILE:-}" ] || cert_in_store; then
|
if [ -z "${NIX_SSL_CERT_FILE:-}" ] || ! [ -f "${NIX_SSL_CERT_FILE:-}" ]; then
|
||||||
_sudo "to install a bootstrapping SSL certificate just for Nix in to the default profile" \
|
_sudo "to installing a bootstrapping SSL certificate just for Nix in to the default Profile" \
|
||||||
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_CACERT"
|
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_CACERT"
|
||||||
export NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
|
export NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
|
||||||
fi
|
fi
|
||||||
@@ -784,13 +643,9 @@ setup_default_profile() {
|
|||||||
# Have to explicitly pass NIX_SSL_CERT_FILE as part of the sudo call,
|
# Have to explicitly pass NIX_SSL_CERT_FILE as part of the sudo call,
|
||||||
# otherwise it will be lost in environments where sudo doesn't pass
|
# otherwise it will be lost in environments where sudo doesn't pass
|
||||||
# all the environment variables by default.
|
# all the environment variables by default.
|
||||||
if ! _sudo "to update the default channel in the default profile" \
|
_sudo "to update the default channel in the default profile" \
|
||||||
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs; then
|
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs \
|
||||||
reminder <<EOF
|
|| channel_update_failed=1
|
||||||
I had trouble fetching the nixpkgs channel (are you offline?)
|
|
||||||
To try again later, run: sudo -i nix-channel --update nixpkgs
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,17 +660,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# TODO: I've moved this out of validate_starting_assumptions so we
|
|
||||||
# can fail faster in this case. Sourcing install-darwin... now runs
|
|
||||||
# `touch /` to detect Read-only root, but it could update times on
|
|
||||||
# pre-Catalina macOS if run as root user.
|
|
||||||
if [ $EUID -eq 0 ]; then
|
|
||||||
failure <<EOF
|
|
||||||
Please do not run this script with root privileges. I will call sudo
|
|
||||||
when I need to.
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
# shellcheck source=./install-darwin-multi-user.sh
|
# shellcheck source=./install-darwin-multi-user.sh
|
||||||
. "$EXTRACTED_NIX_PATH/install-darwin-multi-user.sh"
|
. "$EXTRACTED_NIX_PATH/install-darwin-multi-user.sh"
|
||||||
@@ -829,24 +673,17 @@ EOF
|
|||||||
welcome_to_nix
|
welcome_to_nix
|
||||||
chat_about_sudo
|
chat_about_sudo
|
||||||
|
|
||||||
cure_artifacts
|
|
||||||
# TODO: there's a tension between cure and validate. I moved the
|
|
||||||
# the sudo/root check out of validate to the head of this func.
|
|
||||||
# Cure is *intended* to subsume the validate-and-abort approach,
|
|
||||||
# so it may eventually obsolete it.
|
|
||||||
validate_starting_assumptions
|
validate_starting_assumptions
|
||||||
|
|
||||||
setup_report
|
setup_report
|
||||||
|
|
||||||
if ! ui_confirm "Ready to continue?"; then
|
if ! ui_confirm "Ready to continue?"; then
|
||||||
ok "Alright, no changes have been made :)"
|
ok "Alright, no changes have been made :)"
|
||||||
get_help
|
contactme
|
||||||
trap finish_cleanup EXIT
|
trap finish_cleanup EXIT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
poly_prepare_to_install
|
|
||||||
|
|
||||||
create_build_group
|
create_build_group
|
||||||
create_build_users
|
create_build_users
|
||||||
create_directories
|
create_directories
|
||||||
@@ -856,7 +693,6 @@ EOF
|
|||||||
configure_shell_profile
|
configure_shell_profile
|
||||||
|
|
||||||
set +eu
|
set +eu
|
||||||
# shellcheck disable=SC1091
|
|
||||||
. /etc/profile
|
. /etc/profile
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
@@ -868,20 +704,5 @@ EOF
|
|||||||
trap finish_success EXIT
|
trap finish_success EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
# set an empty initial arg for bare invocations in case we need to
|
|
||||||
# disambiguate someone directly invoking this later.
|
|
||||||
if [ "${#@}" = 0 ]; then
|
|
||||||
set ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ACTION for override
|
main
|
||||||
case "${1-}" in
|
|
||||||
# uninstall)
|
|
||||||
# shift
|
|
||||||
# uninstall "$@";;
|
|
||||||
# install == same as the no-arg condition for now (but, explicit)
|
|
||||||
""|install)
|
|
||||||
main;;
|
|
||||||
*) # holding space for future options (like uninstall + install?)
|
|
||||||
failure "install-multi-user: invalid argument";;
|
|
||||||
esac
|
|
||||||
@@ -26,9 +26,18 @@ fi
|
|||||||
|
|
||||||
# macOS support for 10.12.6 or higher
|
# macOS support for 10.12.6 or higher
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
IFS='.' read -r macos_major macos_minor macos_patch << EOF
|
IFS='.' read macos_major macos_minor macos_patch << EOF
|
||||||
$(sw_vers -productVersion)
|
$(sw_vers -productVersion)
|
||||||
EOF
|
EOF
|
||||||
|
# TODO: this is a temporary speed-bump to keep people from naively installing Nix
|
||||||
|
# on macOS Big Sur (11.0+, 10.16+) until nixpkgs updates are ready for them.
|
||||||
|
# *Ideally* this is gone before next Nix release. If you're intentionally working on
|
||||||
|
# Nix + Big Sur, just comment out this block and be on your way :)
|
||||||
|
if [ "$macos_major" -gt 10 ] || { [ "$macos_major" -eq 10 ] && [ "$macos_minor" -gt 15 ]; }; then
|
||||||
|
echo "$0: nixpkgs isn't quite ready to support macOS $(sw_vers -productVersion) yet"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$macos_major" -lt 10 ] || { [ "$macos_major" -eq 10 ] && [ "$macos_minor" -lt 12 ]; } || { [ "$macos_minor" -eq 12 ] && [ "$macos_patch" -lt 6 ]; }; then
|
if [ "$macos_major" -lt 10 ] || { [ "$macos_major" -eq 10 ] && [ "$macos_minor" -lt 12 ]; } || { [ "$macos_minor" -eq 12 ] && [ "$macos_patch" -lt 6 ]; }; then
|
||||||
# patch may not be present; command substitution for simplicity
|
# patch may not be present; command substitution for simplicity
|
||||||
echo "$0: macOS $(sw_vers -productVersion) is not supported, upgrade to 10.12.6 or higher"
|
echo "$0: macOS $(sw_vers -productVersion) is not supported, upgrade to 10.12.6 or higher"
|
||||||
@@ -37,40 +46,21 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine if we could use the multi-user installer or not
|
# Determine if we could use the multi-user installer or not
|
||||||
if [ "$(uname -s)" = "Linux" ]; then
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
|
echo "Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation" >&2
|
||||||
|
elif [ "$(uname -s)" = "Linux" ]; then
|
||||||
echo "Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation" >&2
|
echo "Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$(uname -s)" in
|
INSTALL_MODE=no-daemon
|
||||||
"Darwin")
|
CREATE_DARWIN_VOLUME=0
|
||||||
INSTALL_MODE=daemon;;
|
|
||||||
*)
|
|
||||||
INSTALL_MODE=no-daemon;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# space-separated string
|
|
||||||
ACTIONS=
|
|
||||||
|
|
||||||
# handle the command line flags
|
# handle the command line flags
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--daemon)
|
--daemon)
|
||||||
INSTALL_MODE=daemon
|
INSTALL_MODE=daemon;;
|
||||||
ACTIONS="${ACTIONS}install "
|
|
||||||
;;
|
|
||||||
--no-daemon)
|
--no-daemon)
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
INSTALL_MODE=no-daemon;;
|
||||||
printf '\e[1;31mError: --no-daemon installs are no-longer supported on Darwin/macOS!\e[0m\n' >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
INSTALL_MODE=no-daemon
|
|
||||||
# intentional tail space
|
|
||||||
ACTIONS="${ACTIONS}install "
|
|
||||||
;;
|
|
||||||
# --uninstall)
|
|
||||||
# # intentional tail space
|
|
||||||
# ACTIONS="${ACTIONS}uninstall "
|
|
||||||
# ;;
|
|
||||||
--no-channel-add)
|
--no-channel-add)
|
||||||
export NIX_INSTALLER_NO_CHANNEL_ADD=1;;
|
export NIX_INSTALLER_NO_CHANNEL_ADD=1;;
|
||||||
--daemon-user-count)
|
--daemon-user-count)
|
||||||
@@ -79,18 +69,13 @@ while [ $# -gt 0 ]; do
|
|||||||
--no-modify-profile)
|
--no-modify-profile)
|
||||||
NIX_INSTALLER_NO_MODIFY_PROFILE=1;;
|
NIX_INSTALLER_NO_MODIFY_PROFILE=1;;
|
||||||
--darwin-use-unencrypted-nix-store-volume)
|
--darwin-use-unencrypted-nix-store-volume)
|
||||||
{
|
CREATE_DARWIN_VOLUME=1;;
|
||||||
echo "Warning: the flag --darwin-use-unencrypted-nix-store-volume"
|
|
||||||
echo " is no longer needed and will be removed in the future."
|
|
||||||
echo ""
|
|
||||||
} >&2;;
|
|
||||||
--nix-extra-conf-file)
|
--nix-extra-conf-file)
|
||||||
# shellcheck disable=SC2155
|
export NIX_EXTRA_CONF="$(cat $2)"
|
||||||
export NIX_EXTRA_CONF="$(cat "$2")"
|
|
||||||
shift;;
|
shift;;
|
||||||
*)
|
*)
|
||||||
{
|
(
|
||||||
echo "Nix Installer [--daemon|--no-daemon] [--daemon-user-count INT] [--no-channel-add] [--no-modify-profile] [--nix-extra-conf-file FILE]"
|
echo "Nix Installer [--daemon|--no-daemon] [--daemon-user-count INT] [--no-channel-add] [--no-modify-profile] [--darwin-use-unencrypted-nix-store-volume] [--nix-extra-conf-file FILE]"
|
||||||
|
|
||||||
echo "Choose installation method."
|
echo "Choose installation method."
|
||||||
echo ""
|
echo ""
|
||||||
@@ -106,25 +91,55 @@ while [ $# -gt 0 ]; do
|
|||||||
echo ""
|
echo ""
|
||||||
echo " --no-channel-add: Don't add any channels. nixpkgs-unstable is installed by default."
|
echo " --no-channel-add: Don't add any channels. nixpkgs-unstable is installed by default."
|
||||||
echo ""
|
echo ""
|
||||||
echo " --no-modify-profile: Don't modify the user profile to automatically load nix."
|
echo " --no-modify-profile: Skip channel installation. When not provided nixpkgs-unstable"
|
||||||
|
echo " is installed by default."
|
||||||
echo ""
|
echo ""
|
||||||
echo " --daemon-user-count: Number of build users to create. Defaults to 32."
|
echo " --daemon-user-count: Number of build users to create. Defaults to 32."
|
||||||
echo ""
|
echo ""
|
||||||
echo " --nix-extra-conf-file: Path to nix.conf to prepend when installing /etc/nix/nix.conf"
|
echo " --nix-extra-conf-file: Path to nix.conf to prepend when installing /etc/nix.conf"
|
||||||
echo ""
|
echo ""
|
||||||
if [ -n "${INVOKED_FROM_INSTALL_IN:-}" ]; then
|
if [ -n "${INVOKED_FROM_INSTALL_IN:-}" ]; then
|
||||||
echo " --tarball-url-prefix URL: Base URL to download the Nix tarball from."
|
echo " --tarball-url-prefix URL: Base URL to download the Nix tarball from."
|
||||||
fi
|
fi
|
||||||
} >&2
|
) >&2
|
||||||
|
|
||||||
|
# darwin and Catalina+
|
||||||
|
if [ "$(uname -s)" = "Darwin" ] && { [ "$macos_major" -gt 10 ] || { [ "$macos_major" -eq 10 ] && [ "$macos_minor" -gt 14 ]; }; }; then
|
||||||
|
(
|
||||||
|
echo " --darwin-use-unencrypted-nix-store-volume: Create an APFS volume for the Nix"
|
||||||
|
echo " store and mount it at /nix. This is the recommended way to create"
|
||||||
|
echo " /nix with a read-only / on macOS >=10.15."
|
||||||
|
echo " See: https://nixos.org/nix/manual/#sect-macos-installation"
|
||||||
|
echo ""
|
||||||
|
) >&2
|
||||||
|
fi
|
||||||
exit;;
|
exit;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
|
if [ "$CREATE_DARWIN_VOLUME" = 1 ]; then
|
||||||
|
printf '\e[1;31mCreating volume and mountpoint /nix.\e[0m\n'
|
||||||
|
"$self/create-darwin-volume.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
writable="$(diskutil info -plist / | xmllint --xpath "name(/plist/dict/key[text()='Writable']/following-sibling::*[1])" -)"
|
||||||
|
if ! [ -e $dest ] && [ "$writable" = "false" ]; then
|
||||||
|
(
|
||||||
|
echo ""
|
||||||
|
echo "Installing on macOS >=10.15 requires relocating the store to an apfs volume."
|
||||||
|
echo "Use sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume or run the preparation steps manually."
|
||||||
|
echo "See https://nixos.org/nix/manual/#sect-macos-installation"
|
||||||
|
echo ""
|
||||||
|
) >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$INSTALL_MODE" = "daemon" ]; then
|
if [ "$INSTALL_MODE" = "daemon" ]; then
|
||||||
printf '\e[1;31mSwitching to the Multi-user Installer\e[0m\n'
|
printf '\e[1;31mSwitching to the Multi-user Installer\e[0m\n'
|
||||||
exec "$self/install-multi-user" $ACTIONS # let ACTIONS split
|
exec "$self/install-multi-user"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -179,7 +194,6 @@ if ! "$nix/bin/nix-store" --load-db < "$self/.reginfo"; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck source=./nix-profile.sh.in
|
|
||||||
. "$nix/etc/profile.d/nix.sh"
|
. "$nix/etc/profile.d/nix.sh"
|
||||||
|
|
||||||
if ! "$nix/bin/nix-env" -i "$nix"; then
|
if ! "$nix/bin/nix-env" -i "$nix"; then
|
||||||
@@ -215,7 +229,7 @@ if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
|
|||||||
if [ -w "$fn" ]; then
|
if [ -w "$fn" ]; then
|
||||||
if ! grep -q "$p" "$fn"; then
|
if ! grep -q "$p" "$fn"; then
|
||||||
echo "modifying $fn..." >&2
|
echo "modifying $fn..." >&2
|
||||||
printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
|
echo -e "\nif [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
|
||||||
fi
|
fi
|
||||||
added=1
|
added=1
|
||||||
break
|
break
|
||||||
@@ -226,7 +240,7 @@ if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
|
|||||||
if [ -w "$fn" ]; then
|
if [ -w "$fn" ]; then
|
||||||
if ! grep -q "$p" "$fn"; then
|
if ! grep -q "$p" "$fn"; then
|
||||||
echo "modifying $fn..." >&2
|
echo "modifying $fn..." >&2
|
||||||
printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
|
echo -e "\nif [ -e $p ]; then . $p; fi # added by Nix installer" >> "$fn"
|
||||||
fi
|
fi
|
||||||
added=1
|
added=1
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ handle_network_proxy() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_cure_artifacts() {
|
poly_validate_assumptions() {
|
||||||
:
|
if [ "$(uname -s)" != "Linux" ]; then
|
||||||
|
failure "This script is for use with Linux!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_service_installed_check() {
|
poly_service_installed_check() {
|
||||||
@@ -70,7 +72,7 @@ poly_service_setup_note() {
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_extra_try_me_commands() {
|
poly_extra_try_me_commands(){
|
||||||
if [ -e /run/systemd/system ]; then
|
if [ -e /run/systemd/system ]; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@@ -79,10 +81,19 @@ poly_extra_try_me_commands() {
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
poly_extra_setup_instructions(){
|
||||||
|
if [ -e /run/systemd/system ]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
cat <<EOF
|
||||||
|
Additionally, you may want to add nix-daemon to your init-system.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
poly_configure_nix_daemon_service() {
|
poly_configure_nix_daemon_service() {
|
||||||
if [ -e /run/systemd/system ]; then
|
if [ -e /run/systemd/system ]; then
|
||||||
task "Setting up the nix-daemon systemd service"
|
|
||||||
_sudo "to set up the nix-daemon service" \
|
_sudo "to set up the nix-daemon service" \
|
||||||
systemctl link "/nix/var/nix/profiles/default$SERVICE_SRC"
|
systemctl link "/nix/var/nix/profiles/default$SERVICE_SRC"
|
||||||
|
|
||||||
@@ -99,8 +110,6 @@ poly_configure_nix_daemon_service() {
|
|||||||
|
|
||||||
_sudo "to start the nix-daemon.service" \
|
_sudo "to start the nix-daemon.service" \
|
||||||
systemctl restart nix-daemon.service
|
systemctl restart nix-daemon.service
|
||||||
else
|
|
||||||
reminder "I don't support your init system yet; you may want to add nix-daemon manually."
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +207,3 @@ poly_create_build_user() {
|
|||||||
--password "!" \
|
--password "!" \
|
||||||
"$username"
|
"$username"
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_prepare_to_install() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
+12
-23
@@ -40,31 +40,27 @@ case "$(uname -s).$(uname -m)" in
|
|||||||
path=@tarballPath_aarch64-linux@
|
path=@tarballPath_aarch64-linux@
|
||||||
system=aarch64-linux
|
system=aarch64-linux
|
||||||
;;
|
;;
|
||||||
Linux.armv6l_linux)
|
|
||||||
hash=@tarballHash_armv6l-linux@
|
|
||||||
path=@tarballPath_armv6l-linux@
|
|
||||||
system=armv6l-linux
|
|
||||||
;;
|
|
||||||
Linux.armv7l_linux)
|
|
||||||
hash=@tarballHash_armv7l-linux@
|
|
||||||
path=@tarballPath_armv7l-linux@
|
|
||||||
system=armv7l-linux
|
|
||||||
;;
|
|
||||||
Darwin.x86_64)
|
Darwin.x86_64)
|
||||||
hash=@tarballHash_x86_64-darwin@
|
hash=@tarballHash_x86_64-darwin@
|
||||||
path=@tarballPath_x86_64-darwin@
|
path=@tarballPath_x86_64-darwin@
|
||||||
system=x86_64-darwin
|
system=x86_64-darwin
|
||||||
;;
|
;;
|
||||||
Darwin.arm64|Darwin.aarch64)
|
Darwin.arm64|Darwin.aarch64)
|
||||||
hash=@tarballHash_aarch64-darwin@
|
# check for Rosetta 2 support
|
||||||
path=@tarballPath_aarch64-darwin@
|
if ! [ -f /Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist ]; then
|
||||||
system=aarch64-darwin
|
oops "Rosetta 2 is not installed on this ARM64 macOS machine. Run softwareupdate --install-rosetta then restart installation"
|
||||||
|
fi
|
||||||
|
|
||||||
|
hash=@binaryTarball_x86_64-darwin@
|
||||||
|
path=@tarballPath_x86_64-darwin@
|
||||||
|
# eventually maybe: aarch64-darwin
|
||||||
|
system=x86_64-darwin
|
||||||
;;
|
;;
|
||||||
*) oops "sorry, there is no binary distribution of Nix for your platform";;
|
*) oops "sorry, there is no binary distribution of Nix for your platform";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Use this command-line option to fetch the tarballs using nar-serve or Cachix
|
# Use this command-line option to fetch the tarballs using nar-serve or Cachix
|
||||||
if [ "${1:-}" = "--tarball-url-prefix" ]; then
|
if "${1:---tarball-url-prefix}"; then
|
||||||
if [ -z "${2:-}" ]; then
|
if [ -z "${2:-}" ]; then
|
||||||
oops "missing argument for --tarball-url-prefix"
|
oops "missing argument for --tarball-url-prefix"
|
||||||
fi
|
fi
|
||||||
@@ -76,21 +72,14 @@ fi
|
|||||||
|
|
||||||
tarball=$tmpDir/nix-@nixVersion@-$system.tar.xz
|
tarball=$tmpDir/nix-@nixVersion@-$system.tar.xz
|
||||||
|
|
||||||
|
require_util curl "download the binary tarball"
|
||||||
require_util tar "unpack the binary tarball"
|
require_util tar "unpack the binary tarball"
|
||||||
if [ "$(uname -s)" != "Darwin" ]; then
|
if [ "$(uname -s)" != "Darwin" ]; then
|
||||||
require_util xz "unpack the binary tarball"
|
require_util xz "unpack the binary tarball"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v wget > /dev/null 2>&1; then
|
|
||||||
fetch() { wget "$1" -O "$2"; }
|
|
||||||
elif command -v curl > /dev/null 2>&1; then
|
|
||||||
fetch() { curl -L "$1" -o "$2"; }
|
|
||||||
else
|
|
||||||
oops "you don't have wget or curl installed, which I need to download the binary tarball"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "downloading Nix @nixVersion@ binary tarball for $system from '$url' to '$tmpDir'..."
|
echo "downloading Nix @nixVersion@ binary tarball for $system from '$url' to '$tmpDir'..."
|
||||||
fetch "$url" "$tarball" || oops "failed to download '$url'"
|
curl -L "$url" -o "$tarball" || oops "failed to download '$url'"
|
||||||
|
|
||||||
if command -v sha256sum > /dev/null 2>&1; then
|
if command -v sha256sum > /dev/null 2>&1; then
|
||||||
hash2="$(sha256sum -b "$tarball" | cut -c1-64)"
|
hash2="$(sha256sum -b "$tarball" | cut -c1-64)"
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
script=$(nix-build -A outputs.hydraJobs.installerScriptForGHA --no-out-link)
|
|
||||||
installerHash=$(echo $script | cut -b12-43 -)
|
|
||||||
|
|
||||||
installerURL=https://$CACHIX_NAME.cachix.org/serve/$installerHash/install
|
|
||||||
|
|
||||||
echo "::set-output name=installerURL::$installerURL"
|
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
#include "local-store.hh"
|
#include "local-store.hh"
|
||||||
#include "legacy.hh"
|
#include "legacy.hh"
|
||||||
#include "experimental-features.hh"
|
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
using std::cin;
|
using std::cin;
|
||||||
@@ -54,9 +53,6 @@ static int main_build_remote(int argc, char * * argv)
|
|||||||
unsetenv("DISPLAY");
|
unsetenv("DISPLAY");
|
||||||
unsetenv("SSH_ASKPASS");
|
unsetenv("SSH_ASKPASS");
|
||||||
|
|
||||||
/* If we ever use the common args framework, make sure to
|
|
||||||
remove initPlugins below and initialize settings first.
|
|
||||||
*/
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
throw UsageError("called without required arguments");
|
throw UsageError("called without required arguments");
|
||||||
|
|
||||||
@@ -131,14 +127,11 @@ static int main_build_remote(int argc, char * * argv)
|
|||||||
for (auto & m : machines) {
|
for (auto & m : machines) {
|
||||||
debug("considering building on remote machine '%s'", m.storeUri);
|
debug("considering building on remote machine '%s'", m.storeUri);
|
||||||
|
|
||||||
if (m.enabled
|
if (m.enabled && std::find(m.systemTypes.begin(),
|
||||||
&& (neededSystem == "builtin"
|
m.systemTypes.end(),
|
||||||
|| std::find(m.systemTypes.begin(),
|
neededSystem) != m.systemTypes.end() &&
|
||||||
m.systemTypes.end(),
|
|
||||||
neededSystem) != m.systemTypes.end()) &&
|
|
||||||
m.allSupported(requiredFeatures) &&
|
m.allSupported(requiredFeatures) &&
|
||||||
m.mandatoryMet(requiredFeatures))
|
m.mandatoryMet(requiredFeatures)) {
|
||||||
{
|
|
||||||
rightType = true;
|
rightType = true;
|
||||||
AutoCloseFD free;
|
AutoCloseFD free;
|
||||||
uint64_t load = 0;
|
uint64_t load = 0;
|
||||||
@@ -255,7 +248,7 @@ connected:
|
|||||||
std::cerr << "# accept\n" << storeUri << "\n";
|
std::cerr << "# accept\n" << storeUri << "\n";
|
||||||
|
|
||||||
auto inputs = readStrings<PathSet>(source);
|
auto inputs = readStrings<PathSet>(source);
|
||||||
auto wantedOutputs = readStrings<StringSet>(source);
|
auto outputs = readStrings<PathSet>(source);
|
||||||
|
|
||||||
AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true);
|
AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true);
|
||||||
|
|
||||||
@@ -274,65 +267,29 @@ connected:
|
|||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri));
|
||||||
copyPaths(*store, *sshStore, store->parseStorePathSet(inputs), NoRepair, NoCheckSigs, substitute);
|
copyPaths(store, ref<Store>(sshStore), store->parseStorePathSet(inputs), NoRepair, NoCheckSigs, substitute);
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadLock = -1;
|
uploadLock = -1;
|
||||||
|
|
||||||
auto drv = store->readDerivation(*drvPath);
|
auto drv = store->readDerivation(*drvPath);
|
||||||
auto outputHashes = staticOutputHashes(*store, drv);
|
drv.inputSrcs = store->parseStorePathSet(inputs);
|
||||||
|
|
||||||
// Hijack the inputs paths of the derivation to include all the paths
|
|
||||||
// that come from the `inputDrvs` set.
|
|
||||||
// We don’t do that for the derivations whose `inputDrvs` is empty
|
|
||||||
// because
|
|
||||||
// 1. It’s not needed
|
|
||||||
// 2. Changing the `inputSrcs` set changes the associated output ids,
|
|
||||||
// which break CA derivations
|
|
||||||
if (!drv.inputDrvs.empty())
|
|
||||||
drv.inputSrcs = store->parseStorePathSet(inputs);
|
|
||||||
|
|
||||||
auto result = sshStore->buildDerivation(*drvPath, drv);
|
auto result = sshStore->buildDerivation(*drvPath, drv);
|
||||||
|
|
||||||
if (!result.success())
|
if (!result.success())
|
||||||
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
|
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
|
||||||
|
|
||||||
std::set<Realisation> missingRealisations;
|
StorePathSet missing;
|
||||||
StorePathSet missingPaths;
|
for (auto & path : outputs)
|
||||||
if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations) && !derivationHasKnownOutputPaths(drv.type())) {
|
if (!store->isValidPath(store->parseStorePath(path))) missing.insert(store->parseStorePath(path));
|
||||||
for (auto & outputName : wantedOutputs) {
|
|
||||||
auto thisOutputHash = outputHashes.at(outputName);
|
|
||||||
auto thisOutputId = DrvOutput{ thisOutputHash, outputName };
|
|
||||||
if (!store->queryRealisation(thisOutputId)) {
|
|
||||||
debug("missing output %s", outputName);
|
|
||||||
assert(result.builtOutputs.count(thisOutputId));
|
|
||||||
auto newRealisation = result.builtOutputs.at(thisOutputId);
|
|
||||||
missingRealisations.insert(newRealisation);
|
|
||||||
missingPaths.insert(newRealisation.outPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto outputPaths = drv.outputsAndOptPaths(*store);
|
|
||||||
for (auto & [outputName, hopefullyOutputPath] : outputPaths) {
|
|
||||||
assert(hopefullyOutputPath.second);
|
|
||||||
if (!store->isValidPath(*hopefullyOutputPath.second))
|
|
||||||
missingPaths.insert(*hopefullyOutputPath.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!missingPaths.empty()) {
|
if (!missing.empty()) {
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri));
|
||||||
if (auto localStore = store.dynamic_pointer_cast<LocalStore>())
|
if (auto localStore = store.dynamic_pointer_cast<LocalStore>())
|
||||||
for (auto & path : missingPaths)
|
for (auto & i : missing)
|
||||||
localStore->locksHeld.insert(store->printStorePath(path)); /* FIXME: ugly */
|
localStore->locksHeld.insert(store->printStorePath(i)); /* FIXME: ugly */
|
||||||
copyPaths(*sshStore, *store, missingPaths, NoRepair, NoCheckSigs, NoSubstitute);
|
copyPaths(ref<Store>(sshStore), store, missing, 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
|
|
||||||
settings.requireExperimentalFeature(Xp::CaDerivations);
|
|
||||||
store->registerDrvOutput(realisation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+28
-56
@@ -54,31 +54,7 @@ void StoreCommand::run()
|
|||||||
run(getStore());
|
run(getStore());
|
||||||
}
|
}
|
||||||
|
|
||||||
EvalCommand::EvalCommand()
|
RealisedPathsCommand::RealisedPathsCommand(bool recursive)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
EvalCommand::~EvalCommand()
|
|
||||||
{
|
|
||||||
if (evalState)
|
|
||||||
evalState->printStats();
|
|
||||||
}
|
|
||||||
|
|
||||||
ref<Store> EvalCommand::getEvalStore()
|
|
||||||
{
|
|
||||||
if (!evalStore)
|
|
||||||
evalStore = evalStoreUrl ? openStore(*evalStoreUrl) : getStore();
|
|
||||||
return ref<Store>(evalStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
ref<EvalState> EvalCommand::getEvalState()
|
|
||||||
{
|
|
||||||
if (!evalState)
|
|
||||||
evalState = std::make_shared<EvalState>(searchPath, getEvalStore(), getStore());
|
|
||||||
return ref<EvalState>(evalState);
|
|
||||||
}
|
|
||||||
|
|
||||||
BuiltPathsCommand::BuiltPathsCommand(bool recursive)
|
|
||||||
: recursive(recursive)
|
: recursive(recursive)
|
||||||
{
|
{
|
||||||
if (recursive)
|
if (recursive)
|
||||||
@@ -105,54 +81,47 @@ BuiltPathsCommand::BuiltPathsCommand(bool recursive)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltPathsCommand::run(ref<Store> store)
|
void RealisedPathsCommand::run(ref<Store> store)
|
||||||
{
|
{
|
||||||
BuiltPaths paths;
|
std::vector<RealisedPath> paths;
|
||||||
if (all) {
|
if (all) {
|
||||||
if (installables.size())
|
if (installables.size())
|
||||||
throw UsageError("'--all' does not expect arguments");
|
throw UsageError("'--all' does not expect arguments");
|
||||||
// XXX: Only uses opaque paths, ignores all the realisations
|
// XXX: Only uses opaque paths, ignores all the realisations
|
||||||
for (auto & p : store->queryAllValidPaths())
|
for (auto & p : store->queryAllValidPaths())
|
||||||
paths.push_back(BuiltPath::Opaque{p});
|
paths.push_back(p);
|
||||||
} else {
|
} else {
|
||||||
paths = toBuiltPaths(getEvalStore(), store, realiseMode, operateOn, installables);
|
auto pathSet = toRealisedPaths(store, realiseMode, operateOn, installables);
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
// XXX: This only computes the store path closure, ignoring
|
auto roots = std::move(pathSet);
|
||||||
// intermediate realisations
|
pathSet = {};
|
||||||
StorePathSet pathsRoots, pathsClosure;
|
RealisedPath::closure(*store, roots, pathSet);
|
||||||
for (auto & root : paths) {
|
|
||||||
auto rootFromThis = root.outPaths();
|
|
||||||
pathsRoots.insert(rootFromThis.begin(), rootFromThis.end());
|
|
||||||
}
|
|
||||||
store->computeFSClosure(pathsRoots, pathsClosure);
|
|
||||||
for (auto & path : pathsClosure)
|
|
||||||
paths.push_back(BuiltPath::Opaque{path});
|
|
||||||
}
|
}
|
||||||
|
for (auto & path : pathSet)
|
||||||
|
paths.push_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
run(store, std::move(paths));
|
run(store, std::move(paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathsCommand::StorePathsCommand(bool recursive)
|
StorePathsCommand::StorePathsCommand(bool recursive)
|
||||||
: BuiltPathsCommand(recursive)
|
: RealisedPathsCommand(recursive)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorePathsCommand::run(ref<Store> store, BuiltPaths && paths)
|
void StorePathsCommand::run(ref<Store> store, std::vector<RealisedPath> paths)
|
||||||
{
|
{
|
||||||
StorePathSet storePaths;
|
StorePaths storePaths;
|
||||||
for (auto & builtPath : paths)
|
for (auto & p : paths)
|
||||||
for (auto & p : builtPath.outPaths())
|
storePaths.push_back(p.path());
|
||||||
storePaths.insert(p);
|
|
||||||
|
|
||||||
auto sorted = store->topoSortPaths(storePaths);
|
run(store, std::move(storePaths));
|
||||||
std::reverse(sorted.begin(), sorted.end());
|
|
||||||
|
|
||||||
run(store, std::move(sorted));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorePathCommand::run(ref<Store> store, std::vector<StorePath> && storePaths)
|
void StorePathCommand::run(ref<Store> store)
|
||||||
{
|
{
|
||||||
|
auto storePaths = toStorePaths(store, Realise::Nothing, operateOn, installables);
|
||||||
|
|
||||||
if (storePaths.size() != 1)
|
if (storePaths.size() != 1)
|
||||||
throw UsageError("this command requires exactly one store path");
|
throw UsageError("this command requires exactly one store path");
|
||||||
|
|
||||||
@@ -195,7 +164,7 @@ void MixProfile::updateProfile(const StorePath & storePath)
|
|||||||
profile2, storePath));
|
profile2, storePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixProfile::updateProfile(const BuiltPaths & buildables)
|
void MixProfile::updateProfile(const Buildables & buildables)
|
||||||
{
|
{
|
||||||
if (!profile) return;
|
if (!profile) return;
|
||||||
|
|
||||||
@@ -203,19 +172,22 @@ void MixProfile::updateProfile(const BuiltPaths & buildables)
|
|||||||
|
|
||||||
for (auto & buildable : buildables) {
|
for (auto & buildable : buildables) {
|
||||||
std::visit(overloaded {
|
std::visit(overloaded {
|
||||||
[&](const BuiltPath::Opaque & bo) {
|
[&](BuildableOpaque bo) {
|
||||||
result.push_back(bo.path);
|
result.push_back(bo.path);
|
||||||
},
|
},
|
||||||
[&](const BuiltPath::Built & bfd) {
|
[&](BuildableFromDrv bfd) {
|
||||||
for (auto & output : bfd.outputs) {
|
for (auto & output : bfd.outputs) {
|
||||||
result.push_back(output.second);
|
/* Output path should be known because we just tried to
|
||||||
|
build it. */
|
||||||
|
assert(output.second);
|
||||||
|
result.push_back(*output.second);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}, buildable.raw());
|
}, buildable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.size() != 1)
|
if (result.size() != 1)
|
||||||
throw UsageError("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
throw Error("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
||||||
|
|
||||||
updateProfile(result[0]);
|
updateProfile(result[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-44
@@ -45,18 +45,11 @@ private:
|
|||||||
|
|
||||||
struct EvalCommand : virtual StoreCommand, MixEvalArgs
|
struct EvalCommand : virtual StoreCommand, MixEvalArgs
|
||||||
{
|
{
|
||||||
EvalCommand();
|
|
||||||
|
|
||||||
~EvalCommand();
|
|
||||||
|
|
||||||
ref<Store> getEvalStore();
|
|
||||||
|
|
||||||
ref<EvalState> getEvalState();
|
ref<EvalState> getEvalState();
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<Store> evalStore;
|
|
||||||
|
|
||||||
std::shared_ptr<EvalState> evalState;
|
std::shared_ptr<EvalState> evalState;
|
||||||
|
|
||||||
|
~EvalCommand();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MixFlakeOptions : virtual Args, EvalCommand
|
struct MixFlakeOptions : virtual Args, EvalCommand
|
||||||
@@ -108,8 +101,6 @@ enum class Realise {
|
|||||||
exists. */
|
exists. */
|
||||||
Derivation,
|
Derivation,
|
||||||
/* Evaluate in dry-run mode. Postcondition: nothing. */
|
/* Evaluate in dry-run mode. Postcondition: nothing. */
|
||||||
// FIXME: currently unused, but could be revived if we can
|
|
||||||
// evaluate derivations in-memory.
|
|
||||||
Nothing
|
Nothing
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -152,7 +143,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* A command that operates on zero or more store paths. */
|
/* A command that operates on zero or more store paths. */
|
||||||
struct BuiltPathsCommand : public InstallablesCommand
|
struct RealisedPathsCommand : public InstallablesCommand
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -165,36 +156,36 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BuiltPathsCommand(bool recursive = false);
|
RealisedPathsCommand(bool recursive = false);
|
||||||
|
|
||||||
using StoreCommand::run;
|
using StoreCommand::run;
|
||||||
|
|
||||||
virtual void run(ref<Store> store, BuiltPaths && paths) = 0;
|
virtual void run(ref<Store> store, std::vector<RealisedPath> paths) = 0;
|
||||||
|
|
||||||
void run(ref<Store> store) override;
|
void run(ref<Store> store) override;
|
||||||
|
|
||||||
bool useDefaultInstallables() override { return !all; }
|
bool useDefaultInstallables() override { return !all; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StorePathsCommand : public BuiltPathsCommand
|
struct StorePathsCommand : public RealisedPathsCommand
|
||||||
{
|
{
|
||||||
StorePathsCommand(bool recursive = false);
|
StorePathsCommand(bool recursive = false);
|
||||||
|
|
||||||
using BuiltPathsCommand::run;
|
using RealisedPathsCommand::run;
|
||||||
|
|
||||||
virtual void run(ref<Store> store, std::vector<StorePath> && storePaths) = 0;
|
virtual void run(ref<Store> store, std::vector<StorePath> storePaths) = 0;
|
||||||
|
|
||||||
void run(ref<Store> store, BuiltPaths && paths) override;
|
void run(ref<Store> store, std::vector<RealisedPath> paths) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A command that operates on exactly one store path. */
|
/* A command that operates on exactly one store path. */
|
||||||
struct StorePathCommand : public StorePathsCommand
|
struct StorePathCommand : public InstallablesCommand
|
||||||
{
|
{
|
||||||
using StorePathsCommand::run;
|
using StoreCommand::run;
|
||||||
|
|
||||||
virtual void run(ref<Store> store, const StorePath & storePath) = 0;
|
virtual void run(ref<Store> store, const StorePath & storePath) = 0;
|
||||||
|
|
||||||
void run(ref<Store> store, std::vector<StorePath> && storePaths) override;
|
void run(ref<Store> store) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A helper class for registering commands globally. */
|
/* A helper class for registering commands globally. */
|
||||||
@@ -225,37 +216,26 @@ static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
|||||||
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltPaths build(
|
Buildables build(ref<Store> store, Realise mode,
|
||||||
ref<Store> evalStore,
|
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode = bmNormal);
|
||||||
ref<Store> store, Realise mode,
|
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables,
|
|
||||||
BuildMode bMode = bmNormal);
|
|
||||||
|
|
||||||
std::set<StorePath> toStorePaths(
|
std::set<StorePath> toStorePaths(ref<Store> store,
|
||||||
ref<Store> evalStore,
|
Realise mode, OperateOn operateOn,
|
||||||
ref<Store> store,
|
std::vector<std::shared_ptr<Installable>> installables);
|
||||||
Realise mode,
|
|
||||||
OperateOn operateOn,
|
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables);
|
|
||||||
|
|
||||||
StorePath toStorePath(
|
StorePath toStorePath(ref<Store> store,
|
||||||
ref<Store> evalStore,
|
Realise mode, OperateOn operateOn,
|
||||||
ref<Store> store,
|
|
||||||
Realise mode,
|
|
||||||
OperateOn operateOn,
|
|
||||||
std::shared_ptr<Installable> installable);
|
std::shared_ptr<Installable> installable);
|
||||||
|
|
||||||
std::set<StorePath> toDerivations(
|
std::set<StorePath> toDerivations(ref<Store> store,
|
||||||
ref<Store> store,
|
std::vector<std::shared_ptr<Installable>> installables,
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables,
|
|
||||||
bool useDeriver = false);
|
bool useDeriver = false);
|
||||||
|
|
||||||
BuiltPaths toBuiltPaths(
|
std::set<RealisedPath> toRealisedPaths(
|
||||||
ref<Store> evalStore,
|
|
||||||
ref<Store> store,
|
ref<Store> store,
|
||||||
Realise mode,
|
Realise mode,
|
||||||
OperateOn operateOn,
|
OperateOn operateOn,
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables);
|
std::vector<std::shared_ptr<Installable>> installables);
|
||||||
|
|
||||||
/* Helper function to generate args that invoke $EDITOR on
|
/* Helper function to generate args that invoke $EDITOR on
|
||||||
filename:lineno. */
|
filename:lineno. */
|
||||||
@@ -272,7 +252,7 @@ struct MixProfile : virtual StoreCommand
|
|||||||
|
|
||||||
/* If 'profile' is set, make it point at the store path produced
|
/* If 'profile' is set, make it point at the store path produced
|
||||||
by 'buildables'. */
|
by 'buildables'. */
|
||||||
void updateProfile(const BuiltPaths & buildables);
|
void updateProfile(const Buildables & buildables);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MixDefaultProfile : MixProfile
|
struct MixDefaultProfile : MixProfile
|
||||||
|
|||||||
+204
-307
@@ -9,7 +9,6 @@
|
|||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "shared.hh"
|
#include "shared.hh"
|
||||||
#include "flake/flake.hh"
|
#include "flake/flake.hh"
|
||||||
#include "eval-cache.hh"
|
|
||||||
#include "url.hh"
|
#include "url.hh"
|
||||||
#include "registry.hh"
|
#include "registry.hh"
|
||||||
|
|
||||||
@@ -20,6 +19,31 @@
|
|||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
nlohmann::json BuildableOpaque::toJSON(ref<Store> store) const {
|
||||||
|
nlohmann::json res;
|
||||||
|
res["path"] = store->printStorePath(path);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json BuildableFromDrv::toJSON(ref<Store> store) const {
|
||||||
|
nlohmann::json res;
|
||||||
|
res["drvPath"] = store->printStorePath(drvPath);
|
||||||
|
for (const auto& [output, path] : outputs) {
|
||||||
|
res["outputs"][output] = path ? store->printStorePath(*path) : "";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json buildablesToJSON(const Buildables & buildables, ref<Store> store) {
|
||||||
|
auto res = nlohmann::json::array();
|
||||||
|
for (const Buildable & buildable : buildables) {
|
||||||
|
std::visit([&res, store](const auto & buildable) {
|
||||||
|
res.push_back(buildable.toJSON(store));
|
||||||
|
}, buildable);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void completeFlakeInputPath(
|
void completeFlakeInputPath(
|
||||||
ref<EvalState> evalState,
|
ref<EvalState> evalState,
|
||||||
const FlakeRef & flakeRef,
|
const FlakeRef & flakeRef,
|
||||||
@@ -58,13 +82,9 @@ MixFlakeOptions::MixFlakeOptions()
|
|||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "no-registries",
|
.longName = "no-registries",
|
||||||
.description =
|
.description = "Don't allow lookups in the flake registries.",
|
||||||
"Don't allow lookups in the flake registries. This option is deprecated; use `--no-use-registries`.",
|
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[&]() {
|
.handler = {&lockFlags.useRegistries, false}
|
||||||
lockFlags.useRegistries = false;
|
|
||||||
warn("'--no-registries' is deprecated; use '--no-use-registries'");
|
|
||||||
}}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
@@ -90,11 +110,10 @@ MixFlakeOptions::MixFlakeOptions()
|
|||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "override-input",
|
.longName = "override-input",
|
||||||
.description = "Override a specific flake input (e.g. `dwarffs/nixpkgs`). This implies `--no-write-lock-file`.",
|
.description = "Override a specific flake input (e.g. `dwarffs/nixpkgs`).",
|
||||||
.category = category,
|
.category = category,
|
||||||
.labels = {"input-path", "flake-url"},
|
.labels = {"input-path", "flake-url"},
|
||||||
.handler = {[&](std::string inputPath, std::string flakeRef) {
|
.handler = {[&](std::string inputPath, std::string flakeRef) {
|
||||||
lockFlags.writeLockFile = false;
|
|
||||||
lockFlags.inputOverrides.insert_or_assign(
|
lockFlags.inputOverrides.insert_or_assign(
|
||||||
flake::parseInputPath(inputPath),
|
flake::parseInputPath(inputPath),
|
||||||
parseFlakeRef(flakeRef, absPath(".")));
|
parseFlakeRef(flakeRef, absPath(".")));
|
||||||
@@ -175,50 +194,14 @@ Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
|
|||||||
|
|
||||||
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
||||||
{
|
{
|
||||||
if (file) {
|
if (file) return; // FIXME
|
||||||
evalSettings.pureEval = false;
|
|
||||||
auto state = getEvalState();
|
|
||||||
Expr *e = state->parseExprFromFile(
|
|
||||||
resolveExprPath(state->checkSourcePath(lookupFileArg(*state, *file)))
|
|
||||||
);
|
|
||||||
|
|
||||||
Value root;
|
completeFlakeRefWithFragment(
|
||||||
state->eval(e, root);
|
getEvalState(),
|
||||||
|
lockFlags,
|
||||||
auto autoArgs = getAutoArgs(*state);
|
getDefaultFlakeAttrPathPrefixes(),
|
||||||
|
getDefaultFlakeAttrPaths(),
|
||||||
std::string prefix_ = std::string(prefix);
|
prefix);
|
||||||
auto sep = prefix_.rfind('.');
|
|
||||||
std::string searchWord;
|
|
||||||
if (sep != std::string::npos) {
|
|
||||||
searchWord = prefix_.substr(sep, std::string::npos);
|
|
||||||
prefix_ = prefix_.substr(0, sep);
|
|
||||||
} else {
|
|
||||||
searchWord = prefix_;
|
|
||||||
prefix_ = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
Value &v1(*findAlongAttrPath(*state, prefix_, *autoArgs, root).first);
|
|
||||||
state->forceValue(v1);
|
|
||||||
Value v2;
|
|
||||||
state->autoCallFunction(*autoArgs, v1, v2);
|
|
||||||
|
|
||||||
if (v2.type() == nAttrs) {
|
|
||||||
for (auto & i : *v2.attrs) {
|
|
||||||
std::string name = i.name;
|
|
||||||
if (name.find(searchWord) == 0) {
|
|
||||||
completions->add(i.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
completeFlakeRefWithFragment(
|
|
||||||
getEvalState(),
|
|
||||||
lockFlags,
|
|
||||||
getDefaultFlakeAttrPathPrefixes(),
|
|
||||||
getDefaultFlakeAttrPaths(),
|
|
||||||
prefix);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void completeFlakeRefWithFragment(
|
void completeFlakeRefWithFragment(
|
||||||
@@ -238,10 +221,8 @@ void completeFlakeRefWithFragment(
|
|||||||
// FIXME: do tilde expansion.
|
// FIXME: do tilde expansion.
|
||||||
auto flakeRef = parseFlakeRef(flakeRefS, absPath("."));
|
auto flakeRef = parseFlakeRef(flakeRefS, absPath("."));
|
||||||
|
|
||||||
auto evalCache = openEvalCache(*evalState,
|
auto lockedFlake = lockFlake(*evalState, flakeRef, lockFlags);
|
||||||
std::make_shared<flake::LockedFlake>(lockFlake(*evalState, flakeRef, lockFlags)));
|
auto rootValue = getFlakeValue(*evalState, lockedFlake);
|
||||||
|
|
||||||
auto root = evalCache->getRoot();
|
|
||||||
|
|
||||||
/* Complete 'fragment' relative to all the
|
/* Complete 'fragment' relative to all the
|
||||||
attrpath prefixes as well as the root of the
|
attrpath prefixes as well as the root of the
|
||||||
@@ -259,12 +240,18 @@ void completeFlakeRefWithFragment(
|
|||||||
attrPath.pop_back();
|
attrPath.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto attr = root->findAlongAttrPath(attrPath);
|
auto cachedFieldNames = rootValue->getCache().listChildrenAtPath(evalState->symbols, attrPath);
|
||||||
if (!attr) continue;
|
|
||||||
|
|
||||||
for (auto & attr2 : attr->getAttrs()) {
|
if (!cachedFieldNames) {
|
||||||
if (hasPrefix(attr2, lastAttr)) {
|
auto accessResult = evalState->getOptionalAttrField(*rootValue, attrPath, noPos);
|
||||||
auto attrPath2 = attr->getAttrPath(attr2);
|
if (accessResult.error) continue;
|
||||||
|
cachedFieldNames = evalState->listAttrFields(*accessResult.value, *accessResult.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto & lastFieldName : *cachedFieldNames) {
|
||||||
|
if (hasPrefix(lastFieldName, lastAttr)) {
|
||||||
|
auto attrPath2 = attrPath;
|
||||||
|
attrPath2.push_back(lastFieldName);
|
||||||
/* Strip the attrpath prefix. */
|
/* Strip the attrpath prefix. */
|
||||||
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
|
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
|
||||||
completions->add(flakeRefS + "#" + concatStringsSep(".", attrPath2));
|
completions->add(flakeRefS + "#" + concatStringsSep(".", attrPath2));
|
||||||
@@ -276,8 +263,8 @@ void completeFlakeRefWithFragment(
|
|||||||
attrpaths. */
|
attrpaths. */
|
||||||
if (fragment.empty()) {
|
if (fragment.empty()) {
|
||||||
for (auto & attrPath : defaultFlakeAttrPaths) {
|
for (auto & attrPath : defaultFlakeAttrPaths) {
|
||||||
auto attr = root->findAlongAttrPath(parseAttrPath(*evalState, attrPath));
|
auto accessResult = evalState->getOptionalAttrField(*rootValue, {evalState->symbols.create(attrPath)}, noPos);
|
||||||
if (!attr) continue;
|
if (accessResult.error) continue;
|
||||||
completions->add(flakeRefS + "#");
|
completions->add(flakeRefS + "#");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,6 +276,19 @@ void completeFlakeRefWithFragment(
|
|||||||
completeFlakeRef(evalState->store, prefix);
|
completeFlakeRef(evalState->store, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ref<EvalState> EvalCommand::getEvalState()
|
||||||
|
{
|
||||||
|
if (!evalState)
|
||||||
|
evalState = std::make_shared<EvalState>(searchPath, getStore());
|
||||||
|
return ref<EvalState>(evalState);
|
||||||
|
}
|
||||||
|
|
||||||
|
EvalCommand::~EvalCommand()
|
||||||
|
{
|
||||||
|
if (evalState)
|
||||||
|
evalState->printStats();
|
||||||
|
}
|
||||||
|
|
||||||
void completeFlakeRef(ref<Store> store, std::string_view prefix)
|
void completeFlakeRef(ref<Store> store, std::string_view prefix)
|
||||||
{
|
{
|
||||||
if (prefix == "")
|
if (prefix == "")
|
||||||
@@ -312,32 +312,14 @@ void completeFlakeRef(ref<Store> store, std::string_view prefix)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivedPath Installable::toDerivedPath()
|
Buildable Installable::toBuildable()
|
||||||
{
|
{
|
||||||
auto buildables = toDerivedPaths();
|
auto buildables = toBuildables();
|
||||||
if (buildables.size() != 1)
|
if (buildables.size() != 1)
|
||||||
throw Error("installable '%s' evaluates to %d derivations, where only one is expected", what(), buildables.size());
|
throw Error("installable '%s' evaluates to %d derivations, where only one is expected", what(), buildables.size());
|
||||||
return std::move(buildables[0]);
|
return std::move(buildables[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
|
||||||
Installable::getCursors(EvalState & state)
|
|
||||||
{
|
|
||||||
auto evalCache =
|
|
||||||
std::make_shared<nix::eval_cache::EvalCache>(std::nullopt, state,
|
|
||||||
[&]() { return toValue(state).first; });
|
|
||||||
return {{evalCache->getRoot(), ""}};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
|
||||||
Installable::getCursor(EvalState & state)
|
|
||||||
{
|
|
||||||
auto cursors = getCursors(state);
|
|
||||||
if (cursors.empty())
|
|
||||||
throw Error("cannot find flake attribute '%s'", what());
|
|
||||||
return cursors[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
struct InstallableStorePath : Installable
|
struct InstallableStorePath : Installable
|
||||||
{
|
{
|
||||||
ref<Store> store;
|
ref<Store> store;
|
||||||
@@ -348,19 +330,22 @@ struct InstallableStorePath : Installable
|
|||||||
|
|
||||||
std::string what() override { return store->printStorePath(storePath); }
|
std::string what() override { return store->printStorePath(storePath); }
|
||||||
|
|
||||||
DerivedPaths toDerivedPaths() override
|
Buildables toBuildables() override
|
||||||
{
|
{
|
||||||
if (storePath.isDerivation()) {
|
if (storePath.isDerivation()) {
|
||||||
|
std::map<std::string, std::optional<StorePath>> outputs;
|
||||||
auto drv = store->readDerivation(storePath);
|
auto drv = store->readDerivation(storePath);
|
||||||
|
for (auto & [name, output] : drv.outputsAndOptPaths(*store))
|
||||||
|
outputs.emplace(name, output.second);
|
||||||
return {
|
return {
|
||||||
DerivedPath::Built {
|
BuildableFromDrv {
|
||||||
.drvPath = storePath,
|
.drvPath = storePath,
|
||||||
.outputs = drv.outputNames(),
|
.outputs = std::move(outputs)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
DerivedPath::Opaque {
|
BuildableOpaque {
|
||||||
.path = storePath,
|
.path = storePath,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -373,24 +358,22 @@ struct InstallableStorePath : Installable
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DerivedPaths InstallableValue::toDerivedPaths()
|
Buildables InstallableValue::toBuildables()
|
||||||
{
|
{
|
||||||
DerivedPaths res;
|
Buildables res;
|
||||||
|
|
||||||
std::map<StorePath, std::set<std::string>> drvsToOutputs;
|
std::map<StorePath, std::map<std::string, std::optional<StorePath>>> drvsToOutputs;
|
||||||
RealisedPath::Set drvsToCopy;
|
|
||||||
|
|
||||||
// Group by derivation, helps with .all in particular
|
// Group by derivation, helps with .all in particular
|
||||||
for (auto & drv : toDerivations()) {
|
for (auto & drv : toDerivations()) {
|
||||||
auto outputName = drv.outputName;
|
auto outputName = drv.outputName;
|
||||||
if (outputName == "")
|
if (outputName == "")
|
||||||
throw Error("derivation '%s' lacks an 'outputName' attribute", state->store->printStorePath(drv.drvPath));
|
throw Error("derivation '%s' lacks an 'outputName' attribute", state->store->printStorePath(drv.drvPath));
|
||||||
drvsToOutputs[drv.drvPath].insert(outputName);
|
drvsToOutputs[drv.drvPath].insert_or_assign(outputName, drv.outPath);
|
||||||
drvsToCopy.insert(drv.drvPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & i : drvsToOutputs)
|
for (auto & i : drvsToOutputs)
|
||||||
res.push_back(DerivedPath::Built { i.first, i.second });
|
res.push_back(BuildableFromDrv { i.first, i.second });
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -407,11 +390,11 @@ struct InstallableAttrPath : InstallableValue
|
|||||||
|
|
||||||
std::string what() override { return attrPath; }
|
std::string what() override { return attrPath; }
|
||||||
|
|
||||||
std::pair<Value *, Pos> toValue(EvalState & state) override
|
std::vector<Installable::ValueInfo> toValues(EvalState & state) override
|
||||||
{
|
{
|
||||||
auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), **v);
|
auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), **v);
|
||||||
state.forceValue(*vRes);
|
state.forceValue(*vRes);
|
||||||
return {vRes, pos};
|
return {{vRes, pos, attrPath}};
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<InstallableValue::DerivationInfo> toDerivations() override;
|
virtual std::vector<InstallableValue::DerivationInfo> toDerivations() override;
|
||||||
@@ -419,7 +402,7 @@ struct InstallableAttrPath : InstallableValue
|
|||||||
|
|
||||||
std::vector<InstallableValue::DerivationInfo> InstallableAttrPath::toDerivations()
|
std::vector<InstallableValue::DerivationInfo> InstallableAttrPath::toDerivations()
|
||||||
{
|
{
|
||||||
auto v = toValue(*state).first;
|
auto v = toValue(*state).value;
|
||||||
|
|
||||||
Bindings & autoArgs = *cmd.getAutoArgs(*state);
|
Bindings & autoArgs = *cmd.getAutoArgs(*state);
|
||||||
|
|
||||||
@@ -453,45 +436,7 @@ std::vector<std::string> InstallableFlake::getActualAttrPaths()
|
|||||||
|
|
||||||
Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake)
|
Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake)
|
||||||
{
|
{
|
||||||
auto vFlake = state.allocValue();
|
return getFlakeValue(state, lockedFlake);
|
||||||
|
|
||||||
callFlake(state, lockedFlake, *vFlake);
|
|
||||||
|
|
||||||
auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs"));
|
|
||||||
assert(aOutputs);
|
|
||||||
|
|
||||||
state.forceValue(*aOutputs->value);
|
|
||||||
|
|
||||||
return aOutputs->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ref<eval_cache::EvalCache> openEvalCache(
|
|
||||||
EvalState & state,
|
|
||||||
std::shared_ptr<flake::LockedFlake> lockedFlake)
|
|
||||||
{
|
|
||||||
auto fingerprint = lockedFlake->getFingerprint();
|
|
||||||
return make_ref<nix::eval_cache::EvalCache>(
|
|
||||||
evalSettings.useEvalCache && evalSettings.pureEval
|
|
||||||
? std::optional { std::cref(fingerprint) }
|
|
||||||
: std::nullopt,
|
|
||||||
state,
|
|
||||||
[&state, lockedFlake]()
|
|
||||||
{
|
|
||||||
/* For testing whether the evaluation cache is
|
|
||||||
complete. */
|
|
||||||
if (getEnv("NIX_ALLOW_EVAL").value_or("1") == "0")
|
|
||||||
throw Error("not everything is cached, but evaluation is not allowed");
|
|
||||||
|
|
||||||
auto vFlake = state.allocValue();
|
|
||||||
flake::callFlake(state, *lockedFlake, *vFlake);
|
|
||||||
|
|
||||||
state.forceAttrs(*vFlake);
|
|
||||||
|
|
||||||
auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs"));
|
|
||||||
assert(aOutputs);
|
|
||||||
|
|
||||||
return aOutputs->value;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string showAttrPaths(const std::vector<std::string> & paths)
|
static std::string showAttrPaths(const std::vector<std::string> & paths)
|
||||||
@@ -504,54 +449,24 @@ static std::string showAttrPaths(const std::vector<std::string> & paths)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallableFlake::InstallableFlake(
|
|
||||||
SourceExprCommand * cmd,
|
|
||||||
ref<EvalState> state,
|
|
||||||
FlakeRef && flakeRef,
|
|
||||||
Strings && attrPaths,
|
|
||||||
Strings && prefixes,
|
|
||||||
const flake::LockFlags & lockFlags)
|
|
||||||
: InstallableValue(state),
|
|
||||||
flakeRef(flakeRef),
|
|
||||||
attrPaths(attrPaths),
|
|
||||||
prefixes(prefixes),
|
|
||||||
lockFlags(lockFlags)
|
|
||||||
{
|
|
||||||
if (cmd && cmd->getAutoArgs(*state)->size())
|
|
||||||
throw UsageError("'--arg' and '--argstr' are incompatible with flakes");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableFlake::toDerivation()
|
std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableFlake::toDerivation()
|
||||||
{
|
{
|
||||||
auto lockedFlake = getLockedFlake();
|
auto lockedFlake = getLockedFlake();
|
||||||
|
|
||||||
auto cache = openEvalCache(*state, lockedFlake);
|
auto flakeValue = toValue(*state);
|
||||||
auto root = cache->getRoot();
|
|
||||||
|
|
||||||
for (auto & attrPath : getActualAttrPaths()) {
|
auto rawDrvInfo = getDerivation(*state, *flakeValue.value, false);
|
||||||
auto attr = root->findAlongAttrPath(
|
if (!rawDrvInfo)
|
||||||
parseAttrPath(*state, attrPath),
|
throw Error("flake output attribute '%s' is not a derivation", flakeValue.positionInfo);
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!attr) continue;
|
auto drvInfo = InstallableValue::DerivationInfo
|
||||||
|
{
|
||||||
|
state->store->parseStorePath(rawDrvInfo->queryDrvPath()),
|
||||||
|
state->store->maybeParseStorePath(rawDrvInfo->queryOutPath()),
|
||||||
|
rawDrvInfo->queryOutputName()
|
||||||
|
};
|
||||||
|
|
||||||
if (!attr->isDerivation())
|
return {flakeValue.positionInfo, lockedFlake->flake.lockedRef, std::move(drvInfo)};
|
||||||
throw Error("flake output attribute '%s' is not a derivation", attrPath);
|
|
||||||
|
|
||||||
auto drvPath = attr->forceDerivation();
|
|
||||||
|
|
||||||
auto drvInfo = DerivationInfo{
|
|
||||||
std::move(drvPath),
|
|
||||||
state->store->maybeParseStorePath(attr->getAttr(state->sOutPath)->getString()),
|
|
||||||
attr->getAttr(state->sOutputName)->getString()
|
|
||||||
};
|
|
||||||
|
|
||||||
return {attrPath, lockedFlake->flake.lockedRef, std::move(drvInfo)};
|
|
||||||
}
|
|
||||||
|
|
||||||
throw Error("flake '%s' does not provide attribute %s",
|
|
||||||
flakeRef, showAttrPaths(getActualAttrPaths()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations()
|
std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations()
|
||||||
@@ -561,8 +476,20 @@ std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state)
|
Installable::ValueInfo InstallableFlake::toValue(EvalState & state)
|
||||||
{
|
{
|
||||||
|
auto values = toValues(state);
|
||||||
|
if (values.empty())
|
||||||
|
throw Error("flake '%s' does not provide attribute %s",
|
||||||
|
flakeRef, showAttrPaths(getActualAttrPaths()));
|
||||||
|
return values[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Installable::ValueInfo>
|
||||||
|
InstallableFlake::toValues(EvalState & state)
|
||||||
|
{
|
||||||
|
std::vector<Installable::ValueInfo> res;
|
||||||
auto lockedFlake = getLockedFlake();
|
auto lockedFlake = getLockedFlake();
|
||||||
|
|
||||||
auto vOutputs = getFlakeOutputs(state, *lockedFlake);
|
auto vOutputs = getFlakeOutputs(state, *lockedFlake);
|
||||||
@@ -573,39 +500,20 @@ std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state)
|
|||||||
try {
|
try {
|
||||||
auto [v, pos] = findAlongAttrPath(state, attrPath, *emptyArgs, *vOutputs);
|
auto [v, pos] = findAlongAttrPath(state, attrPath, *emptyArgs, *vOutputs);
|
||||||
state.forceValue(*v);
|
state.forceValue(*v);
|
||||||
return {v, pos};
|
res.push_back({v, pos, attrPath});
|
||||||
} catch (AttrPathNotFound & e) {
|
} catch (AttrPathNotFound & e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Error("flake '%s' does not provide attribute %s",
|
|
||||||
flakeRef, showAttrPaths(getActualAttrPaths()));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
|
||||||
InstallableFlake::getCursors(EvalState & state)
|
|
||||||
{
|
|
||||||
auto evalCache = openEvalCache(state,
|
|
||||||
std::make_shared<flake::LockedFlake>(lockFlake(state, flakeRef, lockFlags)));
|
|
||||||
|
|
||||||
auto root = evalCache->getRoot();
|
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>> res;
|
|
||||||
|
|
||||||
for (auto & attrPath : getActualAttrPaths()) {
|
|
||||||
auto attr = root->findAlongAttrPath(parseAttrPath(state, attrPath));
|
|
||||||
if (attr) res.push_back({attr, attrPath});
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<flake::LockedFlake> InstallableFlake::getLockedFlake() const
|
std::shared_ptr<flake::LockedFlake> InstallableFlake::getLockedFlake() const
|
||||||
{
|
{
|
||||||
flake::LockFlags lockFlagsApplyConfig = lockFlags;
|
|
||||||
lockFlagsApplyConfig.applyNixConfig = true;
|
|
||||||
if (!_lockedFlake) {
|
if (!_lockedFlake) {
|
||||||
_lockedFlake = std::make_shared<flake::LockedFlake>(lockFlake(*state, flakeRef, lockFlagsApplyConfig));
|
_lockedFlake = std::make_shared<flake::LockedFlake>(lockFlake(*state, flakeRef, lockFlags));
|
||||||
|
_lockedFlake->flake.config.apply();
|
||||||
|
// FIXME: send new config to the daemon.
|
||||||
}
|
}
|
||||||
return _lockedFlake;
|
return _lockedFlake;
|
||||||
}
|
}
|
||||||
@@ -654,6 +562,17 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
|||||||
for (auto & s : ss) {
|
for (auto & s : ss) {
|
||||||
std::exception_ptr ex;
|
std::exception_ptr ex;
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto [flakeRef, fragment] = parseFlakeRefWithFragment(s, absPath("."));
|
||||||
|
result.push_back(std::make_shared<InstallableFlake>(
|
||||||
|
getEvalState(), std::move(flakeRef),
|
||||||
|
fragment == "" ? getDefaultFlakeAttrPaths() : Strings{fragment},
|
||||||
|
getDefaultFlakeAttrPathPrefixes(), lockFlags));
|
||||||
|
continue;
|
||||||
|
} catch (...) {
|
||||||
|
ex = std::current_exception();
|
||||||
|
}
|
||||||
|
|
||||||
if (s.find('/') != std::string::npos) {
|
if (s.find('/') != std::string::npos) {
|
||||||
try {
|
try {
|
||||||
result.push_back(std::make_shared<InstallableStorePath>(store, store->followLinksToStorePath(s)));
|
result.push_back(std::make_shared<InstallableStorePath>(store, store->followLinksToStorePath(s)));
|
||||||
@@ -665,21 +584,14 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
auto [flakeRef, fragment] = parseFlakeRefWithFragment(s, absPath("."));
|
|
||||||
result.push_back(std::make_shared<InstallableFlake>(
|
|
||||||
this,
|
|
||||||
getEvalState(),
|
|
||||||
std::move(flakeRef),
|
|
||||||
fragment == "" ? getDefaultFlakeAttrPaths() : Strings{fragment},
|
|
||||||
getDefaultFlakeAttrPathPrefixes(),
|
|
||||||
lockFlags));
|
|
||||||
continue;
|
|
||||||
} catch (...) {
|
|
||||||
ex = std::current_exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::rethrow_exception(ex);
|
std::rethrow_exception(ex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
throw Error(
|
||||||
|
pathExists(s)
|
||||||
|
? "path '%s' is not a flake or a store path"
|
||||||
|
: "don't know how to handle argument '%s'", s);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,121 +606,108 @@ std::shared_ptr<Installable> SourceExprCommand::parseInstallable(
|
|||||||
return installables.front();
|
return installables.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltPaths getBuiltPaths(ref<Store> evalStore, ref<Store> store, const DerivedPaths & hopefullyBuiltPaths)
|
Buildables build(ref<Store> store, Realise mode,
|
||||||
{
|
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode)
|
||||||
BuiltPaths res;
|
|
||||||
for (const auto & b : hopefullyBuiltPaths)
|
|
||||||
std::visit(
|
|
||||||
overloaded{
|
|
||||||
[&](const DerivedPath::Opaque & bo) {
|
|
||||||
res.push_back(BuiltPath::Opaque{bo.path});
|
|
||||||
},
|
|
||||||
[&](const DerivedPath::Built & bfd) {
|
|
||||||
OutputPathMap outputs;
|
|
||||||
auto drv = evalStore->readDerivation(bfd.drvPath);
|
|
||||||
auto outputHashes = staticOutputHashes(*evalStore, drv); // FIXME: expensive
|
|
||||||
auto drvOutputs = drv.outputsAndOptPaths(*store);
|
|
||||||
for (auto & output : bfd.outputs) {
|
|
||||||
if (!outputHashes.count(output))
|
|
||||||
throw Error(
|
|
||||||
"the derivation '%s' doesn't have an output named '%s'",
|
|
||||||
store->printStorePath(bfd.drvPath), output);
|
|
||||||
if (settings.isExperimentalFeatureEnabled(
|
|
||||||
Xp::CaDerivations)) {
|
|
||||||
auto outputId =
|
|
||||||
DrvOutput{outputHashes.at(output), output};
|
|
||||||
auto realisation =
|
|
||||||
store->queryRealisation(outputId);
|
|
||||||
if (!realisation)
|
|
||||||
throw Error(
|
|
||||||
"cannot operate on an output of unbuilt "
|
|
||||||
"content-addressed derivation '%s'",
|
|
||||||
outputId.to_string());
|
|
||||||
outputs.insert_or_assign(
|
|
||||||
output, realisation->outPath);
|
|
||||||
} else {
|
|
||||||
// If ca-derivations isn't enabled, assume that
|
|
||||||
// the output path is statically known.
|
|
||||||
assert(drvOutputs.count(output));
|
|
||||||
assert(drvOutputs.at(output).second);
|
|
||||||
outputs.insert_or_assign(
|
|
||||||
output, *drvOutputs.at(output).second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.push_back(BuiltPath::Built{bfd.drvPath, outputs});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
b.raw());
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
BuiltPaths build(
|
|
||||||
ref<Store> evalStore,
|
|
||||||
ref<Store> store,
|
|
||||||
Realise mode,
|
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables,
|
|
||||||
BuildMode bMode)
|
|
||||||
{
|
{
|
||||||
if (mode == Realise::Nothing)
|
if (mode == Realise::Nothing)
|
||||||
settings.readOnlyMode = true;
|
settings.readOnlyMode = true;
|
||||||
|
|
||||||
std::vector<DerivedPath> pathsToBuild;
|
Buildables buildables;
|
||||||
|
|
||||||
|
std::vector<StorePathWithOutputs> pathsToBuild;
|
||||||
|
|
||||||
for (auto & i : installables) {
|
for (auto & i : installables) {
|
||||||
auto b = i->toDerivedPaths();
|
for (auto & b : i->toBuildables()) {
|
||||||
pathsToBuild.insert(pathsToBuild.end(), b.begin(), b.end());
|
std::visit(overloaded {
|
||||||
|
[&](BuildableOpaque bo) {
|
||||||
|
pathsToBuild.push_back({bo.path});
|
||||||
|
},
|
||||||
|
[&](BuildableFromDrv bfd) {
|
||||||
|
StringSet outputNames;
|
||||||
|
for (auto & output : bfd.outputs)
|
||||||
|
outputNames.insert(output.first);
|
||||||
|
pathsToBuild.push_back({bfd.drvPath, outputNames});
|
||||||
|
},
|
||||||
|
}, b);
|
||||||
|
buildables.push_back(std::move(b));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Realise::Nothing || mode == Realise::Derivation)
|
if (mode == Realise::Nothing)
|
||||||
printMissing(store, pathsToBuild, lvlError);
|
printMissing(store, pathsToBuild, lvlError);
|
||||||
else if (mode == Realise::Outputs)
|
else if (mode == Realise::Outputs)
|
||||||
store->buildPaths(pathsToBuild, bMode, evalStore);
|
store->buildPaths(pathsToBuild, bMode);
|
||||||
|
|
||||||
return getBuiltPaths(evalStore, store, pathsToBuild);
|
return buildables;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltPaths toBuiltPaths(
|
std::set<RealisedPath> toRealisedPaths(
|
||||||
ref<Store> evalStore,
|
|
||||||
ref<Store> store,
|
ref<Store> store,
|
||||||
Realise mode,
|
Realise mode,
|
||||||
OperateOn operateOn,
|
OperateOn operateOn,
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables)
|
std::vector<std::shared_ptr<Installable>> installables)
|
||||||
{
|
{
|
||||||
if (operateOn == OperateOn::Output)
|
std::set<RealisedPath> res;
|
||||||
return build(evalStore, store, mode, installables);
|
if (operateOn == OperateOn::Output) {
|
||||||
else {
|
for (auto & b : build(store, mode, installables))
|
||||||
|
std::visit(overloaded {
|
||||||
|
[&](BuildableOpaque bo) {
|
||||||
|
res.insert(bo.path);
|
||||||
|
},
|
||||||
|
[&](BuildableFromDrv bfd) {
|
||||||
|
auto drv = store->readDerivation(bfd.drvPath);
|
||||||
|
auto outputHashes = staticOutputHashes(*store, drv);
|
||||||
|
for (auto & output : bfd.outputs) {
|
||||||
|
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
||||||
|
if (!outputHashes.count(output.first))
|
||||||
|
throw Error(
|
||||||
|
"the derivation '%s' doesn't have an output named '%s'",
|
||||||
|
store->printStorePath(bfd.drvPath),
|
||||||
|
output.first);
|
||||||
|
auto outputId = DrvOutput{outputHashes.at(output.first), output.first};
|
||||||
|
auto realisation = store->queryRealisation(outputId);
|
||||||
|
if (!realisation)
|
||||||
|
throw Error("cannot operate on an output of unbuilt content-addresed derivation '%s'", outputId.to_string());
|
||||||
|
res.insert(RealisedPath{*realisation});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// If ca-derivations isn't enabled, behave as if
|
||||||
|
// all the paths are opaque to keep the default
|
||||||
|
// behavior
|
||||||
|
assert(output.second);
|
||||||
|
res.insert(*output.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, b);
|
||||||
|
} else {
|
||||||
if (mode == Realise::Nothing)
|
if (mode == Realise::Nothing)
|
||||||
settings.readOnlyMode = true;
|
settings.readOnlyMode = true;
|
||||||
|
|
||||||
BuiltPaths res;
|
for (auto & i : installables)
|
||||||
for (auto & drvPath : toDerivations(store, installables, true))
|
for (auto & b : i->toBuildables())
|
||||||
res.push_back(BuiltPath::Opaque{drvPath});
|
if (auto bfd = std::get_if<BuildableFromDrv>(&b))
|
||||||
return res;
|
res.insert(bfd->drvPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathSet toStorePaths(
|
StorePathSet toStorePaths(ref<Store> store,
|
||||||
ref<Store> evalStore,
|
|
||||||
ref<Store> store,
|
|
||||||
Realise mode, OperateOn operateOn,
|
Realise mode, OperateOn operateOn,
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables)
|
std::vector<std::shared_ptr<Installable>> installables)
|
||||||
{
|
{
|
||||||
StorePathSet outPaths;
|
StorePathSet outPaths;
|
||||||
for (auto & path : toBuiltPaths(evalStore, store, mode, operateOn, installables)) {
|
for (auto & path : toRealisedPaths(store, mode, operateOn, installables))
|
||||||
auto thisOutPaths = path.outPaths();
|
outPaths.insert(path.path());
|
||||||
outPaths.insert(thisOutPaths.begin(), thisOutPaths.end());
|
|
||||||
}
|
|
||||||
return outPaths;
|
return outPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePath toStorePath(
|
StorePath toStorePath(ref<Store> store,
|
||||||
ref<Store> evalStore,
|
|
||||||
ref<Store> store,
|
|
||||||
Realise mode, OperateOn operateOn,
|
Realise mode, OperateOn operateOn,
|
||||||
std::shared_ptr<Installable> installable)
|
std::shared_ptr<Installable> installable)
|
||||||
{
|
{
|
||||||
auto paths = toStorePaths(evalStore, store, mode, operateOn, {installable});
|
auto paths = toStorePaths(store, mode, operateOn, {installable});
|
||||||
|
|
||||||
if (paths.size() != 1)
|
if (paths.size() != 1)
|
||||||
throw Error("argument '%s' should evaluate to one store path", installable->what());
|
throw Error("argument '%s' should evaluate to one store path", installable->what());
|
||||||
@@ -816,17 +715,15 @@ StorePath toStorePath(
|
|||||||
return *paths.begin();
|
return *paths.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathSet toDerivations(
|
StorePathSet toDerivations(ref<Store> store,
|
||||||
ref<Store> store,
|
std::vector<std::shared_ptr<Installable>> installables, bool useDeriver)
|
||||||
const std::vector<std::shared_ptr<Installable>> & installables,
|
|
||||||
bool useDeriver)
|
|
||||||
{
|
{
|
||||||
StorePathSet drvPaths;
|
StorePathSet drvPaths;
|
||||||
|
|
||||||
for (const auto & i : installables)
|
for (auto & i : installables)
|
||||||
for (const auto & b : i->toDerivedPaths())
|
for (auto & b : i->toBuildables())
|
||||||
std::visit(overloaded {
|
std::visit(overloaded {
|
||||||
[&](const DerivedPath::Opaque & bo) {
|
[&](BuildableOpaque bo) {
|
||||||
if (!useDeriver)
|
if (!useDeriver)
|
||||||
throw Error("argument '%s' did not evaluate to a derivation", i->what());
|
throw Error("argument '%s' did not evaluate to a derivation", i->what());
|
||||||
auto derivers = store->queryValidDerivers(bo.path);
|
auto derivers = store->queryValidDerivers(bo.path);
|
||||||
@@ -835,10 +732,10 @@ StorePathSet toDerivations(
|
|||||||
// FIXME: use all derivers?
|
// FIXME: use all derivers?
|
||||||
drvPaths.insert(*derivers.begin());
|
drvPaths.insert(*derivers.begin());
|
||||||
},
|
},
|
||||||
[&](const DerivedPath::Built & bfd) {
|
[&](BuildableFromDrv bfd) {
|
||||||
drvPaths.insert(bfd.drvPath);
|
drvPaths.insert(bfd.drvPath);
|
||||||
},
|
},
|
||||||
}, b.raw());
|
}, b);
|
||||||
|
|
||||||
return drvPaths;
|
return drvPaths;
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-32
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
#include "path.hh"
|
#include "path.hh"
|
||||||
#include "path-with-outputs.hh"
|
|
||||||
#include "derived-path.hh"
|
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
#include "flake/flake.hh"
|
#include "flake/flake.hh"
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
struct DrvInfo;
|
struct DrvInfo;
|
||||||
@@ -16,6 +16,25 @@ struct SourceExprCommand;
|
|||||||
|
|
||||||
namespace eval_cache { class EvalCache; class AttrCursor; }
|
namespace eval_cache { class EvalCache; class AttrCursor; }
|
||||||
|
|
||||||
|
struct BuildableOpaque {
|
||||||
|
StorePath path;
|
||||||
|
nlohmann::json toJSON(ref<Store> store) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BuildableFromDrv {
|
||||||
|
StorePath drvPath;
|
||||||
|
std::map<std::string, std::optional<StorePath>> outputs;
|
||||||
|
nlohmann::json toJSON(ref<Store> store) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::variant<
|
||||||
|
BuildableOpaque,
|
||||||
|
BuildableFromDrv
|
||||||
|
> Buildable;
|
||||||
|
|
||||||
|
typedef std::vector<Buildable> Buildables;
|
||||||
|
nlohmann::json buildablesToJSON(const Buildables & buildables, ref<Store> store);
|
||||||
|
|
||||||
struct App
|
struct App
|
||||||
{
|
{
|
||||||
std::vector<StorePathWithOutputs> context;
|
std::vector<StorePathWithOutputs> context;
|
||||||
@@ -23,25 +42,35 @@ struct App
|
|||||||
// FIXME: add args, sandbox settings, metadata, ...
|
// FIXME: add args, sandbox settings, metadata, ...
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UnresolvedApp
|
|
||||||
{
|
|
||||||
App unresolved;
|
|
||||||
App resolve(ref<Store> evalStore, ref<Store> store);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Installable
|
struct Installable
|
||||||
{
|
{
|
||||||
virtual ~Installable() { }
|
virtual ~Installable() { }
|
||||||
|
|
||||||
virtual std::string what() = 0;
|
virtual std::string what() = 0;
|
||||||
|
|
||||||
virtual DerivedPaths toDerivedPaths() = 0;
|
virtual Buildables toBuildables() = 0;
|
||||||
|
|
||||||
DerivedPath toDerivedPath();
|
Buildable toBuildable();
|
||||||
|
|
||||||
UnresolvedApp toApp(EvalState & state);
|
App toApp(EvalState & state);
|
||||||
|
|
||||||
virtual std::pair<Value *, Pos> toValue(EvalState & state)
|
struct ValueInfo {
|
||||||
|
Value * value;
|
||||||
|
Pos pos;
|
||||||
|
string positionInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual ValueInfo toValue(EvalState & state)
|
||||||
|
{
|
||||||
|
auto values = toValues(state);
|
||||||
|
if (values.empty())
|
||||||
|
throw Error("Installable '%s' does not provide a default value",
|
||||||
|
what());
|
||||||
|
return values[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::vector<ValueInfo>
|
||||||
|
toValues(EvalState & state)
|
||||||
{
|
{
|
||||||
throw Error("argument '%s' cannot be evaluated", what());
|
throw Error("argument '%s' cannot be evaluated", what());
|
||||||
}
|
}
|
||||||
@@ -53,11 +82,6 @@ struct Installable
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
|
||||||
getCursors(EvalState & state);
|
|
||||||
|
|
||||||
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
|
||||||
getCursor(EvalState & state);
|
|
||||||
|
|
||||||
virtual FlakeRef nixpkgsFlakeRef() const
|
virtual FlakeRef nixpkgsFlakeRef() const
|
||||||
{
|
{
|
||||||
@@ -80,7 +104,7 @@ struct InstallableValue : Installable
|
|||||||
|
|
||||||
virtual std::vector<DerivationInfo> toDerivations() = 0;
|
virtual std::vector<DerivationInfo> toDerivations() = 0;
|
||||||
|
|
||||||
DerivedPaths toDerivedPaths() override;
|
Buildables toBuildables() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InstallableFlake : InstallableValue
|
struct InstallableFlake : InstallableValue
|
||||||
@@ -91,13 +115,11 @@ struct InstallableFlake : InstallableValue
|
|||||||
const flake::LockFlags & lockFlags;
|
const flake::LockFlags & lockFlags;
|
||||||
mutable std::shared_ptr<flake::LockedFlake> _lockedFlake;
|
mutable std::shared_ptr<flake::LockedFlake> _lockedFlake;
|
||||||
|
|
||||||
InstallableFlake(
|
InstallableFlake(ref<EvalState> state, FlakeRef && flakeRef,
|
||||||
SourceExprCommand * cmd,
|
Strings && attrPaths, Strings && prefixes, const flake::LockFlags & lockFlags)
|
||||||
ref<EvalState> state,
|
: InstallableValue(state), flakeRef(flakeRef), attrPaths(attrPaths),
|
||||||
FlakeRef && flakeRef,
|
prefixes(prefixes), lockFlags(lockFlags)
|
||||||
Strings && attrPaths,
|
{ }
|
||||||
Strings && prefixes,
|
|
||||||
const flake::LockFlags & lockFlags);
|
|
||||||
|
|
||||||
std::string what() override { return flakeRef.to_string() + "#" + *attrPaths.begin(); }
|
std::string what() override { return flakeRef.to_string() + "#" + *attrPaths.begin(); }
|
||||||
|
|
||||||
@@ -109,18 +131,14 @@ struct InstallableFlake : InstallableValue
|
|||||||
|
|
||||||
std::vector<DerivationInfo> toDerivations() override;
|
std::vector<DerivationInfo> toDerivations() override;
|
||||||
|
|
||||||
std::pair<Value *, Pos> toValue(EvalState & state) override;
|
ValueInfo toValue(EvalState & state) override;
|
||||||
|
|
||||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
std::vector<ValueInfo>
|
||||||
getCursors(EvalState & state) override;
|
toValues(EvalState & state) override;
|
||||||
|
|
||||||
std::shared_ptr<flake::LockedFlake> getLockedFlake() const;
|
std::shared_ptr<flake::LockedFlake> getLockedFlake() const;
|
||||||
|
|
||||||
FlakeRef nixpkgsFlakeRef() const override;
|
FlakeRef nixpkgsFlakeRef() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
ref<eval_cache::EvalCache> openEvalCache(
|
|
||||||
EvalState & state,
|
|
||||||
std::shared_ptr<flake::LockedFlake> lockedFlake);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -8,8 +8,8 @@ libcmd_SOURCES := $(wildcard $(d)/*.cc)
|
|||||||
|
|
||||||
libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers
|
libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers
|
||||||
|
|
||||||
libcmd_LDFLAGS += -llowdown -pthread
|
libcmd_LDFLAGS = -llowdown
|
||||||
|
|
||||||
libcmd_LIBS = libstore libutil libexpr libmain libfetchers
|
libcmd_LIBS = libstore libutil libexpr libmain libfetchers
|
||||||
|
|
||||||
$(eval $(call install-file-in, $(d)/nix-cmd.pc, $(libdir)/pkgconfig, 0644))
|
$(eval $(call install-file-in, $(d)/nix-cmd.pc, $(prefix)/lib/pkgconfig, 0644))
|
||||||
@@ -12,7 +12,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
|
|||||||
struct lowdown_opts opts {
|
struct lowdown_opts opts {
|
||||||
.type = LOWDOWN_TERM,
|
.type = LOWDOWN_TERM,
|
||||||
.maxdepth = 20,
|
.maxdepth = 20,
|
||||||
.cols = std::max(getWindowSize().second, (unsigned short) 80),
|
.cols = std::min(getWindowSize().second, (unsigned short) 80),
|
||||||
.hmargin = 0,
|
.hmargin = 0,
|
||||||
.vmargin = 0,
|
.vmargin = 0,
|
||||||
.feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,
|
.feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,
|
||||||
@@ -25,7 +25,7 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
|
|||||||
Finally freeDoc([&]() { lowdown_doc_free(doc); });
|
Finally freeDoc([&]() { lowdown_doc_free(doc); });
|
||||||
|
|
||||||
size_t maxn = 0;
|
size_t maxn = 0;
|
||||||
auto node = lowdown_doc_parse(doc, &maxn, markdown.data(), markdown.size(), nullptr);
|
auto node = lowdown_doc_parse(doc, &maxn, markdown.data(), markdown.size());
|
||||||
if (!node)
|
if (!node)
|
||||||
throw Error("cannot parse Markdown document");
|
throw Error("cannot parse Markdown document");
|
||||||
Finally freeNode([&]() { lowdown_node_free(node); });
|
Finally freeNode([&]() { lowdown_node_free(node); });
|
||||||
@@ -40,11 +40,11 @@ std::string renderMarkdownToTerminal(std::string_view markdown)
|
|||||||
throw Error("cannot allocate Markdown output buffer");
|
throw Error("cannot allocate Markdown output buffer");
|
||||||
Finally freeBuffer([&]() { lowdown_buf_free(buf); });
|
Finally freeBuffer([&]() { lowdown_buf_free(buf); });
|
||||||
|
|
||||||
int rndr_res = lowdown_term_rndr(buf, renderer, node);
|
int rndr_res = lowdown_term_rndr(buf, nullptr, renderer, node);
|
||||||
if (!rndr_res)
|
if (!rndr_res)
|
||||||
throw Error("allocation error while rendering Markdown");
|
throw Error("allocation error while rendering Markdown");
|
||||||
|
|
||||||
return filterANSIEscapes(std::string(buf->data, buf->size), !shouldANSI());
|
return std::string(buf->data, buf->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ static Strings parseAttrPath(std::string_view s)
|
|||||||
++i;
|
++i;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (i == s.end())
|
if (i == s.end())
|
||||||
throw ParseError("missing closing quote in selection path '%1%'", s);
|
throw Error("missing closing quote in selection path '%1%'", s);
|
||||||
if (*i == '"') break;
|
if (*i == '"') break;
|
||||||
cur.push_back(*i++);
|
cur.push_back(*i++);
|
||||||
}
|
}
|
||||||
@@ -73,11 +73,12 @@ std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attr
|
|||||||
if (attr.empty())
|
if (attr.empty())
|
||||||
throw Error("empty attribute name in selection path '%1%'", attrPath);
|
throw Error("empty attribute name in selection path '%1%'", attrPath);
|
||||||
|
|
||||||
Bindings::iterator a = v->attrs->find(state.symbols.create(attr));
|
Value * vRes = state.allocValue();
|
||||||
if (a == v->attrs->end())
|
auto getResult = state.getOptionalAttrField(*v, {state.symbols.create(attr)}, pos, *vRes);
|
||||||
|
if (getResult.error)
|
||||||
throw AttrPathNotFound("attribute '%1%' in selection path '%2%' not found", attr, attrPath);
|
throw AttrPathNotFound("attribute '%1%' in selection path '%2%' not found", attr, attrPath);
|
||||||
v = &*a->value;
|
v = vRes;
|
||||||
pos = *a->pos;
|
pos = *getResult.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@@ -100,7 +101,7 @@ std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pos findPackageFilename(EvalState & state, Value & v, std::string what)
|
Pos findDerivationFilename(EvalState & state, Value & v, std::string what)
|
||||||
{
|
{
|
||||||
Value * v2;
|
Value * v2;
|
||||||
try {
|
try {
|
||||||
@@ -116,14 +117,14 @@ Pos findPackageFilename(EvalState & state, Value & v, std::string what)
|
|||||||
|
|
||||||
auto colon = pos.rfind(':');
|
auto colon = pos.rfind(':');
|
||||||
if (colon == std::string::npos)
|
if (colon == std::string::npos)
|
||||||
throw ParseError("cannot parse meta.position attribute '%s'", pos);
|
throw Error("cannot parse meta.position attribute '%s'", pos);
|
||||||
|
|
||||||
std::string filename(pos, 0, colon);
|
std::string filename(pos, 0, colon);
|
||||||
unsigned int lineno;
|
unsigned int lineno;
|
||||||
try {
|
try {
|
||||||
lineno = std::stoi(std::string(pos, colon + 1));
|
lineno = std::stoi(std::string(pos, colon + 1));
|
||||||
} catch (std::invalid_argument & e) {
|
} catch (std::invalid_argument & e) {
|
||||||
throw ParseError("cannot parse line number '%s'", pos);
|
throw Error("cannot parse line number '%s'", pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol file = state.symbols.create(filename);
|
Symbol file = state.symbols.create(filename);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attr
|
|||||||
Bindings & autoArgs, Value & vIn);
|
Bindings & autoArgs, Value & vIn);
|
||||||
|
|
||||||
/* Heuristic to find the filename and lineno or a nix value. */
|
/* Heuristic to find the filename and lineno or a nix value. */
|
||||||
Pos findPackageFilename(EvalState & state, Value & v, std::string what);
|
Pos findDerivationFilename(EvalState & state, Value & v, std::string what);
|
||||||
|
|
||||||
std::vector<Symbol> parseAttrPath(EvalState & state, std::string_view s);
|
std::vector<Symbol> parseAttrPath(EvalState & state, std::string_view s);
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ struct Attr
|
|||||||
{
|
{
|
||||||
Symbol name;
|
Symbol name;
|
||||||
Value * value;
|
Value * value;
|
||||||
ptr<Pos> pos;
|
Pos * pos;
|
||||||
Attr(Symbol name, Value * value, ptr<Pos> pos = ptr(&noPos))
|
Attr(Symbol name, Value * value, Pos * pos = &noPos)
|
||||||
: name(name), value(value), pos(pos) { };
|
: name(name), value(value), pos(pos) { };
|
||||||
Attr() : pos(&noPos) { };
|
Attr() : pos(&noPos) { };
|
||||||
bool operator < (const Attr & a) const
|
bool operator < (const Attr & a) const
|
||||||
@@ -35,13 +35,16 @@ class Bindings
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef uint32_t size_t;
|
typedef uint32_t size_t;
|
||||||
ptr<Pos> pos;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t size_, capacity_;
|
size_t size_, capacity_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
Attr attrs[0];
|
Attr attrs[0];
|
||||||
|
|
||||||
Bindings(size_t capacity) : pos(&noPos), size_(0), capacity_(capacity) { }
|
Bindings(size_t capacity) : size_(0), capacity_(capacity) { }
|
||||||
Bindings(const Bindings & bindings) = delete;
|
Bindings(const Bindings & bindings) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -61,14 +61,6 @@ MixEvalArgs::MixEvalArgs()
|
|||||||
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
|
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
|
||||||
}}
|
}}
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
|
||||||
.longName = "eval-store",
|
|
||||||
.description = "The Nix store to use for evaluations.",
|
|
||||||
.category = category,
|
|
||||||
.labels = {"store-url"},
|
|
||||||
.handler = {&evalStoreUrl},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
|
Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ struct MixEvalArgs : virtual Args
|
|||||||
|
|
||||||
Strings searchPath;
|
Strings searchPath;
|
||||||
|
|
||||||
std::optional<std::string> evalStoreUrl;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<std::string, std::string> autoArgs;
|
std::map<std::string, std::string> autoArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include "context.hh"
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
/* Decode a context string ‘!<name>!<path>’ into a pair <path,
|
||||||
|
name>. */
|
||||||
|
std::pair<string, string> decodeContext(std::string_view s)
|
||||||
|
{
|
||||||
|
if (s.at(0) == '!') {
|
||||||
|
size_t index = s.find("!", 1);
|
||||||
|
return {std::string(s.substr(index + 1)), std::string(s.substr(1, index - 1))};
|
||||||
|
} else
|
||||||
|
return {s.at(0) == '/' ? std::string(s) : std::string(s.substr(1)), ""};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string encodeContext(std::string_view name, std::string_view path)
|
||||||
|
{
|
||||||
|
return "!" + std::string(name) + "!" + std::string(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include "util.hh"
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
/* Decode a context string ‘!<name>!<path>’ into a pair <path,
|
||||||
|
name>. */
|
||||||
|
std::pair<string, string> decodeContext(std::string_view s);
|
||||||
|
|
||||||
|
std::string encodeContext(std::string_view name, std::string_view path);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,629 +0,0 @@
|
|||||||
#include "eval-cache.hh"
|
|
||||||
#include "sqlite.hh"
|
|
||||||
#include "eval.hh"
|
|
||||||
#include "eval-inline.hh"
|
|
||||||
#include "store-api.hh"
|
|
||||||
|
|
||||||
namespace nix::eval_cache {
|
|
||||||
|
|
||||||
static const char * schema = R"sql(
|
|
||||||
create table if not exists Attributes (
|
|
||||||
parent integer not null,
|
|
||||||
name text,
|
|
||||||
type integer not null,
|
|
||||||
value text,
|
|
||||||
context text,
|
|
||||||
primary key (parent, name)
|
|
||||||
);
|
|
||||||
)sql";
|
|
||||||
|
|
||||||
struct AttrDb
|
|
||||||
{
|
|
||||||
std::atomic_bool failed{false};
|
|
||||||
|
|
||||||
struct State
|
|
||||||
{
|
|
||||||
SQLite db;
|
|
||||||
SQLiteStmt insertAttribute;
|
|
||||||
SQLiteStmt insertAttributeWithContext;
|
|
||||||
SQLiteStmt queryAttribute;
|
|
||||||
SQLiteStmt queryAttributes;
|
|
||||||
std::unique_ptr<SQLiteTxn> txn;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<Sync<State>> _state;
|
|
||||||
|
|
||||||
AttrDb(const Hash & fingerprint)
|
|
||||||
: _state(std::make_unique<Sync<State>>())
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
Path cacheDir = getCacheDir() + "/nix/eval-cache-v2";
|
|
||||||
createDirs(cacheDir);
|
|
||||||
|
|
||||||
Path dbPath = cacheDir + "/" + fingerprint.to_string(Base16, false) + ".sqlite";
|
|
||||||
|
|
||||||
state->db = SQLite(dbPath);
|
|
||||||
state->db.isCache();
|
|
||||||
state->db.exec(schema);
|
|
||||||
|
|
||||||
state->insertAttribute.create(state->db,
|
|
||||||
"insert or replace into Attributes(parent, name, type, value) values (?, ?, ?, ?)");
|
|
||||||
|
|
||||||
state->insertAttributeWithContext.create(state->db,
|
|
||||||
"insert or replace into Attributes(parent, name, type, value, context) values (?, ?, ?, ?, ?)");
|
|
||||||
|
|
||||||
state->queryAttribute.create(state->db,
|
|
||||||
"select rowid, type, value, context from Attributes where parent = ? and name = ?");
|
|
||||||
|
|
||||||
state->queryAttributes.create(state->db,
|
|
||||||
"select name from Attributes where parent = ?");
|
|
||||||
|
|
||||||
state->txn = std::make_unique<SQLiteTxn>(state->db);
|
|
||||||
}
|
|
||||||
|
|
||||||
~AttrDb()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
auto state(_state->lock());
|
|
||||||
if (!failed)
|
|
||||||
state->txn->commit();
|
|
||||||
state->txn.reset();
|
|
||||||
} catch (...) {
|
|
||||||
ignoreException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
AttrId doSQLite(F && fun)
|
|
||||||
{
|
|
||||||
if (failed) return 0;
|
|
||||||
try {
|
|
||||||
return fun();
|
|
||||||
} catch (SQLiteError &) {
|
|
||||||
ignoreException();
|
|
||||||
failed = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setAttrs(
|
|
||||||
AttrKey key,
|
|
||||||
const std::vector<Symbol> & attrs)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::FullAttrs)
|
|
||||||
(0, false).exec();
|
|
||||||
|
|
||||||
AttrId rowId = state->db.getLastInsertedRowId();
|
|
||||||
assert(rowId);
|
|
||||||
|
|
||||||
for (auto & attr : attrs)
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(rowId)
|
|
||||||
(attr)
|
|
||||||
(AttrType::Placeholder)
|
|
||||||
(0, false).exec();
|
|
||||||
|
|
||||||
return rowId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setString(
|
|
||||||
AttrKey key,
|
|
||||||
std::string_view s,
|
|
||||||
const char * * context = nullptr)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
if (context) {
|
|
||||||
std::string ctx;
|
|
||||||
for (const char * * p = context; *p; ++p) {
|
|
||||||
if (p != context) ctx.push_back(' ');
|
|
||||||
ctx.append(*p);
|
|
||||||
}
|
|
||||||
state->insertAttributeWithContext.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::String)
|
|
||||||
(s)
|
|
||||||
(ctx).exec();
|
|
||||||
} else {
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::String)
|
|
||||||
(s).exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setBool(
|
|
||||||
AttrKey key,
|
|
||||||
bool b)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::Bool)
|
|
||||||
(b ? 1 : 0).exec();
|
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setPlaceholder(AttrKey key)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::Placeholder)
|
|
||||||
(0, false).exec();
|
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setMissing(AttrKey key)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::Missing)
|
|
||||||
(0, false).exec();
|
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setMisc(AttrKey key)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::Misc)
|
|
||||||
(0, false).exec();
|
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrId setFailed(AttrKey key)
|
|
||||||
{
|
|
||||||
return doSQLite([&]()
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
state->insertAttribute.use()
|
|
||||||
(key.first)
|
|
||||||
(key.second)
|
|
||||||
(AttrType::Failed)
|
|
||||||
(0, false).exec();
|
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::pair<AttrId, AttrValue>> getAttr(
|
|
||||||
AttrKey key,
|
|
||||||
SymbolTable & symbols)
|
|
||||||
{
|
|
||||||
auto state(_state->lock());
|
|
||||||
|
|
||||||
auto queryAttribute(state->queryAttribute.use()(key.first)(key.second));
|
|
||||||
if (!queryAttribute.next()) return {};
|
|
||||||
|
|
||||||
auto rowId = (AttrType) queryAttribute.getInt(0);
|
|
||||||
auto type = (AttrType) queryAttribute.getInt(1);
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case AttrType::Placeholder:
|
|
||||||
return {{rowId, placeholder_t()}};
|
|
||||||
case AttrType::FullAttrs: {
|
|
||||||
// FIXME: expensive, should separate this out.
|
|
||||||
std::vector<Symbol> attrs;
|
|
||||||
auto queryAttributes(state->queryAttributes.use()(rowId));
|
|
||||||
while (queryAttributes.next())
|
|
||||||
attrs.push_back(symbols.create(queryAttributes.getStr(0)));
|
|
||||||
return {{rowId, attrs}};
|
|
||||||
}
|
|
||||||
case AttrType::String: {
|
|
||||||
std::vector<std::pair<Path, std::string>> context;
|
|
||||||
if (!queryAttribute.isNull(3))
|
|
||||||
for (auto & s : tokenizeString<std::vector<std::string>>(queryAttribute.getStr(3), ";"))
|
|
||||||
context.push_back(decodeContext(s));
|
|
||||||
return {{rowId, string_t{queryAttribute.getStr(2), context}}};
|
|
||||||
}
|
|
||||||
case AttrType::Bool:
|
|
||||||
return {{rowId, queryAttribute.getInt(2) != 0}};
|
|
||||||
case AttrType::Missing:
|
|
||||||
return {{rowId, missing_t()}};
|
|
||||||
case AttrType::Misc:
|
|
||||||
return {{rowId, misc_t()}};
|
|
||||||
case AttrType::Failed:
|
|
||||||
return {{rowId, failed_t()}};
|
|
||||||
default:
|
|
||||||
throw Error("unexpected type in evaluation cache");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::shared_ptr<AttrDb> makeAttrDb(const Hash & fingerprint)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return std::make_shared<AttrDb>(fingerprint);
|
|
||||||
} catch (SQLiteError &) {
|
|
||||||
ignoreException();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EvalCache::EvalCache(
|
|
||||||
std::optional<std::reference_wrapper<const Hash>> useCache,
|
|
||||||
EvalState & state,
|
|
||||||
RootLoader rootLoader)
|
|
||||||
: db(useCache ? makeAttrDb(*useCache) : nullptr)
|
|
||||||
, state(state)
|
|
||||||
, rootLoader(rootLoader)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Value * EvalCache::getRootValue()
|
|
||||||
{
|
|
||||||
if (!value) {
|
|
||||||
debug("getting root value");
|
|
||||||
value = allocRootValue(rootLoader());
|
|
||||||
}
|
|
||||||
return *value;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> EvalCache::getRoot()
|
|
||||||
{
|
|
||||||
return std::make_shared<AttrCursor>(ref(shared_from_this()), std::nullopt);
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrCursor::AttrCursor(
|
|
||||||
ref<EvalCache> root,
|
|
||||||
Parent parent,
|
|
||||||
Value * value,
|
|
||||||
std::optional<std::pair<AttrId, AttrValue>> && cachedValue)
|
|
||||||
: root(root), parent(parent), cachedValue(std::move(cachedValue))
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
_value = allocRootValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrKey AttrCursor::getKey()
|
|
||||||
{
|
|
||||||
if (!parent)
|
|
||||||
return {0, root->state.sEpsilon};
|
|
||||||
if (!parent->first->cachedValue) {
|
|
||||||
parent->first->cachedValue = root->db->getAttr(
|
|
||||||
parent->first->getKey(), root->state.symbols);
|
|
||||||
assert(parent->first->cachedValue);
|
|
||||||
}
|
|
||||||
return {parent->first->cachedValue->first, parent->second};
|
|
||||||
}
|
|
||||||
|
|
||||||
Value & AttrCursor::getValue()
|
|
||||||
{
|
|
||||||
if (!_value) {
|
|
||||||
if (parent) {
|
|
||||||
auto & vParent = parent->first->getValue();
|
|
||||||
root->state.forceAttrs(vParent);
|
|
||||||
auto attr = vParent.attrs->get(parent->second);
|
|
||||||
if (!attr)
|
|
||||||
throw Error("attribute '%s' is unexpectedly missing", getAttrPathStr());
|
|
||||||
_value = allocRootValue(attr->value);
|
|
||||||
} else
|
|
||||||
_value = allocRootValue(root->getRootValue());
|
|
||||||
}
|
|
||||||
return **_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Symbol> AttrCursor::getAttrPath() const
|
|
||||||
{
|
|
||||||
if (parent) {
|
|
||||||
auto attrPath = parent->first->getAttrPath();
|
|
||||||
attrPath.push_back(parent->second);
|
|
||||||
return attrPath;
|
|
||||||
} else
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Symbol> AttrCursor::getAttrPath(Symbol name) const
|
|
||||||
{
|
|
||||||
auto attrPath = getAttrPath();
|
|
||||||
attrPath.push_back(name);
|
|
||||||
return attrPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AttrCursor::getAttrPathStr() const
|
|
||||||
{
|
|
||||||
return concatStringsSep(".", getAttrPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AttrCursor::getAttrPathStr(Symbol name) const
|
|
||||||
{
|
|
||||||
return concatStringsSep(".", getAttrPath(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
Value & AttrCursor::forceValue()
|
|
||||||
{
|
|
||||||
debug("evaluating uncached attribute %s", getAttrPathStr());
|
|
||||||
|
|
||||||
auto & v = getValue();
|
|
||||||
|
|
||||||
try {
|
|
||||||
root->state.forceValue(v);
|
|
||||||
} catch (EvalError &) {
|
|
||||||
debug("setting '%s' to failed", getAttrPathStr());
|
|
||||||
if (root->db)
|
|
||||||
cachedValue = {root->db->setFailed(getKey()), failed_t()};
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root->db && (!cachedValue || std::get_if<placeholder_t>(&cachedValue->second))) {
|
|
||||||
if (v.type() == nString)
|
|
||||||
cachedValue = {root->db->setString(getKey(), v.string.s, v.string.context),
|
|
||||||
string_t{v.string.s, {}}};
|
|
||||||
else if (v.type() == nPath)
|
|
||||||
cachedValue = {root->db->setString(getKey(), v.path), string_t{v.path, {}}};
|
|
||||||
else if (v.type() == nBool)
|
|
||||||
cachedValue = {root->db->setBool(getKey(), v.boolean), v.boolean};
|
|
||||||
else if (v.type() == nAttrs)
|
|
||||||
; // FIXME: do something?
|
|
||||||
else
|
|
||||||
cachedValue = {root->db->setMisc(getKey()), misc_t()};
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name, bool forceErrors)
|
|
||||||
{
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = root->db->getAttr(getKey(), root->state.symbols);
|
|
||||||
|
|
||||||
if (cachedValue) {
|
|
||||||
if (auto attrs = std::get_if<std::vector<Symbol>>(&cachedValue->second)) {
|
|
||||||
for (auto & attr : *attrs)
|
|
||||||
if (attr == name)
|
|
||||||
return std::make_shared<AttrCursor>(root, std::make_pair(shared_from_this(), name));
|
|
||||||
return nullptr;
|
|
||||||
} else if (std::get_if<placeholder_t>(&cachedValue->second)) {
|
|
||||||
auto attr = root->db->getAttr({cachedValue->first, name}, root->state.symbols);
|
|
||||||
if (attr) {
|
|
||||||
if (std::get_if<missing_t>(&attr->second))
|
|
||||||
return nullptr;
|
|
||||||
else if (std::get_if<failed_t>(&attr->second)) {
|
|
||||||
if (forceErrors)
|
|
||||||
debug("reevaluating failed cached attribute '%s'");
|
|
||||||
else
|
|
||||||
throw CachedEvalError("cached failure of attribute '%s'", getAttrPathStr(name));
|
|
||||||
} else
|
|
||||||
return std::make_shared<AttrCursor>(root,
|
|
||||||
std::make_pair(shared_from_this(), name), nullptr, std::move(attr));
|
|
||||||
}
|
|
||||||
// Incomplete attrset, so need to fall thru and
|
|
||||||
// evaluate to see whether 'name' exists
|
|
||||||
} else
|
|
||||||
return nullptr;
|
|
||||||
//throw TypeError("'%s' is not an attribute set", getAttrPathStr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto & v = forceValue();
|
|
||||||
|
|
||||||
if (v.type() != nAttrs)
|
|
||||||
return nullptr;
|
|
||||||
//throw TypeError("'%s' is not an attribute set", getAttrPathStr());
|
|
||||||
|
|
||||||
auto attr = v.attrs->get(name);
|
|
||||||
|
|
||||||
if (!attr) {
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = {root->db->setPlaceholder(getKey()), placeholder_t()};
|
|
||||||
root->db->setMissing({cachedValue->first, name});
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<std::pair<AttrId, AttrValue>> cachedValue2;
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = {root->db->setPlaceholder(getKey()), placeholder_t()};
|
|
||||||
cachedValue2 = {root->db->setPlaceholder({cachedValue->first, name}), placeholder_t()};
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_shared<AttrCursor>(
|
|
||||||
root, std::make_pair(shared_from_this(), name), attr->value, std::move(cachedValue2));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(std::string_view name)
|
|
||||||
{
|
|
||||||
return maybeGetAttr(root->state.symbols.create(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> AttrCursor::getAttr(Symbol name, bool forceErrors)
|
|
||||||
{
|
|
||||||
auto p = maybeGetAttr(name, forceErrors);
|
|
||||||
if (!p)
|
|
||||||
throw Error("attribute '%s' does not exist", getAttrPathStr(name));
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> AttrCursor::getAttr(std::string_view name)
|
|
||||||
{
|
|
||||||
return getAttr(root->state.symbols.create(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> AttrCursor::findAlongAttrPath(const std::vector<Symbol> & attrPath, bool force)
|
|
||||||
{
|
|
||||||
auto res = shared_from_this();
|
|
||||||
for (auto & attr : attrPath) {
|
|
||||||
res = res->maybeGetAttr(attr, force);
|
|
||||||
if (!res) return {};
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AttrCursor::getString()
|
|
||||||
{
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = root->db->getAttr(getKey(), root->state.symbols);
|
|
||||||
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
|
|
||||||
if (auto s = std::get_if<string_t>(&cachedValue->second)) {
|
|
||||||
debug("using cached string attribute '%s'", getAttrPathStr());
|
|
||||||
return s->first;
|
|
||||||
} else
|
|
||||||
throw TypeError("'%s' is not a string", getAttrPathStr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto & v = forceValue();
|
|
||||||
|
|
||||||
if (v.type() != nString && v.type() != nPath)
|
|
||||||
throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
|
|
||||||
|
|
||||||
return v.type() == nString ? v.string.s : v.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
string_t AttrCursor::getStringWithContext()
|
|
||||||
{
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = root->db->getAttr(getKey(), root->state.symbols);
|
|
||||||
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
|
|
||||||
if (auto s = std::get_if<string_t>(&cachedValue->second)) {
|
|
||||||
bool valid = true;
|
|
||||||
for (auto & c : s->second) {
|
|
||||||
if (!root->state.store->isValidPath(root->state.store->parseStorePath(c.first))) {
|
|
||||||
valid = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (valid) {
|
|
||||||
debug("using cached string attribute '%s'", getAttrPathStr());
|
|
||||||
return *s;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
throw TypeError("'%s' is not a string", getAttrPathStr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto & v = forceValue();
|
|
||||||
|
|
||||||
if (v.type() == nString)
|
|
||||||
return {v.string.s, v.getContext()};
|
|
||||||
else if (v.type() == nPath)
|
|
||||||
return {v.path, {}};
|
|
||||||
else
|
|
||||||
throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AttrCursor::getBool()
|
|
||||||
{
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = root->db->getAttr(getKey(), root->state.symbols);
|
|
||||||
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
|
|
||||||
if (auto b = std::get_if<bool>(&cachedValue->second)) {
|
|
||||||
debug("using cached Boolean attribute '%s'", getAttrPathStr());
|
|
||||||
return *b;
|
|
||||||
} else
|
|
||||||
throw TypeError("'%s' is not a Boolean", getAttrPathStr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto & v = forceValue();
|
|
||||||
|
|
||||||
if (v.type() != nBool)
|
|
||||||
throw TypeError("'%s' is not a Boolean", getAttrPathStr());
|
|
||||||
|
|
||||||
return v.boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Symbol> AttrCursor::getAttrs()
|
|
||||||
{
|
|
||||||
if (root->db) {
|
|
||||||
if (!cachedValue)
|
|
||||||
cachedValue = root->db->getAttr(getKey(), root->state.symbols);
|
|
||||||
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
|
|
||||||
if (auto attrs = std::get_if<std::vector<Symbol>>(&cachedValue->second)) {
|
|
||||||
debug("using cached attrset attribute '%s'", getAttrPathStr());
|
|
||||||
return *attrs;
|
|
||||||
} else
|
|
||||||
throw TypeError("'%s' is not an attribute set", getAttrPathStr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto & v = forceValue();
|
|
||||||
|
|
||||||
if (v.type() != nAttrs)
|
|
||||||
throw TypeError("'%s' is not an attribute set", getAttrPathStr());
|
|
||||||
|
|
||||||
std::vector<Symbol> attrs;
|
|
||||||
for (auto & attr : *getValue().attrs)
|
|
||||||
attrs.push_back(attr.name);
|
|
||||||
std::sort(attrs.begin(), attrs.end(), [](const Symbol & a, const Symbol & b) {
|
|
||||||
return (const string &) a < (const string &) b;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (root->db)
|
|
||||||
cachedValue = {root->db->setAttrs(getKey(), attrs), attrs};
|
|
||||||
|
|
||||||
return attrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AttrCursor::isDerivation()
|
|
||||||
{
|
|
||||||
auto aType = maybeGetAttr("type");
|
|
||||||
return aType && aType->getString() == "derivation";
|
|
||||||
}
|
|
||||||
|
|
||||||
StorePath AttrCursor::forceDerivation()
|
|
||||||
{
|
|
||||||
auto aDrvPath = getAttr(root->state.sDrvPath, true);
|
|
||||||
auto drvPath = root->state.store->parseStorePath(aDrvPath->getString());
|
|
||||||
if (!root->state.store->isValidPath(drvPath) && !settings.readOnlyMode) {
|
|
||||||
/* The eval cache contains 'drvPath', but the actual path has
|
|
||||||
been garbage-collected. So force it to be regenerated. */
|
|
||||||
aDrvPath->forceValue();
|
|
||||||
if (!root->state.store->isValidPath(drvPath))
|
|
||||||
throw Error("don't know how to recreate store derivation '%s'!",
|
|
||||||
root->state.store->printStorePath(drvPath));
|
|
||||||
}
|
|
||||||
return drvPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "sync.hh"
|
|
||||||
#include "hash.hh"
|
|
||||||
#include "eval.hh"
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
namespace nix::eval_cache {
|
|
||||||
|
|
||||||
MakeError(CachedEvalError, EvalError);
|
|
||||||
|
|
||||||
struct AttrDb;
|
|
||||||
class AttrCursor;
|
|
||||||
|
|
||||||
class EvalCache : public std::enable_shared_from_this<EvalCache>
|
|
||||||
{
|
|
||||||
friend class AttrCursor;
|
|
||||||
|
|
||||||
std::shared_ptr<AttrDb> db;
|
|
||||||
EvalState & state;
|
|
||||||
typedef std::function<Value *()> RootLoader;
|
|
||||||
RootLoader rootLoader;
|
|
||||||
RootValue value;
|
|
||||||
|
|
||||||
Value * getRootValue();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
EvalCache(
|
|
||||||
std::optional<std::reference_wrapper<const Hash>> useCache,
|
|
||||||
EvalState & state,
|
|
||||||
RootLoader rootLoader);
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> getRoot();
|
|
||||||
};
|
|
||||||
|
|
||||||
enum AttrType {
|
|
||||||
Placeholder = 0,
|
|
||||||
FullAttrs = 1,
|
|
||||||
String = 2,
|
|
||||||
Missing = 3,
|
|
||||||
Misc = 4,
|
|
||||||
Failed = 5,
|
|
||||||
Bool = 6,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct placeholder_t {};
|
|
||||||
struct missing_t {};
|
|
||||||
struct misc_t {};
|
|
||||||
struct failed_t {};
|
|
||||||
typedef uint64_t AttrId;
|
|
||||||
typedef std::pair<AttrId, Symbol> AttrKey;
|
|
||||||
typedef std::pair<std::string, std::vector<std::pair<Path, std::string>>> string_t;
|
|
||||||
|
|
||||||
typedef std::variant<
|
|
||||||
std::vector<Symbol>,
|
|
||||||
string_t,
|
|
||||||
placeholder_t,
|
|
||||||
missing_t,
|
|
||||||
misc_t,
|
|
||||||
failed_t,
|
|
||||||
bool
|
|
||||||
> AttrValue;
|
|
||||||
|
|
||||||
class AttrCursor : public std::enable_shared_from_this<AttrCursor>
|
|
||||||
{
|
|
||||||
friend class EvalCache;
|
|
||||||
|
|
||||||
ref<EvalCache> root;
|
|
||||||
typedef std::optional<std::pair<std::shared_ptr<AttrCursor>, Symbol>> Parent;
|
|
||||||
Parent parent;
|
|
||||||
RootValue _value;
|
|
||||||
std::optional<std::pair<AttrId, AttrValue>> cachedValue;
|
|
||||||
|
|
||||||
AttrKey getKey();
|
|
||||||
|
|
||||||
Value & getValue();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
AttrCursor(
|
|
||||||
ref<EvalCache> root,
|
|
||||||
Parent parent,
|
|
||||||
Value * value = nullptr,
|
|
||||||
std::optional<std::pair<AttrId, AttrValue>> && cachedValue = {});
|
|
||||||
|
|
||||||
std::vector<Symbol> getAttrPath() const;
|
|
||||||
|
|
||||||
std::vector<Symbol> getAttrPath(Symbol name) const;
|
|
||||||
|
|
||||||
std::string getAttrPathStr() const;
|
|
||||||
|
|
||||||
std::string getAttrPathStr(Symbol name) const;
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> maybeGetAttr(Symbol name, bool forceErrors = false);
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> maybeGetAttr(std::string_view name);
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> getAttr(Symbol name, bool forceErrors = false);
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> getAttr(std::string_view name);
|
|
||||||
|
|
||||||
std::shared_ptr<AttrCursor> findAlongAttrPath(const std::vector<Symbol> & attrPath, bool force = false);
|
|
||||||
|
|
||||||
std::string getString();
|
|
||||||
|
|
||||||
string_t getStringWithContext();
|
|
||||||
|
|
||||||
bool getBool();
|
|
||||||
|
|
||||||
std::vector<Symbol> getAttrs();
|
|
||||||
|
|
||||||
bool isDerivation();
|
|
||||||
|
|
||||||
Value & forceValue();
|
|
||||||
|
|
||||||
/* Force creation of the .drv file in the Nix store. */
|
|
||||||
StorePath forceDerivation();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
+649
-450
File diff suppressed because it is too large.
Load diff
+42
-53
@@ -1,11 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "attr-set.hh"
|
#include "attr-set.hh"
|
||||||
|
#include "context.hh"
|
||||||
#include "value.hh"
|
#include "value.hh"
|
||||||
#include "nixexpr.hh"
|
#include "nixexpr.hh"
|
||||||
#include "symbol-table.hh"
|
#include "symbol-table.hh"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "experimental-features.hh"
|
#include "hash.hh"
|
||||||
|
#include "sqlite.hh"
|
||||||
|
#include "tree-cache.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -15,6 +18,9 @@
|
|||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
namespace eval_cache {
|
||||||
|
class EvalCache;
|
||||||
|
}
|
||||||
|
|
||||||
class Store;
|
class Store;
|
||||||
class EvalState;
|
class EvalState;
|
||||||
@@ -95,14 +101,8 @@ public:
|
|||||||
|
|
||||||
Value vEmptySet;
|
Value vEmptySet;
|
||||||
|
|
||||||
/* Store used to materialise .drv files. */
|
|
||||||
const ref<Store> store;
|
const ref<Store> store;
|
||||||
|
|
||||||
/* Store used to build stuff. */
|
|
||||||
const ref<Store> buildStore;
|
|
||||||
|
|
||||||
RootValue vCallFlake = nullptr;
|
|
||||||
RootValue vImportedDrvToDerivation = nullptr;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SrcToStore srcToStore;
|
SrcToStore srcToStore;
|
||||||
@@ -123,6 +123,8 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
FileEvalCache fileEvalCache;
|
FileEvalCache fileEvalCache;
|
||||||
|
|
||||||
|
std::map<Hash, std::shared_ptr<tree_cache::Cache>> evalCache;
|
||||||
|
|
||||||
SearchPath searchPath;
|
SearchPath searchPath;
|
||||||
|
|
||||||
std::map<std::string, std::pair<bool, std::string>> searchPathResolved;
|
std::map<std::string, std::pair<bool, std::string>> searchPathResolved;
|
||||||
@@ -135,31 +137,16 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EvalState(
|
EvalState(const Strings & _searchPath, ref<Store> store);
|
||||||
const Strings & _searchPath,
|
|
||||||
ref<Store> store,
|
|
||||||
std::shared_ptr<Store> buildStore = nullptr);
|
|
||||||
~EvalState();
|
~EvalState();
|
||||||
|
|
||||||
void requireExperimentalFeatureOnEvaluation(
|
std::shared_ptr<eval_cache::EvalCache> openCache(Hash, std::function<Value *()> rootLoader);
|
||||||
const ExperimentalFeature &,
|
std::shared_ptr<tree_cache::Cache> openTreeCache(Hash);
|
||||||
const std::string_view fName,
|
|
||||||
const Pos & pos
|
|
||||||
);
|
|
||||||
|
|
||||||
void addToSearchPath(const string & s);
|
void addToSearchPath(const string & s);
|
||||||
|
|
||||||
SearchPath getSearchPath() { return searchPath; }
|
SearchPath getSearchPath() { return searchPath; }
|
||||||
|
|
||||||
/* Allow access to a path. */
|
|
||||||
void allowPath(const Path & path);
|
|
||||||
|
|
||||||
/* Allow access to a store path. Note that this gets remapped to
|
|
||||||
the real store path if `store` is a chroot store. */
|
|
||||||
void allowPath(const StorePath & storePath);
|
|
||||||
|
|
||||||
/* Check whether access to a path is allowed and throw an error if
|
|
||||||
not. Otherwise return the canonicalised path. */
|
|
||||||
Path checkSourcePath(const Path & path);
|
Path checkSourcePath(const Path & path);
|
||||||
|
|
||||||
void checkURI(const std::string & uri);
|
void checkURI(const std::string & uri);
|
||||||
@@ -188,14 +175,6 @@ public:
|
|||||||
trivial (i.e. doesn't require arbitrary computation). */
|
trivial (i.e. doesn't require arbitrary computation). */
|
||||||
void evalFile(const Path & path, Value & v, bool mustBeTrivial = false);
|
void evalFile(const Path & path, Value & v, bool mustBeTrivial = false);
|
||||||
|
|
||||||
/* Like `cacheFile`, but with an already parsed expression. */
|
|
||||||
void cacheFile(
|
|
||||||
const Path & path,
|
|
||||||
const Path & resolvedPath,
|
|
||||||
Expr * e,
|
|
||||||
Value & v,
|
|
||||||
bool mustBeTrivial = false);
|
|
||||||
|
|
||||||
void resetFileCache();
|
void resetFileCache();
|
||||||
|
|
||||||
/* Look up a file in the search path. */
|
/* Look up a file in the search path. */
|
||||||
@@ -250,8 +229,7 @@ public:
|
|||||||
booleans and lists to a string. If `copyToStore' is set,
|
booleans and lists to a string. If `copyToStore' is set,
|
||||||
referenced paths are copied to the Nix store as a side effect. */
|
referenced paths are copied to the Nix store as a side effect. */
|
||||||
string coerceToString(const Pos & pos, Value & v, PathSet & context,
|
string coerceToString(const Pos & pos, Value & v, PathSet & context,
|
||||||
bool coerceMore = false, bool copyToStore = true,
|
bool coerceMore = false, bool copyToStore = true);
|
||||||
bool canonicalizePath = true);
|
|
||||||
|
|
||||||
string copyPathToStore(PathSet & context, const Path & path);
|
string copyPathToStore(PathSet & context, const Path & path);
|
||||||
|
|
||||||
@@ -277,8 +255,6 @@ private:
|
|||||||
|
|
||||||
Value * addConstant(const string & name, Value & v);
|
Value * addConstant(const string & name, Value & v);
|
||||||
|
|
||||||
void addConstant(const string & name, Value * v);
|
|
||||||
|
|
||||||
Value * addPrimOp(const string & name,
|
Value * addPrimOp(const string & name,
|
||||||
size_t arity, PrimOpFun primOp);
|
size_t arity, PrimOpFun primOp);
|
||||||
|
|
||||||
@@ -318,14 +294,8 @@ public:
|
|||||||
|
|
||||||
bool isFunctor(Value & fun);
|
bool isFunctor(Value & fun);
|
||||||
|
|
||||||
// FIXME: use std::span
|
void callFunction(Value & fun, Value & arg, Value & v, const Pos & pos);
|
||||||
void callFunction(Value & fun, size_t nrArgs, Value * * args, Value & vRes, const Pos & pos);
|
void callPrimOp(Value & fun, Value & arg, Value & v, const Pos & pos);
|
||||||
|
|
||||||
void callFunction(Value & fun, Value & arg, Value & vRes, const Pos & pos)
|
|
||||||
{
|
|
||||||
Value * args[] = {&arg};
|
|
||||||
callFunction(fun, 1, args, vRes, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Automatically call a function for which each argument has a
|
/* Automatically call a function for which each argument has a
|
||||||
default value or has a binding in the `args' map. */
|
default value or has a binding in the `args' map. */
|
||||||
@@ -343,7 +313,27 @@ public:
|
|||||||
void mkList(Value & v, size_t length);
|
void mkList(Value & v, size_t length);
|
||||||
void mkAttrs(Value & v, size_t capacity);
|
void mkAttrs(Value & v, size_t capacity);
|
||||||
void mkThunk_(Value & v, Expr * expr);
|
void mkThunk_(Value & v, Expr * expr);
|
||||||
void mkPos(Value & v, ptr<Pos> pos);
|
void mkPos(Value & v, Pos * pos);
|
||||||
|
|
||||||
|
struct AttrAccessError {
|
||||||
|
const Symbol attrName;
|
||||||
|
|
||||||
|
// To distinguish between a missing field in an attribute set
|
||||||
|
// and an access to something that's not an attribute set
|
||||||
|
std::optional<Value* > illTypedValue;
|
||||||
|
};
|
||||||
|
struct AttrAccesResult {
|
||||||
|
std::optional<AttrAccessError> error;
|
||||||
|
const Pos * pos;
|
||||||
|
Value* value;
|
||||||
|
};
|
||||||
|
AttrAccesResult getOptionalAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos, Value & dest);
|
||||||
|
AttrAccesResult getOptionalAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos);
|
||||||
|
AttrAccesResult lazyGetOptionalAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos);
|
||||||
|
void getAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos, Value & dest);
|
||||||
|
Value* getAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos);
|
||||||
|
|
||||||
|
std::vector<Symbol> listAttrFields(Value & attrs, const Pos & pos);
|
||||||
|
|
||||||
void concatLists(Value & v, size_t nrLists, Value * * lists, const Pos & pos);
|
void concatLists(Value & v, size_t nrLists, Value * * lists, const Pos & pos);
|
||||||
|
|
||||||
@@ -352,21 +342,25 @@ public:
|
|||||||
|
|
||||||
void realiseContext(const PathSet & context);
|
void realiseContext(const PathSet & context);
|
||||||
|
|
||||||
|
void updateCacheStats(ValueCache::CacheResult);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned long nrEnvs = 0;
|
unsigned long nrEnvs = 0;
|
||||||
unsigned long nrValuesInEnvs = 0;
|
unsigned long nrValuesInEnvs = 0;
|
||||||
unsigned long nrValues = 0;
|
unsigned long nrValues = 0;
|
||||||
unsigned long nrListElems = 0;
|
unsigned long nrListElems = 0;
|
||||||
unsigned long nrLookups = 0;
|
|
||||||
unsigned long nrAttrsets = 0;
|
unsigned long nrAttrsets = 0;
|
||||||
unsigned long nrAttrsInAttrsets = 0;
|
unsigned long nrAttrsInAttrsets = 0;
|
||||||
unsigned long nrAvoided = 0;
|
|
||||||
unsigned long nrOpUpdates = 0;
|
unsigned long nrOpUpdates = 0;
|
||||||
unsigned long nrOpUpdateValuesCopied = 0;
|
unsigned long nrOpUpdateValuesCopied = 0;
|
||||||
unsigned long nrListConcats = 0;
|
unsigned long nrListConcats = 0;
|
||||||
unsigned long nrPrimOpCalls = 0;
|
unsigned long nrPrimOpCalls = 0;
|
||||||
unsigned long nrFunctionCalls = 0;
|
unsigned long nrFunctionCalls = 0;
|
||||||
|
unsigned long nrCacheHits = 0;
|
||||||
|
unsigned long nrCacheMisses = 0;
|
||||||
|
unsigned long nrUncacheable = 0;
|
||||||
|
unsigned long nrUncached = 0;
|
||||||
|
|
||||||
bool countCalls;
|
bool countCalls;
|
||||||
|
|
||||||
@@ -383,11 +377,6 @@ private:
|
|||||||
|
|
||||||
friend struct ExprOpUpdate;
|
friend struct ExprOpUpdate;
|
||||||
friend struct ExprOpConcatLists;
|
friend struct ExprOpConcatLists;
|
||||||
friend struct ExprVar;
|
|
||||||
friend struct ExprString;
|
|
||||||
friend struct ExprInt;
|
|
||||||
friend struct ExprFloat;
|
|
||||||
friend struct ExprPath;
|
|
||||||
friend struct ExprSelect;
|
friend struct ExprSelect;
|
||||||
friend void prim_getAttr(EvalState & state, const Pos & pos, Value * * args, Value & v);
|
friend void prim_getAttr(EvalState & state, const Pos & pos, Value * * args, Value & v);
|
||||||
friend void prim_match(EvalState & state, const Pos & pos, Value * * args, Value & v);
|
friend void prim_match(EvalState & state, const Pos & pos, Value * * args, Value & v);
|
||||||
|
|||||||
@@ -22,14 +22,12 @@ static TrustedList readTrustedList()
|
|||||||
|
|
||||||
static void writeTrustedList(const TrustedList & trustedList)
|
static void writeTrustedList(const TrustedList & trustedList)
|
||||||
{
|
{
|
||||||
auto path = trustedListPath();
|
writeFile(trustedListPath(), nlohmann::json(trustedList).dump());
|
||||||
createDirs(dirOf(path));
|
|
||||||
writeFile(path, nlohmann::json(trustedList).dump());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigFile::apply()
|
void ConfigFile::apply()
|
||||||
{
|
{
|
||||||
std::set<std::string> whitelist{"bash-prompt", "bash-prompt-suffix", "flake-registry"};
|
std::set<std::string> whitelist{"bash-prompt", "bash-prompt-suffix"};
|
||||||
|
|
||||||
for (auto & [name, value] : settings) {
|
for (auto & [name, value] : settings) {
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 389 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user