summaryrefslogtreecommitdiff
path: root/users/kassouni/palette/default.nix
diff options
context:
space:
mode:
authorAlexander Kassouni <alex@kassouni.net>2026-08-29 23:53:40 -0700
committerAlexander Kassouni <alex@kassouni.net>2026-08-29 23:53:40 -0700
commitaf99b4960a9bf1043234354d685ed23818c14aaa (patch)
tree9d6bd855c76c2c99e16321e1df4eeaadade28739 /users/kassouni/palette/default.nix
parent8dcf355819cc6cd1e87924218c1adcd900ecda84 (diff)
new laptop
Diffstat (limited to 'users/kassouni/palette/default.nix')
-rw-r--r--users/kassouni/palette/default.nix54
1 files changed, 46 insertions, 8 deletions
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 <<EOF
-${lib.concatMapStrings (c: "${c.icon} ${c.name}\n") commands}EOF
+${lib.concatMapStrings (c: "${c.icon} ${c.name}\n") cfg.commands}EOF
)
exec "''${exes[$idx]}"
'')