update my_env. Hopefully does a better job now
svn path=/nixpkgs/trunk/; revision=13037
This commit is contained in:
parent
b1da0a329c
commit
3d90901798
79
pkgs/misc/my-env/default.nix
Normal file
79
pkgs/misc/my-env/default.nix
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# idea: provide nix environment for your developement actions
|
||||||
|
# experimental
|
||||||
|
|
||||||
|
/*
|
||||||
|
# example:
|
||||||
|
# add postgresql to environment and create ctags (tagfiles can be extracted from TAG_FILES)
|
||||||
|
# add this to your ~/.nixpkgs/config.nix
|
||||||
|
|
||||||
|
{
|
||||||
|
packageOverrides = pkgs : with pkgs; with sourceAndTags;
|
||||||
|
let simple = { name, buildInputs ? [], cTags ? [], extraCmds ? ""}:
|
||||||
|
pkgs.myEnvFun {
|
||||||
|
inherit name;
|
||||||
|
buildInputs = buildInputs
|
||||||
|
++ map (x : sourceWithTagsDerivation ( (addCTaggingInfo x ).passthru.sourceWithTags ) ) cTags;
|
||||||
|
extraCmds = ''
|
||||||
|
${extraCmds}
|
||||||
|
HOME=${builtins.getEnv "HOME"}
|
||||||
|
. ~/.bashrc
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in rec {
|
||||||
|
nixEnv = simple {
|
||||||
|
name = "nix";
|
||||||
|
buildInputs = [ libtool stdenv perl curl bzip2 openssl aterm242fixes db45 autoconf automake zlib ];
|
||||||
|
cTags = [ aterm242fixes];
|
||||||
|
};
|
||||||
|
[...]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Put this into your .bashrc
|
||||||
|
loadEnv(){ . "${HOME}/.nix-profile/dev-envs/${1}" }
|
||||||
|
|
||||||
|
then nix-env -iA ...nixEnv
|
||||||
|
and
|
||||||
|
$ loadEnv postgresql
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
{ mkDerivation, substituteAll, pkgs } : { stdenv ? pkgs.stdenv, name, buildInputs ? [], cTags ? [], extraCmds ? ""} :
|
||||||
|
mkDerivation {
|
||||||
|
buildInputs = [ ] ++ buildInputs ;
|
||||||
|
name = "env-${name}";
|
||||||
|
phases = "buildPhase";
|
||||||
|
setupNew = substituteAll {
|
||||||
|
src = ../../stdenv/generic/setup-new.sh;
|
||||||
|
preHook="";
|
||||||
|
postHook="";
|
||||||
|
initialPath= (import ../../stdenv/common-path.nix) { inherit pkgs; };
|
||||||
|
gcc = stdenv.gcc;
|
||||||
|
};
|
||||||
|
buildPhase = ''
|
||||||
|
set -x
|
||||||
|
mkdir -p "$out/dev-envs" "$out/nix-support"
|
||||||
|
s="$out/nix-support/setup-new-modified"
|
||||||
|
cp "$setupNew" "$s"
|
||||||
|
# shut some warning up.., do not use set -e
|
||||||
|
sed -e 's@set -e@@' \
|
||||||
|
-e 's@assertEnvExists\s\+NIX_STORE@:@' \
|
||||||
|
-e 's@trap.*@@' \
|
||||||
|
-i "$s"
|
||||||
|
cat >> "$out/dev-envs/''${name/env-/}" << EOF
|
||||||
|
buildInputs="$buildInputs"
|
||||||
|
# the setup-new script wants to write some data to a temp file.. so just let it do that and tidy up afterwards
|
||||||
|
tmp="\$("${pkgs.coreutils}/bin/mktemp" -d)"
|
||||||
|
NIX_BUILD_TOP="\$tmp"
|
||||||
|
phases=
|
||||||
|
# only do all the setup stuff in nix-support/*
|
||||||
|
set +e
|
||||||
|
source "$s"
|
||||||
|
rm -fr "\$tmp"
|
||||||
|
${extraCmds}
|
||||||
|
export PATH
|
||||||
|
echo $name loaded
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
@ -1,58 +0,0 @@
|
|||||||
# idea: provide nix environment for your developement actions
|
|
||||||
# experimental
|
|
||||||
|
|
||||||
/*
|
|
||||||
# example:
|
|
||||||
# add postgresql to environment and create ctags (tagfiles can be extracted from TAG_FILES)
|
|
||||||
# add this to your ~/.nixpkgs/config.nix
|
|
||||||
|
|
||||||
devEnvs = pkgs : with pkgs; with sourceAndTags;
|
|
||||||
let simple = { name, buildInputs ? [], cTags ? [] }:
|
|
||||||
pkgs.myEnvFun {
|
|
||||||
inherit name stdenv;
|
|
||||||
buildInputs = buildInputs
|
|
||||||
++ map (x : sourceWithTagsDerivation ( (addCTaggingInfo x ).passthru.sourceWithTags ) ) cTags;
|
|
||||||
extraCmds = ". ~/.bashrc; cd $PWD
|
|
||||||
# configure should find them
|
|
||||||
export LDFLAGS=$NIX_LDFLAGS
|
|
||||||
export CFLAGS=$NIX_CFLAGS_COMPILE
|
|
||||||
";
|
|
||||||
preBuild = "export TAG_FILES";
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
postgresql = simple {
|
|
||||||
name = "postgresql";
|
|
||||||
buildInputs = [postgresql];
|
|
||||||
cTags = [postgresql ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
Put this into your .bashrc
|
|
||||||
loadEnv(){ . "${HOME}/.nix-profile/dev-envs/${1}" }
|
|
||||||
then install and
|
|
||||||
$ loadEnv postgresql
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
args: args.stdenv.mkDerivation (
|
|
||||||
{ extraCmds =""; } // {
|
|
||||||
phases = "buildPhase";
|
|
||||||
buildPhase = ''
|
|
||||||
eval "$preBuild"
|
|
||||||
name=${args.name}
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
} // args // { name = "${args.name}-env"; } )
|
|
@ -7746,6 +7746,9 @@ let
|
|||||||
inherit (xlibs) libX11;
|
inherit (xlibs) libX11;
|
||||||
};
|
};
|
||||||
|
|
||||||
myEnvFun = import ../misc/my_env;
|
myEnvFun = import ../misc/my-env {
|
||||||
|
inherit substituteAll pkgs;
|
||||||
|
inherit (stdenv) mkDerivation;
|
||||||
|
};
|
||||||
|
|
||||||
}; in pkgs
|
}; in pkgs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user