mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Nix: add systemd service to home-module
This commit is contained in:
committed by
Matan Bendix Shenhav
parent
a894cdb925
commit
7b634783ae
+32
-2
@@ -16,6 +16,8 @@ in {
|
||||
options.programs.noctalia-shell = {
|
||||
enable = lib.mkEnableOption "Noctalia shell configuration";
|
||||
|
||||
systemd.enable = lib.mkEnableOption "Noctalia shell systemd integration";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
description = "The noctalia-shell package to use";
|
||||
@@ -103,18 +105,46 @@ in {
|
||||
useApp2Unit = cfg.settings.appLauncher.useApp2Unit or false;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
systemd.user.services.noctalia-shell = lib.mkIf cfg.systemd.enable {
|
||||
Unit = {
|
||||
Description = "Noctalia Shell - Wayland desktop shell";
|
||||
Documentation = "https://docs.noctalia.dev/docs";
|
||||
PartOf = [ config.wayland.systemd.target ];
|
||||
After = [ config.wayland.systemd.target ];
|
||||
X-Restart-Triggers = [ "${config.xdg.configFile."noctalia/settings.json".source}" ]
|
||||
++ lib.optional (cfg.colors != { }) "${config.xdg.configFile."noctalia/colors.json".source}";
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = lib.getExe cfg.package;
|
||||
Restart = "on-failure";
|
||||
Environment = [
|
||||
"NOCTALIA_SETTINGS_FALLBACK=%h/.config/noctalia/gui-settings.json"
|
||||
];
|
||||
};
|
||||
|
||||
Install.WantedBy = [ config.wayland.systemd.target ];
|
||||
};
|
||||
|
||||
home.packages = lib.optional useApp2Unit cfg.app2unit.package
|
||||
++ lib.optional (cfg.package != null) cfg.package;
|
||||
|
||||
xdg.configFile = {
|
||||
"noctalia/settings.json" = {
|
||||
onChange = restart;
|
||||
onChange = lib.mkIf (!cfg.systemd.enable) restart;
|
||||
text = builtins.toJSON cfg.settings;
|
||||
};
|
||||
"noctalia/colors.json" = lib.mkIf (cfg.colors != {}) {
|
||||
onChange = restart;
|
||||
onChange = lib.mkIf (!cfg.systemd.enable) restart;
|
||||
text = builtins.toJSON cfg.colors;
|
||||
};
|
||||
};
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = !cfg.systemd.enable || cfg.package != null;
|
||||
message = "noctalia-shell: The package option must not be null when systemd service is enabled.";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user