diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2007-10-29 10:52:04 +0000 |
---|---|---|
committer | Michael Raskin <7c6f434c@mail.ru> | 2007-10-29 10:52:04 +0000 |
commit | d352d54b11b66c8855936d214710460b2944ca2f (patch) | |
tree | 53fa6d5159b3cc2413c21c456c1740d73eafd8ba | |
parent | ae7d316684addd6f087ae384b5a28c5315ce3671 (diff) |
Added a new setup proposal, builder is no more derived from shell script (where edit=glibc rebuild), but is composed from a nix attribute set with strings and dependencies - so if you add a function, old expressions ignore it; collateral damage are packages in this style: Fastest Fourier Transform in the West, Audacity sound editor, Falling Sand game. Also added string equality that ignores dependencies to lib. Note that hasSuffixHack is now the more predictable version, but hasSuffix is left to remind us to fix the bug.
svn path=/nixpkgs/trunk/; revision=9549
-rw-r--r-- | pkgs/applications/audio/audacity/default.nix | 36 | ||||
-rw-r--r-- | pkgs/applications/audio/ladspa-plugins/default.nix | 27 | ||||
-rw-r--r-- | pkgs/applications/audio/ladspa-plugins/ladspah.nix | 29 | ||||
-rw-r--r-- | pkgs/applications/window-managers/compiz/extra.nix | 1 | ||||
-rw-r--r-- | pkgs/development/libraries/fftw/default.nix | 21 | ||||
-rw-r--r-- | pkgs/games/fsg/alt-builder.nix | 36 | ||||
-rw-r--r-- | pkgs/lib/default.nix | 3 | ||||
-rw-r--r-- | pkgs/lib/strings-with-deps.nix | 19 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 44 | ||||
-rw-r--r-- | pkgs/top-level/builder-defs.nix | 157 |
10 files changed, 356 insertions, 17 deletions
diff --git a/pkgs/applications/audio/audacity/default.nix b/pkgs/applications/audio/audacity/default.nix new file mode 100644 index 0000000000000..b8c28a0e22e45 --- /dev/null +++ b/pkgs/applications/audio/audacity/default.nix @@ -0,0 +1,36 @@ +args: with args; + with (builderDefs { + src = + fetchurl { + url = mirror://sourceforge/audacity/audacity-src-1.3.3.tar.gz; + sha256 = "17bjc2rnqspg1mbay4b1hhgg08iadapwf6w98gbv3r84rv1mhgls"; + }; + + buildInputs =[(wxGTK null) libogg libvorbis libsndfile libmad pkgconfig gtk + gettext glib]; + } null); + with stringsWithDeps; +let + postInstall = FullDepEntry (" + old_rpath=$(patchelf --print-rpath \$out/bin/audacity); + patchelf --set-rpath \$old_rpath:${gtk}/lib:${glib}/lib \$out/bin/audacity; + ") [minInit]; + preBuild = FullDepEntry (" + sed -e '/\\/usr\\/local\\/lib\\/ladspa/awxGetApp()."+ + "AddUniquePathToPathList(wxGetenv(wxT(\"HOME\"))+"+ + "wxT(\"/.ladspa-plugins\"), pathList);' + + ") [minInit]; +in +stdenv.mkDerivation { + name = "audacity-1.3.3"; + + builder = writeScript "audacity-1.3.3-builder" + (textClosure [addInputs (doDump "0") (noDepEntry "echo \$PATH; ar --version") doConfigure preBuild doMakeInstall postInstall doForceShare]); + + meta = { + description = " + Audacity sound editor. +"; + }; +} diff --git a/pkgs/applications/audio/ladspa-plugins/default.nix b/pkgs/applications/audio/ladspa-plugins/default.nix new file mode 100644 index 0000000000000..12722356d85d9 --- /dev/null +++ b/pkgs/applications/audio/ladspa-plugins/default.nix @@ -0,0 +1,27 @@ +args: with args; + with (builderDefs { + src = + fetchurl { + url = http://plugin.org.uk/releases/0.4.15/swh-plugins-0.4.15.tar.gz; + sha256 = "0h462s4mmqg4iw7zdsihnrmz2vjg0fd49qxw2a284bnryjjfhpnh"; + }; + buildInputs = [fftw ladspaH pkgconfig]; + configureFlags = []; + } null); + with stringsWithDeps; +let + postInstall = FullDepEntry (" + ensureDir \$out/share/ladspa/ + ln -s \$out/lib/ladspa \$out/share/ladspa/lib + ") [minInit defEnsureDir]; +in +stdenv.mkDerivation { + name = "swh-plugins-0.4.15"; + builder = writeScript "swh-plugins-0.4.15-builder" + (textClosure [doConfigure doMakeInstall postInstall doForceShare]); + meta = { + description = " + LADSPA format audio plugins. +"; + }; +} diff --git a/pkgs/applications/audio/ladspa-plugins/ladspah.nix b/pkgs/applications/audio/ladspa-plugins/ladspah.nix new file mode 100644 index 0000000000000..5ab77db3a2cf6 --- /dev/null +++ b/pkgs/applications/audio/ladspa-plugins/ladspah.nix @@ -0,0 +1,29 @@ +args: with args; + with stringsWithDeps; +let + src = + fetchurl { + url = http://www.ladspa.org/ladspa_sdk/ladspa.h.txt; + sha256 = "1b908csn85ng9sz5s5d1mqk711cmawain2z8px2ajngihdrynb67"; + }; +in + with builderDefs { + buildInputs = []; + inherit src; + } null; +let + copyFile = FullDepEntry (" + ensureDir \$out/include + cp ${src} \$out/include/ladspa.h + ") [minInit defEnsureDir]; +in +stdenv.mkDerivation { + name = "ladspa.h"; + builder = writeScript "ladspa.h-builder" + (textClosure [copyFile]); + meta = { + description = " + LADSPA format audio plugins. +"; + }; +} diff --git a/pkgs/applications/window-managers/compiz/extra.nix b/pkgs/applications/window-managers/compiz/extra.nix index 75d640ca1cad1..501518d3f679d 100644 --- a/pkgs/applications/window-managers/compiz/extra.nix +++ b/pkgs/applications/window-managers/compiz/extra.nix @@ -13,4 +13,5 @@ stdenv.mkDerivation { preBuild = " makeFlagsArray=(moduledir=$out/lib/compiz) "; + preConfigure = "touch m4/Makefile.in"; } diff --git a/pkgs/development/libraries/fftw/default.nix b/pkgs/development/libraries/fftw/default.nix new file mode 100644 index 0000000000000..66c78b3a1c0a6 --- /dev/null +++ b/pkgs/development/libraries/fftw/default.nix @@ -0,0 +1,21 @@ +args : with args; + with builderDefs { + src = + fetchurl { + url = ftp://ftp.fftw.org/pub/fftw/fftw-3.1.2.tar.gz; + sha256 = "1gr63hf5vvsg50b2xwqaxwpvs1y9g8l0sb91a38wpvr7zsbjxfg1"; + }; + buildInputs = []; + configureFlags = ["--enable-float --enable-shared"]; + } null; + with stringsWithDeps; +stdenv.mkDerivation { + name = "fftw-3.1.2"; + builder = writeScript "fftw-3.1.2-builder" + (textClosure [doConfigure doMakeInstall doForceShare]); + meta = { + description = " + Fastest Fourier Transform in the West library. +"; + }; +} diff --git a/pkgs/games/fsg/alt-builder.nix b/pkgs/games/fsg/alt-builder.nix new file mode 100644 index 0000000000000..e0e006df073aa --- /dev/null +++ b/pkgs/games/fsg/alt-builder.nix @@ -0,0 +1,36 @@ +args: with args; + with (builderDefs + { + buildInputs =[(wxGTK null)]; + src = + fetchurl { + url = http://www.piettes.com/fallingsandgame/fsg-src-4.4.tar.gz; + sha256 = "1756y01rkvd3f1pkj88jqh83fqcfl2fy0c48mcq53pjzln9ycv8c"; + }; + } null); + with stringsWithDeps; +let + preBuild = FullDepEntry " + sed -e ' + s@currentProbIndex != 100@0@; + ' -i MainFrame.cpp; + " [minInit]; + + installPhase = FullDepEntry " + ensureDir \$out/bin \$out/libexec; + cp sand \$out/libexec; + echo -e '#! /bin/sh\nLC_ALL=C '\$out'/libexec/sand \"$@\"' >\$out/bin/fsg; + chmod a+x \$out/bin/fsg; + " [minInit defEnsureDir]; +in +stdenv.mkDerivation { + name = "fsg-4.4"; + builder = writeScript "fsg-4.4-builder" + (textClosure [doUnpack addInputs preBuild doMake installPhase doForceShare]); + + meta = { + description = " + Falling Sand Game - a cellular automata engine tuned towards the likes of Falling Sand. +"; + }; +} diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index e631bca4c60a7..d9828a86917ba 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -95,6 +95,8 @@ rec { else if xs == [] || ys == [] then false else head xs == head ys && eqLists (tail xs) (tail ys); + # Workaround, but works in stable Nix now. + eqStrings = a: b: (a+(substring 0 0 b)) == ((substring 0 0 a)+b); # Determine whether a filename ends in the given suffix. hasSuffix = ext: fileName: @@ -103,6 +105,7 @@ rec { in !(lessThan lenFileName lenExt) && substring (sub lenFileName lenExt) lenFileName fileName == ext; + hasSuffixHack = a: b: hasSuffix (a+(substring 0 0 b)) ((substring 0 0 a)+b); # Bring in a path as a source, filtering out all Subversion and CVS # directories, as well as backup files (*~). diff --git a/pkgs/lib/strings-with-deps.nix b/pkgs/lib/strings-with-deps.nix index e5521eff642b2..584afae9838d8 100644 --- a/pkgs/lib/strings-with-deps.nix +++ b/pkgs/lib/strings-with-deps.nix @@ -4,6 +4,7 @@ args: let inherit (builtins) head tail isList; +in rec { /* @@ -28,22 +29,20 @@ rec { */ - textClosureDupList = arg: + textClosureDupList = arg: ( if isList arg then textClosureDupList {text = ""; deps = arg;} else - (if (arg ? deps) then - map textClosureDupList arg.deps - else []) - ++ [arg] + (concatLists (map textClosureDupList arg.deps)) ++ [arg] ); - textClosureList = arg: uniqList (textClosureDupList arg); - textClosure = arg: concatStringsSep " -" (textClosureList arg); + textClosureList = arg: + (map (x : x.text) + (uniqList {inputList = textClosureDupList arg;})); + textClosure = arg: concatStringsSep "\n" (textClosureList arg); - noDepEntry = text : {inherit text;}; - FullDepEntry = text : deps: {inherit text args;}; + noDepEntry = text : {inherit text;deps = [];}; + FullDepEntry = text : deps: {inherit text deps;}; PackEntry = deps: {inherit deps; text="";}; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 76ded87cbdc11..8f8893be5e53d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -213,6 +213,14 @@ rec { abort (toString result)) else x); + builderDefs = lib.sumArgs (import ./builder-defs.nix) { + inherit stringsWithDeps lib stdenv writeScript; + }; + + stringsWithDeps = import ../lib/strings-with-deps.nix { + inherit stdenv lib; + }; + ### STANDARD ENVIRONMENT @@ -1605,6 +1613,10 @@ rec { inherit fetchurl stdenv; }; + fftw = import ../development/libraries/fftw { + inherit fetchurl stdenv builderDefs stringsWithDeps; + }; + # commented out because it's using the new configuration style proposal which is unstable # needs some testing .. @@ -3387,13 +3399,14 @@ rec { libstdcpp = gcc33.gcc; }; -# audacity = import ../applications/audio/audacity { -# inherit fetchurl libogg libvorbis libsndfile libmad -# pkgconfig gettext; -# inherit (gtkLibs) gtk glib; -# wxGTK = wxGTK28; -# stdenv = overrideGCC stdenv gcc41NPTL; -# }; + audacity = import ../applications/audio/audacity { + inherit fetchurl libogg libvorbis libsndfile libmad + pkgconfig gettext; + inherit (gtkLibs) gtk glib; + wxGTK = wxGTK28deps; + stdenv = overrideGCC stdenv gcc41NPTL; + inherit builderDefs stringsWithDeps; + }; batik = import ../applications/graphics/batik { inherit fetchurl stdenv unzip; @@ -3691,6 +3704,14 @@ rec { inherit fetchurl stdenv ; }; + ladspaH = import ../applications/audio/ladspa-plugins/ladspah.nix { + inherit fetchurl stdenv builderDefs stringsWithDeps; + }; + + ladspaPlugins = import ../applications/audio/ladspa-plugins { + inherit fetchurl stdenv builderDefs stringsWithDeps fftw ladspaH pkgconfig; + }; + links = import ../applications/networking/browsers/links { inherit fetchurl stdenv; }; @@ -4121,6 +4142,15 @@ rec { inherit (gtkLibs) glib gtk; wxGTK = wxGTK28deps {unicode = false;}; }; + + fsgAltBuild = import ../games/fsg/alt-builder.nix { + inherit stdenv fetchurl; + wxGTK = wxGTK28deps {unicode = false;}; + stringsWithDeps = import ../lib/strings-with-deps.nix { + inherit stdenv lib; + }; + inherit builderDefs; + }; gemrb = import ../games/gemrb { inherit fetchurl stdenv SDL openal freealut zlib libpng python; diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix new file mode 100644 index 0000000000000..c164aaae4fd96 --- /dev/null +++ b/pkgs/top-level/builder-defs.nix @@ -0,0 +1,157 @@ +args: with args; with stringsWithDeps; with lib; +rec +{ + inherit writeScript; + + forceShare = if args ? forceShare then args.forceShare else ["man" "doc" "info"]; + + archiveType = s: + (if hasSuffixHack ".tar" s then "tar" + else if (hasSuffixHack ".tar.gz" s) || (hasSuffixHack ".tgz" s) then "tgz" + else if (hasSuffixHack ".tar.bz2" s) || (hasSuffixHack ".tbz2" s) then "tbz2" + else (abort "unknown archive type : ${s}")); + + minInit = noDepEntry (" + set -e + NIX_GCC=${stdenv.gcc} + export SHELL=${stdenv.shell} + # Set up the initial path. + PATH= + for i in \$NIX_GCC ${toString stdenv.initialPath}; do + PATH=\$PATH\${PATH:+:}\$i/bin + done + " + (if ((stdenv ? preHook) && (stdenv.preHook != null) && + ((toString stdenv.preHook) != "")) then + " + param1=${stdenv.param1} + param2=${stdenv.param2} + param3=${stdenv.param3} + param4=${stdenv.param4} + param5=${stdenv.param5} + source ${stdenv.preHook} + + export TZ=UTC + + prefix=${if args ? prefix then (toString args.prefix) else "\$out"} + " + else "")); + + addInputs = FullDepEntry (" + # Recursively find all build inputs. + findInputs() + { + local pkg=\$1 + + case \$pkgs in + *\\ \$pkg\\ *) + return 0 + ;; + esac + + pkgs=\"\$pkgs \$pkg \" + + echo \$pkg + if test -f \$pkg/nix-support/setup-hook; then + source \$pkg/nix-support/setup-hook + cat \$pkg/nix-support/setup-hook + echo $PATH; + fi + + if test -f \$pkg/nix-support/propagated-build-inputs; then + for i in \$(cat \$pkg/nix-support/propagated-build-inputs); do + findInputs \$i + done + fi + } + + pkgs=\"\" + for i in \$NIX_GCC ${toString buildInputs} ${toString + (if (args ? propagatedBuildInputs) then + args.propagatedBuildInputs else "")}; do + findInputs \$i + done + + + # Set the relevant environment variables to point to the build inputs + # found above. + addToEnv() + { + local pkg=\$1 + "+ + (if !((args ? ignoreFailedInputs) && (args.ignoreFailedInputs == 1)) then " + if [ -e \$1/nix-support/failed ]; then + echo \"failed input \$1\" >&2 + fail + fi + " else "") + +" + if test -d \$1/bin; then + export _PATH=\$_PATH\${_PATH:+:}\$1/bin + fi + + for i in \"\${envHooks[@]}\"; do + \$i \$pkg + done + } + + for i in \$pkgs; do + addToEnv \$i + done + + + # Add the output as an rpath. + if test \"\$NIX_NO_SELF_RPATH\" != \"1\"; then + export NIX_LDFLAGS=\"-rpath \$out/lib \$NIX_LDFLAGS\" + fi + + PATH=\$_PATH\${_PATH:+:}\$PATH + ") [minInit]; + + defEnsureDir = FullDepEntry (" + # Ensure that the given directories exists. + ensureDir() { + local dir + for dir in \"\$@\"; do + if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi + done + } + ") [minInit]; + + toSrcDir = s : FullDepEntry (if (archiveType s) == "tar" then " + tar xvf ${s} + cd \"\$(tar tf ${s} | head -1 | sed -e 's@/.*@@' )\" + " else if (archiveType s) == "tgz" then " + tar xvzf ${s} + cd \"\$(tar tzf ${s} | head -1 | sed -e 's@/.*@@' )\" + " else if (archiveType s) == "tbz2" then " + tar xvjf ${s} + cd \"\$(tar tjf ${s} | head -1 | sed -e 's@/.*@@' )\" + " else (abort "unknown archive type : ${s}")) [minInit]; + + doConfigure = FullDepEntry (" + ./configure --prefix=\"\$prefix\" ${toString (getAttr ["configureFlags"] "" args)} + ") [minInit addInputs doUnpack]; + + doMake = FullDepEntry (" + make ${toString (getAttr ["makeFlags"] "" args)} + ") [minInit addInputs doUnpack]; + + doUnpack = toSrcDir (toString src); + + doMakeInstall = FullDepEntry (" + make ${toString (getAttr ["makeFlags"] "" args)} "+ + "${toString (getAttr ["installFlags"] "" args)} install") [doMake]; + + doForceShare = FullDepEntry (" + ensureDir \$prefix/share + for d in ${toString forceShare}; do + if [ -d \$prefix/\$d -a ! -d \$prefix/share/\$d ]; then + mv -v \$prefix/\$d \$prefix/share + ln -sv share/\$d \$prefix + fi; + done; + ") [minInit defEnsureDir]; + + doDump = n: noDepEntry "echo Dump number ${n}; set"; + +} |