Skip to content

Commit

Permalink
conky: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleocheng authored and rycee committed Apr 30, 2024
1 parent 28ef93b commit 6d3b6dc
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,18 @@ in {
your habits being tracked. See https://freetubeapp.io/ for more.
'';
}

{
time = "2024-04-30T21:57:23+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.conky'.
Conky is a system monitor for X. Conky can display just about
anything, either on your root desktop or in its own window. See
https://conky.cc/ for more.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ let
./services/clipman.nix
./services/clipmenu.nix
./services/comodoro.nix
./services/conky.nix
./services/copyq.nix
./services/darkman.nix
./services/devilspie2.nix
Expand Down
53 changes: 53 additions & 0 deletions modules/services/conky.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ config, lib, pkgs, ... }:

let

cfg = config.services.conky;

in with lib; {
meta.maintainers = [ hm.maintainers.kaleo ];

options = {
services.conky = {
enable = mkEnableOption "Conky, a light-weight system monitor";

package = mkPackageOption pkgs "conky" { };

extraConfig = lib.mkOption {
type = types.lines;
default = "";
description = ''
Configuration used by the Conky daemon. Check
<https://github.com/brndnmtthws/conky/wiki/Configurations> for
options. If not set, the default configuration, as described by
{command}`conky --print-config`, will be used.
'';
};
};
};

config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "services.conky" pkgs platforms.linux) ];

home.packages = [ cfg.package ];

systemd.user.services.conky = {
Unit = {
Description = "Conky - Lightweight system monitor";
After = [ "graphical-session.target" ];
};

Service = {
Restart = "always";
RestartSec = "3";
ExecStart = toString ([ "${pkgs.conky}/bin/conky" ]
++ optional (cfg.extraConfig != "")
"--config ${pkgs.writeText "conky.conf" cfg.extraConfig}");
};

Install.WantedBy = [ "graphical-session.target" ];
};
};
}

1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ in import nmtSrc {
./modules/services/cliphist
./modules/services/clipman
./modules/services/comodoro
./modules/services/conky
./modules/services/darkman
./modules/services/devilspie2
./modules/services/dropbox
Expand Down
7 changes: 7 additions & 0 deletions tests/modules/services/conky/basic-configuration.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
conky.text = [[
S Y S T E M I N F O
$hr
Host:$alignr $nodename
Uptime:$alignr $uptime
RAM:$alignr $mem/$memmax
]]
30 changes: 30 additions & 0 deletions tests/modules/services/conky/basic-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ config, pkgs, ... }:

{
services.conky = {
enable = true;
extraConfig = ''
conky.text = [[
S Y S T E M I N F O
$hr
Host:$alignr $nodename
Uptime:$alignr $uptime
RAM:$alignr $mem/$memmax
]]
'';
};

test.stubs.conky = { };

nmt.script = ''
serviceFile="$TESTED/home-files/.config/systemd/user/conky.service"
assertFileExists $serviceFile
assertFileRegex "$serviceFile" \
'ExecStart=@conky@/bin/conky --config .*conky.conf'
configFile="$(grep -o '/nix.*conky.conf' "$serviceFile")"
assertFileContent "$configFile" \
${./basic-configuration.conf}
'';
}
1 change: 1 addition & 0 deletions tests/modules/services/conky/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ conky-basic-configuration = ./basic-configuration.nix; }

0 comments on commit 6d3b6dc

Please sign in to comment.