diff --git a/flake.nix b/flake.nix index 238b8f4..6a4595d 100644 --- a/flake.nix +++ b/flake.nix @@ -12,8 +12,8 @@ ... }: { - # NixOS module (system-independent) - nixosModules.default = import ./nix/nixos-module.nix; + # Home Manager module (system-independent) + homeManagerModules.default = import ./nix/nixos-module.nix; # Overlay to add systant to pkgs overlays.default = final: prev: { diff --git a/nix/nixos-module.nix b/nix/nixos-module.nix index 0ef7210..cd0925d 100644 --- a/nix/nixos-module.nix +++ b/nix/nixos-module.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: let - cfg = config.systant; + cfg = config.services.systant; settingsFormat = pkgs.formats.toml { }; configFile = if cfg.configFile != null @@ -11,7 +11,7 @@ let else null; in { - options.systant = { + options.services.systant = { enable = lib.mkEnableOption "systant system monitoring agent"; package = lib.mkOption { @@ -62,17 +62,16 @@ in }; config = lib.mkIf cfg.enable { - # Make the package available system-wide - environment.systemPackages = [ cfg.package ]; + home.packages = [ cfg.package ]; - # Systemd user service - runs in user session with user's environment systemd.user.services.systant = { - description = "Systant system monitoring agent"; - wantedBy = [ "default.target" ]; - after = [ "network-online.target" ]; - wants = [ "network-online.target" ]; + Unit = { + Description = "Systant system monitoring agent"; + After = [ "network-online.target" ]; + Wants = [ "network-online.target" ]; + }; - serviceConfig = { + Service = { Type = "simple"; ExecStart = if configFile != null @@ -81,6 +80,10 @@ in Restart = "on-failure"; RestartSec = "5s"; }; + + Install = { + WantedBy = [ "default.target" ]; + }; }; }; }