add get* helper functions and mass-replace manual outputs search with them

This commit is contained in:
Nikolay Amiantov 2016-04-14 19:00:39 +03:00
parent c779e30d53
commit 5ff40ddedf
20 changed files with 67 additions and 64 deletions

View File

@ -450,6 +450,10 @@ rec {
then pkg.${output} or pkg.out or pkg then pkg.${output} or pkg.out or pkg
else pkg; else pkg;
getBin = getOutput "bin";
getLib = getOutput "lib";
getDev = getOutput "dev";
/*** deprecated stuff ***/ /*** deprecated stuff ***/

View File

@ -12,8 +12,7 @@ let
''; '';
}); });
path = map # outputs TODO? path = map getBin
(pkg: (pkg.bin or (pkg.out or pkg)))
[ pkgs.coreutils pkgs.gnugrep pkgs.findutils [ pkgs.coreutils pkgs.gnugrep pkgs.findutils
pkgs.glibc # needed for getent pkgs.glibc # needed for getent
pkgs.shadow pkgs.shadow

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, bison { stdenv, fetchurl, lib, bison
, qt4, xapian, file, python, perl , qt4, xapian, file, python, perl
, djvulibre, groff, libxslt, unzip, poppler_utils, antiword, catdoc, lyx , djvulibre, groff, libxslt, unzip, poppler_utils, antiword, catdoc, lyx
, libwpd, unrtf, untex , libwpd, unrtf, untex
@ -26,27 +26,27 @@ stdenv.mkDerivation rec {
# the absolute path to the filtering command. # the absolute path to the filtering command.
postInstall = '' postInstall = ''
for f in $out/share/recoll/filters/* ; do for f in $out/share/recoll/filters/* ; do
substituteInPlace $f --replace antiword ${antiword}/bin/antiword substituteInPlace $f --replace antiword ${lib.getBin antiword}/bin/antiword
substituteInPlace $f --replace awk ${gawk}/bin/awk substituteInPlace $f --replace awk ${lib.getBin gawk}/bin/awk
substituteInPlace $f --replace catppt ${catdoc}/bin/catppt substituteInPlace $f --replace catppt ${lib.getBin catdoc}/bin/catppt
substituteInPlace $f --replace djvused ${djvulibre.bin}/bin/djvused substituteInPlace $f --replace djvused ${lib.getBin djvulibre}/bin/djvused
substituteInPlace $f --replace djvutxt ${djvulibre.bin}/bin/djvutxt substituteInPlace $f --replace djvutxt ${lib.getBin djvulibre}/bin/djvutxt
substituteInPlace $f --replace egrep ${gnugrep}/bin/egrep substituteInPlace $f --replace egrep ${lib.getBin gnugrep}/bin/egrep
substituteInPlace $f --replace groff ${groff}/bin/groff substituteInPlace $f --replace groff ${lib.getBin groff}/bin/groff
substituteInPlace $f --replace gunzip ${gzip}/bin/gunzip substituteInPlace $f --replace gunzip ${lib.getBin gzip}/bin/gunzip
substituteInPlace $f --replace iconv ${libiconv.bin or libiconv}/bin/iconv substituteInPlace $f --replace iconv ${lib.getBin libiconv}/bin/iconv
substituteInPlace $f --replace lyx ${lyx}/bin/lyx substituteInPlace $f --replace lyx ${lib.getBin lyx}/bin/lyx
substituteInPlace $f --replace pdftotext ${poppler_utils.out}/bin/pdftotext substituteInPlace $f --replace pdftotext ${lib.getBin poppler_utils}/bin/pdftotext
substituteInPlace $f --replace pstotext ${ghostscript}/bin/ps2ascii substituteInPlace $f --replace pstotext ${lib.getBin ghostscript}/bin/ps2ascii
substituteInPlace $f --replace sed ${gnused}/bin/sed substituteInPlace $f --replace sed ${lib.getBin gnused}/bin/sed
substituteInPlace $f --replace tar ${gnutar}/bin/tar substituteInPlace $f --replace tar ${lib.getBin gnutar}/bin/tar
substituteInPlace $f --replace unzip ${unzip}/bin/unzip substituteInPlace $f --replace unzip ${lib.getBin unzip}/bin/unzip
substituteInPlace $f --replace xls2csv ${catdoc}/bin/xls2csv substituteInPlace $f --replace xls2csv ${lib.getBin catdoc}/bin/xls2csv
substituteInPlace $f --replace xsltproc ${libxslt.bin}/bin/xsltproc substituteInPlace $f --replace xsltproc ${lib.getBin libxslt}/bin/xsltproc
substituteInPlace $f --replace unrtf ${unrtf}/bin/unrtf substituteInPlace $f --replace unrtf ${lib.getBin unrtf}/bin/unrtf
substituteInPlace $f --replace untex ${untex}/bin/untex substituteInPlace $f --replace untex ${lib.getBin untex}/bin/untex
substituteInPlace $f --replace wpd2html ${libwpd}/bin/wpd2html substituteInPlace $f --replace wpd2html ${lib.getBin libwpd}/bin/wpd2html
substituteInPlace $f --replace /usr/bin/perl ${perl}/bin/perl substituteInPlace $f --replace /usr/bin/perl ${lib.getBin perl}/bin/perl
done done
''; '';

View File

@ -27,13 +27,13 @@ let
ccVersion = (builtins.parseDrvName cc.name).version; ccVersion = (builtins.parseDrvName cc.name).version;
ccName = (builtins.parseDrvName cc.name).name; ccName = (builtins.parseDrvName cc.name).name;
libc_bin = if nativeLibc then null else libc.bin or libc; libc_bin = if nativeLibc then null else getBin libc;
libc_dev = if nativeLibc then null else libc.dev or libc; libc_dev = if nativeLibc then null else getDev libc;
libc_lib = if nativeLibc then null else libc.out or libc; libc_lib = if nativeLibc then null else getLib libc;
cc_solib = cc.lib or cc; cc_solib = getLib cc;
binutils_bin = if nativeTools then "" else binutils.bin or binutils; binutils_bin = if nativeTools then "" else getBin binutils;
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils. # The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
coreutils_bin = if nativeTools then "" else coreutils.bin or coreutils; coreutils_bin = if nativeTools then "" else getBin coreutils;
in in
stdenv.mkDerivation { stdenv.mkDerivation {

View File

@ -5,7 +5,7 @@
# stdenv.mkDerivation provides a wrapper that sets up the right environment # stdenv.mkDerivation provides a wrapper that sets up the right environment
# variables so that the compiler and the linker just "work". # variables so that the compiler and the linker just "work".
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" { name ? "", stdenv, lib, nativeTools, nativeLibc, nativePrefix ? ""
, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? "" , gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
, zlib ? null , zlib ? null
}: }:
@ -41,10 +41,10 @@ stdenv.mkDerivation {
addFlags = ./add-flags; addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix gcc; inherit nativeTools nativeLibc nativePrefix gcc;
gcc_lib = gcc.lib or gcc; gcc_lib = lib.getLib gcc;
libc = if nativeLibc then null else libc; libc = if nativeLibc then null else libc;
libc_dev = if nativeLibc then null else libc.dev or libc; libc_dev = if nativeLibc then null else lib.getDev libc;
libc_bin = if nativeLibc then null else libc.bin or libc; libc_bin = if nativeLibc then null else lib.getBin libc;
binutils = if nativeTools then null else binutils; binutils = if nativeTools then null else binutils;
# The wrapper scripts use 'cat', so we may need coreutils # The wrapper scripts use 'cat', so we may need coreutils
coreutils = if nativeTools then null else coreutils; coreutils = if nativeTools then null else coreutils;

View File

@ -33,8 +33,8 @@ stdenv.mkDerivation {
for f in $(find $out); do for f in $(find $out); do
if [ -f "$f" ] && patchelf "$f" 2> /dev/null; then if [ -f "$f" ] && patchelf "$f" 2> /dev/null; then
patchelf --set-interpreter ${glibc.out}/lib/ld-linux.so.2 \ patchelf --set-interpreter ${getLib glibc}/lib/ld-linux.so.2 \
--set-rpath $out/lib:${gcc.lib or gcc}/lib:${ncurses.out}/lib \ --set-rpath $out/lib:${getLib gcc}/lib:${ncurses.out}/lib \
"$f" || true "$f" || true
fi fi
done done

View File

@ -1,4 +1,4 @@
{stdenv, fetchurl, perl, libedit, ncurses, gmp}: {stdenv, lib, fetchurl, perl, libedit, ncurses, gmp}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "6.10.2"; version = "6.10.2";
@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
'' else ""); '' else "");
configurePhase = '' configurePhase = ''
./configure --prefix=$out --with-gmp-libraries=${gmp.out}/lib --with-gmp-includes=${gmp.dev or gmp}/include ./configure --prefix=$out --with-gmp-libraries=${lib.getLib gmp}/lib --with-gmp-includes=${lib.getDev gmp}/include
''; '';
# Stripping combined with patchelf breaks the executables (they die # Stripping combined with patchelf breaks the executables (they die

View File

@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
# Find the loader dynamically # Find the loader dynamically
LOADER="$(find ${libc.out or libc}/lib -name ld-linux\* | head -n 1)" LOADER="$(find ${lib.getLib libc}/lib -name ld-linux\* | head -n 1)"
# Replace references to the loader # Replace references to the loader
find src/cmd -name asm.c -exec sed -i "s,/lib/ld-linux.*\.so\.[0-9],$LOADER," {} \; find src/cmd -name asm.c -exec sed -i "s,/lib/ld-linux.*\.so\.[0-9],$LOADER," {} \;

View File

@ -17,8 +17,8 @@ assert enableThreading -> (stdenv ? glibc);
let let
libc = if stdenv.cc.libc or null != null then stdenv.cc.libc else "/usr"; libc = if stdenv.cc.libc or null != null then stdenv.cc.libc else "/usr";
libcInc = libc.dev or libc; libcInc = lib.getDev libc;
libcLib = libc.out or libc; libcLib = lib.getLib libc;
common = { version, sha256 }: stdenv.mkDerivation rec { common = { version, sha256 }: stdenv.mkDerivation rec {
name = "perl-${version}"; name = "perl-${version}";

View File

@ -25,10 +25,9 @@ let
++ stdenv.lib.optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++ stdenv.lib.optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc
++ stdenv.lib.optional zlibSupport zlib; ++ stdenv.lib.optional zlibSupport zlib;
C_INCLUDE_PATH = stdenv.lib.concatStringsSep ":" (map (p: "${p.dev or p}/include") buildInputs); C_INCLUDE_PATH = stdenv.lib.makeSearchPathOutput "dev" "include" buildInputs;
LIBRARY_PATH = stdenv.lib.concatStringsSep ":" (map (p: "${p.lib or p.out or p}/lib") buildInputs); LIBRARY_PATH = stdenv.lib.makeLibraryPath buildInputs;
LD_LIBRARY_PATH = stdenv.lib.concatStringsSep ":" (map (p: "${p.lib or p.out or p}/lib") LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath (stdenv.lib.filter (x : x.outPath != stdenv.cc.libc.outPath or "") buildInputs);
(stdenv.lib.filter (x : x.outPath != stdenv.cc.libc.outPath or "") buildInputs));
preConfigure = '' preConfigure = ''
# hint pypy to find nix ncurses # hint pypy to find nix ncurses

View File

@ -53,8 +53,8 @@ let
++ optional zlibSupport zlib; ++ optional zlibSupport zlib;
mkPaths = paths: { mkPaths = paths: {
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p.dev or p}/include") paths); C_INCLUDE_PATH = makeSearchPathOutput "dev" "include" paths;
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p.lib or (p.out or p)}/lib") paths); LIBRARY_PATH = makeLibraryPath paths;
}; };
# Build the basic Python interpreter without modules that have # Build the basic Python interpreter without modules that have

View File

@ -102,8 +102,8 @@ let
propagatedBuildInputs = optional stdenv.isDarwin configd; propagatedBuildInputs = optional stdenv.isDarwin configd;
mkPaths = paths: { mkPaths = paths: {
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p.dev or p}/include") paths); C_INCLUDE_PATH = makeSearchPathOutput "dev" "include" paths;
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p.lib or (p.out or p)}/lib") paths); LIBRARY_PATH = makeLibraryPath paths;
}; };
# Build the basic Python interpreter without modules that have # Build the basic Python interpreter without modules that have

View File

@ -44,8 +44,8 @@ stdenv.mkDerivation {
${optionalString stdenv.isDarwin ''export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"''} ${optionalString stdenv.isDarwin ''export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"''}
configureFlagsArray=( --enable-shared --with-threads --with-wide-unicode configureFlagsArray=( --enable-shared --with-threads --with-wide-unicode
CPPFLAGS="${concatStringsSep " " (map (p: "-I${p.dev or p}/include") buildInputs)}" CPPFLAGS="${makeSearchPathOutput "dev" "include" buildInputs}"
LDFLAGS="${concatStringsSep " " (map (p: "-L${p.lib or (p.out or p)}/lib") buildInputs)}" LDFLAGS="${makeLibraryPath buildInputs}"
LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}" LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}"
) )
''; '';

View File

@ -46,8 +46,8 @@ stdenv.mkDerivation {
${optionalString stdenv.isDarwin ''export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"''} ${optionalString stdenv.isDarwin ''export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"''}
configureFlagsArray=( --enable-shared --with-threads configureFlagsArray=( --enable-shared --with-threads
CPPFLAGS="${concatStringsSep " " (map (p: "-I${p.dev or p}/include") buildInputs)}" CPPFLAGS="${makeSearchPathOutput "dev" "include" buildInputs}"
LDFLAGS="${concatStringsSep " " (map (p: "-L${p.lib or (p.out or p)}/lib") buildInputs)}" LDFLAGS="${makeLibraryPath buildInputs}"
LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}" LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}"
) )
''; '';

View File

@ -58,8 +58,8 @@ stdenv.mkDerivation {
''} ''}
configureFlagsArray=( --enable-shared --with-threads configureFlagsArray=( --enable-shared --with-threads
CPPFLAGS="${concatStringsSep " " (map (p: "-I${p.dev or p}/include") buildInputs)}" CPPFLAGS="${makeSearchPathOutput "dev" "include" buildInputs}"
LDFLAGS="${concatStringsSep " " (map (p: "-L${p.lib or (p.out or p)}/lib") buildInputs)}" LDFLAGS="${makeLibraryPath buildInputs}"
LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}" LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}"
) )
''; '';

View File

@ -58,8 +58,8 @@ stdenv.mkDerivation {
''} ''}
configureFlagsArray=( --enable-shared --with-threads configureFlagsArray=( --enable-shared --with-threads
CPPFLAGS="${concatStringsSep " " (map (p: "-I${p.dev or p}/include") buildInputs)}" CPPFLAGS="${makeSearchPathOutput "dev" "include" buildInputs}"
LDFLAGS="${concatStringsSep " " (map (p: "-L${p.lib or (p.out or p)}/lib") buildInputs)}" LDFLAGS="${makeLibraryPath buildInputs}"
LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}" LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}"
) )
''; '';

View File

@ -47,9 +47,9 @@ stdenv.mkDerivation rec {
'' ''
fixCmakeFiles . fixCmakeFiles .
substituteInPlace Modules/Platform/UnixPaths.cmake \ substituteInPlace Modules/Platform/UnixPaths.cmake \
--subst-var-by glibc_bin ${glibc.bin or glibc} \ --subst-var-by glibc_bin ${getBin glibc} \
--subst-var-by glibc_dev ${glibc.dev or glibc} \ --subst-var-by glibc_dev ${getDev glibc} \
--subst-var-by glibc_lib ${glibc.out or glibc} --subst-var-by glibc_lib ${getLib glibc}
''; '';
configureFlags = configureFlags =
[ "--docdir=/share/doc/${name}" [ "--docdir=/share/doc/${name}"

View File

@ -32,9 +32,10 @@ stdenv.mkDerivation ((lib.optionalAttrs (! isNull buildScript) {
# them to the RPATH so that the user doesn't have to set them in # them to the RPATH so that the user doesn't have to set them in
# LD_LIBRARY_PATH. # LD_LIBRARY_PATH.
NIX_LDFLAGS = map (path: "-rpath " + path) ( NIX_LDFLAGS = map (path: "-rpath " + path) (
map (x: "${x}/lib") ([ stdenv.cc.cc ] ++ (map (x: x.lib or x.out) buildInputs)) map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ] ++ buildInputs)
# libpulsecommon.so is linked but not found otherwise # libpulsecommon.so is linked but not found otherwise
++ lib.optionals pulseaudioSupport (map (x: "${x}/lib/pulseaudio") (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ]))) ++ lib.optionals pulseaudioSupport (map (x: "${lib.getLib x}/lib/pulseaudio")
(toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
); );
# Don't shrink the ELF RPATHs in order to keep the extra RPATH # Don't shrink the ELF RPATHs in order to keep the extra RPATH

View File

@ -62,7 +62,7 @@ rec {
cp -d ${openssl.out}/lib/*.dylib $out/lib cp -d ${openssl.out}/lib/*.dylib $out/lib
cp -d ${gnugrep.pcre.out}/lib/libpcre*.dylib $out/lib cp -d ${gnugrep.pcre.out}/lib/libpcre*.dylib $out/lib
cp -d ${libiconv.lib or libiconv}/lib/lib*.dylib $out/lib cp -d ${lib.getLib libiconv}/lib/lib*.dylib $out/lib
cp -d ${gettext}/lib/libintl*.dylib $out/lib cp -d ${gettext}/lib/libintl*.dylib $out/lib
chmod +x $out/lib/libintl*.dylib chmod +x $out/lib/libintl*.dylib
cp -d ${ncurses.out}/lib/libncurses*.dylib $out/lib cp -d ${ncurses.out}/lib/libncurses*.dylib $out/lib

View File

@ -223,7 +223,7 @@ let
# include it in the result, it *is* available to nix-env for queries. # include it in the result, it *is* available to nix-env for queries.
meta = { } meta = { }
# If the packager hasn't specified `outputsToInstall`, choose a default, # If the packager hasn't specified `outputsToInstall`, choose a default,
# namely `p.bin or p.out or p`; # namely `lib.getBin p`;
# if he has specified it, it will be overridden below in `// meta`. # if he has specified it, it will be overridden below in `// meta`.
# Note: This default probably shouldn't be globally configurable. # Note: This default probably shouldn't be globally configurable.
# Services and users should specify outputs explicitly, # Services and users should specify outputs explicitly,