1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-06 00:51:04 +01:00

sherlock: init module

Creating a sherlock module for the sherlock launcher. Prefer a file be
controlled by a single option and using settings for the main config
file.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-08-05 18:56:15 -05:00
parent f0d81a415d
commit a379077675
14 changed files with 586 additions and 0 deletions

View file

@ -0,0 +1,12 @@
{
time = "2025-08-06T00:14:30+00:00";
condition = true;
message = ''
A new module is available: 'programs.sherlock'.
The sherlock module allows configuring Sherlock launcher, a fast and
lightweight application launcher for Linux. You can customize settings,
define custom aliases for web searches, configure fallback launchers,
specify applications to ignore, and apply custom CSS styling.
'';
}

View file

@ -0,0 +1,148 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib)
mkIf
mkEnableOption
mkPackageOption
mkOption
types
;
cfg = config.programs.sherlock;
tomlFormat = pkgs.formats.toml { };
jsonFormat = pkgs.formats.json { };
in
{
meta.maintainers = [ lib.maintainers.khaneliman ];
options.programs.sherlock = {
enable = mkEnableOption "sherlock launcher" // {
description = ''
Enable Sherlock, a fast and lightweight application launcher for Wayland.
See <https://github.com/Skxxtz/sherlock> for more information.
'';
};
package = mkPackageOption pkgs "sherlock" {
default = "sherlock-launcher";
nullable = true;
};
settings = mkOption {
inherit (tomlFormat) type;
default = { };
description = ''
Configuration for Sherlock.
Written to `config.toml`.
See <https://github.com/Skxxtz/sherlock/blob/main/docs/config.md> for available options.
'';
example = {
theme = "dark";
width = 500;
max_results = 8;
};
};
aliases = mkOption {
inherit (jsonFormat) type;
default = { };
description = ''
Defines custom aliases.
Written to `sherlock_alias.json`.
See <https://github.com/Skxxtz/sherlock/blob/main/docs/aliases.md> for more information.
'';
example = {
"NixOS Wiki" = {
name = "NixOS Wiki";
icon = "nixos";
exec = "firefox https://nixos.wiki/index.php?search=%s";
keywords = "nix wiki docs";
};
};
};
ignore = mkOption {
type = types.lines;
default = "";
description = ''
A list of desktop entry IDs to ignore.
Written to `sherlockignore`.
See <https://github.com/Skxxtz/sherlock/blob/main/docs/sherlockignore.md> for more information.
'';
example = ''
hicolor-icon-theme.desktop
user-dirs.desktop
'';
};
launchers = mkOption {
inherit (jsonFormat) type;
default = [ ];
description = ''
Defines fallback launchers.
Written to `fallback.json`.
See <https://github.com/Skxxtz/sherlock/blob/main/docs/launchers.md> for more information.
'';
};
style = mkOption {
type = types.lines;
default = "";
description = ''
Custom CSS to style the Sherlock UI.
Written to `main.css`.
'';
example = ''
window {
background-color: #2E3440;
}
'';
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "programs.sherlock" pkgs lib.platforms.linux)
];
home.packages = mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile = {
"sherlock/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "sherlock-config.toml" cfg.settings;
};
"sherlock/sherlock_alias.json" = mkIf (cfg.aliases != { }) {
source = jsonFormat.generate "sherlock_alias.json" cfg.aliases;
};
"sherlock/fallback.json" = mkIf (cfg.launchers != [ ]) {
source = jsonFormat.generate "sherlock-fallback.json" cfg.launchers;
};
"sherlock/sherlockignore" = mkIf (cfg.ignore != "") {
text = cfg.ignore;
};
"sherlock/main.css" = mkIf (cfg.style != "") {
text = cfg.style;
};
};
};
}