krebs builders: use passAsFile in runCommands
This commit is contained in:
parent
a4683911af
commit
3e01299f90
|
@ -55,16 +55,18 @@ with import <stockholm/lib>;
|
||||||
assert types.filename.check name;
|
assert types.filename.check name;
|
||||||
pkgs.writeBash "/bin/${name}";
|
pkgs.writeBash "/bin/${name}";
|
||||||
|
|
||||||
writeC = name: { destination ? "" }: src: pkgs.runCommand name {} /* sh */ ''
|
writeC = name: { destination ? "" }: text: pkgs.runCommand name {
|
||||||
|
inherit text;
|
||||||
|
passAsFile = [ "text" ];
|
||||||
|
} /* sh */ ''
|
||||||
PATH=${makeBinPath (with pkgs; [
|
PATH=${makeBinPath (with pkgs; [
|
||||||
binutils
|
binutils
|
||||||
coreutils
|
coreutils
|
||||||
gcc
|
gcc
|
||||||
])}
|
])}
|
||||||
src=${pkgs.writeText "${name}.c" src}
|
|
||||||
exe=$out${destination}
|
exe=$out${destination}
|
||||||
mkdir -p "$(dirname "$exe")"
|
mkdir -p "$(dirname "$exe")"
|
||||||
gcc -O -Wall -o "$exe" $src
|
gcc -O -Wall -o "$exe" -x c "$textPath"
|
||||||
strip --strip-unneeded "$exe"
|
strip --strip-unneeded "$exe"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -118,7 +120,10 @@ with import <stockholm/lib>;
|
||||||
${optionalString (check != null) /* sh */ ''
|
${optionalString (check != null) /* sh */ ''
|
||||||
${check} ''$${var}Path
|
${check} ''$${var}Path
|
||||||
''}
|
''}
|
||||||
${pkgs.coreutils}/bin/install -m ${mode} -D ''$${var}Path $out${path}
|
${pkgs.coreutils}/bin/install \
|
||||||
|
-m ${mode} \
|
||||||
|
-D \
|
||||||
|
''$${var}Path $out${path}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -247,15 +252,16 @@ with import <stockholm/lib>;
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
writeJq = name: src: pkgs.runCommand name {} /* sh */ ''
|
writeJq = name: text: pkgs.runCommand name {
|
||||||
|
inherit text;
|
||||||
|
passAsFile = [ "text" ];
|
||||||
|
} /* sh */ ''
|
||||||
name=${assert types.filename.check name; name}
|
name=${assert types.filename.check name; name}
|
||||||
src=${shell.escape src}
|
|
||||||
|
|
||||||
# syntax check
|
# syntax check
|
||||||
printf '%s' "$src" > src.jq
|
${pkgs.jq}/bin/jq -f "$textPath" -n
|
||||||
${pkgs.jq}/bin/jq -f src.jq < /dev/null
|
|
||||||
|
|
||||||
cp src.jq "$out"
|
cp "$textPath" "$out"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
writeJSON = name: value: pkgs.writeText name (toJSON value);
|
writeJSON = name: value: pkgs.writeText name (toJSON value);
|
||||||
|
@ -269,26 +275,28 @@ with import <stockholm/lib>;
|
||||||
${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
|
${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
|
||||||
'');
|
'');
|
||||||
|
|
||||||
writePython2 = name: src: pkgs.runCommand name {} /* sh */ ''
|
writePython2 = name: text: pkgs.runCommand name {
|
||||||
|
inherit text;
|
||||||
|
passAsFile = [ "text" ];
|
||||||
|
} /* sh */ ''
|
||||||
name=${assert types.filename.check name; name}
|
name=${assert types.filename.check name; name}
|
||||||
src=${shell.escape src}
|
|
||||||
|
|
||||||
# syntax check
|
# syntax check
|
||||||
printf '%s' "$src" > src.py
|
${pkgs.python2}/bin/python -m py_compile "$textPath"
|
||||||
${pkgs.python2}/bin/python -m py_compile src.py
|
|
||||||
|
|
||||||
cp src.py "$out"
|
cp "$textPath" "$out"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
writePython3 = name: src: pkgs.runCommand name {} /* sh */ ''
|
writePython3 = name: text: pkgs.runCommand name {
|
||||||
|
inherit text;
|
||||||
|
passAsFile = [ "text" ];
|
||||||
|
} /* sh */ ''
|
||||||
name=${assert types.filename.check name; name}
|
name=${assert types.filename.check name; name}
|
||||||
src=${shell.escape src}
|
|
||||||
|
|
||||||
# syntax check
|
# syntax check
|
||||||
printf '%s' "$src" > src.py
|
${pkgs.python3}/bin/python -m py_compile "$textPath"
|
||||||
${pkgs.python3}/bin/python -m py_compile src.py
|
|
||||||
|
|
||||||
cp src.py "$out"
|
cp "$textPath" "$out"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
writeSed = pkgs.makeScriptWriter "${pkgs.gnused}/bin/sed -f";
|
writeSed = pkgs.makeScriptWriter "${pkgs.gnused}/bin/sed -f";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user