From f7f5e84cf2bcae79e703bf5bdab39619c62ea198 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Tue, 14 Apr 2026 18:32:28 +0530 Subject: replaced rofi with a fzf script for launching desktop applications --- modules/scripts/default.nix | 82 ++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'modules/scripts/default.nix') diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix index 5242280..95d9298 100644 --- a/modules/scripts/default.nix +++ b/modules/scripts/default.nix @@ -4,19 +4,13 @@ pkgs, ... }: - let - # name: Script name - # path: Path to script file - # env: (Optional) Attribute set of environment variables { KEY = "VALUE"; } + shell = + if config.tools.zsh.enable then (lib.getExe config.programs.zsh.package) else "/usr/bin/env sh"; + mkScript = name: path: env: let - # Generate the shell shebang based on your config - shell = - if config.tools.zsh.enable then (lib.getExe config.programs.zsh.package) else "/usr/bin/env sh"; - - # Convert the 'env' attribute set into a string of "export KEY='VALUE'" lines envVars = lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n}=\"${toString v}\"") env); in pkgs.writeTextFile { @@ -29,28 +23,26 @@ let ${builtins.readFile path} ''; }; -in -{ - config = { - home.packages = [ - # Always included (pass empty set {} if no env vars needed) - (mkScript "deep-clean" ./deep-clean.sh { }) - # Conditional scripts - (lib.mkIf config.tools.fzf.enable ( - mkScript "fzf-launcher" ./fzf-launcher.sh { - FZF = lib.getExe pkgs.fzf; - } - )) + scripts = { + deep-clean = mkScript "deep-clean" ./deep-clean.sh { }; + + fzf-launcher = lib.mkIf config.tools.fzf.enable ( + mkScript "fzf-launcher" ./fzf-launcher.sh { + FZF = lib.getExe pkgs.fzf; + SETSID = "${pkgs.util-linux}/bin/setsid"; + } + ); - (lib.mkIf (config.tools.ffmpeg.enable && config.tools.slop.enable) ( - mkScript "screen-recording" ./screen-recording.sh { - FFMPEG = lib.getExe pkgs.ffmpeg-full; - SLOP = lib.getExe pkgs.slop; - } - )) + screen-recording = lib.mkIf (config.tools.ffmpeg.enable && config.tools.slop.enable) ( + mkScript "screen-recording" ./screen-recording.sh { + FFMPEG = lib.getExe pkgs.ffmpeg-full; + SLOP = lib.getExe pkgs.slop; + } + ); - (lib.mkIf + system-monitor = + lib.mkIf ( config.tools.bottom.enable && config.tools.nvtop.enable @@ -64,16 +56,30 @@ in TMUX = lib.getExe pkgs.tmux; KITTY = lib.getExe pkgs.kitty; } - ) - ) + ); + + vpn-connect = lib.mkIf (config.tools.openvpn.enable && config.tools.fzf.enable) ( + mkScript "vpn-connect" ./vpn-connect.sh { + FZF = lib.getExe pkgs.fzf; + OPENVPN = lib.getExe pkgs.openvpn; + SYSTEMD_RESOLVED = "${pkgs.openvpn}/libexec/update-systemd-resolved"; + } + ); + }; +in +{ + options.scripts = lib.mapAttrs ( + name: _: + lib.mkOption { + type = lib.types.nullOr lib.types.package; + default = null; + description = "Derivation for the ${name} script, or null if disabled."; + } + ) scripts; + + config = { + scripts = scripts; - (lib.mkIf (config.tools.openvpn.enable && config.tools.fzf.enable) ( - mkScript "vpn-connect" ./vpn-connect.sh { - FZF = lib.getExe pkgs.fzf; - OPENVPN = lib.getExe pkgs.openvpn; - SYSTEMD_RESOLVED = "${pkgs.openvpn}/libexec/update-systemd-resolved"; - } - )) - ]; + home.packages = lib.filter (x: x != null) (lib.mapAttrsToList (_: v: lib.mkIf true v) scripts); }; } -- cgit v1.2.3