elephant: add module

Add a service module for Elephant with package installation, provider selection, TOML config generation, and a systemd user service.

This gives Elephant its own configuration surface instead of wiring it through Walker.
This commit is contained in:
Austin Horstman
2026-05-17 22:17:42 -05:00
parent 355734d876
commit 84ddd33ed0
6 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
{ config, ... }:
{
time = "2026-05-18T02:52:12+00:00";
condition = config.services.elephant.enable;
message = ''
A new service is available: 'services.elephant'.
Elephant is a data provider service for application launchers such as
Walker. The module can install Elephant, generate
`~/.config/elephant/config.toml`, and run Elephant as a systemd user
service.
'';
}

View File

@@ -0,0 +1,64 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.elephant;
tomlFormat = pkgs.formats.toml { };
in
{
meta.maintainers = [ ];
options.services.elephant = {
enable = lib.mkEnableOption "elephant";
package = lib.mkPackageOption pkgs "elephant" {
example = ''
pkgs.elephant.override {
enabledProviders = [
"desktopapplications"
"runner"
];
}
'';
};
settings = lib.mkOption {
inherit (tomlFormat) type;
default = { };
example = {
providers.default = [
"desktopapplications"
"runner"
];
};
description = ''
Configuration settings for Elephant.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.elephant" pkgs lib.platforms.linux)
];
home.packages = [ cfg.package ];
xdg.configFile."elephant/config.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "elephant-config" cfg.settings;
};
systemd.user.services.elephant = {
Unit.Description = "Elephant - Data provider for application launchers";
Install.WantedBy = [ "graphical-session.target" ];
Service = {
ExecStart = lib.getExe cfg.package;
Restart = "on-failure";
};
};
};
}

View File

@@ -0,0 +1,3 @@
[providers]
default = ["desktopapplications", "runner"]
max_results = 50

View File

@@ -0,0 +1,5 @@
{ lib, pkgs, ... }:
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
elephant-example-config = ./example-config.nix;
}

View File

@@ -0,0 +1,9 @@
[Install]
WantedBy=graphical-session.target
[Service]
ExecStart=@elephant@/bin/elephant
Restart=on-failure
[Unit]
Description=Elephant - Data provider for application launchers

View File

@@ -0,0 +1,25 @@
{
services.elephant = {
enable = true;
settings = {
providers = {
default = [
"desktopapplications"
"runner"
];
max_results = 50;
};
};
};
nmt.script = ''
assertFileExists home-files/.config/elephant/config.toml
assertFileExists home-files/.config/systemd/user/elephant.service
assertFileContent home-files/.config/elephant/config.toml \
${./config.toml}
assertFileContent home-files/.config/systemd/user/elephant.service \
${./elephant.service}
'';
}