From 5233547d76ee4eda5e4ca6a7a806c7b2b53bee49 Mon Sep 17 00:00:00 2001 From: Matan Bendix Shenhav Date: Sat, 20 Sep 2025 11:46:28 +0200 Subject: [PATCH] feat(flake): systemd service --- flake.nix | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/flake.nix b/flake.nix index 401b370d..09696b11 100644 --- a/flake.nix +++ b/flake.nix @@ -80,5 +80,60 @@ }); defaultPackage = eachSystem (system: self.packages.${system}.default); + + nixosModules.default = + { + config, + lib, + pkgs, + ... + }: + let + cfg = config.services.noctalia-shell; + in + { + options.services.noctalia-shell = { + enable = lib.mkEnableOption "Noctalia shell systemd service"; + + package = lib.mkOption { + type = lib.types.package; + default = self.packages.${pkgs.system}.default; + description = "The noctalia-shell package to use"; + }; + + target = lib.mkOption { + type = lib.types.str; + default = "graphical-session.target"; + example = "hyprland-session.target"; + description = "The systemd target for the noctalia-shell service."; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.user.services.noctalia-shell = { + description = "Noctalia Shell - Wayland desktop shell"; + documentation = [ "https://github.com/noctalia-dev/noctalia-shell" ]; + after = [ cfg.target ]; + partOf = [ cfg.target ]; + wantedBy = [ cfg.target ]; + + unitConfig = { + StartLimitIntervalSec = 60; + StartLimitBurst = 3; + }; + + serviceConfig = { + ExecStart = "${cfg.package}/bin/noctalia-shell"; + Restart = "on-failure"; + RestartSec = 3; + TimeoutStartSec = 10; + TimeoutStopSec = 5; + Environment = [ "PATH=${config.system.path}/bin" ]; + }; + }; + + environment.systemPackages = [ cfg.package ]; + }; + }; }; }