diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 1242d640..997c7815 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1667,6 +1667,18 @@ in { - 'nix.channels' ''; } + + { + time = "2024-06-22T05:49:48+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.blanket'. + + Blanket is a program you can use to improve your focus and increase + your productivity by listening to different sounds. See + https://github.com/rafaelmardojai/blanket for more. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 4e1f0e20..5b100d47 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -274,6 +274,7 @@ let ./services/barrier.nix ./services/batsignal.nix ./services/betterlockscreen.nix + ./services/blanket.nix ./services/blueman-applet.nix ./services/borgmatic.nix ./services/cachix-agent.nix diff --git a/modules/services/blanket.nix b/modules/services/blanket.nix new file mode 100644 index 00000000..5eeb2ab1 --- /dev/null +++ b/modules/services/blanket.nix @@ -0,0 +1,40 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.services.blanket; + + inherit (lib) mkIf mkEnableOption mkPackageOption hm platforms; +in { + meta.maintainers = [ lib.maintainers.daru-san ]; + + options.services.blanket = { + enable = mkEnableOption "blanket"; + + package = mkPackageOption pkgs "blanket" { }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "services.blanket" pkgs platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + systemd.user.services.blanket = { + Unit = { + Description = "Blanket daemon"; + Requires = [ "dbus.service" ]; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" "pipewire.service" ]; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + ExecStart = "${cfg.package}/bin/blanket --gapplication-service"; + Restart = "on-failure"; + RestartSec = 5; + }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 4d8d49d4..a5e7fe9e 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -224,6 +224,7 @@ in import nmtSrc { ./modules/services/activitywatch ./modules/services/avizo ./modules/services/barrier + ./modules/services/blanket ./modules/services/borgmatic ./modules/services/cachix-agent ./modules/services/cliphist diff --git a/tests/modules/services/blanket/basic-configuration.nix b/tests/modules/services/blanket/basic-configuration.nix new file mode 100644 index 00000000..740c4d08 --- /dev/null +++ b/tests/modules/services/blanket/basic-configuration.nix @@ -0,0 +1,31 @@ +{ ... }: + +{ + services.blanket = { enable = true; }; + + test.stubs.blanket = { }; + + nmt.script = '' + clientServiceFile=home-files/.config/systemd/user/blanket.service + + assertFileExists $clientServiceFile + assertFileContent $clientServiceFile ${ + builtins.toFile "expected.service" '' + [Install] + WantedBy=graphical-session.target + + [Service] + ExecStart=@blanket@/bin/blanket --gapplication-service + Restart=on-failure + RestartSec=5 + + [Unit] + After=graphical-session-pre.target + Description=Blanket daemon + PartOf=graphical-session.target + PartOf=pipewire.service + Requires=dbus.service + '' + } + ''; +} diff --git a/tests/modules/services/blanket/default.nix b/tests/modules/services/blanket/default.nix new file mode 100644 index 00000000..8a439a52 --- /dev/null +++ b/tests/modules/services/blanket/default.nix @@ -0,0 +1 @@ +{ blanket-basic-configuration = ./basic-configuration.nix; }