TLDR
Can you help me make a semi-decent flake for running examples of the Geant4 toolkit for interaction of particles with matter?
Here is what I have so far: GitHub - jacg/nain4: An API that makes it easier to write Geant4 application code..
Caveats
-
This is a Nix flake, therefore it won’t work without a flakes-enabled (i.e. unstable) Nix.
-
I don’t know how to get Geant4 to work in Nix on MacOS, so this only works on Linux.
Something to try, that should work
nix build github:jacg/g4-examples-flake --out-link /tmp/g4b1
tree /tmp/g4b1 # (assuming you have `tree`)
nix develop
cd $B1_MACRO_DIR
/tmp/g4b1/bin/exampleB1 # Tries to use OpenGL so YMMV
Things that don’t work
-
The executable absolutely needs to know the location of the G4 datasets (and probably some other crucial info). This is done by sourcing
${geant4}/bin/geant4.sh
, which seems to happen automatically innix develop
(I’m not sure how), but I don’t know how to make that happen fornix shell
ornix run
. -
G4 programs are supposed to be executed from the directory containing the
*.mac
files which control the run. In this flake, that’sB1_MACRO_DIR
. I don’t know how to getnix shell
andnix run
tocd B1_MACRO_DIR
.
Consequently nix shell
and nix run
don’t do anything sensible. The latter does demonstrate the need to know the aforementioned G4 data directories, by crashing with the error
G4ENSDFSTATEDATA environment variable must be set
*** Fatal Exception *** core dump ***
.
Questions
-
Can you spot anything obviously stupid/superstitious/misguided in what I have so far?
-
I never remember/understand the distinction between
buildInputs
andnativeBuildInputs
. Can you offer any wisdom? -
Is there any documentation for[Answered below; TLDR: nope, that’s it!]defaultApp
anywhere? From examples I infer that{ type = "app"; program = "<an executable>"; }
works, but can you do anything else with it? Whattype
s are there besides"app"
? -
Can you suggest how to make progress on getting
nix shell
andnix run
?