diff options
Diffstat (limited to 'corepkgs')
-rw-r--r-- | corepkgs/Makefile.am | 12 | ||||
-rw-r--r-- | corepkgs/buildenv.nix (renamed from corepkgs/buildenv/default.nix) | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | corepkgs/buildenv.pl (renamed from corepkgs/buildenv/builder.pl.in) | 2 | ||||
-rw-r--r-- | corepkgs/buildenv/Makefile.am | 11 | ||||
-rw-r--r-- | corepkgs/channels/Makefile.am | 11 | ||||
-rw-r--r-- | corepkgs/channels/unpack.nix | 7 | ||||
-rw-r--r-- | corepkgs/channels/unpack.sh.in | 35 | ||||
-rw-r--r-- | corepkgs/config.nix.in | 13 | ||||
-rw-r--r-- | corepkgs/nar.nix | 30 | ||||
-rw-r--r-- | corepkgs/nar/Makefile.am | 11 | ||||
-rw-r--r-- | corepkgs/nar/nar.nix | 7 | ||||
-rw-r--r-- | corepkgs/nar/nar.sh.in | 12 | ||||
-rw-r--r-- | corepkgs/unpack-channel.nix | 11 | ||||
-rw-r--r-- | corepkgs/unpack-channel.sh | 30 |
14 files changed, 100 insertions, 99 deletions
diff --git a/corepkgs/Makefile.am b/corepkgs/Makefile.am index b303a30eba4a..86d7027ed06e 100644 --- a/corepkgs/Makefile.am +++ b/corepkgs/Makefile.am @@ -1 +1,11 @@ -SUBDIRS = nar buildenv channels +all-local: config.nix + +files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh + +install-exec-local: + $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs + $(INSTALL_DATA) config.nix $(files) $(DESTDIR)$(datadir)/nix/corepkgs + +include ../substitute.mk + +EXTRA_DIST = config.nix.in $(files) diff --git a/corepkgs/buildenv/default.nix b/corepkgs/buildenv.nix index d76f5274099a..6e2bee10b1e7 100644 --- a/corepkgs/buildenv/default.nix +++ b/corepkgs/buildenv.nix @@ -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; diff --git a/corepkgs/buildenv/builder.pl.in b/corepkgs/buildenv.pl index 86abe0ca19ea..52a703c0668f 100755..100644 --- a/corepkgs/buildenv/builder.pl.in +++ b/corepkgs/buildenv.pl @@ -1,5 +1,3 @@ -#! @perl@ -w - use strict; use Cwd; use IO::Handle; diff --git a/corepkgs/buildenv/Makefile.am b/corepkgs/buildenv/Makefile.am deleted file mode 100644 index eeab538abca7..000000000000 --- a/corepkgs/buildenv/Makefile.am +++ /dev/null @@ -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 diff --git a/corepkgs/channels/Makefile.am b/corepkgs/channels/Makefile.am deleted file mode 100644 index d4d478f0e2c5..000000000000 --- a/corepkgs/channels/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -all-local: unpack.sh - -install-exec-local: - $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs - $(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/channels - $(INSTALL_DATA) $(srcdir)/unpack.nix $(DESTDIR)$(datadir)/nix/corepkgs/channels - $(INSTALL_PROGRAM) unpack.sh $(DESTDIR)$(datadir)/nix/corepkgs/channels - -include ../../substitute.mk - -EXTRA_DIST = unpack.nix unpack.sh.in diff --git a/corepkgs/channels/unpack.nix b/corepkgs/channels/unpack.nix deleted file mode 100644 index 80ca4a371034..000000000000 --- a/corepkgs/channels/unpack.nix +++ /dev/null @@ -1,7 +0,0 @@ -{system, inputs}: - -derivation { - name = "channels"; - builder = ./unpack.sh; - inherit system inputs; -} \ No newline at end of file diff --git a/corepkgs/channels/unpack.sh.in b/corepkgs/channels/unpack.sh.in deleted file mode 100644 index 6e5939f4f21b..000000000000 --- a/corepkgs/channels/unpack.sh.in +++ /dev/null @@ -1,35 +0,0 @@ -#! @shell@ -e - -# Cygwin compatibility hack: bunzip2 expects cygwin.dll in $PATH. -export PATH=@coreutils@ - -@coreutils@/mkdir $out -@coreutils@/mkdir $out/tmp -cd $out/tmp - -inputs=($inputs) -for ((n = 0; n < ${#inputs[*]}; n += 2)); do - channelName=${inputs[n]} - channelTarball=${inputs[n+1]} - - echo "unpacking channel $channelName" - - @bzip2@ -d < $channelTarball | @tar@ xf - - - if test -e */channel-name; then - channelName="$(@coreutils@/cat */channel-name)" - fi - - nr=1 - attrName=$(echo $channelName | @tr@ -- '- ' '__') - dirName=$attrName - while test -e ../$dirName; do - nr=$((nr+1)) - dirName=$attrName-$nr - done - - @coreutils@/mv * ../$dirName # !!! hacky -done - -cd .. -@coreutils@/rmdir tmp diff --git a/corepkgs/config.nix.in b/corepkgs/config.nix.in new file mode 100644 index 000000000000..b324d732a1a2 --- /dev/null +++ b/corepkgs/config.nix.in @@ -0,0 +1,13 @@ +let + fromEnv = var: def: + let val = builtins.getEnv var; in + if val != "" then val else def; +in { + perl = "@perl@"; + shell = "@shell@"; + coreutils = "@coreutils@"; + bzip2 = fromEnv "NIX_BZIP2" "@bzip2@"; + tar = "@tar@"; + tr = "@tr@"; + nixBinDir = fromEnv "NIX_BIN_DIR" "@bindir@"; +} diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix new file mode 100644 index 000000000000..70a4af2f9ddb --- /dev/null +++ b/corepkgs/nar.nix @@ -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; +} diff --git a/corepkgs/nar/Makefile.am b/corepkgs/nar/Makefile.am deleted file mode 100644 index 103051e22537..000000000000 --- a/corepkgs/nar/Makefile.am +++ /dev/null @@ -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 diff --git a/corepkgs/nar/nar.nix b/corepkgs/nar/nar.nix deleted file mode 100644 index d3d799998f10..000000000000 --- a/corepkgs/nar/nar.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ system, storePath, hashAlgo }: - -derivation { - name = "nar"; - builder = ./nar.sh; - inherit system storePath hashAlgo; -} diff --git a/corepkgs/nar/nar.sh.in b/corepkgs/nar/nar.sh.in deleted file mode 100644 index 1369d3a21fb2..000000000000 --- a/corepkgs/nar/nar.sh.in +++ /dev/null @@ -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 diff --git a/corepkgs/unpack-channel.nix b/corepkgs/unpack-channel.nix new file mode 100644 index 000000000000..5e6ccf23fd47 --- /dev/null +++ b/corepkgs/unpack-channel.nix @@ -0,0 +1,11 @@ +with import <nix/config.nix>; + +{ system, inputs }: + +derivation { + name = "channels"; + builder = shell; + args = [ "-e" ./unpack-channel.sh ]; + inherit system inputs bzip2 tar tr; + PATH = "${nixBinDir}:${coreutils}"; +} diff --git a/corepkgs/unpack-channel.sh b/corepkgs/unpack-channel.sh new file mode 100644 index 000000000000..7c244a6a8552 --- /dev/null +++ b/corepkgs/unpack-channel.sh @@ -0,0 +1,30 @@ +mkdir $out +mkdir $out/tmp +cd $out/tmp + +inputs=($inputs) +for ((n = 0; n < ${#inputs[*]}; n += 2)); do + channelName=${inputs[n]} + channelTarball=${inputs[n+1]} + + echo "unpacking channel $channelName" + + $bzip2 -d < $channelTarball | $tar xf - + + if test -e */channel-name; then + channelName="$(cat */channel-name)" + fi + + nr=1 + attrName=$(echo $channelName | $tr -- '- ' '__') + dirName=$attrName + while test -e ../$dirName; do + nr=$((nr+1)) + dirName=$attrName-$nr + done + + mv * ../$dirName # !!! hacky +done + +cd .. +rmdir tmp |