mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
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:
14
modules/misc/news/2026/05/2026-05-18_02-52-12.nix
Normal file
14
modules/misc/news/2026/05/2026-05-18_02-52-12.nix
Normal 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.
|
||||
'';
|
||||
}
|
||||
64
modules/services/elephant.nix
Normal file
64
modules/services/elephant.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
tests/modules/services/elephant/config.toml
Normal file
3
tests/modules/services/elephant/config.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
[providers]
|
||||
default = ["desktopapplications", "runner"]
|
||||
max_results = 50
|
||||
5
tests/modules/services/elephant/default.nix
Normal file
5
tests/modules/services/elephant/default.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
elephant-example-config = ./example-config.nix;
|
||||
}
|
||||
9
tests/modules/services/elephant/elephant.service
Normal file
9
tests/modules/services/elephant/elephant.service
Normal 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
|
||||
25
tests/modules/services/elephant/example-config.nix
Normal file
25
tests/modules/services/elephant/example-config.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user