stdexp: Run python snippets and import the result
This commit is contained in:
parent
7d4db6b6de
commit
5a8cc1e514
@ -5,6 +5,9 @@
|
|||||||
, targetMachine
|
, targetMachine
|
||||||
, garlicTools
|
, garlicTools
|
||||||
, bsc
|
, bsc
|
||||||
|
, writeTextFile
|
||||||
|
, runCommandLocal
|
||||||
|
, python
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
@ -113,4 +116,19 @@ rec {
|
|||||||
units = genUnits { inherit configs pipeline; };
|
units = genUnits { inherit configs pipeline; };
|
||||||
in
|
in
|
||||||
buildTrebuchet units;
|
buildTrebuchet units;
|
||||||
|
|
||||||
|
# Runs a python script and the standard output is directly imported as
|
||||||
|
# nix code
|
||||||
|
printPython = code:
|
||||||
|
let
|
||||||
|
p = writeTextFile {
|
||||||
|
name = "python-script";
|
||||||
|
text = ''
|
||||||
|
from math import *
|
||||||
|
${code}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
import (runCommandLocal "a" { buildInputs = [ python ]; } ''
|
||||||
|
python ${p} > $out'');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user