Skip to content

Commit

Permalink
inori: init module
Browse files Browse the repository at this point in the history
  • Loading branch information
miku4k committed Jan 8, 2025
1 parent fcc4259 commit d69c795
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,10 @@
github = "ALameLlama";
githubId = 55490546;
};
lunahd = {
name = "Miku B";
email = "[email protected]";
github = "miku4k";
githubId = 89653242;
};
}
10 changes: 10 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,7 @@ in {
speed, features, or native UIs. Ghostty provides all three.
'';
}

{
time = "2025-01-04T15:00:00+00:00";
condition = hostPlatform.isLinux;
Expand All @@ -1960,6 +1961,15 @@ in {
as well as wf-shell.
'';
}

{
time = "2025-01-08T15:43:53+00:00";
message = ''
A new module is available: 'programs.inori'.
inori is a client for the Music Player Daemon (MPD)
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ let
./programs/i3status.nix
./programs/imv.nix
./programs/info.nix
./programs/inori.nix
./programs/ion.nix
./programs/irssi.nix
./programs/java.nix
Expand Down
47 changes: 47 additions & 0 deletions modules/programs/inori.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ lib, config, pkgs, ... }:

with lib;

let
cfg = config.programs.inori;

tomlFormat = pkgs.formats.toml { };
in {
meta.mointoiners = [ hm.maintainers.lunahd ];

options.programs.inori = {
enable = mkEnableOption "inori";

package = mkOption {
type = types.package;
default = pkgs.inori;
defaultText = literalExpression "pkgs.inori";
description = "The inori package to use.";
};

settings = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
{
seek_seconds = 10;
dvorak_keybindings = true;
}
'';
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/inori/config.toml`.
See <https://github.com/eshrh/inori/blob/master/CONFIGURATION.md> for available options.
'';
};
};

config = mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."inori/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "config.toml" cfg.settings;
};
};
}

1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ in import nmtSrc {
./modules/programs/htop
./modules/programs/hyfetch
./modules/programs/i3status
./modules/programs/inori
./modules/programs/irssi
./modules/programs/jujutsu
./modules/programs/joplin-desktop
Expand Down
11 changes: 11 additions & 0 deletions tests/modules/programs/inori/default-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ config, ... }:

{
config = {
programs.inori.enable = true;

nmt.script = ''
assertPathNotExist ${config.xdg.configHome}/inori/config.toml
'';
};
}
4 changes: 4 additions & 0 deletions tests/modules/programs/inori/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
inori-default-config = ./default-config.nix;
inori-full-config = ./full-config.nix;
}
46 changes: 46 additions & 0 deletions tests/modules/programs/inori/full-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{ config, ... }:

{
config = {
programs.inori = {
enable = true;
patch_array_keybindings = true;
settings = {
seek_seconds = 10;
dvorak_keybindings = true;
keybindings = {
toggle_playpause = [ "p" "<space>" ];
next_song = [ ">" "C-n" ];
previous_song = [ "<" "C-p" ];
seek = "<right>";
seek_backwards = "<left>";

up = "k";
down = "j";
left = "h";
right = "l";
top = [ "g g" "<home>" ];
bottom = [ "G" "<end>" ];
quit = [ "<esc>" "q" ];
};
theme = {
status_artist.fg = "#fab387";
status_album.fg = "#89b4fa";
status_title = {
fg = "#cba6f7";
add_modifier = "BOLD";
};
album.fg = "#89b4fa";
playing.fg = "#a6e3a1";
};
};
};

nmt.script = ''
assertFileExists ${config.xdg.configHome}/inori/config.toml
assertFileContent ${config.xdg.configHome}/inori/config.toml ${
./full-config.toml
}
'';
};
}
31 changes: 31 additions & 0 deletions tests/modules/programs/inori/full-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
seek_seconds = 10
dvorak_keybindings = true
[keybindings]
bottom = ["G", "<end>"]
down = "j"
left = "h"
next_song = [">", "C-n"]
previous_song = ["<", "C-p"]
quit = ["<esc>", "q"]
right = "l"
seek = "<right>"
seek_backwards = "<left>"
toggle_playpause = ["s p", "s <space>"]
top = ["g g", "<home>"]
up = "k"

[theme.album]
fg = "#89b4fa"

[theme.playing]
fg = "#a6e3a1"

[theme.status_album]
fg = "#89b4fa"

[theme.status_artist]
fg = "#fab387"

[theme.status_title]
add_modifier = "BOLD"
fg = "#cba6f7"

0 comments on commit d69c795

Please sign in to comment.