mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
Add an option to order Walker's user service after elephant.service and add a systemd Requires= dependency when enabled. The option defaults to services.elephant.enable, so Home Manager-managed Elephant setups work automatically while users can still enable the dependency for an externally managed elephant.service.
148 lines
4.2 KiB
Nix
148 lines
4.2 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib)
|
|
types
|
|
mkIf
|
|
mkMerge
|
|
mkEnableOption
|
|
mkPackageOption
|
|
mkOption
|
|
;
|
|
|
|
cfg = config.services.walker;
|
|
tomlFormat = pkgs.formats.toml { };
|
|
in
|
|
{
|
|
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
|
|
|
options.services.walker = {
|
|
enable = mkEnableOption "walker";
|
|
|
|
package = mkPackageOption pkgs "walker" { nullable = true; };
|
|
|
|
enableElephantIntegration = mkOption {
|
|
type = types.bool;
|
|
default = config.services.elephant.enable;
|
|
defaultText = lib.literalExpression "config.services.elephant.enable";
|
|
example = true;
|
|
description = ''
|
|
Whether to make Walker's systemd service depend on
|
|
{option}`services.elephant`.
|
|
'';
|
|
};
|
|
|
|
settings = mkOption {
|
|
inherit (tomlFormat) type;
|
|
default = { };
|
|
example = {
|
|
app_launch_prefix = "";
|
|
terminal_title_flag = "";
|
|
locale = "";
|
|
close_when_open = false;
|
|
theme = "default";
|
|
monitor = "";
|
|
hotreload_theme = false;
|
|
as_window = false;
|
|
timeout = 0;
|
|
disable_click_to_close = false;
|
|
force_keyboard_focus = false;
|
|
};
|
|
description = ''
|
|
Configuration settings for walker. All the available options can be found here:
|
|
<https://github.com/abenz1267/walker/blob/master/resources/config.toml>
|
|
'';
|
|
};
|
|
|
|
theme = mkOption {
|
|
type =
|
|
with types;
|
|
nullOr (submodule {
|
|
options = {
|
|
name = mkOption {
|
|
type = types.str;
|
|
default = "nixos";
|
|
description = "The theme name.";
|
|
};
|
|
|
|
style = mkOption {
|
|
type = lines;
|
|
default = "";
|
|
description = "The styling of the theme, written in GTK CSS.";
|
|
};
|
|
|
|
layout = mkOption {
|
|
type = with types; attrsOf (either path lines);
|
|
default = { };
|
|
description = ''
|
|
The GTK XML layout used.
|
|
See the default layout for the correct structure: <https://github.com/abenz1267/walker/tree/master/resources/themes/default>
|
|
'';
|
|
example = lib.literalExpression ''{ "item" = ./myfile.xml; };'';
|
|
};
|
|
};
|
|
});
|
|
default = null;
|
|
description = "The custom theme used by walker. Setting this option overrides `settings.theme`.";
|
|
};
|
|
|
|
systemd.enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
example = true;
|
|
description = "Whatever to enable Walker's Systemd Unit.";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
{
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.walker" pkgs lib.platforms.linux)
|
|
{
|
|
assertion = cfg.systemd.enable -> (cfg.package != null);
|
|
message = "Can't set services.walker.package to null if services.walker.systemd.enable is set to true;";
|
|
}
|
|
];
|
|
|
|
home.packages = lib.optional (cfg.package != null) cfg.package;
|
|
xdg.configFile."walker/config.toml" = mkIf (cfg.settings != { }) {
|
|
source = tomlFormat.generate "walker-config" cfg.settings;
|
|
};
|
|
systemd.user.services.walker = mkIf (cfg.systemd.enable && cfg.package != null) {
|
|
Unit = {
|
|
Description = "Walker - Application Runner";
|
|
}
|
|
// lib.optionalAttrs cfg.enableElephantIntegration {
|
|
After = [ "elephant.service" ];
|
|
Requires = [ "elephant.service" ];
|
|
};
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
|
Service = {
|
|
ExecStart = "${lib.getExe cfg.package} --gapplication-service";
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
}
|
|
(mkIf (cfg.theme != null) {
|
|
services.walker.settings.theme = cfg.theme.name;
|
|
xdg.configFile = {
|
|
"walker/themes/${cfg.theme.name}/style.css".text = cfg.theme.style;
|
|
}
|
|
// lib.mapAttrs' (
|
|
n: v:
|
|
lib.nameValuePair "walker/themes/${cfg.theme.name}/${n}.xml" {
|
|
source =
|
|
if builtins.isPath v || lib.isStorePath v then
|
|
v
|
|
else
|
|
pkgs.writeText "walker-theme-${cfg.theme.name}-${n}.xml" v;
|
|
}
|
|
) cfg.theme.layout;
|
|
})
|
|
]);
|
|
}
|