From f2665c346f16db4b082a9cdb304bfca950706961 Mon Sep 17 00:00:00 2001 From: nicoo Date: Mon, 19 Aug 2024 09:44:43 +0000 Subject: [PATCH] nix-your-shell: support arbitrary CLI arguments Useful to implement higher-level (and more ergonomic) options --- modules/programs/nix-your-shell.nix | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/programs/nix-your-shell.nix b/modules/programs/nix-your-shell.nix index 6914ee810..144fd84ec 100644 --- a/modules/programs/nix-your-shell.nix +++ b/modules/programs/nix-your-shell.nix @@ -3,17 +3,29 @@ let cfg = config.programs.nix-your-shell; exe = lib.getExe pkgs.nix-your-shell; + args = lib.concatStringsSep " " cfg.extraArgs; + mkShellAliases = shell: { - nix = "${exe} ${shell} nix --"; - nix-shell = "${exe} ${shell} nix-shell --"; + nix = "${exe} ${args} ${shell} nix --"; + nix-shell = "${exe} ${args} ${shell} nix-shell --"; }; in { meta.maintainers = with lib.maintainers; [ nicoo ]; - options.programs.nix-your-shell.enable = lib.mkEnableOption '' - `nix-your-shell`, a wrapper for `nix develop` or `nix-shell` - to run the same shell inside the new environment. - ''; + options.programs.nix-your-shell = { + enable = lib.mkEnableOption '' + `nix-your-shell`, a wrapper for `nix develop` or `nix-shell` + to run the same shell inside the new environment. + ''; + + extraArgs = lib.mkOption { + default = [ ]; + description = '' + additional command-line arguments, to be passed to `nix-your-shell` + ''; + type = with lib.types; listOf str; + }; + }; config.programs = lib.mkIf cfg.enable { fish.shellAliases = mkShellAliases "fish";