Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1472989
Make glibc compilation more pure.
alexanderkjeldaas Oct 1, 2013
2410fa1
Make perl 5.16 binary deterministic.
alexanderkjeldaas Apr 7, 2014
61c55ad
Make the linux bootstrap environments more deterministic.
alexanderkjeldaas Apr 8, 2014
0d6467c
Improve python library determinism.
alexanderkjeldaas Apr 8, 2014
84a9791
Improve determinism for libgcrypt, libgpg-error, and busybox.
alexanderkjeldaas Apr 8, 2014
7f014c7
Make openssl deterministic.
alexanderkjeldaas Apr 9, 2014
30a92c4
Make groff and opensp deterministic.
alexanderkjeldaas Apr 9, 2014
3dba999
Make __DATE__/__TIME__ deterministic when NIX_ENFORCE_PURITY=1
alexanderkjeldaas Apr 9, 2014
31e433b
Added a fixed time using libfaketime to stdenv.
alexanderkjeldaas Apr 10, 2014
cb8bd05
Make libfaketime deterministic.
alexanderkjeldaas Apr 13, 2014
f82b30f
perl-modules: Do not create perllocal.pod, for determinism.
alexanderkjeldaas Apr 10, 2014
2919cee
Remove dates from kernel 3.10.35
alexanderkjeldaas Apr 10, 2014
c232efa
Add a fake date utility together with setup.
alexanderkjeldaas Apr 10, 2014
f15d234
Fix typo/breakage in setup.sh
alexanderkjeldaas Apr 10, 2014
36bba24
Use real address for __DATE__ and __TIME__.
alexanderkjeldaas Apr 11, 2014
64ef7aa
Remove libfaketime from propagatedUserEnvPkgs and propagatedNativeBui…
alexanderkjeldaas Apr 11, 2014
673415e
When useFakeTime, set FAKETIME unless set.
alexanderkjeldaas Apr 11, 2014
139262e
Add useFakeTime for python, groff, kernel.
alexanderkjeldaas Apr 11, 2014
67a921d
Do not introduce indeterminism when compressing initrd.
alexanderkjeldaas Apr 11, 2014
62f0019
Fix non-deterministic id-generation for the nixos-manual.
alexanderkjeldaas Apr 12, 2014
dc2fe83
Make python 2.7 deterministic.
alexanderkjeldaas Apr 12, 2014
969208b
Make apr-util deterministic.
alexanderkjeldaas Apr 12, 2014
4b78a5b
Make the system tarball deterministic.
alexanderkjeldaas Apr 12, 2014
15cb459
Not patching elf binaries result in non-deterministic builds.
alexanderkjeldaas Apr 12, 2014
d6eefe6
Fix date in version string.
alexanderkjeldaas Apr 12, 2014
fd1101a
Make smartmontools deterministic.
alexanderkjeldaas Apr 12, 2014
5b81457
Set useFakeTime on a set of derivations.
alexanderkjeldaas Apr 12, 2014
1462666
Do not set nlink when cleaning cpio archives.
alexanderkjeldaas Apr 13, 2014
3d28eb3
Create consistent initrd cpio archive.
alexanderkjeldaas Apr 13, 2014
855843b
Disable useFakeTime for smartmontools.
alexanderkjeldaas Apr 13, 2014
a8e7ddd
Eradicate gzip -9 without -n
alexanderkjeldaas Apr 13, 2014
f97b73b
Set the linux kernel timestamp properly.
alexanderkjeldaas Apr 14, 2014
e8ee36a
Make syslinux deterministic.
alexanderkjeldaas Apr 14, 2014
0ca9e10
Disable profile-guided-optimization (PGO) for gcc.
alexanderkjeldaas Apr 14, 2014
e52a6a2
Barf on finding the build directory in build artifacts.
alexanderkjeldaas Apr 14, 2014
3157dbe
Remove build artifacts from e2fsprogs output.
alexanderkjeldaas Apr 14, 2014
449193d
Change some fixed timestamp to != (time_t)0
alexanderkjeldaas Apr 16, 2014
3823348
Add atomic-ops package.
alexanderkjeldaas Apr 16, 2014
4156801
Excluding directories makes initrd fail for the kernel.
alexanderkjeldaas Apr 23, 2014
90c307e
python 2.7.7 updates to deterministic builds.
alexanderkjeldaas Jun 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion nixos/doc/manual/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ in rec {

inherit sources;

buildInputs = [ libxml2 libxslt ];
buildInputs = [ libxml2 libxslt perl ];

buildCommand = ''
${copySources}
Expand Down Expand Up @@ -83,6 +83,21 @@ in rec {
--nonet --xinclude --output $dst/ \
${docbook5_xsl}/xml/xsl/docbook/xhtml/chunkfast.xsl ./manual.xml

# Fix the non-deterministic id-generation used by xsltproc
# !!! Move this somewhere else
perl -0777 -pi -e '
# xsltproc html output id remapping
# pretty weird that xsltproc cannot do this
# Author: Alexander Kjeldaas <ak@formalprivacy.com>
my @parts = split(/(href="#|id="|href="#ftn.|id="ftn.)(id.\d+")/g, $_);
my %remap = {};
for (my $i = 0; $i < @parts; $i += 3) {
my $id = @parts[ $i+2 ];
$remap{$id} = $i unless exists $remap{$id};
@parts[ $i+2 ] = "idp$remap{$id}\"";
}
$_ = join "", @parts; ' $dst/manual.html

mkdir -p $dst/images/callouts
cp ${docbook5_xsl}/xml/xsl/docbook/images/callouts/*.gif $dst/images/callouts/

Expand Down
7 changes: 6 additions & 1 deletion nixos/lib/make-system-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ done

mkdir -p $out/tarball

tar cvJf $out/tarball/$fileName.tar.xz * $extraArgs

rm ./env-vars

find * ! -type d -print0 | sort -z |
tar -cv --mtime='1970-01-01' -T- --null -f- $extraArgs |
xz -c > $out/tarball/$fileName.tar.xz

mkdir -p $out/nix-support
echo $system > $out/nix-support/system
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/system/boot/stage-1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ in

boot.initrd.compressor = mkOption {
internal = true;
default = "gzip -9";
default = "gzip -9n";
type = types.str;
description = "The compressor to use on the initrd image.";
example = "xz";
Expand Down
26 changes: 18 additions & 8 deletions pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,32 @@ fi
extraAfter=($NIX_CFLAGS_COMPILE)
extraBefore=()

# When enforcing purity, pretend gcc can't find the current date and
# time
if test "$NIX_ENFORCE_PURITY" = "1"; then
extraBefore=(-D__DATE__=\"Jan\ \ 1\ 1970\"
-D__TIME__=\"00:00:01\"
-Wno-builtin-macro-redefined
"${extraBefore[@]}")
fi


if test "$dontLink" != "1"; then

# Add the flags that should only be passed to the compiler when
# linking.
extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
extraAfter=("${extraAfter[@]}" $NIX_CFLAGS_LINK)

# Add the flags that should be passed to the linker (and prevent
# `ld-wrapper' from adding NIX_LDFLAGS again).
for i in $NIX_LDFLAGS_BEFORE; do
extraBefore=(${extraBefore[@]} "-Wl,$i")
extraBefore=("${extraBefore[@]}" "-Wl,$i")
done
for i in $NIX_LDFLAGS; do
if test "${i:0:3}" = "-L/"; then
extraAfter=(${extraAfter[@]} "$i")
extraAfter=("${extraAfter[@]}" "$i")
else
extraAfter=(${extraAfter[@]} "-Wl,$i")
extraAfter=("${extraAfter[@]}" "-Wl,$i")
fi
done
export NIX_LDFLAGS_SET=1
Expand All @@ -122,11 +132,11 @@ if test "$NIX_DEBUG" = "1"; then
echo " $i" >&2
done
echo "extraBefore flags to @gccProg@:" >&2
for i in ${extraBefore[@]}; do
for i in "${extraBefore[@]}"; do
echo " $i" >&2
done
echo "extraAfter flags to @gccProg@:" >&2
for i in ${extraAfter[@]}; do
for i in "${extraAfter[@]}"; do
echo " $i" >&2
done
fi
Expand All @@ -140,9 +150,9 @@ fi
# `-B' flags, since they confuse some programs. Deep bash magic to
# apply grep to stderr (by swapping stdin/stderr twice).
if test -z "$NIX_GCC_NEEDS_GREP"; then
@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
@gccProg@ "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}"
else
(@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
(@gccProg@ "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}" 3>&2 2>&1 1>&3- \
| (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
exit $?
fi
3 changes: 3 additions & 0 deletions pkgs/build-support/kernel/cpio-clean.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
my $cpio = Archive::Cpio->new;
my $IN = \*STDIN;
my $ino = 1;
my %ino_remap = {};
$cpio->read_with_handler($IN, sub {
my ($e) = @_;
$ino_remap{$e->{inode}} = $ino++ unless exists $ino_remap{$e->{inode}};
$e->{inode} = $ino_remap{$e->{inode}};
$e->{mtime} = 1;
$cpio->write_one(\*STDOUT, $e);
});
Expand Down
6 changes: 5 additions & 1 deletion pkgs/build-support/kernel/make-initrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ storePaths=$(perl $pathsFromGraph closure-*)

# Put the closure in a gzipped cpio archive.
mkdir -p $out
(cd root && find * -print0 | cpio -o -H newc --null | perl $cpioClean | $compressor > $out/initrd)
(cd root && find * -print0 |
sort -z |
cpio -o -H newc -R 0.0 --null |
perl $cpioClean |
$compressor > $out/initrd)

if [ -n "$makeUInitrd" ]; then
mv $out/initrd $out/initrd.gz
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/qcmm/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ installPhase() {
mv $file ${file%.opt}
done

find $out/man -type f -exec gzip -9 {} \;
find $out/man -type f -exec gzip -9n {} \;

find $out -name \*.a -exec echo stripping {} \; \
-exec strip -S {} \;
Expand Down
29 changes: 29 additions & 0 deletions pkgs/development/interpreters/perl/5.16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ stdenv.mkDerivation rec {
patches =
[ # Do not look in /usr etc. for dependencies.
./no-sys-dirs.patch
./no-impure-config-time.patch
./fixed-man-page-date.patch
./no-date-in-perl-binary.patch
]
++ optional stdenv.isSunOS ./ld-shared.patch
++ stdenv.lib.optional stdenv.isDarwin [ ./cpp-precomp.patch ./no-libutil.patch ] ;
Expand Down Expand Up @@ -64,5 +67,31 @@ stdenv.mkDerivation rec {

setupHook = ./setup-hook.sh;

doCheck = !stdenv.isDarwin;

# some network-related tests don't work, mostly probably due to our sandboxing
# man-heading.t is skipped due to output determinism (no dates)
testsToSkip = ''
lib/Net/hostent.t \
dist/IO/t/{io_multihomed.t,io_sock.t} \
dist/Net-Ping/t/*.t \
cpan/autodie/t/truncate.t \
t/porting/{maintainers.t,regen.t} \
cpan/Socket/t/get{name,addr}info.t \
cpan/podlators/t/man-heading.t \
'' + optionalString stdenv.isFreeBSD ''
cpan/CPANPLUS/t/04_CPANPLUS-Module.t \
cpan/CPANPLUS/t/20_CPANPLUS-Dist-MM.t \
'' + " ";

postPatch = optionalString (!stdenv.isDarwin) /* this failed on Darwin, no idea why */ ''
for test in ${testsToSkip}; do
echo "Removing test" $test
rm "$test"
pat=`echo "$test" | sed 's,/,\\\\/,g'` # just escape slashes
sed "/^$pat/d" -i MANIFEST
done
'';

passthru.libPrefix = "lib/perl5/site_perl";
}
11 changes: 11 additions & 0 deletions pkgs/development/interpreters/perl/5.16/fixed-man-page-date.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/cpan/podlators/lib/Pod/Man.pm 2014-04-07 06:25:23.730505243 +0200
+++ b/cpan/podlators/lib/Pod/Man.pm 2014-04-07 06:26:40.816552603 +0200
@@ -768,7 +768,7 @@
} else {
($name, $section) = $self->devise_title;
}
- my $date = $$self{date} || $self->devise_date;
+ my $date = "1970-01-01"; # Fixed date for NixOS, orig: $$self{date} || $self->devise_date;
$self->preamble ($name, $section, $date)
unless $self->bare_output or DEBUG > 9;

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/perl.c 2014-04-07 07:58:01.402831615 +0200
+++ b/perl.c 2014-04-07 07:59:38.556945298 +0200
@@ -1754,7 +1754,7 @@
PUSHs(Perl_newSVpvn_flags(aTHX_ non_bincompat_options,
sizeof(non_bincompat_options) - 1, SVs_TEMP));

-#ifdef __DATE__
+#if 0
# ifdef __TIME__
PUSHs(Perl_newSVpvn_flags(aTHX_
STR_WITH_LEN("Compiled at " __DATE__ " " __TIME__),
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/Configure 2014-04-05 20:21:33.714635700 +0200
+++ b/Configure 2014-04-05 20:23:23.377441026 +0200
@@ -3609,6 +3609,8 @@

: who configured the system
cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
+cf_time='Thu Jan 1 00:00:01 UTC 1970'
+
case "$cf_by" in
"")
cf_by=`(logname) 2>/dev/null`
11 changes: 10 additions & 1 deletion pkgs/development/interpreters/python/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ let
[ # Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
./search-path.patch

# No time in the bdist wininst
./no-time-wininst.patch

# Python recompiles a Python if the mtime stored *in* the
# pyc/pyo file differs from the mtime of the source file. This
# doesn't work in Nix because Nix changes the mtime of files in
Expand Down Expand Up @@ -72,7 +75,8 @@ let
'';

NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";

DETERMINISTIC_BUILD = 1;
useFakeTime = 1;
setupHook = ./setup-hook.sh;

postInstall =
Expand All @@ -83,6 +87,11 @@ let
ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}

paxmark E $out/bin/python${majorVersion}
# !!! This is a stopgap measure for getting deterministic builds.
# It disables creation of windows installers and the lib2to3 which
# can rewrite python2-programs to python3.
rm $out/lib/python${majorVersion}/distutils/command/wininst-*.exe
rm $out/lib/python${majorVersion}/lib2to3/Grammar2.7.7.final.0.pickle
'';

passthru = rec {
Expand Down
12 changes: 12 additions & 0 deletions pkgs/development/interpreters/python/2.7/no-time-wininst.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -ur Python-2.7.6.orig/Lib/distutils/command/bdist_wininst.py Python-2.7.6/Lib/distutils/command/bdist_wininst.py
--- Python-2.7.6.orig/Lib/distutils/command/bdist_wininst.py 2013-11-10 08:36:40.000000000 +0100
+++ Python-2.7.6/Lib/distutils/command/bdist_wininst.py 2014-04-11 14:49:49.789235982 +0200
@@ -245,7 +245,7 @@
import time
import distutils
build_info = "Built %s with distutils-%s" % \
- (time.ctime(time.time()), distutils.__version__)
+ (time.ctime(0), distutils.__version__)
lines.append("build_info=%s" % build_info)
return string.join(lines, "\n")

5 changes: 5 additions & 0 deletions pkgs/development/libraries/apr-util/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ stdenv.mkDerivation rec {

# Give apr1 access to sed for runtime invocations
postInstall = ''
# Determinism changes
sed -i -e 's/APU_SOURCE_DIR=".*"/APU_SOURCE_DIR="unknown"/g' \
-e 's/APU_BUILD_DIR=".*"/APU_BUILD_DIR="unknown"/g' \
$out/bin/apu-1-config

wrapProgram $out/bin/apu-1-config --prefix PATH : "${gnused}/bin"
'';

Expand Down
28 changes: 28 additions & 0 deletions pkgs/development/libraries/atomic-ops/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{stdenv, fetchgit, autoconf, automake, libtool}:

stdenv.mkDerivation rec {
baseName = "atomic-ops";
version = "7.4.0";
name="${baseName}-${version}";

buildInputs = [ autoconf automake libtool ];

preConfigure = ''
./autogen.sh
'';

src = fetchgit {
url = "https://github.com/ivmai/libatomic_ops";
rev = "a5df11ab031f7541442bac387e2ec5b6c88d8600";
sha256 = "0ij9i0m9lq7ipx5mbp0qpr1y95zpgiv8cp11d46sss2fs1jkj1i3";
};

meta = {
homepage = "https://github.com/ivmai/libatomic_ops";
description = ''
This package provides semi-portable access to hardware-provided
atomic memory update operations on a number architectures.'';
platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
maintainers = [ stdenv.lib.maintainers.ak ];
};
}
1 change: 1 addition & 0 deletions pkgs/development/libraries/glib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ stdenv.mkDerivation rec {
'';

postInstall = ''rm -rvf $out/share/gtk-doc'';
DETERMINISTIC_BUILD = 1;

passthru = {
gioModuleDir = "lib/gio/modules";
Expand Down
8 changes: 8 additions & 0 deletions pkgs/development/libraries/glibc/2.19/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ stdenv.mkDerivation ({
./fix-math.patch

./cve-2014-0475.patch

/* Remove references to the compilation date. */
./glibc-remove-date-from-compilation-banner.patch

/* Remove the date and time from nscd. It is used as a protocol
compatibility check, but we assume nix takes care of that for
us. */
./glibc-remove-datetime-from-nscd.patch
];

postPatch = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -ur glibc-2.17.orig/csu/Makefile glibc-2.17/csu/Makefile
--- glibc-2.17.orig/csu/Makefile 2012-12-25 04:02:13.000000000 +0100
+++ glibc-2.17/csu/Makefile 2013-08-19 16:01:57.132378550 +0200
@@ -172,7 +172,7 @@
os=Linux; \
fi; \
printf '"Compiled on a %s %s system on %s.\\n"\n' \
- "$$os" "$$version" "`date +%Y-%m-%d`";; \
+ "$$os" "$$version";; \
*) ;; \
esac; \
files="$(all-Banner-files)"; \
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/nscd/nscd_stat.c 2014-04-08 20:35:24.253715420 +0200
+++ b/nscd/nscd_stat.c 2014-04-08 20:38:32.526634400 +0200
@@ -37,7 +37,7 @@


/* We use this to make sure the receiver is the same. */
-static const char compilation[21] = __DATE__ " " __TIME__;
+static const char compilation[21] = "Thu 1 1970 00:00:01"; /* __DATE__ " " __TIME__; */

/* Statistic data for one database. */
struct dbstat
1 change: 1 addition & 0 deletions pkgs/development/libraries/icu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ stdenv.mkDerivation {
stdenv.lib.optionalString stdenv.isDarwin " --enable-rpath";

enableParallelBuilding = true;
useFakeTime = 1;

meta = {
description = "Unicode and globalization support library";
Expand Down
12 changes: 12 additions & 0 deletions pkgs/development/libraries/libfaketime/avoid-spurious-lrt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -ur libfaketime-0.9.5.orig/src/Makefile libfaketime-0.9.5/src/Makefile
--- libfaketime-0.9.5.orig/src/Makefile 2013-10-13 11:19:30.000000000 +0200
+++ libfaketime-0.9.5/src/Makefile 2014-04-11 21:58:06.285435083 +0200
@@ -69,7 +69,7 @@

CFLAGS += -std=gnu99 -Wall -Wextra -Werror -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"'
LIB_LDFLAGS += -shared
-LDFLAGS += -Wl,--version-script=libfaketime.map -lrt
+LDFLAGS += -Wl,--version-script=libfaketime.map
LDADD += -ldl -lm -lpthread -lrt

SRC = libfaketime.c
Loading