mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-28 00:26:15 +02:00
d4dcffd643
In this mode, the following restrictions apply: * The builtins currentTime, currentSystem and storePath throw an error. * $NIX_PATH and -I are ignored. * fetchGit and fetchMercurial require a revision hash. * fetchurl and fetchTarball require a sha256 attribute. * No file system access is allowed outside of the paths returned by fetch{Git,Mercurial,url,Tarball}. Thus 'nix build -f ./foo.nix' is not allowed. Thus, the evaluation result is completely reproducible from the command line arguments. E.g. nix build --pure-eval '( let nix = fetchGit { url = https://github.com/NixOS/nixpkgs.git; rev = "9c927de4b179a6dd210dd88d34bda8af4b575680"; }; nixpkgs = fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-17.09"; rev = "66b4de79e3841530e6d9c6baf98702aa1f7124e4"; }; in (import (nix + "/release.nix") { inherit nix nixpkgs; }).build.x86_64-linux )' The goal is to enable completely reproducible and traceable evaluation. For example, a NixOS configuration could be fully described by a single Git commit hash. 'nixos-rebuild' would do something like nix build --pure-eval '( (import (fetchGit { url = file:///my-nixos-config; rev = "..."; })).system ') where the Git repository /my-nixos-config would use further fetchGit calls or Git externals to fetch Nixpkgs and whatever other dependencies it has. Either way, the commit hash would uniquely identify the NixOS configuration and allow it to reproduced.
45 lines
1 KiB
Makefile
45 lines
1 KiB
Makefile
# Run program $1 as part of ‘make installcheck’.
|
||
define run-install-test
|
||
|
||
installcheck: $1
|
||
|
||
_installcheck-list += $1
|
||
|
||
endef
|
||
|
||
# Color code from https://unix.stackexchange.com/a/10065
|
||
installcheck:
|
||
@total=0; failed=0; \
|
||
red=""; \
|
||
green=""; \
|
||
yellow=""; \
|
||
normal=""; \
|
||
if [ -t 1 ]; then \
|
||
red="[31;1m"; \
|
||
green="[32;1m"; \
|
||
yellow="[33;1m"; \
|
||
normal="[m"; \
|
||
fi; \
|
||
for i in $(_installcheck-list); do \
|
||
total=$$((total + 1)); \
|
||
printf "running test $$i..."; \
|
||
log="$$(cd $$(dirname $$i) && $(tests-environment) $$(basename $$i) 2>&1)"; \
|
||
status=$$?; \
|
||
if [ $$status -eq 0 ]; then \
|
||
echo " [$${green}PASS$$normal]"; \
|
||
elif [ $$status -eq 99 ]; then \
|
||
echo " [$${yellow}SKIP$$normal]"; \
|
||
else \
|
||
echo " [$${red}FAIL$$normal]"; \
|
||
echo "$$log" | sed 's/^/ /'; \
|
||
failed=$$((failed + 1)); \
|
||
fi; \
|
||
done; \
|
||
if [ "$$failed" != 0 ]; then \
|
||
echo "$${red}$$failed out of $$total tests failed $$normal"; \
|
||
exit 1; \
|
||
else \
|
||
echo "$${green}All tests succeeded$$normal"; \
|
||
fi
|
||
|
||
.PHONY: check installcheck
|