From 1a39cf221e3f647df0767c88d89a54e3813e7019 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sat, 29 Aug 2026 03:45:10 +0530 Subject: refactor: adding explicit options to enable scripts - some scripts that are not critical to the functioning of other options, can be enabled/disabled --- modules/networking/usque/default.nix | 50 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'modules/networking/usque') diff --git a/modules/networking/usque/default.nix b/modules/networking/usque/default.nix index 9d04ab7..ffde47a 100644 --- a/modules/networking/usque/default.nix +++ b/modules/networking/usque/default.nix @@ -6,21 +6,32 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - usqueWarp = mkScriptModule { - scope = [ - "networking" - "usque" - ]; + usqueWarpScript = pkgs.writeShellApplication { name = "usque-warp"; - path = ./usque-warp.sh; - description = "Connect/disconnect to Cloudflare WARP via usque MASQUE tunnel"; - deps = [ + runtimeInputs = [ config.networking.usque.package pkgs.bash ]; - completion.zsh = builtins.readFile ./usque-warp.zsh; - inherit config; + text = builtins.readFile ./usque-warp.sh; + }; + + usqueWarpCompletion = + pkgs.runCommand "usque-warp-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion --zsh --name _usque-warp ${pkgs.writeText "usque-warp.zsh" (builtins.readFile ./usque-warp.zsh)} + ''; + + usqueWarpScriptPkg = pkgs.symlinkJoin { + name = "usque-warp"; + paths = [ + usqueWarpScript + usqueWarpCompletion + ]; + meta = usqueWarpScript.meta or { }; }; in { @@ -31,13 +42,24 @@ in default = pkgs.usque; description = "The usque package to use."; }; - } - // usqueWarp.options.networking.usque; + + warp = { + enable = lib.mkEnableOption "Enables the usque-warp script."; + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = usqueWarpScriptPkg; + description = "The usque-warp script package."; + }; + }; + }; config = lib.mkMerge [ (lib.mkIf config.networking.usque.enable { home.packages = [ config.networking.usque.package ]; }) - usqueWarp.config + (lib.mkIf config.networking.usque.warp.enable { + home.packages = [ config.networking.usque.warp.package ]; + }) ]; } -- cgit v1.2.3