From 6e4a14b54f3f62e078f999bf746ebfa2020890f8 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 10 Oct 2022 15:58:42 +0200 Subject: [PATCH] writers: add writeFish and writeFishBin This adds writers for Fish shell scripts, with syntax checking. --- pkgs/build-support/writers/default.nix | 15 +++++++++++++++ pkgs/build-support/writers/test.nix | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 9fbc571daab4..fd22c0c4b030 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -119,6 +119,21 @@ let writeDashBin = name: writeDash "/bin/${name}"; + # Like writeScript but the first line is a shebang to fish + # + # Example: + # writeFish "example" '' + # echo hello world + # '' + writeFish = makeScriptWriter { + interpreter = "${pkgs.fish}/bin/fish"; + check = "${pkgs.fish}/bin/fish --no-execute"; # syntax check only + }; + + # Like writeScriptBin but the first line is a shebang to fish + writeFishBin = name: + writeFish "/bin/${name}"; + # writeHaskell takes a name, an attrset with libraries and haskell version (both optional) # and some haskell source code and returns an executable. # diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix index d2e5cef83aad..561c3e4ab002 100644 --- a/pkgs/build-support/writers/test.nix +++ b/pkgs/build-support/writers/test.nix @@ -22,6 +22,12 @@ let test '~' = '~' && echo 'success' ''; + fish = writeFishBin "test-writers-fish-bin" '' + if test "test" = "test" + echo "success" + end + ''; + rust = writeRustBin "test-writers-rust-bin" {} '' fn main(){ println!("success") @@ -94,6 +100,12 @@ let test '~' = '~' && echo 'success' ''; + fish = writeFish "test-writers-fish" '' + if test "test" = "test" + echo "success" + end + ''; + haskell = writeHaskell "test-writers-haskell" { libraries = [ haskellPackages.acme-default ]; } '' import Data.Default