Avoid loading .bashrc

This commit is contained in:
Rodrigo Arias 2020-09-22 17:39:26 +02:00
parent cd37d513e8
commit edf429c932
9 changed files with 72 additions and 9 deletions

View File

@ -74,6 +74,7 @@ let
nixsetup = {stage, conf, ...}: with conf; w.nixsetup { nixsetup = {stage, conf, ...}: with conf; w.nixsetup {
program = stageProgram stage; program = stageProgram stage;
nixsetup = "${nixPrefix}/bin/nix-setup";
}; };
extrae = {stage, conf, ...}: extrae = {stage, conf, ...}:
@ -102,6 +103,14 @@ let
]; ];
}; };
# Print the environment to ensure we don't get anything nasty
envRecord = {stage, conf, ...}: w.envRecord {
program = stageProgram stage;
};
broom = {stage, conf, ...}: w.broom {
program = stageProgram stage;
};
# We may be able to use overlays by invoking the fix function directly, but we # We may be able to use overlays by invoking the fix function directly, but we
# have to get the definition of the bsc packages and the garlic ones as # have to get the definition of the bsc packages and the garlic ones as
# overlays. # overlays.
@ -119,11 +128,18 @@ let
}; };
stages = with common; [] stages = with common; []
# Cleans ALL environment variables
++ [ broom ]
# Use sbatch to request resources first # Use sbatch to request resources first
++ optional enableSbatch sbatch ++ optional enableSbatch sbatch
# Repeats the next stages N times # Record the current env vars set by SLURM to verify we don't have something
++ optionals enableControl [ nixsetup control ] # nasty (like sourcing .bashrc). Take a look at #26
++ [ envRecord ]
# Repeats the next stages N=30 times
++ optional enableControl control
# Executes srun to launch the program in the requested nodes, and # Executes srun to launch the program in the requested nodes, and
# immediately after enters the nix environment again, as slurmstepd launches # immediately after enters the nix environment again, as slurmstepd launches

View File

@ -17,7 +17,7 @@ stdenv.mkDerivation {
phases = [ "installPhase" ]; phases = [ "installPhase" ];
installPhase = '' installPhase = ''
cat > $out <<EOF cat > $out <<EOF
#!${bash}/bin/bash #!${bash}/bin/bash --norc
# Requires /nix to use bash # Requires /nix to use bash
${env} ${env}

23
garlic/stages/broom.nix Normal file
View File

@ -0,0 +1,23 @@
{
stdenv
}:
{
program
}:
# This stage provides a clean environment to run experiments
stdenv.mkDerivation {
name = "broom";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
cat > $out <<EOF
#!/bin/sh
# Removes all environment variables
/usr/bin/env -i ${program}
EOF
chmod +x $out
'';
}

View File

@ -15,7 +15,6 @@ stdenv.mkDerivation {
installPhase = '' installPhase = ''
cat > $out <<EOF cat > $out <<EOF
#!/bin/sh #!/bin/sh
#set -e
for n in {1..${toString loops}}; do for n in {1..${toString loops}}; do
${program} ${program}
done done

View File

@ -0,0 +1,25 @@
{
stdenv
}:
{
program
}:
stdenv.mkDerivation {
name = "argv";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
cat > $out <<EOF
#!/bin/sh
echo ----- ENV BEGIN -------
/usr/bin/env
echo ----- ENV END -------
exec ${program} \''${argv[@]}
EOF
chmod +x $out
'';
}

View File

@ -24,8 +24,7 @@ stdenv.mkDerivation {
phases = [ "installPhase" ]; phases = [ "installPhase" ];
installPhase = '' installPhase = ''
cat > $out <<EOF cat > $out <<EOF
#!${bash}/bin/bash #!/bin/sh
# Requires /nix to use bash
export EXTRAE_HOME=${extrae} export EXTRAE_HOME=${extrae}
export LD_PRELOAD=${extrae}/lib/lib${traceLib}trace.so:$LD_PRELOAD export LD_PRELOAD=${extrae}/lib/lib${traceLib}trace.so:$LD_PRELOAD

View File

@ -4,6 +4,7 @@
{ {
program program
, nixsetup
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
@ -18,7 +19,7 @@ stdenv.mkDerivation {
# We need to enter the nix namespace first, in order to have /nix # We need to enter the nix namespace first, in order to have /nix
# available, so we use this hack: # available, so we use this hack:
if [ ! -e /nix ]; then if [ ! -e /nix ]; then
exec nix-setup \$0 exec ${nixsetup} \$0
fi fi
exec ${program} exec ${program}

View File

@ -15,7 +15,7 @@ stdenv.mkDerivation {
phases = [ "installPhase" ]; phases = [ "installPhase" ];
installPhase = '' installPhase = ''
cat > $out <<EOF cat > $out <<EOF
#!${bash}/bin/bash #!/bin/sh
exec ${perf}/bin/perf ${perfArgs} ${program} exec ${perf}/bin/perf ${perfArgs} ${program}
EOF EOF

View File

@ -16,7 +16,7 @@ stdenv.mkDerivation {
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cat > $out/bin/${name} <<EOF cat > $out/bin/${name} <<EOF
#!${bash}/bin/bash #!/bin/sh
mkdir -p ${outputDir} mkdir -p ${outputDir}
cat /proc/[0-9]*/stat | sort -n > ${outputDir}/statspy.\$(date +%s.%3N).begin cat /proc/[0-9]*/stat | sort -n > ${outputDir}/statspy.\$(date +%s.%3N).begin