develop: Experimental interactive support

This commit is contained in:
Rodrigo Arias 2020-12-02 11:58:00 +01:00
parent 1f841649f8
commit 1340d1d2e8
2 changed files with 77 additions and 1 deletions

50
garlic/develop.nix Normal file
View File

@ -0,0 +1,50 @@
{
stdenv
, bash
, bashInteractive
, busybox
, extraInputs ? []
}:
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.
export "buildInputs=$buildInputs"
# ${stdenv}
export "PATH=$PATH"
export "TERM=linux"
export "out=/fake-output-directory"
export NIX_BUILD_TOP=.
export NIX_STORE=/nix/store
export PS1='\033[1;32mdevelop\$\033[0m '
#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
export TERM=linux
source ${stdenv}/setup
if [[ -z "\$@" ]]; then
exec ${bashInteractive}/bin/bash
else
exec "\$@"
fi
EOF
chmod +x $out
'';
}

View File

@ -184,8 +184,34 @@ let
# Aliases bsc.apps -> bsc.garlic.apps # Aliases bsc.apps -> bsc.garlic.apps
inherit (bsc.garlic) apps fig exp ds; inherit (bsc.garlic) apps fig exp ds;
# TODO: move into garlic/default.nix
garlic = { garlic = {
# TODO: move into garlic/default.nix
unsafeDevelop = callPackage ./garlic/develop.nix {
extraInputs = with self; [
coreutils htop procps-ng vim which strace
tmux gdb kakoune universal-ctags bashInteractive
glibcLocales ncurses
# Add more nixpkgs packages here...
bsc.slurm bsc.clangOmpss2 bsc.icc bsc.mcxx bsc.perf
# Add more bscpkgs packages here...
];
};
develop = bsc.garlic.stages.exec {
nextStage = bsc.garlic.stages.isolate {
nextStage = bsc.garlic.unsafeDevelop;
nixPrefix = bsc.garlic.targetMachine.config.nixPrefix;
extraMounts = [ "/tmp:$TMPDIR" ];
};
nixPrefix = bsc.garlic.targetMachine.config.nixPrefix;
# This hack uploads all dependencies to MN4
pre = ''
# Hack to upload this to MN4: @upload-to-mn@
# Run the following command in a normal interactive shell (outside nix)
'';
post = "\n";
};
# Configuration for the machines # Configuration for the machines
machines = callPackage ./garlic/machines.nix { }; machines = callPackage ./garlic/machines.nix { };