Merge pull request #15002 from abbradar/symlink-join-wrappers

Use symlinkJoin for wrappers
This commit is contained in:
Nikolay Amiantov 2016-04-26 16:47:43 +04:00
commit f6eb686222
16 changed files with 82 additions and 150 deletions

View File

@ -11,7 +11,10 @@ let
rm $out/logcheck.* rm $out/logcheck.*
''; '';
rulesDir = pkgs.symlinkJoin "logcheck-rules-dir" ([ defaultRules ] ++ cfg.extraRulesDirs); rulesDir = pkgs.symlinkJoin
{ name = "logcheck-rules-dir";
paths = ([ defaultRules ] ++ cfg.extraRulesDirs);
};
configFile = pkgs.writeText "logcheck.conf" cfg.config; configFile = pkgs.writeText "logcheck.conf" cfg.config;

View File

@ -63,8 +63,10 @@ let
cfg.extraConfig cfg.extraConfig
]; ];
modulesDir = pkgs.symlinkJoin "dovecot-modules" modulesDir = pkgs.symlinkJoin {
(map (pkg: "${pkg}/lib/dovecot") ([ dovecotPkg ] ++ map (module: module.override { dovecot = dovecotPkg; }) cfg.modules)); name = "dovecot-modules";
paths = map (pkg: "${pkg}/lib/dovecot") ([ dovecotPkg ] ++ map (module: module.override { dovecot = dovecotPkg; }) cfg.modules);
};
in in
{ {

View File

@ -1,22 +1,14 @@
{ stdenv, buildEnv, deadbeef, makeWrapper, plugins }: { stdenv, symlinkJoin, deadbeef, makeWrapper, plugins }:
let symlinkJoin {
drv = buildEnv { name = "deadbeef-with-plugins-${deadbeef.version}";
name = "deadbeef-with-plugins-" + (builtins.parseDrvName deadbeef.name).version;
paths = [ deadbeef ] ++ plugins; paths = [ deadbeef ] ++ plugins;
buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${deadbeef}/bin/*; do
ln -s $i $out/bin
done
fi
wrapProgram $out/bin/deadbeef \ wrapProgram $out/bin/deadbeef \
--set DEADBEEF_PLUGIN_DIR "$out/lib/deadbeef" --set DEADBEEF_PLUGIN_DIR "$out/lib/deadbeef"
''; '';
}; }
in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; })

View File

@ -1,23 +1,16 @@
{ stdenv, buildEnv, puredata, makeWrapper, plugins }: { stdenv, symlinkJoin, puredata, makeWrapper, plugins }:
let let
puredataFlags = map (x: "-path ${x}/") plugins; puredataFlags = map (x: "-path ${x}/") plugins;
drv = buildEnv { in symlinkJoin {
name = "puredata-with-plugins-" + (builtins.parseDrvName puredata.name).version; name = "puredata-with-plugins-${puredata.version}";
paths = [ puredata ] ++ plugins; paths = [ puredata ] ++ plugins;
buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${puredata}/bin/*; do
ln -s $i $out/bin
done
fi
wrapProgram $out/bin/pd \ wrapProgram $out/bin/pd \
--add-flags "${toString puredataFlags}" --add-flags "${toString puredataFlags}"
''; '';
}; }
in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; })

View File

@ -4,7 +4,8 @@
, python, pygtk, libart_lgpl, libexif, gettext, xorg, wrapPython }: , python, pygtk, libart_lgpl, libexif, gettext, xorg, wrapPython }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "gimp-2.8.16"; name = "gimp-${version}";
version = "2.8.16";
# This declarations for `gimp-with-plugins` wrapper, # This declarations for `gimp-with-plugins` wrapper,
# (used for determining $out/lib/gimp/${majorVersion}/ paths) # (used for determining $out/lib/gimp/${majorVersion}/ paths)

View File

@ -1,24 +1,18 @@
{ stdenv, lib, buildEnv, gimp, makeWrapper, gimpPlugins, plugins ? null}: { stdenv, lib, symlinkJoin, gimp, makeWrapper, gimpPlugins, plugins ? null}:
let let
allPlugins = lib.filter (pkg: builtins.isAttrs pkg && pkg.type == "derivation") (lib.attrValues gimpPlugins); allPlugins = lib.filter (pkg: builtins.isAttrs pkg && pkg.type == "derivation") (lib.attrValues gimpPlugins);
selectedPlugins = if plugins == null then allPlugins else plugins; selectedPlugins = if plugins == null then allPlugins else plugins;
extraArgs = map (x: x.wrapArgs or "") selectedPlugins; extraArgs = map (x: x.wrapArgs or "") selectedPlugins;
drv = buildEnv { in symlinkJoin {
name = "gimp-with-plugins-" + (builtins.parseDrvName gimp.name).version; name = "gimp-with-plugins-${gimp.version}";
paths = [ gimp ] ++ selectedPlugins; paths = [ gimp ] ++ selectedPlugins;
buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${gimp}/bin/*; do
ln -s $i $out/bin
done
fi
for each in gimp-2.8 gimp-console-2.8; do for each in gimp-2.8 gimp-console-2.8; do
wrapProgram $out/bin/$each \ wrapProgram $out/bin/$each \
--set GIMP2_PLUGINDIR "$out/lib/gimp/2.0" \ --set GIMP2_PLUGINDIR "$out/lib/gimp/2.0" \
@ -29,5 +23,4 @@ drv = buildEnv {
ln -sf "$each-2.8" $out/bin/$each ln -sf "$each-2.8" $out/bin/$each
done done
''; '';
}; }
in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; })

View File

@ -1,22 +1,14 @@
{ lib, buildEnv, k3b-original, cdrtools, makeWrapper }: { lib, symlinkJoin, k3b-original, cdrtools, makeWrapper }:
let let
binPath = lib.makeBinPath [ cdrtools ]; binPath = lib.makeBinPath [ cdrtools ];
in buildEnv { in symlinkJoin {
name = "k3b-${k3b-original.version}"; name = "k3b-${k3b-original.version}";
paths = [ k3b-original ]; paths = [ k3b-original ];
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${k3b-original}/bin/*; do
ln -s $i $out/bin
done
fi
wrapProgram $out/bin/k3b \ wrapProgram $out/bin/k3b \
--prefix PATH ':' ${binPath} --prefix PATH ':' ${binPath}
''; '';

View File

@ -1,28 +1,21 @@
{ stdenv, buildEnv, rxvt_unicode, makeWrapper, plugins }: { stdenv, symlinkJoin, rxvt_unicode, makeWrapper, plugins }:
let let
rxvt = rxvt_unicode.override { rxvt = rxvt_unicode.override {
perlSupport = true; perlSupport = true;
}; };
drv = buildEnv { in symlinkJoin {
name = "${rxvt.name}-with-plugins"; name = "${rxvt.name}-with-plugins";
paths = [ rxvt ] ++ plugins; paths = [ rxvt ] ++ plugins;
postBuild = '' buildInputs = [ makeWrapper ];
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then postBuild = ''
rm $out/bin wrapProgram $out/bin/urxvt \
mkdir $out/bin --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
for i in ${rxvt}/bin/*; do wrapProgram $out/bin/urxvtd \
ln -s $i $out/bin --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
done '';
fi }
wrapProgram $out/bin/urxvt \
--suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
wrapProgram $out/bin/urxvtd \
--suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
'';
};
in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; })

View File

@ -1,24 +1,17 @@
{ stdenv, buildEnv, pidgin, makeWrapper, plugins }: { stdenv, symlinkJoin, pidgin, makeWrapper, plugins }:
let let
extraArgs = map (x: x.wrapArgs or "") plugins; extraArgs = map (x: x.wrapArgs or "") plugins;
drv = buildEnv { in symlinkJoin {
name = "pidgin-with-plugins-" + (builtins.parseDrvName pidgin.name).version; name = "pidgin-with-plugins-${pidgin.version}";
paths = [ pidgin ] ++ plugins; paths = [ pidgin ] ++ plugins;
buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${pidgin}/bin/*; do
ln -s $i $out/bin
done
fi
wrapProgram $out/bin/pidgin \ wrapProgram $out/bin/pidgin \
--suffix-each PURPLE_PLUGIN_PATH ':' "$out/lib/purple-${pidgin.majorVersion} $out/lib/pidgin" \ --suffix-each PURPLE_PLUGIN_PATH ':' "$out/lib/purple-${pidgin.majorVersion} $out/lib/pidgin" \
${toString extraArgs} ${toString extraArgs}
''; '';
}; }
in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; })

View File

@ -1,4 +1,4 @@
{ buildEnv, avidemux_unwrapped, makeWrapper { symlinkJoin, avidemux_unwrapped, makeWrapper
# GTK version is broken upstream, see https://bugzilla.redhat.com/show_bug.cgi?id=1244340 # GTK version is broken upstream, see https://bugzilla.redhat.com/show_bug.cgi?id=1244340
, withUi ? "qt4" , withUi ? "qt4"
}: }:
@ -7,24 +7,14 @@ let ui = builtins.getAttr "avidemux_${withUi}" avidemux_unwrapped; in
assert ui.isUi; assert ui.isUi;
buildEnv { symlinkJoin {
name = "avidemux-${withUi}-" + ui.version; name = "avidemux-${withUi}-${ui.version}";
paths = [ ui avidemux_unwrapped.avidemux_common avidemux_unwrapped.avidemux_settings ]; paths = [ ui avidemux_unwrapped.avidemux_common avidemux_unwrapped.avidemux_settings ];
ignoreCollisions = true;
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${ui}/bin/*; do
ln -s $i $out/bin
done
fi
for i in $out/bin/*; do for i in $out/bin/*; do
wrapProgram $i --set ADM_ROOT_DIR $out wrapProgram $i --set ADM_ROOT_DIR $out
done done

View File

@ -47,16 +47,24 @@ rec {
# Create a forest of symlinks to the files in `paths'. # Create a forest of symlinks to the files in `paths'.
symlinkJoin = name: paths: symlinkJoin =
{ name
, paths
, preferLocalBuild ? true
, allowSubstitutes ? false
, postBuild ? ""
, buildInputs ? []
, meta ? {}
}:
runCommand name runCommand name
{ inherit paths; { inherit paths preferLocalBuild allowSubstitutes buildInputs meta;
preferLocalBuild = true; allowSubstitutes = false;
} }
'' ''
mkdir -p $out mkdir -p $out
for i in $paths; do for i in $paths; do
${lndir}/bin/lndir $i $out ${lndir}/bin/lndir $i $out
done done
${postBuild}
''; '';

View File

@ -51,8 +51,10 @@ let
let let
version = (builtins.parseDrvName breeze-qt5.name).version; version = (builtins.parseDrvName breeze-qt5.name).version;
in in
symlinkJoin "breeze-${version}" symlinkJoin {
(map (pkg: pkg.out or pkg) [ breeze-gtk breeze-qt4 breeze-qt5 ]); name = "breeze-${version}";
paths = map (pkg: pkg.out or pkg) [ breeze-gtk breeze-qt4 breeze-qt5 ];
};
kde-cli-tools = callPackage ./kde-cli-tools.nix {}; kde-cli-tools = callPackage ./kde-cli-tools.nix {};
kde-gtk-config = callPackage ./kde-gtk-config {}; kde-gtk-config = callPackage ./kde-gtk-config {};
kdecoration = callPackage ./kdecoration.nix {}; kdecoration = callPackage ./kdecoration.nix {};

View File

@ -1,10 +1,8 @@
{ stdenv, fetchFromGitHub, coreutils, qtbase, qtdeclarative, qmakeHook, texlive }: { stdenv, fetchFromGitHub, coreutils, qtbase, qtdeclarative, qmakeHook, texlive }:
let stdenv.mkDerivation rec {
version = "37.0.0";
in
stdenv.mkDerivation {
name = "dwarf-therapist-original-${version}"; name = "dwarf-therapist-original-${version}";
version = "37.0.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "splintermind"; owner = "splintermind";

View File

@ -1,4 +1,4 @@
{ buildEnv, lib, dwarf-therapist-original, dwarf-fortress-original, makeWrapper }: { symlinkJoin, lib, dwarf-therapist-original, dwarf-fortress-original, makeWrapper }:
let let
df = dwarf-fortress-original; df = dwarf-fortress-original;
@ -6,8 +6,8 @@ let
inifile = "linux/v0${df.baseVersion}.${df.patchVersion}.ini"; inifile = "linux/v0${df.baseVersion}.${df.patchVersion}.ini";
dfHashFile = "${df}/hash.md5"; dfHashFile = "${df}/hash.md5";
in buildEnv { in symlinkJoin {
name = "dwarf-therapist-${lib.getVersion dt}"; name = "dwarf-therapist-${dt.version}";
paths = [ dt ]; paths = [ dt ];
@ -16,22 +16,10 @@ in buildEnv {
postBuild = '' postBuild = ''
# DwarfTherapist assumes it's run in $out/share/dwarftherapist and # DwarfTherapist assumes it's run in $out/share/dwarftherapist and
# therefore uses many relative paths. # therefore uses many relative paths.
rm $out/bin wrapProgram $out/bin/DwarfTherapist \
mkdir $out/bin
makeWrapper ${dt}/bin/DwarfTherapist $out/bin/DwarfTherapist \
--run "cd $out/share/dwarftherapist" --run "cd $out/share/dwarftherapist"
# Fix checksum of memory access directives. We really need #4621 fixed! rm -rf $out/share/dwarftherapist/memory_layouts/linux
recreate_dir() {
rm "$out/$1"
mkdir -p "$out/$1"
for i in "${dt}/$1/"*; do
ln -s "$i" "$out/$1"
done
}
recreate_dir share
recreate_dir share/dwarftherapist
mkdir -p $out/share/dwarftherapist/memory_layouts/linux mkdir -p $out/share/dwarftherapist/memory_layouts/linux
origmd5=$(cat "${dfHashFile}.orig" | cut -c1-8) origmd5=$(cat "${dfHashFile}.orig" | cut -c1-8)
patchedmd5=$(cat "${dfHashFile}" | cut -c1-8) patchedmd5=$(cat "${dfHashFile}" | cut -c1-8)

View File

@ -1,22 +1,14 @@
{ lib, buildEnv, brasero-original, cdrtools, makeWrapper }: { lib, symlinkJoin, brasero-original, cdrtools, makeWrapper }:
let let
binPath = lib.makeBinPath [ cdrtools ]; binPath = lib.makeBinPath [ cdrtools ];
in buildEnv { in symlinkJoin {
name = "brasero-${brasero-original.version}"; name = "brasero-${brasero-original.version}";
paths = [ brasero-original ]; paths = [ brasero-original ];
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${brasero-original}/bin/*; do
ln -s $i $out/bin
done
fi
wrapProgram $out/bin/brasero \ wrapProgram $out/bin/brasero \
--prefix PATH ':' ${binPath} --prefix PATH ':' ${binPath}
''; '';

View File

@ -1,4 +1,4 @@
{ stdenv, buildEnv, fcitx, fcitx-configtool, makeWrapper, plugins, kde5 }: { stdenv, symlinkJoin, fcitx, fcitx-configtool, makeWrapper, plugins, kde5 }:
# This is based on the pidgin-with-plugins package. # This is based on the pidgin-with-plugins package.
# Users should be able to configure what plugins are used # Users should be able to configure what plugins are used
@ -12,24 +12,16 @@
# (fcitx-with-plugins.override { plugins = [ fcitx-anthy ]; }) # (fcitx-with-plugins.override { plugins = [ fcitx-anthy ]; })
# } # }
let symlinkJoin {
drv = buildEnv { name = "fcitx-with-plugins-${fcitx.version}";
name = "fcitx-with-plugins-" + (builtins.parseDrvName fcitx.name).version;
paths = [ fcitx fcitx-configtool kde5.fcitx-qt5 ] ++ plugins; paths = [ fcitx fcitx-configtool kde5.fcitx-qt5 ] ++ plugins;
buildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
# TODO: This could be avoided if buildEnv could be forced to create all directories
if [ -L $out/bin ]; then
rm $out/bin
mkdir $out/bin
for i in ${fcitx}/bin/*; do
ln -s $i $out/bin
done
fi
wrapProgram $out/bin/fcitx \ wrapProgram $out/bin/fcitx \
--set FCITXDIR "$out/" --set FCITXDIR "$out/"
''; '';
}; }
in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; })