Philip Potter / @philandstuff
rpm, dpkg, rubygems, bundler, zip, docker, rsync?
given identical inputs, the software should behave the same on an end-user machine as on the developer machine
-- from http://nixos.org/~eelco/pubs/phd-thesis.pdf, section 1.1
/nix/store/n0a1y0yd54sh10p7rdi0alysscvac5x5-certificate-transparency-2016-01-14/bin/ct
Where other binaries might search for libjson in /usr/lib
or /usr/local/lib
, we search in
/nix/store/6hcccvdx29r4j8n0wxl85b6mlmq0gvs1-libjson-7.6.1
, and nowhere else
Only the exact same version is acceptable
$ nix-store --query --references /nix/store/n0a1y0yd54sh10p7rdi0alysscvac5x5-certificate-transparency-2016-01-14
$ nix-store --query --requisites /nix/store/n0a1y0yd54sh10p7rdi0alysscvac5x5-certificate-transparency-2016-01-14
This works for any target machine (with matching arch & kernel): Ubuntu, RHEL, CentOS...
Command: nix-copy-closure
An example of ./configure ; make ; make install
{ stdenv, fetchurl, autoreconfHook, libsass }:
stdenv.mkDerivation rec {
name = "sassc-${version}";
version = "3.3.2";
src = fetchurl {
url = "https://github.com/sass/sassc/archive/${version}.tar.gz";
sha256 = "15a2b2698639dfdc7bd6a5ba7a9ecdaf8ebb9f15503fb04dea1be3133308e41d";
};
patchPhase = ''
export SASSC_VERSION=${version}
'';
nativeBuildInputs = [ autoreconfHook ];
buildInputs = [ libsass ];
meta = with stdenv.lib; {
description = "A front-end for libsass";
homepage = https://github.com/sass/sassc/;
license = licenses.mit;
maintainers = with maintainers; [ codyopel pjones ];
platforms = platforms.unix;
};
}
{ stdenv, fetchurl, autoreconfHook, libsass }:
stdenv.mkDerivation rec {
# ...
}
{ stdenv, fetchurl, autoreconfHook, libsass }:
stdenv.mkDerivation rec {
name = "sassc-${version}";
version = "3.3.2";
src = fetchurl {
url = "https://github.com/sass/sassc/archive/${version}.tar.gz";
sha256 = "15a2b2698639dfdc7bd6a5ba7a9ecdaf8ebb9f15503fb04dea1be3133308e41d";
};
# ...
}
{ stdenv, fetchurl, autoreconfHook, libsass }:
stdenv.mkDerivation rec {
name = "sassc-${version}";
version = "3.3.2";
src = fetchurl # ...;
patchPhase = ''
export SASSC_VERSION=${version}
'';
nativeBuildInputs = [ autoreconfHook ];
buildInputs = [ libsass ];
# ...;
}
{ stdenv, fetchurl, autoreconfHook, libsass }:
stdenv.mkDerivation rec {
name = "sassc-${version}";
version = "3.3.2";
src = fetchurl # ...;
# ...;
meta = with stdenv.lib; {
description = "A front-end for libsass";
homepage = https://github.com/sass/sassc/;
license = licenses.mit;
maintainers = with maintainers; [ codyopel pjones ];
platforms = platforms.unix;
};
}
nix-shell --pure -A pkgs.sassc
env | grep libsass
{ stdenv, fetchurl, python3, texinfo, makeWrapper }:
stdenv.mkDerivation rec {
buildInputs = [ python3 texinfo makeWrapper ];
phases = "unpackPhase installPhase fixupPhase";
installPhase = ''
find -type f -name "*.py" | xargs sed -i "s@/usr/bin/env python3@$python3/bin/python3@g"
substituteInPlace setup.py --replace \
"fileout.write(('#!/usr/bin/env %s\n' % env).encode('utf-8'))" \
"fileout.write(('#!%s/bin/%s\n' % (os.environ['python3'], env)).encode('utf-8'))"
python3 setup.py --prefix=$out --freedom=partial install \
--with-shared-cache=$out/share/ponysay \
--with-bash
'';
}
{ stdenv, fetchgit, makeWrapper, ... configH}:
stdenv.mkDerivation rec {
# ...;
buildPhase = ''
cat >src/config.h <<EOF
${configH}
EOF
make
'';
}
/nix/store/mi14q2q22c1fvj4ck79q51j315yb9fr6-etc-hosts
$ ls -l
lrwxrwxrwx bashrc -> /nix/store/r6i1gl85qch03qn7w5w0h5by3nz654c1-etc-bashrc
lrwxrwxrwx fstab -> /nix/store/9rf80psk56v90r23kgii9nmbhdxiq86r-etc-fstab
lrwxrwxrwx hosts -> /nix/store/mi14q2q22c1fvj4ck79q51j315yb9fr6-etc-hosts
lrwxrwxrwx issue -> /nix/store/i233z50axwxgbkf2n5hrqrmpq2ndjhi1-issue
lrwxrwxrwx locale.conf -> /nix/store/ldnwp9g7x6v6g5ms69n8zjy5j39lb6vj-locale.conf
lrwxrwxrwx localtime -> /nix/store/j7hg0289hdcmw7fby9yhcklf50791c8z-tzdata-2015g/share/zoneinfo/Europe/London
lrwxrwxrwx os-release -> /nix/store/yn0p31bvgra01wnm2gnrali6dbh9k0gj-etc-os-release
lrwxrwxrwx profile -> /nix/store/9mj0i0psq7b27vvf7inw87ahgnfw1aq8-etc-profile
lrwxrwxrwx protocols -> /nix/store/4dqzkdz6699zh8bck82jl19mv759n37v-iana-etc-2.30/etc/protocols
lrwxrwxrwx resolvconf.conf -> /nix/store/qjmv1x2j1sp9m61k08xpb7ppqa92qxgs-etc-resolvconf.conf
lrwxrwxrwx services -> /nix/store/4dqzkdz6699zh8bck82jl19mv759n37v-iana-etc-2.30/etc/services
lrwxrwxrwx shells -> /nix/store/4b6n2yyx69ba0km3jajyjbms4cggjjc6-etc-shells
lrwxrwxrwx sudoers -> /nix/store/5656vj85srl1vhkywbhsmcpxpki77mpn-sudoers
lrwxrwxrwx vconsole.conf -> /nix/store/z18ipnvjp88r6iy8gydvxxlakd272vyh-vconsole.conf
lrwxrwxrwx zoneinfo -> /nix/store/j7hg0289hdcmw7fby9yhcklf50791c8z-tzdata-2015g/share/zoneinfo
Philip Potter / @philandstuff