From 4557a207a793776b1eaba1657e3574f459876096 Mon Sep 17 00:00:00 2001 From: David Flanagan Date: Sat, 8 Jun 2024 11:21:42 +0100 Subject: [PATCH 1/4] feat(scripts): allow custom interpreters --- examples/scripts/devenv.nix | 29 +++++++++++++++++-- src/modules/scripts.nix | 55 +++++++++++++++++++++++++++---------- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/examples/scripts/devenv.nix b/examples/scripts/devenv.nix index d3eacc4de..9731166c4 100644 --- a/examples/scripts/devenv.nix +++ b/examples/scripts/devenv.nix @@ -1,7 +1,15 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { - packages = [ pkgs.curl pkgs.jq ]; + packages = [ + pkgs.curl + pkgs.jq + ]; scripts.silly-example.exec = ''curl "https://httpbin.org/get?$1" | jq .args''; scripts.silly-example.description = "curls httpbin with provided arg"; @@ -9,12 +17,27 @@ scripts.serious-example.exec = ''${pkgs.cowsay}/bin/cowsay "$*"''; scripts.serious-example.description = ''echoes args in a very serious manner''; + # Example with custom package + scripts.python-hello.exec = ''print("Hello, world!")''; + scripts.python-hello.package = pkgs.python311; + + # Example when package and binary are different + scripts.nushell-greet.exec = '' + def greet [name] { + ["hello" $name] + } + + greet "world" + ''; + scripts.nushell-greet.package = pkgs.nushell; + scripts.nushell-greet.binary = "nu"; + enterShell = '' echo echo 🦾 Helper scripts you can run to make your development richer: echo 🦾 ${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' < Date: Sat, 8 Jun 2024 16:08:00 +0100 Subject: [PATCH 2/4] fix(scripts): default to bash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Domen Kožar --- src/modules/scripts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/scripts.nix b/src/modules/scripts.nix index bb7931673..5b6a864d3 100644 --- a/src/modules/scripts.nix +++ b/src/modules/scripts.nix @@ -18,7 +18,7 @@ let package = lib.mkOption { type = types.package; description = "The package to use to run the script."; - default = ""; + default = pkgs.bash; }; binary = lib.mkOption { type = types.str; From c763fb4b5f8694d32bbe5961dfa3e67247456979 Mon Sep 17 00:00:00 2001 From: David Flanagan Date: Sat, 8 Jun 2024 16:21:37 +0100 Subject: [PATCH 3/4] chore(scripts): format with nixpkgs-fmt --- examples/scripts/devenv.nix | 9 ++++----- src/modules/scripts.nix | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/scripts/devenv.nix b/examples/scripts/devenv.nix index 9731166c4..b859389ef 100644 --- a/examples/scripts/devenv.nix +++ b/examples/scripts/devenv.nix @@ -1,8 +1,7 @@ -{ - config, - lib, - pkgs, - ... +{ config +, lib +, pkgs +, ... }: { diff --git a/src/modules/scripts.nix b/src/modules/scripts.nix index 5b6a864d3..a8754a082 100644 --- a/src/modules/scripts.nix +++ b/src/modules/scripts.nix @@ -1,8 +1,7 @@ -{ - lib, - config, - pkgs, - ... +{ lib +, config +, pkgs +, ... }: let From ed2c68d026ac0a1a3983ebbea45cab93bfd737cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Sat, 8 Jun 2024 20:21:19 +0100 Subject: [PATCH 4/4] scripts: fix description default --- src/modules/scripts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/scripts.nix b/src/modules/scripts.nix index a8754a082..7ed4ad34d 100644 --- a/src/modules/scripts.nix +++ b/src/modules/scripts.nix @@ -27,7 +27,7 @@ let description = lib.mkOption { type = types.str; description = "Description of the script."; - default = pkgs.bash; + default = ""; }; }; }