mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
writers: add babashka
This commit is contained in:
parent
3b216ee005
commit
55903a2f8e
@ -522,6 +522,89 @@ rec {
|
||||
*/
|
||||
writeFishBin = name: writeFish "/bin/${name}";
|
||||
|
||||
/**
|
||||
Like writeScript but the first line is a shebang to babashka
|
||||
|
||||
Can be called with or without extra arguments.
|
||||
|
||||
:::{.example}
|
||||
## `pkgs.writers.writeBabashka` without arguments
|
||||
|
||||
```nix
|
||||
writeBabashka "example" ''
|
||||
(println "hello world")
|
||||
''
|
||||
```
|
||||
:::
|
||||
|
||||
:::{.example}
|
||||
## `pkgs.writers.writeBabashka` with arguments
|
||||
|
||||
```nix
|
||||
writeBabashka "example"
|
||||
{
|
||||
makeWrapperArgs = [
|
||||
"--prefix" "PATH" ":" "${lib.makeBinPath [ pkgs.hello ]}"
|
||||
];
|
||||
}
|
||||
''
|
||||
(require '[babashka.tasks :as tasks])
|
||||
(tasks/shell "hello" "-g" "Hello babashka!")
|
||||
''
|
||||
```
|
||||
:::
|
||||
*/
|
||||
writeBabashka =
|
||||
name: argsOrScript:
|
||||
if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript then
|
||||
makeScriptWriter (
|
||||
argsOrScript
|
||||
// {
|
||||
interpreter = "${lib.getExe pkgs.babashka}";
|
||||
check = "${lib.getExe pkgs.clj-kondo} --lint";
|
||||
}
|
||||
) name
|
||||
else
|
||||
makeScriptWriter {
|
||||
interpreter = "${lib.getExe pkgs.babashka}";
|
||||
check = "${lib.getExe pkgs.clj-kondo} --lint";
|
||||
} name argsOrScript;
|
||||
|
||||
/**
|
||||
Like writeScriptBin but the first line is a shebang to babashka
|
||||
|
||||
Can be called with or without extra arguments.
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `pkgs.writers.writeBabashkaBin` without arguments
|
||||
|
||||
```nix
|
||||
writeBabashkaBin "example" ''
|
||||
(println "hello world")
|
||||
''
|
||||
```
|
||||
:::
|
||||
|
||||
:::{.example}
|
||||
## `pkgs.writers.writeBabashkaBin` with arguments
|
||||
|
||||
```nix
|
||||
writeBabashkaBin "example"
|
||||
{
|
||||
makeWrapperArgs = [
|
||||
"--prefix" "PATH" ":" "${lib.makeBinPath [ pkgs.hello ]}"
|
||||
];
|
||||
}
|
||||
''
|
||||
(require '[babashka.tasks :as tasks])
|
||||
(tasks/shell "hello" "-g" "Hello babashka!")
|
||||
''
|
||||
```
|
||||
:::
|
||||
*/
|
||||
writeBabashkaBin = name: writeBabashka "/bin/${name}";
|
||||
|
||||
/**
|
||||
writeHaskell takes a name, an attrset with libraries and haskell version (both optional)
|
||||
and some haskell source code and returns an executable.
|
||||
|
@ -18,6 +18,8 @@ let
|
||||
makeFSharpWriter
|
||||
writeBash
|
||||
writeBashBin
|
||||
writeBabashka
|
||||
writeBabashkaBin
|
||||
writeDash
|
||||
writeDashBin
|
||||
writeFish
|
||||
@ -85,6 +87,10 @@ recurseIntoAttrs {
|
||||
end
|
||||
'');
|
||||
|
||||
babashka = expectSuccessBin (writeBabashkaBin "test-writers-babashka-bin" ''
|
||||
(println "success")
|
||||
'');
|
||||
|
||||
rust = expectSuccessBin (writeRustBin "test-writers-rust-bin" {} ''
|
||||
fn main(){
|
||||
println!("success")
|
||||
@ -189,6 +195,10 @@ recurseIntoAttrs {
|
||||
echo "success"
|
||||
'');
|
||||
|
||||
babashka = expectSuccess (writeBabashka "test-writers-babashka" ''
|
||||
(println "success")
|
||||
'');
|
||||
|
||||
haskell = expectSuccess (writeHaskell "test-writers-haskell" { libraries = [ haskellPackages.acme-default ]; } ''
|
||||
import Data.Default
|
||||
|
||||
@ -369,6 +379,36 @@ recurseIntoAttrs {
|
||||
''
|
||||
);
|
||||
|
||||
babashka-bin = expectSuccessBin (
|
||||
writeBabashkaBin "test-writers-wrapping-babashka-bin"
|
||||
{
|
||||
makeWrapperArgs = [
|
||||
"--set"
|
||||
"ThaigerSprint"
|
||||
"Thailand"
|
||||
];
|
||||
}
|
||||
''
|
||||
(when (= (System/getenv "ThaigerSprint") "Thailand")
|
||||
(println "success"))
|
||||
''
|
||||
);
|
||||
|
||||
babashka = expectSuccess (
|
||||
writeBabashka "test-writers-wrapping-babashka"
|
||||
{
|
||||
makeWrapperArgs = [
|
||||
"--set"
|
||||
"ThaigerSprint"
|
||||
"Thailand"
|
||||
];
|
||||
}
|
||||
''
|
||||
(when (= (System/getenv "ThaigerSprint") "Thailand")
|
||||
(println "success"))
|
||||
''
|
||||
);
|
||||
|
||||
python = expectSuccess (
|
||||
writePython3 "test-writers-wrapping-python"
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user