mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
clock-rs: add module
clock-rs is a modern, digital clock that effortlessly runs in your terminal
This commit is contained in:
parent
ac21ae3716
commit
14eda3db4e
8 changed files with 154 additions and 0 deletions
9
modules/misc/news/2025-04-20_20-12-03.nix
Normal file
9
modules/misc/news/2025-04-20_20-12-03.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
time = "2025-04-21T01:12:03+00:00";
|
||||||
|
condition = true;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.clock-rs'.
|
||||||
|
|
||||||
|
clock-rs is a modern, digital clock that effortlessly runs in your terminal.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -86,6 +86,7 @@ let
|
||||||
./programs/cavalier.nix
|
./programs/cavalier.nix
|
||||||
./programs/chawan.nix
|
./programs/chawan.nix
|
||||||
./programs/chromium.nix
|
./programs/chromium.nix
|
||||||
|
./programs/clock-rs.nix
|
||||||
./programs/cmus.nix
|
./programs/cmus.nix
|
||||||
./programs/command-not-found/command-not-found.nix
|
./programs/command-not-found/command-not-found.nix
|
||||||
./programs/comodoro.nix
|
./programs/comodoro.nix
|
||||||
|
|
|
||||||
62
modules/programs/clock-rs.nix
Normal file
62
modules/programs/clock-rs.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.programs.clock-rs;
|
||||||
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.maintainers; [ oughie ];
|
||||||
|
|
||||||
|
options.programs.clock-rs = {
|
||||||
|
enable = lib.mkEnableOption "clock-rs";
|
||||||
|
|
||||||
|
package = lib.mkPackageOption pkgs "clock-rs" { nullable = true; };
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = tomlFormat.type;
|
||||||
|
default = { };
|
||||||
|
description = "The configuration file to be used for clock-rs";
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
general = {
|
||||||
|
color = "magenta";
|
||||||
|
interval = 250;
|
||||||
|
blink = true;
|
||||||
|
bold = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
position = {
|
||||||
|
horizontal = "start";
|
||||||
|
vertical = "end";
|
||||||
|
};
|
||||||
|
|
||||||
|
date = {
|
||||||
|
fmt = "%A, %B %d, %Y";
|
||||||
|
use_12h = true;
|
||||||
|
utc = true;
|
||||||
|
hide_seconds = true;
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
home =
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
|
||||||
|
file."${configDir}/clock-rs/conf.toml" = lib.mkIf (cfg.settings != { }) {
|
||||||
|
source = tomlFormat.generate "clock-rs-config" cfg.settings;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -353,6 +353,7 @@ import nmtSrc {
|
||||||
./modules/programs/btop
|
./modules/programs/btop
|
||||||
./modules/programs/carapace
|
./modules/programs/carapace
|
||||||
./modules/programs/cava
|
./modules/programs/cava
|
||||||
|
./modules/programs/clock-rs
|
||||||
./modules/programs/cmus
|
./modules/programs/cmus
|
||||||
./modules/programs/comodoro
|
./modules/programs/comodoro
|
||||||
./modules/programs/darcs
|
./modules/programs/darcs
|
||||||
|
|
|
||||||
4
tests/modules/programs/clock-rs/default.nix
Normal file
4
tests/modules/programs/clock-rs/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
clock-rs-example-settings = ./example-settings.nix;
|
||||||
|
clock-rs-empty-settings = ./empty-settings.nix;
|
||||||
|
}
|
||||||
20
tests/modules/programs/clock-rs/empty-settings.nix
Normal file
20
tests/modules/programs/clock-rs/empty-settings.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.clock-rs.enable = true;
|
||||||
|
|
||||||
|
tests.stubs.clock-rs = { };
|
||||||
|
|
||||||
|
nmt.script =
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.isDarwin then
|
||||||
|
"home-files/Library/Application Support/clock-rs"
|
||||||
|
else
|
||||||
|
"home-files/.config/clock-rs";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
assertPathNotExists "${configDir}/conf.toml"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
[date]
|
||||||
|
fmt = "%A, %B %d, %Y"
|
||||||
|
hide_seconds = true
|
||||||
|
use_12h = true
|
||||||
|
utc = true
|
||||||
|
|
||||||
|
[general]
|
||||||
|
blink = true
|
||||||
|
bold = true
|
||||||
|
color = "magenta"
|
||||||
|
interval = 250
|
||||||
|
|
||||||
|
[position]
|
||||||
|
horizontal = "start"
|
||||||
|
vertical = "end"
|
||||||
42
tests/modules/programs/clock-rs/example-settings.nix
Normal file
42
tests/modules/programs/clock-rs/example-settings.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.clock-rs = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
general = {
|
||||||
|
color = "magenta";
|
||||||
|
interval = 250;
|
||||||
|
blink = true;
|
||||||
|
bold = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
position = {
|
||||||
|
horizontal = "start";
|
||||||
|
vertical = "end";
|
||||||
|
};
|
||||||
|
|
||||||
|
date = {
|
||||||
|
fmt = "%A, %B %d, %Y";
|
||||||
|
use_12h = true;
|
||||||
|
utc = true;
|
||||||
|
hide_seconds = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script =
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.isDarwin then
|
||||||
|
"home-files/Library/Application Support/clock-rs"
|
||||||
|
else
|
||||||
|
"home-files/.config/clock-rs";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
assertFileExists "${configDir}/conf.toml"
|
||||||
|
assertFileContent "${configDir}/conf.toml" \
|
||||||
|
${./example-settings-expected.toml}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue