From af99b4960a9bf1043234354d685ed23818c14aaa Mon Sep 17 00:00:00 2001 From: Alexander Kassouni Date: Sat, 29 Aug 2026 23:53:40 -0700 Subject: new laptop --- users/kassouni/palette/default.nix | 54 ++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'users/kassouni/palette/default.nix') diff --git a/users/kassouni/palette/default.nix b/users/kassouni/palette/default.nix index 235f774..7e9eec4 100644 --- a/users/kassouni/palette/default.nix +++ b/users/kassouni/palette/default.nix @@ -1,18 +1,56 @@ -{ pkgs, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: let - commandFiles = lib.attrNames ( - lib.filterAttrs (name: type: type == "regular" && name != "default.nix" && lib.hasSuffix ".nix" name) - (builtins.readDir ./.) + cfg = config.kassouni.palette; + + # Every sibling .nix file is an ordinary home-manager module that appends to + # kassouni.palette.commands, so dropping a file in here adds an entry. + commandModules = map (file: ./. + "/${file}") ( + lib.attrNames ( + lib.filterAttrs (name: type: type == "regular" && name != "default.nix" && lib.hasSuffix ".nix" name) + (builtins.readDir ./.) + ) ); - commands = map (file: pkgs.callPackage (./. + "/${file}") { }) commandFiles; in { - home.packages = [ + imports = commandModules; + + options.kassouni.palette.commands = lib.mkOption { + type = lib.types.listOf ( + lib.types.submodule { + options = { + name = lib.mkOption { + type = lib.types.str; + description = "Label shown in the palette menu."; + }; + icon = lib.mkOption { + type = lib.types.str; + description = "Nerd Font glyph shown before the label."; + }; + exe = lib.mkOption { + type = lib.types.package; + description = "Executable to run when the entry is selected."; + }; + }; + } + ); + default = [ ]; + description = '' + Entries shown in the rofi command palette. Menu order follows module + import order, which is alphabetical by filename. + ''; + }; + + config.home.packages = [ (pkgs.writers.writeBashBin "open-palette" '' set -eu - exes=(${lib.concatMapStringsSep " " (c: c.exe) commands}) + exes=(${lib.concatMapStringsSep " " (c: "${c.exe}") cfg.commands}) idx=$(${pkgs.rofi}/bin/rofi -dmenu -i -format i -p palette <