* Refactoring: Get rid of a few subdirectories in corepkgs/, and some

other simplifications.
* Use <nix/...> to locate the corepkgs.  This allows them to be
  overriden through $NIX_PATH.
* Use bash's pipefail option in the NAR builder so that we don't need
  to create a temporary file.
This commit is contained in:
Eelco Dolstra 2012-01-03 00:16:29 +00:00
parent 93e71e6ab6
commit 48cea0d01e
15 changed files with 52 additions and 84 deletions

View file

@ -1 +1,11 @@
SUBDIRS = nar buildenv channels
SUBDIRS = channels
all-local: config.nix
install-exec-local:
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
$(INSTALL_DATA) config.nix $(srcdir)/nar.nix $(srcdir)/buildenv.nix $(srcdir)/buildenv.pl $(DESTDIR)$(datadir)/nix/corepkgs
include ../substitute.mk
EXTRA_DIST = config.nix.in nar.nix buildenv.nix buildenv.pl

View file

@ -1,9 +1,12 @@
{system, derivations, manifest}:
with import <nix/config.nix>;
{ system, derivations, manifest }:
derivation {
name = "user-environment";
system = system;
builder = ./builder.pl;
builder = perl;
args = [ "-w" ./buildenv.pl ];
manifest = manifest;

View file

@ -1,5 +1,3 @@
#! @perl@ -w
use strict;
use Cwd;
use IO::Handle;

View file

@ -1,11 +0,0 @@
all-local: builder.pl
install-exec-local:
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
$(INSTALL_DATA) $(srcdir)/default.nix $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
$(INSTALL_PROGRAM) builder.pl $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
include ../../substitute.mk
EXTRA_DIST = default.nix builder.pl.in

30
corepkgs/nar.nix Normal file
View file

@ -0,0 +1,30 @@
with import <nix/config.nix>;
let
builder = builtins.toFile "nar.sh"
''
export PATH=${nixBinDir}:${coreutils}
echo "packing $storePath..."
mkdir $out
dst=$out/tmp.nar.bz2
set -o pipefail
nix-store --dump "$storePath" | ${bzip2} > $dst
nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2
'';
in
{ system, storePath, hashAlgo }:
derivation {
name = "nar";
builder = shell;
args = [ "-e" builder ];
inherit system storePath hashAlgo;
}

View file

@ -1,11 +0,0 @@
all-local: nar.sh
install-exec-local:
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nar
$(INSTALL_DATA) $(srcdir)/nar.nix $(DESTDIR)$(datadir)/nix/corepkgs/nar
$(INSTALL_PROGRAM) nar.sh $(DESTDIR)$(datadir)/nix/corepkgs/nar
include ../../substitute.mk
EXTRA_DIST = nar.nix nar.sh.in

View file

@ -1,7 +0,0 @@
{ system, storePath, hashAlgo }:
derivation {
name = "nar";
builder = ./nar.sh;
inherit system storePath hashAlgo;
}

View file

@ -1,12 +0,0 @@
#! @shell@ -e
echo "packing $storePath into $out..."
@coreutils@/mkdir $out
dst=$out/tmp.nar.bz2
@bindir@/nix-store --dump "$storePath" > tmp
@bzip2@ < tmp > $dst
@bindir@/nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
@coreutils@/mv $out/tmp.nar.bz2 $out/$(@coreutils@/cat $out/narbz2-hash).nar.bz2