diff options
author | Marc Weber <marco-oweber@gmx.de> | 2008-06-15 11:54:22 +0000 |
---|---|---|
committer | Marc Weber <marco-oweber@gmx.de> | 2008-06-15 11:54:22 +0000 |
commit | 51651a4ec097737f7a5b9d4460a2eebee55b15fd (patch) | |
tree | 3fad68d42b49e18182aec4e91f955247a39f5279 /pkgs/misc | |
parent | 74cb80f8fa73e4e65fca8f9c28a79ebaabaf93fe (diff) | |
download | nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.tar nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.tar.gz nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.tar.bz2 nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.tar.lz nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.tar.xz nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.tar.zst nixlib-51651a4ec097737f7a5b9d4460a2eebee55b15fd.zip |
put all source with tags stuff into its own file, now appends tag files to TAG_FILES env var using nix-support
updated myEnvFun svn path=/nixpkgs/trunk/; revision=12097
Diffstat (limited to 'pkgs/misc')
-rw-r--r-- | pkgs/misc/my_env/default.nix | 37 | ||||
-rw-r--r-- | pkgs/misc/source-and-tags/default.nix | 80 |
2 files changed, 103 insertions, 14 deletions
diff --git a/pkgs/misc/my_env/default.nix b/pkgs/misc/my_env/default.nix index 94c7a591081d..bd1726039ca5 100644 --- a/pkgs/misc/my_env/default.nix +++ b/pkgs/misc/my_env/default.nix @@ -14,22 +14,31 @@ PS1='\033]2;\h:\u:\w\007\\nenv ${name} \[\033[1;32m\][\u@\h: \w ]$\[\033[0m\] ' "; }; +Put this into your .bashrc +loadEnv(){ + . "${HOME}/.nix-profile/dev-envs/${1}" +} */ -args: stdenv.mkDerivation ( - { userCmds =""; } // { +args: args.stdenv.mkDerivation ( + { extraCmds =""; } // { phases = "buildPhase"; - buildPhase = " - ensureDir \$out/bin + buildPhase = '' name=${args.name} - o=\$out/bin/$name - echo -e \"#!/bin/sh --login\\n\" >> \$o - export | grep -v HOME= | grep -v PATH= >> \$o - echo \"export PATH=\$PATH:\\\$PATH entering $name\" >> \$o - echo \"echo entering $name\" >> \$o - echo \"$userCmds\" >> \$o - echo \"/bin/sh\" >> $o - echo \"echo leaving $name\" >> \$o + o=$out/dev-envs/$name + ensureDir `dirname $o` + echo " + OLDPATH=\$PATH " >> $o + export | grep -v HOME= | grep -v PATH= | grep -v PWD= | grep -v TEMP= | grep -v TMP= >> $o + echo " + PATH=$PATH:$OLDPATH + for i in \$buildInputs; do + export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$i/lib + done + export PATH=\$PATH:\$OLDPATH + $extraCmds + echo env $name loaded + " >> $o chmod +x $o - "; -} //args); + ''; +} // args // { name = "${args.name}-env"; } ) diff --git a/pkgs/misc/source-and-tags/default.nix b/pkgs/misc/source-and-tags/default.nix new file mode 100644 index 000000000000..3d15be20597f --- /dev/null +++ b/pkgs/misc/source-and-tags/default.nix @@ -0,0 +1,80 @@ +args: with args; { + # optional srcDir + annotatedWithSourceAndTagInfo = x : (x ? passthru && x.passthru ? sourceWithTags + || x ? meta && x.meta ? sourceWithTags ); + # hack because passthru doesn't work the way I'd expect. Don't have time to spend on this right now + # that's why I'm abusing meta for the same purpose in ghcsAndLibs + sourceWithTagsFromDerivation = x : if (x ? passthru && x.passthru ? sourceWithTags ) then x.passthru.sourceWithTags + else if (x ? meta && x.meta ? sourceWithTags ) then x.meta.sourceWithTags + else null; + + # createTagFiles = [ { name = "my_tag_name_without_suffix", tagCmd = "ctags -R . -o \$TAG_FILE"; } ] + # tag command must create file named $TAG_FILE + sourceWithTagsDerivation = {name, src, srcDir ? ".", tagSuffix ? "_tags", createTagFiles ? []} : + stdenv.mkDerivation { + phases = "unpackPhase buildPhase"; + inherit src srcDir tagSuffix; + name = "${name}-source-with-tags"; + buildInputs = [ unzip ]; + # using separate tag directory so that you don't have to glob that much files when starting your editor + # is this a good choice? + buildPhase = + lib.defineShList "sh_list_names" (lib.catAttrs "name" createTagFiles) + + lib.defineShList "sh_list_cmds" (lib.catAttrs "tagCmd" createTagFiles) + + "SRC_DEST=\$out/src/\$name + ensureDir \$SRC_DEST + cp -r \$srcDir \$SRC_DEST + cd \$SRC_DEST + for a in `seq 0 \${#sh_list}`; do + TAG_FILE=\"\$SRC_DEST/\"\${sh_list_names[$a]}$tagSuffix + cmd=\"\${sh_list_cmds[$a]}\" + echo running tag cmd \"$cmd\" in `pwd` + eval \"\$cmd\"; + TAG_FILES=\"\$TAG_FILES\${TAG_FILES:+:}\$TAG_FILE\" + done + echo \"TAG_FILES=\\\"\\\$TAG_FILES\\\${TAG_FILES:+:}$TAG_FILES\\\"\" >> $out/nix-support + "; + }; + # example usage + #testSourceWithTags = sourceWithTagsDerivation (ghc68extraLibs ghcsAndLibs.ghc68).happs_server_darcs.passthru.sourceWithTags; + + + # creates annotated derivation (comments see above) + addHasktagsTaggingInfo = deriv : deriv // { + passthru = { + sourceWithTags = { + inherit (deriv) src; + srcDir = if deriv ? srcDir then deriv.srcDir else "."; + name = deriv.name + "-src-with-tags"; + createTagFiles = [ + { name = "${deriv.name}_haskell"; + # tagCmd = "${toString ghcsAndLibs.ghc68.ghc}/bin/hasktags --ignore-close-implementation --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; } + tagCmd = "${toString hasktags}/bin/hasktags-modified --ignore-close-implementation --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; } + ]; + }; + }; + }; + + + addCTaggingInfo = deriv : + deriv // { + passthru = { + sourceWithTags = { + inherit (deriv) src; + name = "${deriv.name}-source-ctags"; + createTagFiles = [ + { inherit (deriv) name; + tagCmd = "${toString ctags}/bin/ctags --sort=yes -o \$TAG_FILE -R ."; } + ]; + }; + }; }; +} +/* +experimental +idea: +a) Attach some information to a nexpression telling how to create a tag file which can then be used within your favourite editor + Do this in a way not affecting the expression (using passthru or meta which is ignored when calculating the hash) + implementations: addCTaggingInfo (C / C++) and addHasktagsTaggingInfo (Haskell) +b) use sourceWithTagsDerivation function to create a derivation installing the source along with the generated tag files + so that you can use them easily witihn your favourite text editor +*/ |