From 71fcc80fd9c205625eb5acd11686e143d95b5129 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 14 Jan 2025 18:21:59 +0100 Subject: [PATCH] feat(lib): Add nix-shell helper This allows running the specified script in a nix-shell invocation --- default.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index ad3e003..7a6d22e 100644 --- a/default.nix +++ b/default.nix @@ -10,7 +10,13 @@ let inherit (pkgs) mkShell; - inherit (pkgs.lib) evalModules getExe recursiveUpdate; + inherit (pkgs.lib) + escapeShellArgs + evalModules + getExe + optionals + recursiveUpdate + ; inherit (pkgs.lib.fileset) gitTracked toSource; @@ -146,6 +152,24 @@ in lib = rec { expr = repr: "\${{ ${repr} }}"; secret = name: expr "secrets.${name}"; + nix-shell = + { + script, + extraArgs ? [ ], + shell ? null, + }: + escapeShellArgs ( + [ "nix-shell" ] + ++ extraArgs + ++ (optionals (shell != null) [ + "-A" + shell + ]) + ++ [ + "--run" + script + ] + ); }; steps =