bscpkgs/garlic/develop/default.nix

59 lines
1.2 KiB
Nix
Raw Normal View History

{
stdenv
, bash
, bashInteractive
, busybox
, extraInputs ? []
}:
2020-12-03 20:09:42 +08:00
let
inputrc = ./inputrc;
in
stdenv.mkDerivation {
name = "develop";
preferLocalBuild = true;
phases = [ "installPhase" ];
buildInputs = extraInputs ++ [ busybox ];
installPhase = ''
cat > $out <<EOF
#!${bash}/bin/bash
# This program loads a environment with the given programs available.
# Requires /nix to be available.
2020-12-03 19:14:04 +08:00
curdir="\$(pwd)"
export "buildInputs=$buildInputs"
# ${stdenv}
export "PATH=$PATH"
export "out=/fake-output-directory"
export NIX_BUILD_TOP=.
export NIX_STORE=/nix/store
2020-12-02 19:22:20 +08:00
export PS1='\[\033[1;32m\]develop\$\[\033[0m\] '
export TMUX_TMPDIR=/tmp
export TMPDIR=/tmp
export TEMPDIR=/tmp
export TMP=/tmp
export TEMP=/tmp
export LANG=en_US.UTF-8
source ${stdenv}/setup
2020-12-02 20:38:43 +08:00
# Access to bin and nix tools for srun, as it keeps the PATH
export "PATH=\$PATH:/bin"
export "PATH=$PATH:/gpfs/projects/bsc15/nix/bin"
2020-12-03 19:14:04 +08:00
export "SHELL=${bashInteractive}/bin/bash"
export HISTFILE="\$curdir/.histfile"
2020-12-03 20:09:42 +08:00
export INPUTRC=${inputrc}
2020-12-02 20:38:43 +08:00
if [[ -z "\$@" ]]; then
exec ${bashInteractive}/bin/bash
else
exec "\$@"
fi
EOF
chmod +x $out
'';
}