Compare commits
105
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77a9ac165c | ||
|
|
9feca5cdf6 | ||
|
|
4d058f49e7 | ||
|
|
777c688a98 | ||
|
|
c189d80b4a | ||
|
|
decc14d4b7 | ||
|
|
6182ae6898 | ||
|
|
f5320299dd | ||
|
|
bf68c693dc | ||
|
|
8b6fba2b63 | ||
|
|
08270af7fe | ||
|
|
7746cb13dc | ||
|
|
8eaf03bcb4 | ||
|
|
be7a4a6a13 | ||
|
|
01a3f4d7ec | ||
|
|
fd3f5e9085 | ||
|
|
323e5450a1 | ||
|
|
0a535dd5ac | ||
|
|
f9f773b332 | ||
|
|
c878cee895 | ||
|
|
16fb7d8d95 | ||
|
|
40f925b2da | ||
|
|
d32cf0c17a | ||
|
|
b8f7177a7b | ||
|
|
7945055c63 | ||
|
|
a5df669bc6 | ||
|
|
4a5aa1dbf6 | ||
|
|
2ab7c821f3 | ||
|
|
26d2c62225 | ||
|
|
d9a43d3137 | ||
|
|
3e4126b67c | ||
|
|
4f9508c3b5 | ||
|
|
ed0e21a88d | ||
|
|
7c96a76dd7 | ||
|
|
8d09a4f9a0 | ||
|
|
c13d7d0b97 | ||
|
|
3b58dbb356 | ||
|
|
4b23bf797a | ||
|
|
9676c9f6a3 | ||
|
|
dcabb46124 | ||
|
|
610baf359a | ||
|
|
24e7353232 | ||
|
|
55b4623d21 | ||
|
|
ce674cb2cf | ||
|
|
608434722b | ||
|
|
3784c66a46 | ||
|
|
498677cbed | ||
|
|
db3de0727e | ||
|
|
4202a3bc4e | ||
|
|
a3ce88725b | ||
|
|
e6150de90d | ||
|
|
79674c6cdb | ||
|
|
96d7170e12 | ||
|
|
2cf591a134 | ||
|
|
56605b4688 | ||
|
|
7ac038fa4b | ||
|
|
7c077d2a0f | ||
|
|
8e6ee1b9e9 | ||
|
|
196b77b686 | ||
|
|
f35f9af787 | ||
|
|
bb06640971 | ||
|
|
f1b604f603 | ||
|
|
50dc88a56c | ||
|
|
7c3cb8506f | ||
|
|
cc9aa8d4b1 | ||
|
|
838f862f4f | ||
|
|
7565308d04 | ||
|
|
7d651f5c3f | ||
|
|
d12b12a15b | ||
|
|
aedb5c7301 | ||
|
|
5985b8b527 | ||
|
|
48396d940e | ||
|
|
b8fbfc80fd | ||
|
|
f357cea40e | ||
|
|
83f694762e | ||
|
|
caef6f4314 | ||
|
|
c57ab17687 | ||
|
|
9f1a7f9d37 | ||
|
|
1fefe808f6 | ||
|
|
f674f7f434 | ||
|
|
e8f585be70 | ||
|
|
1f390922d0 | ||
|
|
4da9ec772c | ||
|
|
b10256af51 | ||
|
|
cf1d4299a8 | ||
|
|
822e338e5c | ||
|
|
a22755721b | ||
|
|
1f3ff0d193 | ||
|
|
ce1a6c6b13 | ||
|
|
cb46d70794 | ||
|
|
63ebfc73c5 | ||
|
|
8c30acc3e8 | ||
|
|
af3afd25ea | ||
|
|
eca6ff06d6 | ||
|
|
7ce0441d80 | ||
|
|
4077d55775 | ||
|
|
7616268812 | ||
|
|
129384bcf3 | ||
|
|
79ae9e4558 | ||
|
|
19396f2a8a | ||
|
|
9e9a8456d7 | ||
|
|
af4ff644d5 | ||
|
|
a8416866cf | ||
|
|
184558834a | ||
|
|
45473d02c9 |
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 the [#nixos IRC channel](https://webchat.freenode.net/#nixos).
|
- 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).
|
||||||
|
|
||||||
## Suggestions for PRs
|
## Suggestions for PRs
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ jobs:
|
|||||||
name: '${{ env.CACHIX_NAME }}'
|
name: '${{ env.CACHIX_NAME }}'
|
||||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
#- run: nix flake check
|
- run: nix-build -A checks.$(nix-instantiate --eval -E '(builtins.currentSystem)')
|
||||||
- run: nix-build -A checks.$(if [[ `uname` = Linux ]]; then echo x86_64-linux; else echo x86_64-darwin; fi)
|
|
||||||
check_cachix:
|
check_cachix:
|
||||||
name: Cachix secret present for installer tests
|
name: Cachix secret present for installer tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ 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/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 \
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ 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/)
|
||||||
- [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
- [Matrix - #nix:nixos.org](https://matrix.to/#/#nix:nixos.org)
|
||||||
|
- [IRC - #nixos on libera.chat](irc://irc.libera.chat/#nixos)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Vendored
+11
-9
@@ -1,8 +1,8 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Attempt to guess a canonical system name.
|
# Attempt to guess a canonical system name.
|
||||||
# Copyright 1992-2020 Free Software Foundation, Inc.
|
# Copyright 1992-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
timestamp='2020-11-19'
|
timestamp='2021-01-25'
|
||||||
|
|
||||||
# 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-2020 Free Software Foundation, Inc.
|
Copyright 1992-2021 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,10 +188,9 @@ 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" 2>/dev/null || \
|
/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
|
||||||
"/usr/sbin/$sysctl" 2>/dev/null || \
|
/usr/sbin/sysctl -n hw.machine_arch 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 ;;
|
||||||
@@ -996,6 +995,9 @@ 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 ;;
|
||||||
@@ -1084,7 +1086,7 @@ EOF
|
|||||||
ppcle:Linux:*:*)
|
ppcle:Linux:*:*)
|
||||||
echo powerpcle-unknown-linux-"$LIBC"
|
echo powerpcle-unknown-linux-"$LIBC"
|
||||||
exit ;;
|
exit ;;
|
||||||
riscv32:Linux:*:* | riscv64:Linux:*:*)
|
riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
|
||||||
exit ;;
|
exit ;;
|
||||||
s390:Linux:*:* | s390x:Linux:*:*)
|
s390:Linux:*:* | s390x:Linux:*:*)
|
||||||
@@ -1480,8 +1482,8 @@ EOF
|
|||||||
i*86:rdos:*:*)
|
i*86:rdos:*:*)
|
||||||
echo "$UNAME_MACHINE"-pc-rdos
|
echo "$UNAME_MACHINE"-pc-rdos
|
||||||
exit ;;
|
exit ;;
|
||||||
i*86:AROS:*:*)
|
*:AROS:*:*)
|
||||||
echo "$UNAME_MACHINE"-pc-aros
|
echo "$UNAME_MACHINE"-unknown-aros
|
||||||
exit ;;
|
exit ;;
|
||||||
x86_64:VMkernel:*:*)
|
x86_64:VMkernel:*:*)
|
||||||
echo "$UNAME_MACHINE"-unknown-esx
|
echo "$UNAME_MACHINE"-unknown-esx
|
||||||
|
|||||||
Vendored
+13
-7
@@ -1,8 +1,8 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Configuration validation subroutine script.
|
# Configuration validation subroutine script.
|
||||||
# Copyright 1992-2020 Free Software Foundation, Inc.
|
# Copyright 1992-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
timestamp='2020-12-02'
|
timestamp='2021-01-08'
|
||||||
|
|
||||||
# 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-2020 Free Software Foundation, Inc.
|
Copyright 1992-2021 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,6 +1185,7 @@ 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 \
|
||||||
@@ -1229,7 +1230,7 @@ case $cpu-$vendor in
|
|||||||
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
|
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
|
||||||
| pru \
|
| pru \
|
||||||
| pyramid \
|
| pyramid \
|
||||||
| riscv | riscv32 | riscv64 \
|
| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
|
||||||
| rl78 | romp | rs6000 | rx \
|
| rl78 | romp | rs6000 | rx \
|
||||||
| s390 | s390x \
|
| s390 | s390x \
|
||||||
| score \
|
| score \
|
||||||
@@ -1682,11 +1683,14 @@ 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-abi", so those need to count as OSes.
|
# Sometimes we do "kernel-libc", so those need to count as OSes.
|
||||||
musl* | newlib* | uclibc*)
|
musl* | newlib* | uclibc*)
|
||||||
;;
|
;;
|
||||||
# Likewise for "kernel-libc"
|
# Likewise for "kernel-abi"
|
||||||
eabi | eabihf | gnueabi | gnueabihf)
|
eabi* | gnueabi*)
|
||||||
|
;;
|
||||||
|
# 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.
|
||||||
@@ -1750,6 +1754,8 @@ 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)
|
||||||
|
|||||||
+14
-21
@@ -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,8 +9,7 @@ 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, AC_HELP_STRING([--with-system=SYSTEM],
|
AC_ARG_WITH(system, AS_HELP_STRING([--with-system=SYSTEM],[Platform identifier (e.g., `i686-linux').]),
|
||||||
[Platform identifier (e.g., `i686-linux').]),
|
|
||||||
[system=$withval],
|
[system=$withval],
|
||||||
[case "$host_cpu" in
|
[case "$host_cpu" in
|
||||||
i*86)
|
i*86)
|
||||||
@@ -66,7 +65,7 @@ AC_SYS_LARGEFILE
|
|||||||
AC_STRUCT_DIRENT_D_TYPE
|
AC_STRUCT_DIRENT_D_TYPE
|
||||||
if test "$sys_name" = sunos; then
|
if test "$sys_name" = sunos; then
|
||||||
# Solaris requires -lsocket -lnsl for network functions
|
# Solaris requires -lsocket -lnsl for network functions
|
||||||
LIBS="-lsocket -lnsl $LIBS"
|
LDFLAGS="-lsocket -lnsl $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -127,8 +126,7 @@ NEED_PROG(jq, jq)
|
|||||||
AC_SUBST(coreutils, [$(dirname $(type -p cat))])
|
AC_SUBST(coreutils, [$(dirname $(type -p cat))])
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_WITH(store-dir, AC_HELP_STRING([--with-store-dir=PATH],
|
AC_ARG_WITH(store-dir, AS_HELP_STRING([--with-store-dir=PATH],[path of the Nix store (defaults to /nix/store)]),
|
||||||
[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)
|
||||||
|
|
||||||
@@ -152,13 +150,12 @@ 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
|
||||||
LIBS="-latomic $LIBS"
|
LDFLAGS="-latomic $LDFLAGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared],
|
AC_ARG_ENABLE(shared, AS_HELP_STRING([--enable-shared],[Build shared libraries for Nix [default=yes]]),
|
||||||
[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.])
|
||||||
@@ -215,9 +212,8 @@ AC_SUBST(HAVE_LIBCPUID, [$have_libcpuid])
|
|||||||
# Look for libseccomp, required for Linux sandboxing.
|
# Look for libseccomp, required for Linux sandboxing.
|
||||||
if test "$sys_name" = linux; then
|
if test "$sys_name" = linux; then
|
||||||
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"])
|
||||||
@@ -235,8 +231,8 @@ 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.])
|
[AC_DEFINE([ENABLE_S3], [1], [Whether to enable S3 support via aws-sdk-cpp.]) enable_s3=1],
|
||||||
enable_s3=1], [enable_s3=])
|
[AC_DEFINE([ENABLE_S3], [0], [Whether to enable S3 support via aws-sdk-cpp.]) enable_s3=])
|
||||||
AC_SUBST(ENABLE_S3, [$enable_s3])
|
AC_SUBST(ENABLE_S3, [$enable_s3])
|
||||||
AC_LANG_POP(C++)
|
AC_LANG_POP(C++)
|
||||||
|
|
||||||
@@ -249,8 +245,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# Whether to use the Boehm garbage collector.
|
# Whether to use the Boehm garbage collector.
|
||||||
AC_ARG_ENABLE(gc, AC_HELP_STRING([--enable-gc],
|
AC_ARG_ENABLE(gc, AS_HELP_STRING([--enable-gc],[enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=yes]]),
|
||||||
[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])
|
||||||
@@ -264,8 +259,7 @@ PKG_CHECK_MODULES([GTEST], [gtest_main])
|
|||||||
|
|
||||||
|
|
||||||
# documentation generation switch
|
# documentation generation switch
|
||||||
AC_ARG_ENABLE(doc-gen, AC_HELP_STRING([--disable-doc-gen],
|
AC_ARG_ENABLE(doc-gen, AS_HELP_STRING([--disable-doc-gen],[disable documentation generation]),
|
||||||
[disable documentation generation]),
|
|
||||||
doc_generate=$enableval, doc_generate=yes)
|
doc_generate=$enableval, doc_generate=yes)
|
||||||
AC_SUBST(doc_generate)
|
AC_SUBST(doc_generate)
|
||||||
|
|
||||||
@@ -285,8 +279,7 @@ if test "$(uname)" = "Darwin"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_WITH(sandbox-shell, AC_HELP_STRING([--with-sandbox-shell=PATH],
|
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]),
|
||||||
[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)
|
||||||
|
|
||||||
@@ -301,6 +294,6 @@ done
|
|||||||
|
|
||||||
rm -f Makefile.config
|
rm -f Makefile.config
|
||||||
|
|
||||||
AC_CONFIG_HEADER([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_FILES([])
|
AC_CONFIG_FILES([])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
@@ -10,35 +10,39 @@ Most Nix commands interpret the following environment variables:
|
|||||||
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
|
nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
|
||||||
|
|
||||||
tells Nix to download the latest revision in the Nixpkgs/NixOS 15.09
|
tells Nix to download and use the current contents of the
|
||||||
channel.
|
`master` branch in the `nixpkgs` repository.
|
||||||
|
|
||||||
A following shorthand can be used to refer to the official channels:
|
The URLs of the tarballs from the official nixos.org channels (see
|
||||||
|
[the manual for `nix-channel`](nix-channel.md)) can be abbreviated
|
||||||
nixpkgs=channel:nixos-15.09
|
as `channel:<channel-name>`. For instance, the following two
|
||||||
|
values of `NIX_PATH` are equivalent:
|
||||||
The search path can be extended using the `-I` option, which takes
|
|
||||||
precedence over `NIX_PATH`.
|
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`\
|
- `NIX_IGNORE_SYMLINK_STORE`\
|
||||||
Normally, the Nix store directory (typically `/nix/store`) is not
|
Normally, the Nix store directory (typically `/nix/store`) is not
|
||||||
@@ -50,7 +54,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.,
|
||||||
@@ -59,7 +63,7 @@ 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`\
|
||||||
|
|||||||
Generated
+4
-4
@@ -19,16 +19,16 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1614309161,
|
"lastModified": 1624862269,
|
||||||
"narHash": "sha256-93kRxDPyEW9QIpxU71kCaV1r+hgOgP6/aVgC7vvO8IU=",
|
"narHash": "sha256-JFcsh2+7QtfKdJFoPibLFPLgIW6Ycnv8Bts9a7RYme0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0e499fde7af3c28d63e9b13636716b86c3162b93",
|
"rev": "f77036342e2b690c61c97202bf48f2ce13acc022",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-20.09-small",
|
"ref": "nixos-21.05-small",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
description = "The purely functional package manager";
|
description = "The purely functional package manager";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-20.09-small";
|
inputs.nixpkgs.url = "nixpkgs/nixos-21.05-small";
|
||||||
inputs.lowdown-src = { url = "github:kristapsdz/lowdown/VERSION_0_8_4"; flake = false; };
|
inputs.lowdown-src = { url = "github:kristapsdz/lowdown/VERSION_0_8_4"; flake = false; };
|
||||||
|
|
||||||
outputs = { self, nixpkgs, lowdown-src }:
|
outputs = { self, nixpkgs, lowdown-src }:
|
||||||
@@ -18,7 +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" ];
|
systems = linuxSystems ++ [ "x86_64-darwin" "aarch64-darwin" ];
|
||||||
|
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||||
|
|
||||||
@@ -256,7 +256,8 @@
|
|||||||
boost
|
boost
|
||||||
nlohmann_json
|
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}
|
||||||
@@ -286,8 +287,8 @@
|
|||||||
|
|
||||||
nativeBuildInputs = [ 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
|
||||||
@@ -387,7 +388,7 @@
|
|||||||
# 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" "x86_64-darwin" "aarch64-linux" ];
|
installerScript = installScriptFor [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||||
installerScriptForGHA = installScriptFor [ "x86_64-linux" "x86_64-darwin" ];
|
installerScriptForGHA = installScriptFor [ "x86_64-linux" "x86_64-darwin" ];
|
||||||
|
|
||||||
# Line coverage analysis.
|
# Line coverage analysis.
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#compdef nix
|
||||||
|
|
||||||
function _nix() {
|
function _nix() {
|
||||||
local ifs_bk="$IFS"
|
local ifs_bk="$IFS"
|
||||||
local input=("${(Q)words[@]}")
|
local input=("${(Q)words[@]}")
|
||||||
@@ -18,4 +20,4 @@ function _nix() {
|
|||||||
_describe 'nix' suggestions
|
_describe 'nix' suggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
compdef _nix nix
|
_nix "$@"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
$(eval $(call install-file-as, $(d)/completion.zsh, $(datarootdir)/zsh/site-functions/_nix, 0644))
|
||||||
+7
-2
@@ -8,8 +8,13 @@ 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 -ldl
|
libnixrust_LDFLAGS_USE := -L$(d)/target/$(RUST_DIR) -lnixrust
|
||||||
libnixrust_LDFLAGS_USE_INSTALLED := -L$(libdir) -lnixrust -ldl
|
libnixrust_LDFLAGS_USE_INSTALLED := -L$(libdir) -lnixrust
|
||||||
|
|
||||||
|
ifeq ($(OS), Linux)
|
||||||
|
libnixrust_LDFLAGS_USE += -ldl
|
||||||
|
libnixrust_LDFLAGS_USE_INSTALLED += -ldl
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(OS), Darwin)
|
ifeq ($(OS), Darwin)
|
||||||
libnixrust_BUILD_FLAGS = NIX_LDFLAGS="-undefined dynamic_lookup"
|
libnixrust_BUILD_FLAGS = NIX_LDFLAGS="-undefined dynamic_lookup"
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ contact_us() {
|
|||||||
echo "You can open an issue at https://github.com/nixos/nix/issues"
|
echo "You can open an issue at https://github.com/nixos/nix/issues"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Or feel free to contact the team:"
|
echo "Or feel free to contact the team:"
|
||||||
echo " - IRC: in #nixos on irc.freenode.net"
|
echo " - Matrix: #nix:nixos.org"
|
||||||
|
echo " - IRC: in #nixos on irc.libera.chat"
|
||||||
echo " - twitter: @nixos_org"
|
echo " - twitter: @nixos_org"
|
||||||
echo " - forum: https://discourse.nixos.org"
|
echo " - forum: https://discourse.nixos.org"
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-9
@@ -46,15 +46,9 @@ case "$(uname -s).$(uname -m)" in
|
|||||||
system=x86_64-darwin
|
system=x86_64-darwin
|
||||||
;;
|
;;
|
||||||
Darwin.arm64|Darwin.aarch64)
|
Darwin.arm64|Darwin.aarch64)
|
||||||
# check for Rosetta 2 support
|
hash=@binaryTarball_aarch64-darwin@
|
||||||
if ! [ -f /Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist ]; then
|
path=@tarballPath_aarch64-darwin@
|
||||||
oops "Rosetta 2 is not installed on this ARM64 macOS machine. Run softwareupdate --install-rosetta then restart installation"
|
system=aarch64-darwin
|
||||||
fi
|
|
||||||
|
|
||||||
hash=@tarballHash_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
|
||||||
|
|||||||
@@ -277,7 +277,16 @@ connected:
|
|||||||
|
|
||||||
auto drv = store->readDerivation(*drvPath);
|
auto drv = store->readDerivation(*drvPath);
|
||||||
auto outputHashes = staticOutputHashes(*store, drv);
|
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);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/lib
|
|||||||
libexpr_LIBS = libutil libstore libfetchers
|
libexpr_LIBS = libutil libstore libfetchers
|
||||||
|
|
||||||
libexpr_LDFLAGS = -lboost_context
|
libexpr_LDFLAGS = -lboost_context
|
||||||
ifneq ($(OS), FreeBSD)
|
ifeq ($(OS), Linux)
|
||||||
libexpr_LDFLAGS += -ldl
|
libexpr_LDFLAGS += -ldl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <nlohmann/json_fwd.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace nix::fetchers {
|
namespace nix::fetchers {
|
||||||
|
|
||||||
typedef std::variant<std::string, uint64_t, Explicit<bool>> Attr;
|
typedef std::variant<std::string, uint64_t, Explicit<bool>> Attr;
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ struct TarballInputScheme : InputScheme
|
|||||||
&& !hasSuffix(url.path, ".tar")
|
&& !hasSuffix(url.path, ".tar")
|
||||||
&& !hasSuffix(url.path, ".tar.gz")
|
&& !hasSuffix(url.path, ".tar.gz")
|
||||||
&& !hasSuffix(url.path, ".tar.xz")
|
&& !hasSuffix(url.path, ".tar.xz")
|
||||||
&& !hasSuffix(url.path, ".tar.bz2"))
|
&& !hasSuffix(url.path, ".tar.bz2")
|
||||||
|
&& !hasSuffix(url.path, ".tar.zst"))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
Input input;
|
Input input;
|
||||||
|
|||||||
@@ -739,6 +739,63 @@ void DerivationGoal::cleanupPostOutputsRegisteredModeNonCheck()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runPostBuildHook(
|
||||||
|
Store & store,
|
||||||
|
Logger & logger,
|
||||||
|
const StorePath & drvPath,
|
||||||
|
StorePathSet outputPaths
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto hook = settings.postBuildHook;
|
||||||
|
if (hook == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
Activity act(logger, lvlInfo, actPostBuildHook,
|
||||||
|
fmt("running post-build-hook '%s'", settings.postBuildHook),
|
||||||
|
Logger::Fields{store.printStorePath(drvPath)});
|
||||||
|
PushActivity pact(act.id);
|
||||||
|
std::map<std::string, std::string> hookEnvironment = getEnv();
|
||||||
|
|
||||||
|
hookEnvironment.emplace("DRV_PATH", store.printStorePath(drvPath));
|
||||||
|
hookEnvironment.emplace("OUT_PATHS", chomp(concatStringsSep(" ", store.printStorePathSet(outputPaths))));
|
||||||
|
|
||||||
|
RunOptions opts(settings.postBuildHook, {});
|
||||||
|
opts.environment = hookEnvironment;
|
||||||
|
|
||||||
|
struct LogSink : Sink {
|
||||||
|
Activity & act;
|
||||||
|
std::string currentLine;
|
||||||
|
|
||||||
|
LogSink(Activity & act) : act(act) { }
|
||||||
|
|
||||||
|
void operator() (std::string_view data) override {
|
||||||
|
for (auto c : data) {
|
||||||
|
if (c == '\n') {
|
||||||
|
flushLine();
|
||||||
|
} else {
|
||||||
|
currentLine += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void flushLine() {
|
||||||
|
act.result(resPostBuildLogLine, currentLine);
|
||||||
|
currentLine.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
~LogSink() {
|
||||||
|
if (currentLine != "") {
|
||||||
|
currentLine += '\n';
|
||||||
|
flushLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
LogSink sink(act);
|
||||||
|
|
||||||
|
opts.standardOut = &sink;
|
||||||
|
opts.mergeStderrToStdout = true;
|
||||||
|
runProgram2(opts);
|
||||||
|
}
|
||||||
|
|
||||||
void DerivationGoal::buildDone()
|
void DerivationGoal::buildDone()
|
||||||
{
|
{
|
||||||
@@ -804,57 +861,15 @@ void DerivationGoal::buildDone()
|
|||||||
being valid. */
|
being valid. */
|
||||||
registerOutputs();
|
registerOutputs();
|
||||||
|
|
||||||
if (settings.postBuildHook != "") {
|
StorePathSet outputPaths;
|
||||||
Activity act(*logger, lvlInfo, actPostBuildHook,
|
for (auto & [_, path] : finalOutputs)
|
||||||
fmt("running post-build-hook '%s'", settings.postBuildHook),
|
outputPaths.insert(path);
|
||||||
Logger::Fields{worker.store.printStorePath(drvPath)});
|
runPostBuildHook(
|
||||||
PushActivity pact(act.id);
|
worker.store,
|
||||||
StorePathSet outputPaths;
|
*logger,
|
||||||
for (auto i : drv->outputs) {
|
drvPath,
|
||||||
outputPaths.insert(finalOutputs.at(i.first));
|
outputPaths
|
||||||
}
|
);
|
||||||
std::map<std::string, std::string> hookEnvironment = getEnv();
|
|
||||||
|
|
||||||
hookEnvironment.emplace("DRV_PATH", worker.store.printStorePath(drvPath));
|
|
||||||
hookEnvironment.emplace("OUT_PATHS", chomp(concatStringsSep(" ", worker.store.printStorePathSet(outputPaths))));
|
|
||||||
|
|
||||||
RunOptions opts(settings.postBuildHook, {});
|
|
||||||
opts.environment = hookEnvironment;
|
|
||||||
|
|
||||||
struct LogSink : Sink {
|
|
||||||
Activity & act;
|
|
||||||
std::string currentLine;
|
|
||||||
|
|
||||||
LogSink(Activity & act) : act(act) { }
|
|
||||||
|
|
||||||
void operator() (std::string_view data) override {
|
|
||||||
for (auto c : data) {
|
|
||||||
if (c == '\n') {
|
|
||||||
flushLine();
|
|
||||||
} else {
|
|
||||||
currentLine += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void flushLine() {
|
|
||||||
act.result(resPostBuildLogLine, currentLine);
|
|
||||||
currentLine.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
~LogSink() {
|
|
||||||
if (currentLine != "") {
|
|
||||||
currentLine += '\n';
|
|
||||||
flushLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
LogSink sink(act);
|
|
||||||
|
|
||||||
opts.standardOut = &sink;
|
|
||||||
opts.mergeStderrToStdout = true;
|
|
||||||
runProgram2(opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildMode == bmCheck) {
|
if (buildMode == bmCheck) {
|
||||||
cleanupPostOutputsRegisteredModeCheck();
|
cleanupPostOutputsRegisteredModeCheck();
|
||||||
@@ -910,6 +925,8 @@ void DerivationGoal::resolvedFinished() {
|
|||||||
|
|
||||||
auto resolvedHashes = staticOutputHashes(worker.store, *resolvedDrv);
|
auto resolvedHashes = staticOutputHashes(worker.store, *resolvedDrv);
|
||||||
|
|
||||||
|
StorePathSet outputPaths;
|
||||||
|
|
||||||
// `wantedOutputs` might be empty, which means “all the outputs”
|
// `wantedOutputs` might be empty, which means “all the outputs”
|
||||||
auto realWantedOutputs = wantedOutputs;
|
auto realWantedOutputs = wantedOutputs;
|
||||||
if (realWantedOutputs.empty())
|
if (realWantedOutputs.empty())
|
||||||
@@ -927,8 +944,10 @@ void DerivationGoal::resolvedFinished() {
|
|||||||
auto newRealisation = *realisation;
|
auto newRealisation = *realisation;
|
||||||
newRealisation.id = DrvOutput{initialOutputs.at(wantedOutput).outputHash, wantedOutput};
|
newRealisation.id = DrvOutput{initialOutputs.at(wantedOutput).outputHash, wantedOutput};
|
||||||
newRealisation.signatures.clear();
|
newRealisation.signatures.clear();
|
||||||
|
newRealisation.dependentRealisations = drvOutputReferences(worker.store, *drv, realisation->outPath);
|
||||||
signRealisation(newRealisation);
|
signRealisation(newRealisation);
|
||||||
worker.store.registerDrvOutput(newRealisation);
|
worker.store.registerDrvOutput(newRealisation);
|
||||||
|
outputPaths.insert(realisation->outPath);
|
||||||
} else {
|
} else {
|
||||||
// If we don't have a realisation, then it must mean that something
|
// If we don't have a realisation, then it must mean that something
|
||||||
// failed when building the resolved drv
|
// failed when building the resolved drv
|
||||||
@@ -936,6 +955,13 @@ void DerivationGoal::resolvedFinished() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPostBuildHook(
|
||||||
|
worker.store,
|
||||||
|
*logger,
|
||||||
|
drvPath,
|
||||||
|
outputPaths
|
||||||
|
);
|
||||||
|
|
||||||
// This is potentially a bit fishy in terms of error reporting. Not sure
|
// This is potentially a bit fishy in terms of error reporting. Not sure
|
||||||
// how to do it in a cleaner way
|
// how to do it in a cleaner way
|
||||||
amDone(nrFailed == 0 ? ecSuccess : ecFailed, ex);
|
amDone(nrFailed == 0 ? ecSuccess : ecFailed, ex);
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(const DrvOutput& id, Worker
|
|||||||
void DrvOutputSubstitutionGoal::init()
|
void DrvOutputSubstitutionGoal::init()
|
||||||
{
|
{
|
||||||
trace("init");
|
trace("init");
|
||||||
|
|
||||||
|
/* If the derivation already exists, we’re done */
|
||||||
|
if (worker.store.queryRealisation(id)) {
|
||||||
|
amDone(ecSuccess);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
subs = settings.useSubstitutes ? getDefaultSubstituters() : std::list<ref<Store>>();
|
subs = settings.useSubstitutes ? getDefaultSubstituters() : std::list<ref<Store>>();
|
||||||
tryNext();
|
tryNext();
|
||||||
}
|
}
|
||||||
@@ -53,6 +60,26 @@ void DrvOutputSubstitutionGoal::tryNext()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto & [depId, depPath] : outputInfo->dependentRealisations) {
|
||||||
|
if (depId != id) {
|
||||||
|
if (auto localOutputInfo = worker.store.queryRealisation(depId);
|
||||||
|
localOutputInfo && localOutputInfo->outPath != depPath) {
|
||||||
|
warn(
|
||||||
|
"substituter '%s' has an incompatible realisation for '%s', ignoring.\n"
|
||||||
|
"Local: %s\n"
|
||||||
|
"Remote: %s",
|
||||||
|
sub->getUri(),
|
||||||
|
depId.to_string(),
|
||||||
|
worker.store.printStorePath(localOutputInfo->outPath),
|
||||||
|
worker.store.printStorePath(depPath)
|
||||||
|
);
|
||||||
|
tryNext();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addWaitee(worker.makeDrvOutputSubstitutionGoal(depId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addWaitee(worker.makePathSubstitutionGoal(outputInfo->outPath));
|
addWaitee(worker.makePathSubstitutionGoal(outputInfo->outPath));
|
||||||
|
|
||||||
if (waitees.empty()) outPathValid();
|
if (waitees.empty()) outPathValid();
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ bool LocalDerivationGoal::cleanupDecideWhetherDiskFull()
|
|||||||
auto & localStore = getLocalStore();
|
auto & localStore = getLocalStore();
|
||||||
uint64_t required = 8ULL * 1024 * 1024; // FIXME: make configurable
|
uint64_t required = 8ULL * 1024 * 1024; // FIXME: make configurable
|
||||||
struct statvfs st;
|
struct statvfs st;
|
||||||
if (statvfs(localStore.realStoreDir.c_str(), &st) == 0 &&
|
if (statvfs(localStore.realStoreDir.get().c_str(), &st) == 0 &&
|
||||||
(uint64_t) st.f_bavail * st.f_bsize < required)
|
(uint64_t) st.f_bavail * st.f_bsize < required)
|
||||||
diskFull = true;
|
diskFull = true;
|
||||||
if (statvfs(tmpDir.c_str(), &st) == 0 &&
|
if (statvfs(tmpDir.c_str(), &st) == 0 &&
|
||||||
@@ -417,7 +417,7 @@ void LocalDerivationGoal::startBuilder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto & localStore = getLocalStore();
|
auto & localStore = getLocalStore();
|
||||||
if (localStore.storeDir != localStore.realStoreDir) {
|
if (localStore.storeDir != localStore.realStoreDir.get()) {
|
||||||
#if __linux__
|
#if __linux__
|
||||||
useChroot = true;
|
useChroot = true;
|
||||||
#else
|
#else
|
||||||
@@ -726,7 +726,7 @@ void LocalDerivationGoal::startBuilder()
|
|||||||
Path logFile = openLogFile();
|
Path logFile = openLogFile();
|
||||||
|
|
||||||
/* Create a pipe to get the output of the builder. */
|
/* Create a pipe to get the output of the builder. */
|
||||||
//builderOut.create();
|
builderOut.create();
|
||||||
|
|
||||||
builderOut.readSide = posix_openpt(O_RDWR | O_NOCTTY);
|
builderOut.readSide = posix_openpt(O_RDWR | O_NOCTTY);
|
||||||
if (!builderOut.readSide)
|
if (!builderOut.readSide)
|
||||||
@@ -1333,13 +1333,18 @@ struct RestrictedStore : public virtual RestrictedStoreConfig, public virtual Lo
|
|||||||
std::optional<const Realisation> queryRealisation(const DrvOutput & id) override
|
std::optional<const Realisation> queryRealisation(const DrvOutput & id) override
|
||||||
// XXX: This should probably be allowed if the realisation corresponds to
|
// XXX: This should probably be allowed if the realisation corresponds to
|
||||||
// an allowed derivation
|
// an allowed derivation
|
||||||
{ throw Error("queryRealisation"); }
|
{
|
||||||
|
if (!goal.isAllowed(id))
|
||||||
|
throw InvalidPath("cannot query an unknown output id '%s' in recursive Nix", id.to_string());
|
||||||
|
return next->queryRealisation(id);
|
||||||
|
}
|
||||||
|
|
||||||
void buildPaths(const std::vector<DerivedPath> & paths, BuildMode buildMode) override
|
void buildPaths(const std::vector<DerivedPath> & paths, BuildMode buildMode) override
|
||||||
{
|
{
|
||||||
if (buildMode != bmNormal) throw Error("unsupported build mode");
|
if (buildMode != bmNormal) throw Error("unsupported build mode");
|
||||||
|
|
||||||
StorePathSet newPaths;
|
StorePathSet newPaths;
|
||||||
|
std::set<Realisation> newRealisations;
|
||||||
|
|
||||||
for (auto & req : paths) {
|
for (auto & req : paths) {
|
||||||
if (!goal.isAllowed(req))
|
if (!goal.isAllowed(req))
|
||||||
@@ -1352,16 +1357,28 @@ struct RestrictedStore : public virtual RestrictedStoreConfig, public virtual Lo
|
|||||||
auto p = std::get_if<DerivedPath::Built>(&path);
|
auto p = std::get_if<DerivedPath::Built>(&path);
|
||||||
if (!p) continue;
|
if (!p) continue;
|
||||||
auto & bfd = *p;
|
auto & bfd = *p;
|
||||||
|
auto drv = readDerivation(bfd.drvPath);
|
||||||
|
auto drvHashes = staticOutputHashes(*this, drv);
|
||||||
auto outputs = next->queryDerivationOutputMap(bfd.drvPath);
|
auto outputs = next->queryDerivationOutputMap(bfd.drvPath);
|
||||||
for (auto & [outputName, outputPath] : outputs)
|
for (auto & [outputName, outputPath] : outputs)
|
||||||
if (wantOutput(outputName, bfd.outputs))
|
if (wantOutput(outputName, bfd.outputs)) {
|
||||||
newPaths.insert(outputPath);
|
newPaths.insert(outputPath);
|
||||||
|
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
||||||
|
auto thisRealisation = next->queryRealisation(
|
||||||
|
DrvOutput{drvHashes.at(outputName), outputName}
|
||||||
|
);
|
||||||
|
assert(thisRealisation);
|
||||||
|
newRealisations.insert(*thisRealisation);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePathSet closure;
|
StorePathSet closure;
|
||||||
next->computeFSClosure(newPaths, closure);
|
next->computeFSClosure(newPaths, closure);
|
||||||
for (auto & path : closure)
|
for (auto & path : closure)
|
||||||
goal.addDependency(path);
|
goal.addDependency(path);
|
||||||
|
for (auto & real : Realisation::closure(*next, newRealisations))
|
||||||
|
goal.addedDrvOutputs.insert(real.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildResult buildDerivation(const StorePath & drvPath, const BasicDerivation & drv,
|
BuildResult buildDerivation(const StorePath & drvPath, const BasicDerivation & drv,
|
||||||
@@ -2354,32 +2371,19 @@ void LocalDerivationGoal::registerOutputs()
|
|||||||
}
|
}
|
||||||
auto got = caSink.finish().first;
|
auto got = caSink.finish().first;
|
||||||
auto refs = rewriteRefs();
|
auto refs = rewriteRefs();
|
||||||
HashModuloSink narSink { htSHA256, oldHashPart };
|
|
||||||
dumpPath(actualPath, narSink);
|
auto finalPath = worker.store.makeFixedOutputPath(
|
||||||
auto narHashAndSize = narSink.finish();
|
|
||||||
ValidPathInfo newInfo0 {
|
|
||||||
worker.store.makeFixedOutputPath(
|
|
||||||
outputHash.method,
|
outputHash.method,
|
||||||
got,
|
got,
|
||||||
outputPathName(drv->name, outputName),
|
outputPathName(drv->name, outputName),
|
||||||
refs.second,
|
refs.second,
|
||||||
refs.first),
|
refs.first);
|
||||||
narHashAndSize.first,
|
if (scratchPath != finalPath) {
|
||||||
};
|
|
||||||
newInfo0.narSize = narHashAndSize.second;
|
|
||||||
newInfo0.ca = FixedOutputHash {
|
|
||||||
.method = outputHash.method,
|
|
||||||
.hash = got,
|
|
||||||
};
|
|
||||||
newInfo0.references = refs.second;
|
|
||||||
if (refs.first)
|
|
||||||
newInfo0.references.insert(newInfo0.path);
|
|
||||||
if (scratchPath != newInfo0.path) {
|
|
||||||
// Also rewrite the output path
|
// Also rewrite the output path
|
||||||
auto source = sinkToSource([&](Sink & nextSink) {
|
auto source = sinkToSource([&](Sink & nextSink) {
|
||||||
StringSink sink;
|
StringSink sink;
|
||||||
dumpPath(actualPath, sink);
|
dumpPath(actualPath, sink);
|
||||||
RewritingSink rsink2(oldHashPart, std::string(newInfo0.path.hashPart()), nextSink);
|
RewritingSink rsink2(oldHashPart, std::string(finalPath.hashPart()), nextSink);
|
||||||
rsink2(*sink.s);
|
rsink2(*sink.s);
|
||||||
rsink2.flush();
|
rsink2.flush();
|
||||||
});
|
});
|
||||||
@@ -2389,6 +2393,21 @@ void LocalDerivationGoal::registerOutputs()
|
|||||||
movePath(tmpPath, actualPath);
|
movePath(tmpPath, actualPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HashResult narHashAndSize = hashPath(htSHA256, actualPath);
|
||||||
|
ValidPathInfo newInfo0 {
|
||||||
|
finalPath,
|
||||||
|
narHashAndSize.first,
|
||||||
|
};
|
||||||
|
|
||||||
|
newInfo0.narSize = narHashAndSize.second;
|
||||||
|
newInfo0.ca = FixedOutputHash {
|
||||||
|
.method = outputHash.method,
|
||||||
|
.hash = got,
|
||||||
|
};
|
||||||
|
newInfo0.references = refs.second;
|
||||||
|
if (refs.first)
|
||||||
|
newInfo0.references.insert(newInfo0.path);
|
||||||
|
|
||||||
assert(newInfo0.ca);
|
assert(newInfo0.ca);
|
||||||
return newInfo0;
|
return newInfo0;
|
||||||
};
|
};
|
||||||
@@ -2462,6 +2481,7 @@ void LocalDerivationGoal::registerOutputs()
|
|||||||
floating CA derivations and hash-mismatching fixed-output
|
floating CA derivations and hash-mismatching fixed-output
|
||||||
derivations. */
|
derivations. */
|
||||||
PathLocks dynamicOutputLock;
|
PathLocks dynamicOutputLock;
|
||||||
|
dynamicOutputLock.setDeletion(true);
|
||||||
auto optFixedPath = output.path(worker.store, drv->name, outputName);
|
auto optFixedPath = output.path(worker.store, drv->name, outputName);
|
||||||
if (!optFixedPath ||
|
if (!optFixedPath ||
|
||||||
worker.store.printStorePath(*optFixedPath) != finalDestPath)
|
worker.store.printStorePath(*optFixedPath) != finalDestPath)
|
||||||
@@ -2485,6 +2505,7 @@ void LocalDerivationGoal::registerOutputs()
|
|||||||
assert(newInfo.ca);
|
assert(newInfo.ca);
|
||||||
} else {
|
} else {
|
||||||
auto destPath = worker.store.toRealPath(finalDestPath);
|
auto destPath = worker.store.toRealPath(finalDestPath);
|
||||||
|
deletePath(destPath);
|
||||||
movePath(actualPath, destPath);
|
movePath(actualPath, destPath);
|
||||||
actualPath = destPath;
|
actualPath = destPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ struct LocalDerivationGoal : public DerivationGoal
|
|||||||
/* Paths that were added via recursive Nix calls. */
|
/* Paths that were added via recursive Nix calls. */
|
||||||
StorePathSet addedPaths;
|
StorePathSet addedPaths;
|
||||||
|
|
||||||
|
/* Realisations that were added via recursive Nix calls. */
|
||||||
|
std::set<DrvOutput> addedDrvOutputs;
|
||||||
|
|
||||||
/* Recursive Nix calls are only allowed to build or realize paths
|
/* Recursive Nix calls are only allowed to build or realize paths
|
||||||
in the original input closure or added via a recursive Nix call
|
in the original input closure or added via a recursive Nix call
|
||||||
(so e.g. you can't do 'nix-store -r /nix/store/<bla>' where
|
(so e.g. you can't do 'nix-store -r /nix/store/<bla>' where
|
||||||
@@ -116,6 +119,11 @@ struct LocalDerivationGoal : public DerivationGoal
|
|||||||
{
|
{
|
||||||
return inputPaths.count(path) || addedPaths.count(path);
|
return inputPaths.count(path) || addedPaths.count(path);
|
||||||
}
|
}
|
||||||
|
bool isAllowed(const DrvOutput & id)
|
||||||
|
{
|
||||||
|
return addedDrvOutputs.count(id);
|
||||||
|
}
|
||||||
|
|
||||||
bool isAllowed(const DerivedPath & req);
|
bool isAllowed(const DerivedPath & req);
|
||||||
|
|
||||||
friend struct RestrictedStore;
|
friend struct RestrictedStore;
|
||||||
|
|||||||
@@ -3,10 +3,19 @@
|
|||||||
-- is enabled
|
-- is enabled
|
||||||
|
|
||||||
create table if not exists Realisations (
|
create table if not exists Realisations (
|
||||||
|
id integer primary key autoincrement not null,
|
||||||
drvPath text not null,
|
drvPath text not null,
|
||||||
outputName text not null, -- symbolic output id, usually "out"
|
outputName text not null, -- symbolic output id, usually "out"
|
||||||
outputPath integer not null,
|
outputPath integer not null,
|
||||||
signatures text, -- space-separated list
|
signatures text, -- space-separated list
|
||||||
primary key (drvPath, outputName),
|
|
||||||
foreign key (outputPath) references ValidPaths(id) on delete cascade
|
foreign key (outputPath) references ValidPaths(id) on delete cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create index if not exists IndexRealisations on Realisations(drvPath, outputName);
|
||||||
|
|
||||||
|
create table if not exists RealisationsRefs (
|
||||||
|
referrer integer not null,
|
||||||
|
realisationReference integer,
|
||||||
|
foreign key (referrer) references Realisations(id) on delete cascade,
|
||||||
|
foreign key (realisationReference) references Realisations(id) on delete restrict
|
||||||
|
);
|
||||||
+18
-7
@@ -885,10 +885,15 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||||||
|
|
||||||
case wopRegisterDrvOutput: {
|
case wopRegisterDrvOutput: {
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto outputId = DrvOutput::parse(readString(from));
|
if (GET_PROTOCOL_MINOR(clientVersion) < 31) {
|
||||||
auto outputPath = StorePath(readString(from));
|
auto outputId = DrvOutput::parse(readString(from));
|
||||||
store->registerDrvOutput(Realisation{
|
auto outputPath = StorePath(readString(from));
|
||||||
.id = outputId, .outPath = outputPath});
|
store->registerDrvOutput(Realisation{
|
||||||
|
.id = outputId, .outPath = outputPath});
|
||||||
|
} else {
|
||||||
|
auto realisation = worker_proto::read(*store, from, Phantom<Realisation>());
|
||||||
|
store->registerDrvOutput(realisation);
|
||||||
|
}
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -898,9 +903,15 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||||||
auto outputId = DrvOutput::parse(readString(from));
|
auto outputId = DrvOutput::parse(readString(from));
|
||||||
auto info = store->queryRealisation(outputId);
|
auto info = store->queryRealisation(outputId);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
std::set<StorePath> outPaths;
|
if (GET_PROTOCOL_MINOR(clientVersion) < 31) {
|
||||||
if (info) outPaths.insert(info->outPath);
|
std::set<StorePath> outPaths;
|
||||||
worker_proto::write(*store, to, outPaths);
|
if (info) outPaths.insert(info->outPath);
|
||||||
|
worker_proto::write(*store, to, outPaths);
|
||||||
|
} else {
|
||||||
|
std::set<Realisation> realisations;
|
||||||
|
if (info) realisations.insert(*info);
|
||||||
|
worker_proto::write(*store, to, realisations);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "finally.hh"
|
#include "finally.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
|
|
||||||
#ifdef ENABLE_S3
|
#if ENABLE_S3
|
||||||
#include <aws/core/client/ClientConfiguration.h>
|
#include <aws/core/client/ClientConfiguration.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -665,7 +665,7 @@ struct curlFileTransfer : public FileTransfer
|
|||||||
writeFull(wakeupPipe.writeSide.get(), " ");
|
writeFull(wakeupPipe.writeSide.get(), " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_S3
|
#if ENABLE_S3
|
||||||
std::tuple<std::string, std::string, Store::Params> parseS3Uri(std::string uri)
|
std::tuple<std::string, std::string, Store::Params> parseS3Uri(std::string uri)
|
||||||
{
|
{
|
||||||
auto [path, params] = splitUriAndParams(uri);
|
auto [path, params] = splitUriAndParams(uri);
|
||||||
@@ -688,7 +688,7 @@ struct curlFileTransfer : public FileTransfer
|
|||||||
if (hasPrefix(request.uri, "s3://")) {
|
if (hasPrefix(request.uri, "s3://")) {
|
||||||
// FIXME: do this on a worker thread
|
// FIXME: do this on a worker thread
|
||||||
try {
|
try {
|
||||||
#ifdef ENABLE_S3
|
#if ENABLE_S3
|
||||||
auto [bucketName, key, params] = parseS3Uri(request.uri);
|
auto [bucketName, key, params] = parseS3Uri(request.uri);
|
||||||
|
|
||||||
std::string profile = get(params, "profile").value_or("");
|
std::string profile = get(params, "profile").value_or("");
|
||||||
|
|||||||
+2
-2
@@ -775,7 +775,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
AutoCloseDir dir(opendir(realStoreDir.c_str()));
|
AutoCloseDir dir(opendir(realStoreDir.get().c_str()));
|
||||||
if (!dir) throw SysError("opening directory '%1%'", realStoreDir);
|
if (!dir) throw SysError("opening directory '%1%'", realStoreDir);
|
||||||
|
|
||||||
/* Read the store and immediately delete all paths that
|
/* Read the store and immediately delete all paths that
|
||||||
@@ -856,7 +856,7 @@ void LocalStore::autoGC(bool sync)
|
|||||||
return std::stoll(readFile(*fakeFreeSpaceFile));
|
return std::stoll(readFile(*fakeFreeSpaceFile));
|
||||||
|
|
||||||
struct statvfs st;
|
struct statvfs st;
|
||||||
if (statvfs(realStoreDir.c_str(), &st))
|
if (statvfs(realStoreDir.get().c_str(), &st))
|
||||||
throw SysError("getting filesystem info about '%s'", realStoreDir);
|
throw SysError("getting filesystem info about '%s'", realStoreDir);
|
||||||
|
|
||||||
return (uint64_t) st.f_bavail * st.f_frsize;
|
return (uint64_t) st.f_bavail * st.f_frsize;
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ struct LocalFSStoreConfig : virtual StoreConfig
|
|||||||
const PathSetting logDir{(StoreConfig*) this, false,
|
const PathSetting logDir{(StoreConfig*) this, false,
|
||||||
rootDir != "" ? rootDir + "/nix/var/log/nix" : settings.nixLogDir,
|
rootDir != "" ? rootDir + "/nix/var/log/nix" : settings.nixLogDir,
|
||||||
"log", "directory where Nix will store state"};
|
"log", "directory where Nix will store state"};
|
||||||
|
const PathSetting realStoreDir{(StoreConfig*) this, false,
|
||||||
|
rootDir != "" ? rootDir + "/nix/store" : storeDir, "real",
|
||||||
|
"physical path to the Nix store"};
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocalFSStore : public virtual LocalFSStoreConfig, public virtual Store
|
class LocalFSStore : public virtual LocalFSStoreConfig, public virtual Store
|
||||||
@@ -34,7 +37,7 @@ public:
|
|||||||
/* Register a permanent GC root. */
|
/* Register a permanent GC root. */
|
||||||
Path addPermRoot(const StorePath & storePath, const Path & gcRoot);
|
Path addPermRoot(const StorePath & storePath, const Path & gcRoot);
|
||||||
|
|
||||||
virtual Path getRealStoreDir() { return storeDir; }
|
virtual Path getRealStoreDir() { return realStoreDir; }
|
||||||
|
|
||||||
Path toRealPath(const Path & storePath) override
|
Path toRealPath(const Path & storePath) override
|
||||||
{
|
{
|
||||||
|
|||||||
+232
-43
@@ -53,12 +53,15 @@ struct LocalStore::State::Stmts {
|
|||||||
SQLiteStmt InvalidatePath;
|
SQLiteStmt InvalidatePath;
|
||||||
SQLiteStmt AddDerivationOutput;
|
SQLiteStmt AddDerivationOutput;
|
||||||
SQLiteStmt RegisterRealisedOutput;
|
SQLiteStmt RegisterRealisedOutput;
|
||||||
|
SQLiteStmt UpdateRealisedOutput;
|
||||||
SQLiteStmt QueryValidDerivers;
|
SQLiteStmt QueryValidDerivers;
|
||||||
SQLiteStmt QueryDerivationOutputs;
|
SQLiteStmt QueryDerivationOutputs;
|
||||||
SQLiteStmt QueryRealisedOutput;
|
SQLiteStmt QueryRealisedOutput;
|
||||||
SQLiteStmt QueryAllRealisedOutputs;
|
SQLiteStmt QueryAllRealisedOutputs;
|
||||||
SQLiteStmt QueryPathFromHashPart;
|
SQLiteStmt QueryPathFromHashPart;
|
||||||
SQLiteStmt QueryValidPaths;
|
SQLiteStmt QueryValidPaths;
|
||||||
|
SQLiteStmt QueryRealisationReferences;
|
||||||
|
SQLiteStmt AddRealisationReference;
|
||||||
};
|
};
|
||||||
|
|
||||||
int getSchema(Path schemaPath)
|
int getSchema(Path schemaPath)
|
||||||
@@ -76,7 +79,7 @@ int getSchema(Path schemaPath)
|
|||||||
|
|
||||||
void migrateCASchema(SQLite& db, Path schemaPath, AutoCloseFD& lockFd)
|
void migrateCASchema(SQLite& db, Path schemaPath, AutoCloseFD& lockFd)
|
||||||
{
|
{
|
||||||
const int nixCASchemaVersion = 1;
|
const int nixCASchemaVersion = 2;
|
||||||
int curCASchema = getSchema(schemaPath);
|
int curCASchema = getSchema(schemaPath);
|
||||||
if (curCASchema != nixCASchemaVersion) {
|
if (curCASchema != nixCASchemaVersion) {
|
||||||
if (curCASchema > nixCASchemaVersion) {
|
if (curCASchema > nixCASchemaVersion) {
|
||||||
@@ -94,7 +97,39 @@ void migrateCASchema(SQLite& db, Path schemaPath, AutoCloseFD& lockFd)
|
|||||||
#include "ca-specific-schema.sql.gen.hh"
|
#include "ca-specific-schema.sql.gen.hh"
|
||||||
;
|
;
|
||||||
db.exec(schema);
|
db.exec(schema);
|
||||||
|
curCASchema = nixCASchemaVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curCASchema < 2) {
|
||||||
|
SQLiteTxn txn(db);
|
||||||
|
// Ugly little sql dance to add a new `id` column and make it the primary key
|
||||||
|
db.exec(R"(
|
||||||
|
create table Realisations2 (
|
||||||
|
id integer primary key autoincrement not null,
|
||||||
|
drvPath text not null,
|
||||||
|
outputName text not null, -- symbolic output id, usually "out"
|
||||||
|
outputPath integer not null,
|
||||||
|
signatures text, -- space-separated list
|
||||||
|
foreign key (outputPath) references ValidPaths(id) on delete cascade
|
||||||
|
);
|
||||||
|
insert into Realisations2 (drvPath, outputName, outputPath, signatures)
|
||||||
|
select drvPath, outputName, outputPath, signatures from Realisations;
|
||||||
|
drop table Realisations;
|
||||||
|
alter table Realisations2 rename to Realisations;
|
||||||
|
)");
|
||||||
|
db.exec(R"(
|
||||||
|
create index if not exists IndexRealisations on Realisations(drvPath, outputName);
|
||||||
|
|
||||||
|
create table if not exists RealisationsRefs (
|
||||||
|
referrer integer not null,
|
||||||
|
realisationReference integer,
|
||||||
|
foreign key (referrer) references Realisations(id) on delete cascade,
|
||||||
|
foreign key (realisationReference) references Realisations(id) on delete restrict
|
||||||
|
);
|
||||||
|
)");
|
||||||
|
txn.commit();
|
||||||
|
}
|
||||||
|
|
||||||
writeFile(schemaPath, fmt("%d", nixCASchemaVersion));
|
writeFile(schemaPath, fmt("%d", nixCASchemaVersion));
|
||||||
lockFile(lockFd.get(), ltRead, true);
|
lockFile(lockFd.get(), ltRead, true);
|
||||||
}
|
}
|
||||||
@@ -106,9 +141,6 @@ LocalStore::LocalStore(const Params & params)
|
|||||||
, LocalStoreConfig(params)
|
, LocalStoreConfig(params)
|
||||||
, Store(params)
|
, Store(params)
|
||||||
, LocalFSStore(params)
|
, LocalFSStore(params)
|
||||||
, realStoreDir_{this, false, rootDir != "" ? rootDir + "/nix/store" : storeDir, "real",
|
|
||||||
"physical path to the Nix store"}
|
|
||||||
, realStoreDir(realStoreDir_)
|
|
||||||
, dbDir(stateDir + "/db")
|
, dbDir(stateDir + "/db")
|
||||||
, linksDir(realStoreDir + "/.links")
|
, linksDir(realStoreDir + "/.links")
|
||||||
, reservedPath(dbDir + "/reserved")
|
, reservedPath(dbDir + "/reserved")
|
||||||
@@ -153,13 +185,13 @@ LocalStore::LocalStore(const Params & params)
|
|||||||
printError("warning: the group '%1%' specified in 'build-users-group' does not exist", settings.buildUsersGroup);
|
printError("warning: the group '%1%' specified in 'build-users-group' does not exist", settings.buildUsersGroup);
|
||||||
else {
|
else {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(realStoreDir.c_str(), &st))
|
if (stat(realStoreDir.get().c_str(), &st))
|
||||||
throw SysError("getting attributes of path '%1%'", realStoreDir);
|
throw SysError("getting attributes of path '%1%'", realStoreDir);
|
||||||
|
|
||||||
if (st.st_uid != 0 || st.st_gid != gr->gr_gid || (st.st_mode & ~S_IFMT) != perm) {
|
if (st.st_uid != 0 || st.st_gid != gr->gr_gid || (st.st_mode & ~S_IFMT) != perm) {
|
||||||
if (chown(realStoreDir.c_str(), 0, gr->gr_gid) == -1)
|
if (chown(realStoreDir.get().c_str(), 0, gr->gr_gid) == -1)
|
||||||
throw SysError("changing ownership of path '%1%'", realStoreDir);
|
throw SysError("changing ownership of path '%1%'", realStoreDir);
|
||||||
if (chmod(realStoreDir.c_str(), perm) == -1)
|
if (chmod(realStoreDir.get().c_str(), perm) == -1)
|
||||||
throw SysError("changing permissions on path '%1%'", realStoreDir);
|
throw SysError("changing permissions on path '%1%'", realStoreDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,9 +346,18 @@ LocalStore::LocalStore(const Params & params)
|
|||||||
values (?, ?, (select id from ValidPaths where path = ?), ?)
|
values (?, ?, (select id from ValidPaths where path = ?), ?)
|
||||||
;
|
;
|
||||||
)");
|
)");
|
||||||
|
state->stmts->UpdateRealisedOutput.create(state->db,
|
||||||
|
R"(
|
||||||
|
update Realisations
|
||||||
|
set signatures = ?
|
||||||
|
where
|
||||||
|
drvPath = ? and
|
||||||
|
outputName = ?
|
||||||
|
;
|
||||||
|
)");
|
||||||
state->stmts->QueryRealisedOutput.create(state->db,
|
state->stmts->QueryRealisedOutput.create(state->db,
|
||||||
R"(
|
R"(
|
||||||
select Output.path, Realisations.signatures from Realisations
|
select Realisations.id, Output.path, Realisations.signatures from Realisations
|
||||||
inner join ValidPaths as Output on Output.id = Realisations.outputPath
|
inner join ValidPaths as Output on Output.id = Realisations.outputPath
|
||||||
where drvPath = ? and outputName = ?
|
where drvPath = ? and outputName = ?
|
||||||
;
|
;
|
||||||
@@ -328,6 +369,19 @@ LocalStore::LocalStore(const Params & params)
|
|||||||
where drvPath = ?
|
where drvPath = ?
|
||||||
;
|
;
|
||||||
)");
|
)");
|
||||||
|
state->stmts->QueryRealisationReferences.create(state->db,
|
||||||
|
R"(
|
||||||
|
select drvPath, outputName from Realisations
|
||||||
|
join RealisationsRefs on realisationReference = Realisations.id
|
||||||
|
where referrer = ?;
|
||||||
|
)");
|
||||||
|
state->stmts->AddRealisationReference.create(state->db,
|
||||||
|
R"(
|
||||||
|
insert or replace into RealisationsRefs (referrer, realisationReference)
|
||||||
|
values (
|
||||||
|
?,
|
||||||
|
(select id from Realisations where drvPath = ? and outputName = ?));
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,14 +491,14 @@ void LocalStore::makeStoreWritable()
|
|||||||
if (getuid() != 0) return;
|
if (getuid() != 0) return;
|
||||||
/* Check if /nix/store is on a read-only mount. */
|
/* Check if /nix/store is on a read-only mount. */
|
||||||
struct statvfs stat;
|
struct statvfs stat;
|
||||||
if (statvfs(realStoreDir.c_str(), &stat) != 0)
|
if (statvfs(realStoreDir.get().c_str(), &stat) != 0)
|
||||||
throw SysError("getting info about the Nix store mount point");
|
throw SysError("getting info about the Nix store mount point");
|
||||||
|
|
||||||
if (stat.f_flag & ST_RDONLY) {
|
if (stat.f_flag & ST_RDONLY) {
|
||||||
if (unshare(CLONE_NEWNS) == -1)
|
if (unshare(CLONE_NEWNS) == -1)
|
||||||
throw SysError("setting up a private mount namespace");
|
throw SysError("setting up a private mount namespace");
|
||||||
|
|
||||||
if (mount(0, realStoreDir.c_str(), "none", MS_REMOUNT | MS_BIND, 0) == -1)
|
if (mount(0, realStoreDir.get().c_str(), "none", MS_REMOUNT | MS_BIND, 0) == -1)
|
||||||
throw SysError("remounting %1% writable", realStoreDir);
|
throw SysError("remounting %1% writable", realStoreDir);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -664,14 +718,54 @@ void LocalStore::registerDrvOutput(const Realisation & info, CheckSigsFlag check
|
|||||||
void LocalStore::registerDrvOutput(const Realisation & info)
|
void LocalStore::registerDrvOutput(const Realisation & info)
|
||||||
{
|
{
|
||||||
settings.requireExperimentalFeature("ca-derivations");
|
settings.requireExperimentalFeature("ca-derivations");
|
||||||
auto state(_state.lock());
|
|
||||||
retrySQLite<void>([&]() {
|
retrySQLite<void>([&]() {
|
||||||
state->stmts->RegisterRealisedOutput.use()
|
auto state(_state.lock());
|
||||||
(info.id.strHash())
|
if (auto oldR = queryRealisation_(*state, info.id)) {
|
||||||
(info.id.outputName)
|
if (info.isCompatibleWith(*oldR)) {
|
||||||
(printStorePath(info.outPath))
|
auto combinedSignatures = oldR->signatures;
|
||||||
(concatStringsSep(" ", info.signatures))
|
combinedSignatures.insert(info.signatures.begin(),
|
||||||
.exec();
|
info.signatures.end());
|
||||||
|
state->stmts->UpdateRealisedOutput.use()
|
||||||
|
(concatStringsSep(" ", combinedSignatures))
|
||||||
|
(info.id.strHash())
|
||||||
|
(info.id.outputName)
|
||||||
|
.exec();
|
||||||
|
} else {
|
||||||
|
throw Error("Trying to register a realisation of '%s', but we already "
|
||||||
|
"have another one locally.\n"
|
||||||
|
"Local: %s\n"
|
||||||
|
"Remote: %s",
|
||||||
|
info.id.to_string(),
|
||||||
|
printStorePath(oldR->outPath),
|
||||||
|
printStorePath(info.outPath)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state->stmts->RegisterRealisedOutput.use()
|
||||||
|
(info.id.strHash())
|
||||||
|
(info.id.outputName)
|
||||||
|
(printStorePath(info.outPath))
|
||||||
|
(concatStringsSep(" ", info.signatures))
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
|
uint64_t myId = state->db.getLastInsertedRowId();
|
||||||
|
for (auto & [outputId, depPath] : info.dependentRealisations) {
|
||||||
|
auto localRealisation = queryRealisationCore_(*state, outputId);
|
||||||
|
if (!localRealisation)
|
||||||
|
throw Error("unable to register the derivation '%s' as it "
|
||||||
|
"depends on the non existent '%s'",
|
||||||
|
info.id.to_string(), outputId.to_string());
|
||||||
|
if (localRealisation->second.outPath != depPath)
|
||||||
|
throw Error("unable to register the derivation '%s' as it "
|
||||||
|
"depends on a realisation of '%s' that doesn’t"
|
||||||
|
"match what we have locally",
|
||||||
|
info.id.to_string(), outputId.to_string());
|
||||||
|
state->stmts->AddRealisationReference.use()
|
||||||
|
(myId)
|
||||||
|
(outputId.strHash())
|
||||||
|
(outputId.outputName)
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1152,17 +1246,13 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
|
|||||||
|
|
||||||
/* While restoring the path from the NAR, compute the hash
|
/* While restoring the path from the NAR, compute the hash
|
||||||
of the NAR. */
|
of the NAR. */
|
||||||
std::unique_ptr<AbstractHashSink> hashSink;
|
HashSink hashSink(htSHA256);
|
||||||
if (!info.ca.has_value() || !info.references.count(info.path))
|
|
||||||
hashSink = std::make_unique<HashSink>(htSHA256);
|
|
||||||
else
|
|
||||||
hashSink = std::make_unique<HashModuloSink>(htSHA256, std::string(info.path.hashPart()));
|
|
||||||
|
|
||||||
TeeSource wrapperSource { source, *hashSink };
|
TeeSource wrapperSource { source, hashSink };
|
||||||
|
|
||||||
restorePath(realPath, wrapperSource);
|
restorePath(realPath, wrapperSource);
|
||||||
|
|
||||||
auto hashResult = hashSink->finish();
|
auto hashResult = hashSink.finish();
|
||||||
|
|
||||||
if (hashResult.first != info.narHash)
|
if (hashResult.first != info.narHash)
|
||||||
throw Error("hash mismatch importing path '%s';\n specified: %s\n got: %s",
|
throw Error("hash mismatch importing path '%s';\n specified: %s\n got: %s",
|
||||||
@@ -1172,6 +1262,31 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
|
|||||||
throw Error("size mismatch importing path '%s';\n specified: %s\n got: %s",
|
throw Error("size mismatch importing path '%s';\n specified: %s\n got: %s",
|
||||||
printStorePath(info.path), info.narSize, hashResult.second);
|
printStorePath(info.path), info.narSize, hashResult.second);
|
||||||
|
|
||||||
|
if (info.ca) {
|
||||||
|
if (auto foHash = std::get_if<FixedOutputHash>(&*info.ca)) {
|
||||||
|
auto actualFoHash = hashCAPath(
|
||||||
|
foHash->method,
|
||||||
|
foHash->hash.type,
|
||||||
|
info.path
|
||||||
|
);
|
||||||
|
if (foHash->hash != actualFoHash.hash) {
|
||||||
|
throw Error("ca hash mismatch importing path '%s';\n specified: %s\n got: %s",
|
||||||
|
printStorePath(info.path),
|
||||||
|
foHash->hash.to_string(Base32, true),
|
||||||
|
actualFoHash.hash.to_string(Base32, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (auto textHash = std::get_if<TextHash>(&*info.ca)) {
|
||||||
|
auto actualTextHash = hashString(htSHA256, readFile(realPath));
|
||||||
|
if (textHash->hash != actualTextHash) {
|
||||||
|
throw Error("ca hash mismatch importing path '%s';\n specified: %s\n got: %s",
|
||||||
|
printStorePath(info.path),
|
||||||
|
textHash->hash.to_string(Base32, true),
|
||||||
|
actualTextHash.to_string(Base32, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
autoGC();
|
autoGC();
|
||||||
|
|
||||||
canonicalisePathMetaData(realPath, -1);
|
canonicalisePathMetaData(realPath, -1);
|
||||||
@@ -1440,14 +1555,10 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
|||||||
/* Check the content hash (optionally - slow). */
|
/* Check the content hash (optionally - slow). */
|
||||||
printMsg(lvlTalkative, "checking contents of '%s'", printStorePath(i));
|
printMsg(lvlTalkative, "checking contents of '%s'", printStorePath(i));
|
||||||
|
|
||||||
std::unique_ptr<AbstractHashSink> hashSink;
|
auto hashSink = HashSink(info->narHash.type);
|
||||||
if (!info->ca || !info->references.count(info->path))
|
|
||||||
hashSink = std::make_unique<HashSink>(info->narHash.type);
|
|
||||||
else
|
|
||||||
hashSink = std::make_unique<HashModuloSink>(info->narHash.type, std::string(info->path.hashPart()));
|
|
||||||
|
|
||||||
dumpPath(Store::toRealPath(i), *hashSink);
|
dumpPath(Store::toRealPath(i), hashSink);
|
||||||
auto current = hashSink->finish();
|
auto current = hashSink.finish();
|
||||||
|
|
||||||
if (info->narHash != nullHash && info->narHash != current.first) {
|
if (info->narHash != nullHash && info->narHash != current.first) {
|
||||||
printError("path '%s' was modified! expected hash '%s', got '%s'",
|
printError("path '%s' was modified! expected hash '%s', got '%s'",
|
||||||
@@ -1665,19 +1776,97 @@ void LocalStore::createUser(const std::string & userName, uid_t userId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<const Realisation> LocalStore::queryRealisation(
|
std::optional<std::pair<int64_t, Realisation>> LocalStore::queryRealisationCore_(
|
||||||
const DrvOutput& id) {
|
LocalStore::State & state,
|
||||||
typedef std::optional<const Realisation> Ret;
|
const DrvOutput & id)
|
||||||
return retrySQLite<Ret>([&]() -> Ret {
|
{
|
||||||
|
auto useQueryRealisedOutput(
|
||||||
|
state.stmts->QueryRealisedOutput.use()
|
||||||
|
(id.strHash())
|
||||||
|
(id.outputName));
|
||||||
|
if (!useQueryRealisedOutput.next())
|
||||||
|
return std::nullopt;
|
||||||
|
auto realisationDbId = useQueryRealisedOutput.getInt(0);
|
||||||
|
auto outputPath = parseStorePath(useQueryRealisedOutput.getStr(1));
|
||||||
|
auto signatures =
|
||||||
|
tokenizeString<StringSet>(useQueryRealisedOutput.getStr(2));
|
||||||
|
|
||||||
|
return {{
|
||||||
|
realisationDbId,
|
||||||
|
Realisation{
|
||||||
|
.id = id,
|
||||||
|
.outPath = outputPath,
|
||||||
|
.signatures = signatures,
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<const Realisation> LocalStore::queryRealisation_(
|
||||||
|
LocalStore::State & state,
|
||||||
|
const DrvOutput & id)
|
||||||
|
{
|
||||||
|
auto maybeCore = queryRealisationCore_(state, id);
|
||||||
|
if (!maybeCore)
|
||||||
|
return std::nullopt;
|
||||||
|
auto [realisationDbId, res] = *maybeCore;
|
||||||
|
|
||||||
|
std::map<DrvOutput, StorePath> dependentRealisations;
|
||||||
|
auto useRealisationRefs(
|
||||||
|
state.stmts->QueryRealisationReferences.use()
|
||||||
|
(realisationDbId));
|
||||||
|
while (useRealisationRefs.next()) {
|
||||||
|
auto depId = DrvOutput {
|
||||||
|
Hash::parseAnyPrefixed(useRealisationRefs.getStr(0)),
|
||||||
|
useRealisationRefs.getStr(1),
|
||||||
|
};
|
||||||
|
auto dependentRealisation = queryRealisationCore_(state, depId);
|
||||||
|
assert(dependentRealisation); // Enforced by the db schema
|
||||||
|
auto outputPath = dependentRealisation->second.outPath;
|
||||||
|
dependentRealisations.insert({depId, outputPath});
|
||||||
|
}
|
||||||
|
|
||||||
|
res.dependentRealisations = dependentRealisations;
|
||||||
|
|
||||||
|
return { res };
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<const Realisation>
|
||||||
|
LocalStore::queryRealisation(const DrvOutput & id)
|
||||||
|
{
|
||||||
|
return retrySQLite<std::optional<const Realisation>>([&]() {
|
||||||
auto state(_state.lock());
|
auto state(_state.lock());
|
||||||
auto use(state->stmts->QueryRealisedOutput.use()(id.strHash())(
|
return queryRealisation_(*state, id);
|
||||||
id.outputName));
|
|
||||||
if (!use.next())
|
|
||||||
return std::nullopt;
|
|
||||||
auto outputPath = parseStorePath(use.getStr(0));
|
|
||||||
auto signatures = tokenizeString<StringSet>(use.getStr(1));
|
|
||||||
return Ret{Realisation{
|
|
||||||
.id = id, .outPath = outputPath, .signatures = signatures}};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FixedOutputHash LocalStore::hashCAPath(
|
||||||
|
const FileIngestionMethod & method, const HashType & hashType,
|
||||||
|
const StorePath & path)
|
||||||
|
{
|
||||||
|
return hashCAPath(method, hashType, Store::toRealPath(path), path.hashPart());
|
||||||
|
}
|
||||||
|
|
||||||
|
FixedOutputHash LocalStore::hashCAPath(
|
||||||
|
const FileIngestionMethod & method,
|
||||||
|
const HashType & hashType,
|
||||||
|
const Path & path,
|
||||||
|
const std::string_view pathHash
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HashModuloSink caSink ( hashType, std::string(pathHash) );
|
||||||
|
switch (method) {
|
||||||
|
case FileIngestionMethod::Recursive:
|
||||||
|
dumpPath(path, caSink);
|
||||||
|
break;
|
||||||
|
case FileIngestionMethod::Flat:
|
||||||
|
readFile(path, caSink);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto hash = caSink.finish().first;
|
||||||
|
return FixedOutputHash{
|
||||||
|
.method = method,
|
||||||
|
.hash = hash,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
@@ -83,9 +83,6 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PathSetting realStoreDir_;
|
|
||||||
|
|
||||||
const Path realStoreDir;
|
|
||||||
const Path dbDir;
|
const Path dbDir;
|
||||||
const Path linksDir;
|
const Path linksDir;
|
||||||
const Path reservedPath;
|
const Path reservedPath;
|
||||||
@@ -206,6 +203,8 @@ public:
|
|||||||
void registerDrvOutput(const Realisation & info, CheckSigsFlag checkSigs) override;
|
void registerDrvOutput(const Realisation & info, CheckSigsFlag checkSigs) override;
|
||||||
void cacheDrvOutputMapping(State & state, const uint64_t deriver, const string & outputName, const StorePath & output);
|
void cacheDrvOutputMapping(State & state, const uint64_t deriver, const string & outputName, const StorePath & output);
|
||||||
|
|
||||||
|
std::optional<const Realisation> queryRealisation_(State & state, const DrvOutput & id);
|
||||||
|
std::optional<std::pair<int64_t, Realisation>> queryRealisationCore_(State & state, const DrvOutput & id);
|
||||||
std::optional<const Realisation> queryRealisation(const DrvOutput&) override;
|
std::optional<const Realisation> queryRealisation(const DrvOutput&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -279,10 +278,21 @@ private:
|
|||||||
void signPathInfo(ValidPathInfo & info);
|
void signPathInfo(ValidPathInfo & info);
|
||||||
void signRealisation(Realisation &);
|
void signRealisation(Realisation &);
|
||||||
|
|
||||||
Path getRealStoreDir() override { return realStoreDir; }
|
|
||||||
|
|
||||||
void createUser(const std::string & userName, uid_t userId) override;
|
void createUser(const std::string & userName, uid_t userId) override;
|
||||||
|
|
||||||
|
// XXX: Make a generic `Store` method
|
||||||
|
FixedOutputHash hashCAPath(
|
||||||
|
const FileIngestionMethod & method,
|
||||||
|
const HashType & hashType,
|
||||||
|
const StorePath & path);
|
||||||
|
|
||||||
|
FixedOutputHash hashCAPath(
|
||||||
|
const FileIngestionMethod & method,
|
||||||
|
const HashType & hashType,
|
||||||
|
const Path & path,
|
||||||
|
const std::string_view pathHash
|
||||||
|
);
|
||||||
|
|
||||||
friend struct LocalDerivationGoal;
|
friend struct LocalDerivationGoal;
|
||||||
friend struct PathSubstitutionGoal;
|
friend struct PathSubstitutionGoal;
|
||||||
friend struct SubstitutionGoal;
|
friend struct SubstitutionGoal;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc $(d)/build/*.cc)
|
|||||||
libstore_LIBS = libutil
|
libstore_LIBS = libutil
|
||||||
|
|
||||||
libstore_LDFLAGS = $(SQLITE3_LIBS) -lbz2 $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread
|
libstore_LDFLAGS = $(SQLITE3_LIBS) -lbz2 $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread
|
||||||
ifneq ($(OS), FreeBSD)
|
ifeq ($(OS), Linux)
|
||||||
libstore_LDFLAGS += -ldl
|
libstore_LDFLAGS += -ldl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
+93
-79
@@ -6,98 +6,73 @@
|
|||||||
#include "thread-pool.hh"
|
#include "thread-pool.hh"
|
||||||
#include "topo-sort.hh"
|
#include "topo-sort.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
|
#include "closure.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
void Store::computeFSClosure(const StorePathSet & startPaths,
|
void Store::computeFSClosure(const StorePathSet & startPaths,
|
||||||
StorePathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
StorePathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
||||||
{
|
{
|
||||||
struct State
|
std::function<std::set<StorePath>(const StorePath & path, std::future<ref<const ValidPathInfo>> &)> queryDeps;
|
||||||
{
|
if (flipDirection)
|
||||||
size_t pending;
|
queryDeps = [&](const StorePath& path,
|
||||||
StorePathSet & paths;
|
std::future<ref<const ValidPathInfo>> & fut) {
|
||||||
std::exception_ptr exc;
|
StorePathSet res;
|
||||||
};
|
StorePathSet referrers;
|
||||||
|
queryReferrers(path, referrers);
|
||||||
|
for (auto& ref : referrers)
|
||||||
|
if (ref != path)
|
||||||
|
res.insert(ref);
|
||||||
|
|
||||||
Sync<State> state_(State{0, paths_, 0});
|
if (includeOutputs)
|
||||||
|
for (auto& i : queryValidDerivers(path))
|
||||||
|
res.insert(i);
|
||||||
|
|
||||||
std::function<void(const StorePath &)> enqueue;
|
if (includeDerivers && path.isDerivation())
|
||||||
|
for (auto& [_, maybeOutPath] : queryPartialDerivationOutputMap(path))
|
||||||
|
if (maybeOutPath && isValidPath(*maybeOutPath))
|
||||||
|
res.insert(*maybeOutPath);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
else
|
||||||
|
queryDeps = [&](const StorePath& path,
|
||||||
|
std::future<ref<const ValidPathInfo>> & fut) {
|
||||||
|
StorePathSet res;
|
||||||
|
auto info = fut.get();
|
||||||
|
for (auto& ref : info->references)
|
||||||
|
if (ref != path)
|
||||||
|
res.insert(ref);
|
||||||
|
|
||||||
std::condition_variable done;
|
if (includeOutputs && path.isDerivation())
|
||||||
|
for (auto& [_, maybeOutPath] : queryPartialDerivationOutputMap(path))
|
||||||
|
if (maybeOutPath && isValidPath(*maybeOutPath))
|
||||||
|
res.insert(*maybeOutPath);
|
||||||
|
|
||||||
enqueue = [&](const StorePath & path) -> void {
|
if (includeDerivers && info->deriver && isValidPath(*info->deriver))
|
||||||
{
|
res.insert(*info->deriver);
|
||||||
auto state(state_.lock());
|
return res;
|
||||||
if (state->exc) return;
|
};
|
||||||
if (!state->paths.insert(path).second) return;
|
|
||||||
state->pending++;
|
|
||||||
}
|
|
||||||
|
|
||||||
queryPathInfo(path, {[&](std::future<ref<const ValidPathInfo>> fut) {
|
computeClosure<StorePath>(
|
||||||
// FIXME: calls to isValidPath() should be async
|
startPaths, paths_,
|
||||||
|
[&](const StorePath& path,
|
||||||
try {
|
std::function<void(std::promise<std::set<StorePath>>&)>
|
||||||
auto info = fut.get();
|
processEdges) {
|
||||||
|
std::promise<std::set<StorePath>> promise;
|
||||||
if (flipDirection) {
|
std::function<void(std::future<ref<const ValidPathInfo>>)>
|
||||||
|
getDependencies =
|
||||||
StorePathSet referrers;
|
[&](std::future<ref<const ValidPathInfo>> fut) {
|
||||||
queryReferrers(path, referrers);
|
try {
|
||||||
for (auto & ref : referrers)
|
promise.set_value(queryDeps(path, fut));
|
||||||
if (ref != path)
|
} catch (...) {
|
||||||
enqueue(ref);
|
promise.set_exception(std::current_exception());
|
||||||
|
}
|
||||||
if (includeOutputs)
|
};
|
||||||
for (auto & i : queryValidDerivers(path))
|
queryPathInfo(path, getDependencies);
|
||||||
enqueue(i);
|
processEdges(promise);
|
||||||
|
});
|
||||||
if (includeDerivers && path.isDerivation())
|
|
||||||
for (auto & i : queryDerivationOutputs(path))
|
|
||||||
if (isValidPath(i) && queryPathInfo(i)->deriver == path)
|
|
||||||
enqueue(i);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
for (auto & ref : info->references)
|
|
||||||
if (ref != path)
|
|
||||||
enqueue(ref);
|
|
||||||
|
|
||||||
if (includeOutputs && path.isDerivation())
|
|
||||||
for (auto & i : queryDerivationOutputs(path))
|
|
||||||
if (isValidPath(i)) enqueue(i);
|
|
||||||
|
|
||||||
if (includeDerivers && info->deriver && isValidPath(*info->deriver))
|
|
||||||
enqueue(*info->deriver);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto state(state_.lock());
|
|
||||||
assert(state->pending);
|
|
||||||
if (!--state->pending) done.notify_one();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (...) {
|
|
||||||
auto state(state_.lock());
|
|
||||||
if (!state->exc) state->exc = std::current_exception();
|
|
||||||
assert(state->pending);
|
|
||||||
if (!--state->pending) done.notify_one();
|
|
||||||
};
|
|
||||||
}});
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto & startPath : startPaths)
|
|
||||||
enqueue(startPath);
|
|
||||||
|
|
||||||
{
|
|
||||||
auto state(state_.lock());
|
|
||||||
while (state->pending) state.wait(done);
|
|
||||||
if (state->exc) std::rethrow_exception(state->exc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Store::computeFSClosure(const StorePath & startPath,
|
void Store::computeFSClosure(const StorePath & startPath,
|
||||||
StorePathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
StorePathSet & paths_, bool flipDirection, bool includeOutputs, bool includeDerivers)
|
||||||
{
|
{
|
||||||
@@ -279,5 +254,44 @@ StorePaths Store::topoSortPaths(const StorePathSet & paths)
|
|||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<DrvOutput, StorePath> drvOutputReferences(
|
||||||
|
const std::set<Realisation> & inputRealisations,
|
||||||
|
const StorePathSet & pathReferences)
|
||||||
|
{
|
||||||
|
std::map<DrvOutput, StorePath> res;
|
||||||
|
|
||||||
|
for (const auto & input : inputRealisations) {
|
||||||
|
if (pathReferences.count(input.outPath)) {
|
||||||
|
res.insert({input.id, input.outPath});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<DrvOutput, StorePath> drvOutputReferences(
|
||||||
|
Store & store,
|
||||||
|
const Derivation & drv,
|
||||||
|
const StorePath & outputPath)
|
||||||
|
{
|
||||||
|
std::set<Realisation> inputRealisations;
|
||||||
|
|
||||||
|
for (const auto& [inputDrv, outputNames] : drv.inputDrvs) {
|
||||||
|
auto outputHashes =
|
||||||
|
staticOutputHashes(store, store.readDerivation(inputDrv));
|
||||||
|
for (const auto& outputName : outputNames) {
|
||||||
|
auto thisRealisation = store.queryRealisation(
|
||||||
|
DrvOutput{outputHashes.at(outputName), outputName});
|
||||||
|
if (!thisRealisation)
|
||||||
|
throw Error(
|
||||||
|
"output '%s' of derivation '%s' isn’t built", outputName,
|
||||||
|
store.printStorePath(inputDrv));
|
||||||
|
inputRealisations.insert(*thisRealisation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto info = store.queryPathInfo(outputPath);
|
||||||
|
|
||||||
|
return drvOutputReferences(Realisation::closure(store, inputRealisations), info->references);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
|
|||||||
/* Make the containing directory writable, but only if it's not
|
/* Make the containing directory writable, but only if it's not
|
||||||
the store itself (we don't want or need to mess with its
|
the store itself (we don't want or need to mess with its
|
||||||
permissions). */
|
permissions). */
|
||||||
bool mustToggle = dirOf(path) != realStoreDir;
|
bool mustToggle = dirOf(path) != realStoreDir.get();
|
||||||
if (mustToggle) makeWritable(dirOf(path));
|
if (mustToggle) makeWritable(dirOf(path));
|
||||||
|
|
||||||
/* When we're done, make the directory read-only again and reset
|
/* When we're done, make the directory read-only again and reset
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ StringSet ParsedDerivation::getRequiredSystemFeatures() const
|
|||||||
StringSet res;
|
StringSet res;
|
||||||
for (auto & i : getStringsAttr("requiredSystemFeatures").value_or(Strings()))
|
for (auto & i : getStringsAttr("requiredSystemFeatures").value_or(Strings()))
|
||||||
res.insert(i);
|
res.insert(i);
|
||||||
|
if (!derivationHasKnownOutputPaths(drv.type()))
|
||||||
|
res.insert("ca-derivations");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "realisation.hh"
|
#include "realisation.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "closure.hh"
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
@@ -21,11 +22,52 @@ std::string DrvOutput::to_string() const {
|
|||||||
return strHash() + "!" + outputName;
|
return strHash() + "!" + outputName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<Realisation> Realisation::closure(Store & store, const std::set<Realisation> & startOutputs)
|
||||||
|
{
|
||||||
|
std::set<Realisation> res;
|
||||||
|
Realisation::closure(store, startOutputs, res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Realisation::closure(Store & store, const std::set<Realisation> & startOutputs, std::set<Realisation> & res)
|
||||||
|
{
|
||||||
|
auto getDeps = [&](const Realisation& current) -> std::set<Realisation> {
|
||||||
|
std::set<Realisation> res;
|
||||||
|
for (auto& [currentDep, _] : current.dependentRealisations) {
|
||||||
|
if (auto currentRealisation = store.queryRealisation(currentDep))
|
||||||
|
res.insert(*currentRealisation);
|
||||||
|
else
|
||||||
|
throw Error(
|
||||||
|
"Unrealised derivation '%s'", currentDep.to_string());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
computeClosure<Realisation>(
|
||||||
|
startOutputs, res,
|
||||||
|
[&](const Realisation& current,
|
||||||
|
std::function<void(std::promise<std::set<Realisation>>&)>
|
||||||
|
processEdges) {
|
||||||
|
std::promise<std::set<Realisation>> promise;
|
||||||
|
try {
|
||||||
|
auto res = getDeps(current);
|
||||||
|
promise.set_value(res);
|
||||||
|
} catch (...) {
|
||||||
|
promise.set_exception(std::current_exception());
|
||||||
|
}
|
||||||
|
return processEdges(promise);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
nlohmann::json Realisation::toJSON() const {
|
nlohmann::json Realisation::toJSON() const {
|
||||||
|
auto jsonDependentRealisations = nlohmann::json::object();
|
||||||
|
for (auto & [depId, depOutPath] : dependentRealisations)
|
||||||
|
jsonDependentRealisations.emplace(depId.to_string(), depOutPath.to_string());
|
||||||
return nlohmann::json{
|
return nlohmann::json{
|
||||||
{"id", id.to_string()},
|
{"id", id.to_string()},
|
||||||
{"outPath", outPath.to_string()},
|
{"outPath", outPath.to_string()},
|
||||||
{"signatures", signatures},
|
{"signatures", signatures},
|
||||||
|
{"dependentRealisations", jsonDependentRealisations},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,10 +93,16 @@ Realisation Realisation::fromJSON(
|
|||||||
if (auto signaturesIterator = json.find("signatures"); signaturesIterator != json.end())
|
if (auto signaturesIterator = json.find("signatures"); signaturesIterator != json.end())
|
||||||
signatures.insert(signaturesIterator->begin(), signaturesIterator->end());
|
signatures.insert(signaturesIterator->begin(), signaturesIterator->end());
|
||||||
|
|
||||||
|
std::map <DrvOutput, StorePath> dependentRealisations;
|
||||||
|
if (auto jsonDependencies = json.find("dependentRealisations"); jsonDependencies != json.end())
|
||||||
|
for (auto & [jsonDepId, jsonDepOutPath] : jsonDependencies->get<std::map<std::string, std::string>>())
|
||||||
|
dependentRealisations.insert({DrvOutput::parse(jsonDepId), StorePath(jsonDepOutPath)});
|
||||||
|
|
||||||
return Realisation{
|
return Realisation{
|
||||||
.id = DrvOutput::parse(getField("id")),
|
.id = DrvOutput::parse(getField("id")),
|
||||||
.outPath = StorePath(getField("outPath")),
|
.outPath = StorePath(getField("outPath")),
|
||||||
.signatures = signatures,
|
.signatures = signatures,
|
||||||
|
.dependentRealisations = dependentRealisations,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +140,16 @@ StorePath RealisedPath::path() const {
|
|||||||
return std::visit([](auto && arg) { return arg.getPath(); }, raw);
|
return std::visit([](auto && arg) { return arg.getPath(); }, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Realisation::isCompatibleWith(const Realisation & other) const
|
||||||
|
{
|
||||||
|
assert (id == other.id);
|
||||||
|
if (outPath == other.outPath) {
|
||||||
|
assert(dependentRealisations == other.dependentRealisations);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void RealisedPath::closure(
|
void RealisedPath::closure(
|
||||||
Store& store,
|
Store& store,
|
||||||
const RealisedPath::Set& startPaths,
|
const RealisedPath::Set& startPaths,
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ struct Realisation {
|
|||||||
|
|
||||||
StringSet signatures;
|
StringSet signatures;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The realisations that are required for the current one to be valid.
|
||||||
|
*
|
||||||
|
* When importing this realisation, the store will first check that all its
|
||||||
|
* dependencies exist, and map to the correct output path
|
||||||
|
*/
|
||||||
|
std::map<DrvOutput, StorePath> dependentRealisations;
|
||||||
|
|
||||||
nlohmann::json toJSON() const;
|
nlohmann::json toJSON() const;
|
||||||
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);
|
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);
|
||||||
|
|
||||||
@@ -36,6 +44,11 @@ struct Realisation {
|
|||||||
bool checkSignature(const PublicKeys & publicKeys, const std::string & sig) const;
|
bool checkSignature(const PublicKeys & publicKeys, const std::string & sig) const;
|
||||||
size_t checkSignatures(const PublicKeys & publicKeys) const;
|
size_t checkSignatures(const PublicKeys & publicKeys) const;
|
||||||
|
|
||||||
|
static std::set<Realisation> closure(Store &, const std::set<Realisation> &);
|
||||||
|
static void closure(Store &, const std::set<Realisation> &, std::set<Realisation>& res);
|
||||||
|
|
||||||
|
bool isCompatibleWith(const Realisation & other) const;
|
||||||
|
|
||||||
StorePath getPath() const { return outPath; }
|
StorePath getPath() const { return outPath; }
|
||||||
|
|
||||||
GENERATE_CMP(Realisation, me->id, me->outPath);
|
GENERATE_CMP(Realisation, me->id, me->outPath);
|
||||||
|
|||||||
@@ -653,8 +653,12 @@ void RemoteStore::registerDrvOutput(const Realisation & info)
|
|||||||
{
|
{
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopRegisterDrvOutput;
|
conn->to << wopRegisterDrvOutput;
|
||||||
conn->to << info.id.to_string();
|
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) {
|
||||||
conn->to << std::string(info.outPath.to_string());
|
conn->to << info.id.to_string();
|
||||||
|
conn->to << std::string(info.outPath.to_string());
|
||||||
|
} else {
|
||||||
|
worker_proto::write(*this, conn->to, info);
|
||||||
|
}
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -664,10 +668,17 @@ std::optional<const Realisation> RemoteStore::queryRealisation(const DrvOutput &
|
|||||||
conn->to << wopQueryRealisation;
|
conn->to << wopQueryRealisation;
|
||||||
conn->to << id.to_string();
|
conn->to << id.to_string();
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
auto outPaths = worker_proto::read(*this, conn->from, Phantom<std::set<StorePath>>{});
|
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) {
|
||||||
if (outPaths.empty())
|
auto outPaths = worker_proto::read(*this, conn->from, Phantom<std::set<StorePath>>{});
|
||||||
return std::nullopt;
|
if (outPaths.empty())
|
||||||
return {Realisation{.id = id, .outPath = *outPaths.begin()}};
|
return std::nullopt;
|
||||||
|
return {Realisation{.id = id, .outPath = *outPaths.begin()}};
|
||||||
|
} else {
|
||||||
|
auto realisations = worker_proto::read(*this, conn->from, Phantom<std::set<Realisation>>{});
|
||||||
|
if (realisations.empty())
|
||||||
|
return std::nullopt;
|
||||||
|
return *realisations.begin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeDerivedPaths(RemoteStore & store, ConnectionHandle & conn, const std::vector<DerivedPath> & reqs)
|
static void writeDerivedPaths(RemoteStore & store, ConnectionHandle & conn, const std::vector<DerivedPath> & reqs)
|
||||||
|
|||||||
@@ -337,6 +337,13 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringSet StoreConfig::getDefaultSystemFeatures()
|
||||||
|
{
|
||||||
|
auto res = settings.systemFeatures.get();
|
||||||
|
if (settings.isExperimentalFeatureEnabled("ca-derivations"))
|
||||||
|
res.insert("ca-derivations");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
Store::Store(const Params & params)
|
Store::Store(const Params & params)
|
||||||
: StoreConfig(params)
|
: StoreConfig(params)
|
||||||
@@ -780,20 +787,39 @@ std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStor
|
|||||||
RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
|
RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
|
||||||
{
|
{
|
||||||
StorePathSet storePaths;
|
StorePathSet storePaths;
|
||||||
std::set<Realisation> realisations;
|
std::set<Realisation> toplevelRealisations;
|
||||||
for (auto & path : paths) {
|
for (auto & path : paths) {
|
||||||
storePaths.insert(path.path());
|
storePaths.insert(path.path());
|
||||||
if (auto realisation = std::get_if<Realisation>(&path.raw)) {
|
if (auto realisation = std::get_if<Realisation>(&path.raw)) {
|
||||||
settings.requireExperimentalFeature("ca-derivations");
|
settings.requireExperimentalFeature("ca-derivations");
|
||||||
realisations.insert(*realisation);
|
toplevelRealisations.insert(*realisation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute);
|
auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute);
|
||||||
|
|
||||||
|
ThreadPool pool;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (auto & realisation : realisations) {
|
// Copy the realisation closure
|
||||||
dstStore->registerDrvOutput(realisation, checkSigs);
|
processGraph<Realisation>(
|
||||||
}
|
pool, Realisation::closure(*srcStore, toplevelRealisations),
|
||||||
} catch (MissingExperimentalFeature & e) {
|
[&](const Realisation& current) -> std::set<Realisation> {
|
||||||
|
std::set<Realisation> children;
|
||||||
|
for (const auto& [drvOutput, _] : current.dependentRealisations) {
|
||||||
|
auto currentChild = srcStore->queryRealisation(drvOutput);
|
||||||
|
if (!currentChild)
|
||||||
|
throw Error(
|
||||||
|
"Incomplete realisation closure: '%s' is a "
|
||||||
|
"dependency of '%s' but isn’t registered",
|
||||||
|
drvOutput.to_string(), current.id.to_string());
|
||||||
|
children.insert(*currentChild);
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
},
|
||||||
|
[&](const Realisation& current) -> void {
|
||||||
|
dstStore->registerDrvOutput(current, checkSigs);
|
||||||
|
});
|
||||||
|
} catch (MissingExperimentalFeature& e) {
|
||||||
// Don't fail if the remote doesn't support CA derivations is it might
|
// Don't fail if the remote doesn't support CA derivations is it might
|
||||||
// not be within our control to change that, and we might still want
|
// not be within our control to change that, and we might still want
|
||||||
// to at least copy the output paths.
|
// to at least copy the output paths.
|
||||||
|
|||||||
@@ -180,6 +180,8 @@ struct StoreConfig : public Config
|
|||||||
|
|
||||||
StoreConfig() = delete;
|
StoreConfig() = delete;
|
||||||
|
|
||||||
|
StringSet getDefaultSystemFeatures();
|
||||||
|
|
||||||
virtual ~StoreConfig() { }
|
virtual ~StoreConfig() { }
|
||||||
|
|
||||||
virtual const std::string name() = 0;
|
virtual const std::string name() = 0;
|
||||||
@@ -196,7 +198,7 @@ struct StoreConfig : public Config
|
|||||||
|
|
||||||
Setting<bool> wantMassQuery{this, false, "want-mass-query", "whether this substituter can be queried efficiently for path validity"};
|
Setting<bool> wantMassQuery{this, false, "want-mass-query", "whether this substituter can be queried efficiently for path validity"};
|
||||||
|
|
||||||
Setting<StringSet> systemFeatures{this, settings.systemFeatures,
|
Setting<StringSet> systemFeatures{this, getDefaultSystemFeatures(),
|
||||||
"system-features",
|
"system-features",
|
||||||
"Optional features that the system this store builds on implements (like \"kvm\")."};
|
"Optional features that the system this store builds on implements (like \"kvm\")."};
|
||||||
|
|
||||||
@@ -864,4 +866,9 @@ std::pair<std::string, Store::Params> splitUriAndParams(const std::string & uri)
|
|||||||
|
|
||||||
std::optional<ContentAddress> getDerivationCA(const BasicDerivation & drv);
|
std::optional<ContentAddress> getDerivationCA(const BasicDerivation & drv);
|
||||||
|
|
||||||
|
std::map<DrvOutput, StorePath> drvOutputReferences(
|
||||||
|
Store & store,
|
||||||
|
const Derivation & drv,
|
||||||
|
const StorePath & outputPath);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ namespace nix {
|
|||||||
#define WORKER_MAGIC_1 0x6e697863
|
#define WORKER_MAGIC_1 0x6e697863
|
||||||
#define WORKER_MAGIC_2 0x6478696f
|
#define WORKER_MAGIC_2 0x6478696f
|
||||||
|
|
||||||
#define PROTOCOL_VERSION (1 << 8 | 30)
|
#define PROTOCOL_VERSION (1 << 8 | 31)
|
||||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
||||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#include <set>
|
||||||
|
#include <future>
|
||||||
|
#include "sync.hh"
|
||||||
|
|
||||||
|
using std::set;
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using GetEdgesAsync = std::function<void(const T &, std::function<void(std::promise<set<T>> &)>)>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void computeClosure(
|
||||||
|
const set<T> startElts,
|
||||||
|
set<T> & res,
|
||||||
|
GetEdgesAsync<T> getEdgesAsync
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
size_t pending;
|
||||||
|
set<T> & res;
|
||||||
|
std::exception_ptr exc;
|
||||||
|
};
|
||||||
|
|
||||||
|
Sync<State> state_(State{0, res, 0});
|
||||||
|
|
||||||
|
std::function<void(const T &)> enqueue;
|
||||||
|
|
||||||
|
std::condition_variable done;
|
||||||
|
|
||||||
|
enqueue = [&](const T & current) -> void {
|
||||||
|
{
|
||||||
|
auto state(state_.lock());
|
||||||
|
if (state->exc) return;
|
||||||
|
if (!state->res.insert(current).second) return;
|
||||||
|
state->pending++;
|
||||||
|
}
|
||||||
|
|
||||||
|
getEdgesAsync(current, [&](std::promise<set<T>> & prom) {
|
||||||
|
try {
|
||||||
|
auto children = prom.get_future().get();
|
||||||
|
for (auto & child : children)
|
||||||
|
enqueue(child);
|
||||||
|
{
|
||||||
|
auto state(state_.lock());
|
||||||
|
assert(state->pending);
|
||||||
|
if (!--state->pending) done.notify_one();
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
auto state(state_.lock());
|
||||||
|
if (!state->exc) state->exc = std::current_exception();
|
||||||
|
assert(state->pending);
|
||||||
|
if (!--state->pending) done.notify_one();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto & startElt : startElts)
|
||||||
|
enqueue(startElt);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto state(state_.lock());
|
||||||
|
while (state->pending) state.wait(done);
|
||||||
|
if (state->exc) std::rethrow_exception(state->exc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -25,6 +25,8 @@
|
|||||||
}
|
}
|
||||||
#define GENERATE_EQUAL(args...) GENERATE_ONE_CMP(==, args)
|
#define GENERATE_EQUAL(args...) GENERATE_ONE_CMP(==, args)
|
||||||
#define GENERATE_LEQ(args...) GENERATE_ONE_CMP(<, args)
|
#define GENERATE_LEQ(args...) GENERATE_ONE_CMP(<, args)
|
||||||
|
#define GENERATE_NEQ(args...) GENERATE_ONE_CMP(!=, args)
|
||||||
#define GENERATE_CMP(args...) \
|
#define GENERATE_CMP(args...) \
|
||||||
GENERATE_EQUAL(args) \
|
GENERATE_EQUAL(args) \
|
||||||
GENERATE_LEQ(args)
|
GENERATE_LEQ(args) \
|
||||||
|
GENERATE_NEQ(args)
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#include "closure.hh"
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
map<string, set<string>> testGraph = {
|
||||||
|
{ "A", { "B", "C", "G" } },
|
||||||
|
{ "B", { "A" } }, // Loops back to A
|
||||||
|
{ "C", { "F" } }, // Indirect reference
|
||||||
|
{ "D", { "A" } }, // Not reachable, but has backreferences
|
||||||
|
{ "E", {} }, // Just not reachable
|
||||||
|
{ "F", {} },
|
||||||
|
{ "G", { "G" } }, // Self reference
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(closure, correctClosure) {
|
||||||
|
set<string> aClosure;
|
||||||
|
set<string> expectedClosure = {"A", "B", "C", "F", "G"};
|
||||||
|
computeClosure<string>(
|
||||||
|
{"A"},
|
||||||
|
aClosure,
|
||||||
|
[&](const string currentNode, function<void(promise<set<string>> &)> processEdges) {
|
||||||
|
promise<set<string>> promisedNodes;
|
||||||
|
promisedNodes.set_value(testGraph[currentNode]);
|
||||||
|
processEdges(promisedNodes);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ASSERT_EQ(aClosure, expectedClosure);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(closure, properlyHandlesDirectExceptions) {
|
||||||
|
struct TestExn {};
|
||||||
|
set<string> aClosure;
|
||||||
|
EXPECT_THROW(
|
||||||
|
computeClosure<string>(
|
||||||
|
{"A"},
|
||||||
|
aClosure,
|
||||||
|
[&](const string currentNode, function<void(promise<set<string>> &)> processEdges) {
|
||||||
|
throw TestExn();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
TestExn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(closure, properlyHandlesExceptionsInPromise) {
|
||||||
|
struct TestExn {};
|
||||||
|
set<string> aClosure;
|
||||||
|
EXPECT_THROW(
|
||||||
|
computeClosure<string>(
|
||||||
|
{"A"},
|
||||||
|
aClosure,
|
||||||
|
[&](const string currentNode, function<void(promise<set<string>> &)> processEdges) {
|
||||||
|
promise<set<string>> promise;
|
||||||
|
try {
|
||||||
|
throw TestExn();
|
||||||
|
} catch (...) {
|
||||||
|
promise.set_exception(std::current_exception());
|
||||||
|
}
|
||||||
|
processEdges(promise);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
TestExn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -387,6 +387,12 @@ static void main_nix_build(int argc, char * * argv)
|
|||||||
|
|
||||||
if (dryRun) return;
|
if (dryRun) return;
|
||||||
|
|
||||||
|
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
||||||
|
auto resolvedDrv = drv.tryResolve(*store);
|
||||||
|
assert(resolvedDrv && "Successfully resolved the derivation");
|
||||||
|
drv = *resolvedDrv;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the environment.
|
// Set the environment.
|
||||||
auto env = getEnv();
|
auto env = getEnv();
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -69,8 +69,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
|
|||||||
store2->addPermRoot(bo.path, absPath(symlink));
|
store2->addPermRoot(bo.path, absPath(symlink));
|
||||||
},
|
},
|
||||||
[&](BuiltPath::Built bfd) {
|
[&](BuiltPath::Built bfd) {
|
||||||
auto builtOutputs = store->queryDerivationOutputMap(bfd.drvPath);
|
for (auto & output : bfd.outputs) {
|
||||||
for (auto & output : builtOutputs) {
|
|
||||||
std::string symlink = outLink;
|
std::string symlink = outLink;
|
||||||
if (i) symlink += fmt("-%d", i);
|
if (i) symlink += fmt("-%d", i);
|
||||||
if (output.first != "out") symlink += fmt("-%s", output.first);
|
if (output.first != "out") symlink += fmt("-%s", output.first);
|
||||||
|
|||||||
+20
-11
@@ -144,17 +144,26 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
|
|||||||
/* Rehash and write the derivation. FIXME: would be nice to use
|
/* Rehash and write the derivation. FIXME: would be nice to use
|
||||||
'buildDerivation', but that's privileged. */
|
'buildDerivation', but that's privileged. */
|
||||||
drv.name += "-env";
|
drv.name += "-env";
|
||||||
for (auto & output : drv.outputs) {
|
|
||||||
output.second = { .output = DerivationOutputInputAddressed { .path = StorePath::dummy } };
|
|
||||||
drv.env[output.first] = "";
|
|
||||||
}
|
|
||||||
drv.inputSrcs.insert(std::move(getEnvShPath));
|
drv.inputSrcs.insert(std::move(getEnvShPath));
|
||||||
Hash h = std::get<0>(hashDerivationModulo(*store, drv, true));
|
if (settings.isExperimentalFeatureEnabled("ca-derivations")) {
|
||||||
|
for (auto & output : drv.outputs) {
|
||||||
|
output.second = {
|
||||||
|
.output = DerivationOutputDeferred{},
|
||||||
|
};
|
||||||
|
drv.env[output.first] = hashPlaceholder(output.first);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (auto & output : drv.outputs) {
|
||||||
|
output.second = { .output = DerivationOutputInputAddressed { .path = StorePath::dummy } };
|
||||||
|
drv.env[output.first] = "";
|
||||||
|
}
|
||||||
|
Hash h = std::get<0>(hashDerivationModulo(*store, drv, true));
|
||||||
|
|
||||||
for (auto & output : drv.outputs) {
|
for (auto & output : drv.outputs) {
|
||||||
auto outPath = store->makeOutputPath(output.first, h, drv.name);
|
auto outPath = store->makeOutputPath(output.first, h, drv.name);
|
||||||
output.second = { .output = DerivationOutputInputAddressed { .path = outPath } };
|
output.second = { .output = DerivationOutputInputAddressed { .path = outPath } };
|
||||||
drv.env[output.first] = store->printStorePath(outPath);
|
drv.env[output.first] = store->printStorePath(outPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto shellDrvPath = writeDerivation(*store, drv);
|
auto shellDrvPath = writeDerivation(*store, drv);
|
||||||
@@ -162,8 +171,7 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
|
|||||||
/* Build the derivation. */
|
/* Build the derivation. */
|
||||||
store->buildPaths({DerivedPath::Built{shellDrvPath}});
|
store->buildPaths({DerivedPath::Built{shellDrvPath}});
|
||||||
|
|
||||||
for (auto & [_0, outputAndOptPath] : drv.outputsAndOptPaths(*store)) {
|
for (auto & [_0, optPath] : store->queryPartialDerivationOutputMap(shellDrvPath)) {
|
||||||
auto & [_1, optPath] = outputAndOptPath;
|
|
||||||
assert(optPath);
|
assert(optPath);
|
||||||
auto & outPath = *optPath;
|
auto & outPath = *optPath;
|
||||||
assert(store->isValidPath(outPath));
|
assert(store->isValidPath(outPath));
|
||||||
@@ -185,6 +193,7 @@ struct Common : InstallableCommand, MixProfile
|
|||||||
"NIX_BUILD_TOP",
|
"NIX_BUILD_TOP",
|
||||||
"NIX_ENFORCE_PURITY",
|
"NIX_ENFORCE_PURITY",
|
||||||
"NIX_LOG_FD",
|
"NIX_LOG_FD",
|
||||||
|
"NIX_REMOTE",
|
||||||
"PPID",
|
"PPID",
|
||||||
"PWD",
|
"PWD",
|
||||||
"SHELLOPTS",
|
"SHELLOPTS",
|
||||||
|
|||||||
@@ -22,9 +22,13 @@ This command verifies that the flake specified by flake reference
|
|||||||
that the derivations specified by the flake's `checks` output can be
|
that the derivations specified by the flake's `checks` output can be
|
||||||
built successfully.
|
built successfully.
|
||||||
|
|
||||||
|
If the `keep-going` option is set to `true`, Nix will keep evaluating as much
|
||||||
|
as it can and report the errors as it encounters them. Otherwise it will stop
|
||||||
|
at the first error.
|
||||||
|
|
||||||
# Evaluation checks
|
# Evaluation checks
|
||||||
|
|
||||||
This following flake output attributes must be derivations:
|
The following flake output attributes must be derivations:
|
||||||
|
|
||||||
* `checks.`*system*`.`*name*
|
* `checks.`*system*`.`*name*
|
||||||
* `defaultPackage.`*system*`
|
* `defaultPackage.`*system*`
|
||||||
|
|||||||
+31
-14
@@ -272,25 +272,40 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
auto state = getEvalState();
|
auto state = getEvalState();
|
||||||
auto flake = lockFlake();
|
auto flake = lockFlake();
|
||||||
|
|
||||||
|
bool hasErrors = false;
|
||||||
|
auto reportError = [&](const Error & e) {
|
||||||
|
try {
|
||||||
|
throw e;
|
||||||
|
} catch (Error & e) {
|
||||||
|
if (settings.keepGoing) {
|
||||||
|
ignoreException();
|
||||||
|
hasErrors = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: rewrite to use EvalCache.
|
// FIXME: rewrite to use EvalCache.
|
||||||
|
|
||||||
auto checkSystemName = [&](const std::string & system, const Pos & pos) {
|
auto checkSystemName = [&](const std::string & system, const Pos & pos) {
|
||||||
// FIXME: what's the format of "system"?
|
// FIXME: what's the format of "system"?
|
||||||
if (system.find('-') == std::string::npos)
|
if (system.find('-') == std::string::npos)
|
||||||
throw Error("'%s' is not a valid system type, at %s", system, pos);
|
reportError(Error("'%s' is not a valid system type, at %s", system, pos));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto checkDerivation = [&](const std::string & attrPath, Value & v, const Pos & pos) {
|
auto checkDerivation = [&](const std::string & attrPath, Value & v, const Pos & pos) -> std::optional<StorePath> {
|
||||||
try {
|
try {
|
||||||
auto drvInfo = getDerivation(*state, v, false);
|
auto drvInfo = getDerivation(*state, v, false);
|
||||||
if (!drvInfo)
|
if (!drvInfo)
|
||||||
throw Error("flake attribute '%s' is not a derivation", attrPath);
|
throw Error("flake attribute '%s' is not a derivation", attrPath);
|
||||||
// FIXME: check meta attributes
|
// FIXME: check meta attributes
|
||||||
return store->parseStorePath(drvInfo->queryDrvPath());
|
return std::make_optional(store->parseStorePath(drvInfo->queryDrvPath()));
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the derivation '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the derivation '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
|
return std::nullopt;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<DerivedPath> drvPaths;
|
std::vector<DerivedPath> drvPaths;
|
||||||
@@ -307,7 +322,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
#endif
|
#endif
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the app definition '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the app definition '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -323,7 +338,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
// evaluate the overlay.
|
// evaluate the overlay.
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the overlay '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the overlay '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -347,7 +362,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
// check the module.
|
// check the module.
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the NixOS module '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the NixOS module '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -369,7 +384,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the Hydra jobset '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the Hydra jobset '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -384,7 +399,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
throw Error("attribute 'config.system.build.toplevel' is not a derivation");
|
throw Error("attribute 'config.system.build.toplevel' is not a derivation");
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the NixOS configuration '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the NixOS configuration '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -418,7 +433,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
}
|
}
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -433,7 +448,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
throw Error("bundler must take formal arguments 'program' and 'system'");
|
throw Error("bundler must take formal arguments 'program' and 'system'");
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
|
e.addTrace(pos, hintfmt("while checking the template '%s'", attrPath));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -461,8 +476,8 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
auto drvPath = checkDerivation(
|
auto drvPath = checkDerivation(
|
||||||
fmt("%s.%s.%s", name, attr.name, attr2.name),
|
fmt("%s.%s.%s", name, attr.name, attr2.name),
|
||||||
*attr2.value, *attr2.pos);
|
*attr2.value, *attr2.pos);
|
||||||
if ((std::string) attr.name == settings.thisSystem.get())
|
if (drvPath && (std::string) attr.name == settings.thisSystem.get())
|
||||||
drvPaths.push_back(DerivedPath::Built{drvPath});
|
drvPaths.push_back(DerivedPath::Built{*drvPath});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -574,7 +589,7 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace(pos, hintfmt("while checking flake output '%s'", name));
|
e.addTrace(pos, hintfmt("while checking flake output '%s'", name));
|
||||||
throw;
|
reportError(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -583,6 +598,8 @@ struct CmdFlakeCheck : FlakeCommand
|
|||||||
Activity act(*logger, lvlInfo, actUnknown, "running flake checks");
|
Activity act(*logger, lvlInfo, actUnknown, "running flake checks");
|
||||||
store->buildPaths(drvPaths);
|
store->buildPaths(drvPaths);
|
||||||
}
|
}
|
||||||
|
if (hasErrors)
|
||||||
|
throw Error("Some errors were encountered during the evaluation");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -186,8 +186,8 @@ Currently the `type` attribute can be one of the following:
|
|||||||
attribute `url`.
|
attribute `url`.
|
||||||
|
|
||||||
In URL form, the schema must be `http://`, `https://` or `file://`
|
In URL form, the schema must be `http://`, `https://` or `file://`
|
||||||
URLs and the extension must be `.zip`, `.tar`, `.tar.gz`, `.tar.xz`
|
URLs and the extension must be `.zip`, `.tar`, `.tar.gz`, `.tar.xz`,
|
||||||
or `.tar.bz2`.
|
`.tar.bz2` or `.tar.zst`.
|
||||||
|
|
||||||
* `github`: A more efficient way to fetch repositories from
|
* `github`: A more efficient way to fetch repositories from
|
||||||
GitHub. The following attributes are required:
|
GitHub. The following attributes are required:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ R""(
|
|||||||
```
|
```
|
||||||
|
|
||||||
* Remove all packages:
|
* Remove all packages:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# nix profile remove '.*'
|
# nix profile remove '.*'
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ R""(
|
|||||||
* Upgrade a specific profile element by number:
|
* Upgrade a specific profile element by number:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# nix profile info
|
# nix profile list
|
||||||
0 flake:nixpkgs#legacyPackages.x86_64-linux.spotify …
|
0 flake:nixpkgs#legacyPackages.x86_64-linux.spotify …
|
||||||
|
|
||||||
# nix profile upgrade 0
|
# nix profile upgrade 0
|
||||||
|
|||||||
+2
-2
@@ -43,8 +43,8 @@ struct RunCommon : virtual Command
|
|||||||
helper program (chrootHelper() below) to do the work. */
|
helper program (chrootHelper() below) to do the work. */
|
||||||
auto store2 = store.dynamic_pointer_cast<LocalStore>();
|
auto store2 = store.dynamic_pointer_cast<LocalStore>();
|
||||||
|
|
||||||
if (store2 && store->storeDir != store2->realStoreDir) {
|
if (store2 && store->storeDir != store2->getRealStoreDir()) {
|
||||||
Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, program };
|
Strings helperArgs = { chrootHelperName, store->storeDir, store2->getRealStoreDir(), program };
|
||||||
for (auto & arg : args) helperArgs.push_back(arg);
|
for (auto & arg : args) helperArgs.push_back(arg);
|
||||||
|
|
||||||
execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data());
|
execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data());
|
||||||
|
|||||||
+3
-7
@@ -97,15 +97,11 @@ struct CmdVerify : StorePathsCommand
|
|||||||
|
|
||||||
if (!noContents) {
|
if (!noContents) {
|
||||||
|
|
||||||
std::unique_ptr<AbstractHashSink> hashSink;
|
auto hashSink = HashSink(info->narHash.type);
|
||||||
if (!info->ca)
|
|
||||||
hashSink = std::make_unique<HashSink>(info->narHash.type);
|
|
||||||
else
|
|
||||||
hashSink = std::make_unique<HashModuloSink>(info->narHash.type, std::string(info->path.hashPart()));
|
|
||||||
|
|
||||||
store->narFromPath(info->path, *hashSink);
|
store->narFromPath(info->path, hashSink);
|
||||||
|
|
||||||
auto hash = hashSink->finish();
|
auto hash = hashSink.finish();
|
||||||
|
|
||||||
if (hash.first != info->narHash) {
|
if (hash.first != info->narHash) {
|
||||||
corrupted++;
|
corrupted++;
|
||||||
|
|||||||
@@ -4,4 +4,6 @@ file=build-hook-ca-floating.nix
|
|||||||
|
|
||||||
sed -i 's/experimental-features .*/& ca-derivations/' "$NIX_CONF_DIR"/nix.conf
|
sed -i 's/experimental-features .*/& ca-derivations/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
CONTENT_ADDRESSED=true
|
||||||
|
|
||||||
source build-remote.sh
|
source build-remote.sh
|
||||||
@@ -6,12 +6,17 @@ unset NIX_STATE_DIR
|
|||||||
|
|
||||||
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
||||||
|
|
||||||
|
EXTRA_SYSTEM_FEATURES=()
|
||||||
|
if [[ -n "$CONTENT_ADDRESSED" ]]; then
|
||||||
|
EXTRA_SYSTEM_FEATURES=("ca-derivations")
|
||||||
|
fi
|
||||||
|
|
||||||
builders=(
|
builders=(
|
||||||
# system-features will automatically be added to the outer URL, but not inner
|
# system-features will automatically be added to the outer URL, but not inner
|
||||||
# remote-store URL.
|
# remote-store URL.
|
||||||
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=foo - - 1 1 foo"
|
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=$(join_by "%20" foo ${EXTRA_SYSTEM_FEATURES[@]}) - - 1 1 $(join_by "," foo ${EXTRA_SYSTEM_FEATURES[@]})"
|
||||||
"$TEST_ROOT/machine2 - - 1 1 bar"
|
"$TEST_ROOT/machine2 - - 1 1 $(join_by "," bar ${EXTRA_SYSTEM_FEATURES[@]})"
|
||||||
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=baz - - 1 1 baz"
|
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=$(join_by "%20" baz ${EXTRA_SYSTEM_FEATURES[@]}) - - 1 1 $(join_by "," baz ${EXTRA_SYSTEM_FEATURES[@]})"
|
||||||
)
|
)
|
||||||
|
|
||||||
chmod -R +w $TEST_ROOT/machine* || true
|
chmod -R +w $TEST_ROOT/machine* || true
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
expectedJSONRegex='\[\{"drvPath":".*multiple-outputs-a.drv","outputs":\{"first":".*multiple-outputs-a-first","second":".*multiple-outputs-a-second"}},\{"drvPath":".*multiple-outputs-b.drv","outputs":\{"out":".*multiple-outputs-b"}}]'
|
expectedJSONRegex='\[\{"drvPath":".*multiple-outputs-a.drv","outputs":\{"first":".*multiple-outputs-a-first","second":".*multiple-outputs-a-second"}},\{"drvPath":".*multiple-outputs-b.drv","outputs":\{"out":".*multiple-outputs-b"}}]'
|
||||||
nix build -f multiple-outputs.nix --json a.all b.all | jq --exit-status '
|
nix build -f multiple-outputs.nix --json a.all b.all --no-link | jq --exit-status '
|
||||||
(.[0] |
|
(.[0] |
|
||||||
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
||||||
(.outputs.first | match(".*multiple-outputs-a-first")) and
|
(.outputs.first | match(".*multiple-outputs-a-first")) and
|
||||||
@@ -10,10 +10,10 @@ nix build -f multiple-outputs.nix --json a.all b.all | jq --exit-status '
|
|||||||
(.drvPath | match(".*multiple-outputs-b.drv")) and
|
(.drvPath | match(".*multiple-outputs-b.drv")) and
|
||||||
(.outputs.out | match(".*multiple-outputs-b")))
|
(.outputs.out | match(".*multiple-outputs-b")))
|
||||||
'
|
'
|
||||||
|
|
||||||
testNormalization () {
|
testNormalization () {
|
||||||
clearStore
|
clearStore
|
||||||
outPath=$(nix-build ./simple.nix)
|
outPath=$(nix-build ./simple.nix --no-out-link)
|
||||||
test "$(stat -c %Y $outPath)" -eq 1
|
test "$(stat -c %Y $outPath)" -eq 1
|
||||||
}
|
}
|
||||||
|
|
||||||
testNormalization
|
testNormalization
|
||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Regression test for https://github.com/NixOS/nix/issues/4858
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
# Get the output path of `rootCA`, and put some garbage instead
|
||||||
|
outPath="$(nix-build ./content-addressed.nix -A rootCA --no-out-link)"
|
||||||
|
nix-store --delete "$outPath"
|
||||||
|
touch "$outPath"
|
||||||
|
|
||||||
|
# The build should correctly remove the garbage and put the expected path instead
|
||||||
|
nix-build ./content-addressed.nix -A rootCA --no-out-link
|
||||||
|
|
||||||
|
# Rebuild it. This shouldn’t overwrite the existing path
|
||||||
|
oldInode=$(stat -c '%i' "$outPath")
|
||||||
|
nix-build ./content-addressed.nix -A rootCA --no-out-link --arg seed 2
|
||||||
|
newInode=$(stat -c '%i' "$outPath")
|
||||||
|
[[ "$oldInode" == "$newInode" ]]
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
source ./common.sh
|
||||||
|
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
export REMOTE_STORE_DIR="$TEST_ROOT/remote_store"
|
||||||
|
export REMOTE_STORE="file://$REMOTE_STORE_DIR"
|
||||||
|
|
||||||
|
rm -rf $REMOTE_STORE_DIR
|
||||||
|
clearStore
|
||||||
|
|
||||||
|
# Build dep1 and push that to the binary cache.
|
||||||
|
# This entails building (and pushing) current-time.
|
||||||
|
nix copy --to "$REMOTE_STORE" -f nondeterministic.nix dep1
|
||||||
|
clearStore
|
||||||
|
sleep 2 # To make sure that `$(date)` will be different
|
||||||
|
# Build dep2.
|
||||||
|
# As we’ve cleared the cache, we’ll have to rebuild current-time. And because
|
||||||
|
# the current time isn’t the same as before, this will yield a new (different)
|
||||||
|
# realisation
|
||||||
|
nix build -f nondeterministic.nix dep2 --no-link
|
||||||
|
|
||||||
|
# Build something that depends both on dep1 and dep2.
|
||||||
|
# If everything goes right, we should rebuild dep2 rather than fetch it from
|
||||||
|
# the cache (because that would mean duplicating `current-time` in the closure),
|
||||||
|
# and have `dep1 == dep2`.
|
||||||
|
nix build --substituters "$REMOTE_STORE" -f nondeterministic.nix toplevel --no-require-sigs --no-link
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Ensure that garbage collection works properly with ca derivations
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
source gc.sh
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
CONTENT_ADDRESSED=true
|
||||||
|
cd ..
|
||||||
|
source ./nix-shell.sh
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
with import ./config.nix;
|
||||||
|
|
||||||
|
let mkCADerivation = args: mkDerivation ({
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
} // args);
|
||||||
|
in
|
||||||
|
|
||||||
|
rec {
|
||||||
|
currentTime = mkCADerivation {
|
||||||
|
name = "current-time";
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir $out
|
||||||
|
echo $(date) > $out/current-time
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
dep = seed: mkCADerivation {
|
||||||
|
name = "dep";
|
||||||
|
inherit seed;
|
||||||
|
buildCommand = ''
|
||||||
|
echo ${currentTime} > $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
dep1 = dep 1;
|
||||||
|
dep2 = dep 2;
|
||||||
|
toplevel = mkCADerivation {
|
||||||
|
name = "toplevel";
|
||||||
|
buildCommand = ''
|
||||||
|
test ${dep1} == ${dep2}
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
cd ..
|
||||||
|
source ./post-hook.sh
|
||||||
|
|
||||||
|
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
|
||||||
|
|
||||||
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
cd ..
|
||||||
|
source ./recursive.sh
|
||||||
|
|
||||||
|
|
||||||
@@ -17,11 +17,15 @@ buildDrvs () {
|
|||||||
|
|
||||||
# Populate the remote cache
|
# Populate the remote cache
|
||||||
clearStore
|
clearStore
|
||||||
buildDrvs --post-build-hook ../push-to-store.sh
|
nix copy --to $REMOTE_STORE --file ./content-addressed.nix
|
||||||
|
|
||||||
# Restart the build on an empty store, ensuring that we don't build
|
# Restart the build on an empty store, ensuring that we don't build
|
||||||
clearStore
|
clearStore
|
||||||
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0
|
buildDrvs --substitute --substituters $REMOTE_STORE --no-require-sigs -j0 transitivelyDependentCA
|
||||||
|
# Check that the thing we’ve just substituted has its realisation stored
|
||||||
|
nix realisation info --file ./content-addressed.nix transitivelyDependentCA
|
||||||
|
# Check that its dependencies have it too
|
||||||
|
nix realisation info --file ./content-addressed.nix dependentCA rootCA
|
||||||
|
|
||||||
# Same thing, but
|
# Same thing, but
|
||||||
# 1. With non-ca derivations
|
# 1. With non-ca derivations
|
||||||
|
|||||||
+10
-1
@@ -1,3 +1,12 @@
|
|||||||
|
let
|
||||||
|
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1";
|
||||||
|
caArgs = if contentAddressedByDefault then {
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
} else {};
|
||||||
|
in
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
shell = "@bash@";
|
shell = "@bash@";
|
||||||
|
|
||||||
@@ -13,6 +22,6 @@ rec {
|
|||||||
builder = shell;
|
builder = shell;
|
||||||
args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
|
args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
|
||||||
PATH = path;
|
PATH = path;
|
||||||
} // removeAttrs args ["builder" "meta"])
|
} // caArgs // removeAttrs args ["builder" "meta"])
|
||||||
// { meta = args.meta or {}; };
|
// { meta = args.meta or {}; };
|
||||||
}
|
}
|
||||||
@@ -535,6 +535,21 @@ EOF
|
|||||||
|
|
||||||
(! nix flake check $flake3Dir)
|
(! nix flake check $flake3Dir)
|
||||||
|
|
||||||
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
|
{
|
||||||
|
outputs = { flake1, self }: {
|
||||||
|
defaultPackage = {
|
||||||
|
system-1 = "foo";
|
||||||
|
system-2 = "bar";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
checkRes=$(nix flake check --keep-going $flake3Dir 2>&1 && fail "nix flake check should have failed" || true)
|
||||||
|
echo "$checkRes" | grep -q "defaultPackage.system-1"
|
||||||
|
echo "$checkRes" | grep -q "defaultPackage.system-2"
|
||||||
|
|
||||||
# Test 'follows' inputs.
|
# Test 'follows' inputs.
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ ln -sf $outPath "$NIX_STATE_DIR"/gcroots/foo
|
|||||||
nix-store --gc --print-roots | grep $outPath
|
nix-store --gc --print-roots | grep $outPath
|
||||||
nix-store --gc --print-live | grep $outPath
|
nix-store --gc --print-live | grep $outPath
|
||||||
nix-store --gc --print-dead | grep $drvPath
|
nix-store --gc --print-dead | grep $drvPath
|
||||||
if nix-store --gc --print-dead | grep $outPath; then false; fi
|
if nix-store --gc --print-dead | grep -E $outPath$; then false; fi
|
||||||
|
|
||||||
nix-store --gc --print-dead
|
nix-store --gc --print-dead
|
||||||
|
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2
|
http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2
|
||||||
http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz
|
http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz
|
||||||
http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz
|
http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz
|
||||||
|
https://ftp5.gwdg.de/pub/linux/archlinux/extra/os/x86_64/unzip-6.0-14-x86_64.pkg.tar.zst
|
||||||
ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz
|
ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz
|
||||||
]
|
]
|
||||||
@@ -2,6 +2,7 @@ nix_tests = \
|
|||||||
hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
||||||
config.sh \
|
config.sh \
|
||||||
gc.sh \
|
gc.sh \
|
||||||
|
ca/gc.sh \
|
||||||
gc-concurrent.sh \
|
gc-concurrent.sh \
|
||||||
gc-auto.sh \
|
gc-auto.sh \
|
||||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||||
@@ -11,6 +12,7 @@ nix_tests = \
|
|||||||
timeout.sh secure-drv-outputs.sh nix-channel.sh \
|
timeout.sh secure-drv-outputs.sh nix-channel.sh \
|
||||||
multiple-outputs.sh import-derivation.sh fetchurl.sh optimise-store.sh \
|
multiple-outputs.sh import-derivation.sh fetchurl.sh optimise-store.sh \
|
||||||
binary-cache.sh \
|
binary-cache.sh \
|
||||||
|
substitute-with-invalid-ca.sh \
|
||||||
binary-cache-build-remote.sh \
|
binary-cache-build-remote.sh \
|
||||||
nix-profile.sh repair.sh dump-db.sh case-hack.sh \
|
nix-profile.sh repair.sh dump-db.sh case-hack.sh \
|
||||||
check-reqs.sh pass-as-file.sh tarball.sh restricted.sh \
|
check-reqs.sh pass-as-file.sh tarball.sh restricted.sh \
|
||||||
@@ -37,6 +39,7 @@ nix_tests = \
|
|||||||
search.sh \
|
search.sh \
|
||||||
nix-copy-ssh.sh \
|
nix-copy-ssh.sh \
|
||||||
post-hook.sh \
|
post-hook.sh \
|
||||||
|
ca/post-hook.sh \
|
||||||
function-trace.sh \
|
function-trace.sh \
|
||||||
recursive.sh \
|
recursive.sh \
|
||||||
describe-stores.sh \
|
describe-stores.sh \
|
||||||
@@ -44,9 +47,13 @@ nix_tests = \
|
|||||||
build.sh \
|
build.sh \
|
||||||
compute-levels.sh \
|
compute-levels.sh \
|
||||||
ca/build.sh \
|
ca/build.sh \
|
||||||
|
ca/build-with-garbage-path.sh \
|
||||||
|
ca/duplicate-realisation-in-closure.sh \
|
||||||
ca/substitute.sh \
|
ca/substitute.sh \
|
||||||
ca/signatures.sh \
|
ca/signatures.sh \
|
||||||
|
ca/nix-shell.sh \
|
||||||
ca/nix-run.sh \
|
ca/nix-run.sh \
|
||||||
|
ca/recursive.sh \
|
||||||
ca/nix-copy.sh
|
ca/nix-copy.sh
|
||||||
# parallel.sh
|
# parallel.sh
|
||||||
|
|
||||||
|
|||||||
+20
-6
@@ -2,6 +2,20 @@ source common.sh
|
|||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
|
if [[ -n ${CONTENT_ADDRESSED:-} ]]; then
|
||||||
|
nix-shell () {
|
||||||
|
command nix-shell --arg contentAddressed true "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
nix_develop() {
|
||||||
|
nix develop --arg contentAddressed true "$@"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nix_develop() {
|
||||||
|
nix develop "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Test nix-shell -A
|
# Test nix-shell -A
|
||||||
export IMPURE_VAR=foo
|
export IMPURE_VAR=foo
|
||||||
export SELECTED_IMPURE_VAR=baz
|
export SELECTED_IMPURE_VAR=baz
|
||||||
@@ -41,7 +55,7 @@ output=$(NIX_PATH=nixpkgs=shell.nix nix-shell --pure -p foo bar --run 'echo "$(f
|
|||||||
[ "$output" = "foo bar" ]
|
[ "$output" = "foo bar" ]
|
||||||
|
|
||||||
# Test nix-shell shebang mode
|
# Test nix-shell shebang mode
|
||||||
sed -e "s|@ENV_PROG@|$(type -p env)|" shell.shebang.sh > $TEST_ROOT/shell.shebang.sh
|
sed -e "s|@ENV_PROG@|$(type -P env)|" shell.shebang.sh > $TEST_ROOT/shell.shebang.sh
|
||||||
chmod a+rx $TEST_ROOT/shell.shebang.sh
|
chmod a+rx $TEST_ROOT/shell.shebang.sh
|
||||||
|
|
||||||
output=$($TEST_ROOT/shell.shebang.sh abc def)
|
output=$($TEST_ROOT/shell.shebang.sh abc def)
|
||||||
@@ -49,7 +63,7 @@ output=$($TEST_ROOT/shell.shebang.sh abc def)
|
|||||||
|
|
||||||
# Test nix-shell shebang mode again with metacharacters in the filename.
|
# Test nix-shell shebang mode again with metacharacters in the filename.
|
||||||
# First word of filename is chosen to not match any file in the test root.
|
# First word of filename is chosen to not match any file in the test root.
|
||||||
sed -e "s|@ENV_PROG@|$(type -p env)|" shell.shebang.sh > $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
sed -e "s|@ENV_PROG@|$(type -P env)|" shell.shebang.sh > $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
||||||
chmod a+rx $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
chmod a+rx $TEST_ROOT/spaced\ \\\'\"shell.shebang.sh
|
||||||
|
|
||||||
output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.sh abc def)
|
output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.sh abc def)
|
||||||
@@ -58,7 +72,7 @@ output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.sh abc def)
|
|||||||
# Test nix-shell shebang mode for ruby
|
# Test nix-shell shebang mode for ruby
|
||||||
# This uses a fake interpreter that returns the arguments passed
|
# This uses a fake interpreter that returns the arguments passed
|
||||||
# This, in turn, verifies the `rc` script is valid and the `load()` script (given using `-e`) is as expected.
|
# This, in turn, verifies the `rc` script is valid and the `load()` script (given using `-e`) is as expected.
|
||||||
sed -e "s|@SHELL_PROG@|$(type -p nix-shell)|" shell.shebang.rb > $TEST_ROOT/shell.shebang.rb
|
sed -e "s|@SHELL_PROG@|$(type -P nix-shell)|" shell.shebang.rb > $TEST_ROOT/shell.shebang.rb
|
||||||
chmod a+rx $TEST_ROOT/shell.shebang.rb
|
chmod a+rx $TEST_ROOT/shell.shebang.rb
|
||||||
|
|
||||||
output=$($TEST_ROOT/shell.shebang.rb abc ruby)
|
output=$($TEST_ROOT/shell.shebang.rb abc ruby)
|
||||||
@@ -66,20 +80,20 @@ output=$($TEST_ROOT/shell.shebang.rb abc ruby)
|
|||||||
|
|
||||||
# Test nix-shell shebang mode for ruby again with metacharacters in the filename.
|
# Test nix-shell shebang mode for ruby again with metacharacters in the filename.
|
||||||
# Note: fake interpreter only space-separates args without adding escapes to its output.
|
# Note: fake interpreter only space-separates args without adding escapes to its output.
|
||||||
sed -e "s|@SHELL_PROG@|$(type -p nix-shell)|" shell.shebang.rb > $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
sed -e "s|@SHELL_PROG@|$(type -P nix-shell)|" shell.shebang.rb > $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
||||||
chmod a+rx $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
chmod a+rx $TEST_ROOT/spaced\ \\\'\"shell.shebang.rb
|
||||||
|
|
||||||
output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.rb abc ruby)
|
output=$($TEST_ROOT/spaced\ \\\'\"shell.shebang.rb abc ruby)
|
||||||
[ "$output" = '-e load(ARGV.shift) -- '"$TEST_ROOT"'/spaced \'\''"shell.shebang.rb abc ruby' ]
|
[ "$output" = '-e load(ARGV.shift) -- '"$TEST_ROOT"'/spaced \'\''"shell.shebang.rb abc ruby' ]
|
||||||
|
|
||||||
# Test 'nix develop'.
|
# Test 'nix develop'.
|
||||||
nix develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
|
nix_develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
|
||||||
|
|
||||||
# Ensure `nix develop -c` preserves stdin
|
# Ensure `nix develop -c` preserves stdin
|
||||||
echo foo | nix develop -f shell.nix shellDrv -c cat | grep -q foo
|
echo foo | nix develop -f shell.nix shellDrv -c cat | grep -q foo
|
||||||
|
|
||||||
# Ensure `nix develop -c` actually executes the command if stdout isn't a terminal
|
# Ensure `nix develop -c` actually executes the command if stdout isn't a terminal
|
||||||
nix develop -f shell.nix shellDrv -c echo foo |& grep -q foo
|
nix_develop -f shell.nix shellDrv -c echo foo |& grep -q foo
|
||||||
|
|
||||||
# Test 'nix print-dev-env'.
|
# Test 'nix print-dev-env'.
|
||||||
source <(nix print-dev-env -f shell.nix shellDrv)
|
source <(nix print-dev-env -f shell.nix shellDrv)
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ clearStore
|
|||||||
|
|
||||||
rm -f $TEST_ROOT/result
|
rm -f $TEST_ROOT/result
|
||||||
|
|
||||||
export REMOTE_STORE=$TEST_ROOT/remote_store
|
export REMOTE_STORE=file:$TEST_ROOT/remote_store
|
||||||
|
|
||||||
# Build the dependencies and push them to the remote store
|
# Build the dependencies and push them to the remote store
|
||||||
nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook $PWD/push-to-store.sh
|
nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook $PWD/push-to-store.sh
|
||||||
|
|||||||
+9
-8
@@ -9,9 +9,9 @@ rm -f $TEST_ROOT/result
|
|||||||
|
|
||||||
export unreachable=$(nix store add-path ./recursive.sh)
|
export unreachable=$(nix store add-path ./recursive.sh)
|
||||||
|
|
||||||
NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command recursive-nix' build -o $TEST_ROOT/result -L --impure --expr '
|
NIX_BIN_DIR=$(dirname $(type -p nix)) nix --extra-experimental-features 'nix-command recursive-nix' build -o $TEST_ROOT/result -L --impure --expr '
|
||||||
with import ./config.nix;
|
with import ./config.nix;
|
||||||
mkDerivation {
|
mkDerivation rec {
|
||||||
name = "recursive";
|
name = "recursive";
|
||||||
dummy = builtins.toFile "dummy" "bla bla";
|
dummy = builtins.toFile "dummy" "bla bla";
|
||||||
SHELL = shell;
|
SHELL = shell;
|
||||||
@@ -19,11 +19,13 @@ NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command r
|
|||||||
# Note: this is a string without context.
|
# Note: this is a string without context.
|
||||||
unreachable = builtins.getEnv "unreachable";
|
unreachable = builtins.getEnv "unreachable";
|
||||||
|
|
||||||
|
NIX_TESTS_CA_BY_DEFAULT = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT";
|
||||||
|
|
||||||
requiredSystemFeatures = [ "recursive-nix" ];
|
requiredSystemFeatures = [ "recursive-nix" ];
|
||||||
|
|
||||||
buildCommand = '\'\''
|
buildCommand = '\'\''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
opts="--experimental-features nix-command"
|
opts="--experimental-features nix-command ${if (NIX_TESTS_CA_BY_DEFAULT == "1") then "--extra-experimental-features ca-derivations" else ""}"
|
||||||
|
|
||||||
PATH=${builtins.getEnv "NIX_BIN_DIR"}:$PATH
|
PATH=${builtins.getEnv "NIX_BIN_DIR"}:$PATH
|
||||||
|
|
||||||
@@ -46,16 +48,15 @@ NIX_BIN_DIR=$(dirname $(type -p nix)) nix --experimental-features 'nix-command r
|
|||||||
# Add it to our closure.
|
# Add it to our closure.
|
||||||
ln -s $foobar $out/foobar
|
ln -s $foobar $out/foobar
|
||||||
|
|
||||||
[[ $(nix $opts path-info --all | wc -l) -eq 3 ]]
|
[[ $(nix $opts path-info --all | wc -l) -eq 4 ]]
|
||||||
|
|
||||||
# Build a derivation.
|
# Build a derivation.
|
||||||
nix $opts build -L --impure --expr '\''
|
nix $opts build -L --impure --expr '\''
|
||||||
derivation {
|
with import ${./config.nix};
|
||||||
|
mkDerivation {
|
||||||
name = "inner1";
|
name = "inner1";
|
||||||
builder = builtins.getEnv "SHELL";
|
buildCommand = "echo $fnord blaat > $out";
|
||||||
system = builtins.getEnv "system";
|
|
||||||
fnord = builtins.toFile "fnord" "fnord";
|
fnord = builtins.toFile "fnord" "fnord";
|
||||||
args = [ "-c" "echo $fnord blaat > $out" ];
|
|
||||||
}
|
}
|
||||||
'\''
|
'\''
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -1,6 +1,18 @@
|
|||||||
{ inNixShell ? false }:
|
{ inNixShell ? false, contentAddressed ? false }:
|
||||||
|
|
||||||
with import ./config.nix;
|
let cfg = import ./config.nix; in
|
||||||
|
with cfg;
|
||||||
|
|
||||||
|
let
|
||||||
|
mkDerivation =
|
||||||
|
if contentAddressed then
|
||||||
|
args: cfg.mkDerivation ({
|
||||||
|
__contentAddressed = true;
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
} // args)
|
||||||
|
else cfg.mkDerivation;
|
||||||
|
in
|
||||||
|
|
||||||
let pkgs = rec {
|
let pkgs = rec {
|
||||||
setupSh = builtins.toFile "setup" ''
|
setupSh = builtins.toFile "setup" ''
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
source common.sh
|
||||||
|
|
||||||
|
BINARY_CACHE=file://$cacheDir
|
||||||
|
|
||||||
|
getHash() {
|
||||||
|
basename "$1" | cut -d '-' -f 1
|
||||||
|
}
|
||||||
|
getRemoteNarInfo () {
|
||||||
|
echo "$cacheDir/$(getHash "$1").narinfo"
|
||||||
|
}
|
||||||
|
|
||||||
|
cat <<EOF > $TEST_HOME/good.txt
|
||||||
|
I’m a good path
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > $TEST_HOME/bad.txt
|
||||||
|
I’m a bad path
|
||||||
|
EOF
|
||||||
|
|
||||||
|
good=$(nix-store --add $TEST_HOME/good.txt)
|
||||||
|
bad=$(nix-store --add $TEST_HOME/bad.txt)
|
||||||
|
nix copy --to "$BINARY_CACHE" "$good"
|
||||||
|
nix copy --to "$BINARY_CACHE" "$bad"
|
||||||
|
nix-collect-garbage >/dev/null 2>&1
|
||||||
|
|
||||||
|
# Falsifying the narinfo file for '$good'
|
||||||
|
goodPathNarInfo=$(getRemoteNarInfo "$good")
|
||||||
|
badPathNarInfo=$(getRemoteNarInfo "$bad")
|
||||||
|
for fieldName in URL FileHash FileSize NarHash NarSize; do
|
||||||
|
sed -i "/^$fieldName/d" "$goodPathNarInfo"
|
||||||
|
grep -E "^$fieldName" "$badPathNarInfo" >> "$goodPathNarInfo"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Copying back '$good' from the binary cache. This should fail as it is
|
||||||
|
# corrupted
|
||||||
|
if nix copy --from "$BINARY_CACHE" "$good"; then
|
||||||
|
fail "Importing a path with a wrong CA field should fail"
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user