Skip to content

Commit

Permalink
cava: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
bddvlpr authored and rycee committed Oct 24, 2023
1 parent f540f30 commit 6045b68
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,13 @@ in
A new module is available: 'services.darkman'.
'';
}

{
time = "2023-10-24T06:14:53+00:00";
message = ''
A new module is available: 'programs.cava'.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ let
./programs/browserpass.nix
./programs/btop.nix
./programs/carapace.nix
./programs/cava.nix
./programs/chromium.nix
./programs/command-not-found/command-not-found.nix
./programs/comodoro.nix
Expand Down
52 changes: 52 additions & 0 deletions modules/programs/cava.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{ pkgs, config, lib, ... }:

with lib;

let

cfg = config.programs.cava;

iniFmt = pkgs.formats.ini { };

in {
meta.maintainers = [ maintainers.bddvlpr ];

options.programs.cava = {
enable = mkEnableOption "Cava audio visualizer";

package = mkPackageOption pkgs "cava" { };

settings = mkOption {
type = iniFmt.type;
default = { };
example = literalExpression ''
{
general.framerate = 60;
input.method = "alsa";
smoothing.noise_reduction = 88;
color = {
background = "'#000000'";
foreground = "'#FFFFFF'";
};
}
'';
description = ''
Settings to be written to the Cava configuration file. See
<https://github.com/karlstav/cava/blob/master/example_files/config> for
all available options.
'';
};
};

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

xdg.configFile."cava/config" = mkIf (cfg.settings != { }) {
text = ''
; Generated by Home Manager
${generators.toINI { } cfg.settings}
'';
};
};
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import nmt {
./modules/programs/browserpass
./modules/programs/btop
./modules/programs/carapace
./modules/programs/cava
./modules/programs/comodoro
./modules/programs/darcs
./modules/programs/dircolors
Expand Down
15 changes: 15 additions & 0 deletions tests/modules/programs/cava/cava-basic-configuration-expected.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; Generated by Home Manager

[color]
background='#000000'
foreground='#ffffff'

[general]
framerate=30

[input]
source=alsa

[smoothing]
noise_reduction=65

25 changes: 25 additions & 0 deletions tests/modules/programs/cava/cava-basic-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ config, pkgs, ... }:

{
programs.cava = {
enable = true;

package = config.lib.test.mkStubPackage { };

settings = {
general.framerate = 30;
input.source = "alsa";
smoothing.noise_reduction = 65;
color = {
background = "'#000000'";
foreground = "'#ffffff'";
};
};
};

nmt.script = ''
configFile=home-files/.config/cava/config
assertFileExists $configFile
assertFileContent $configFile ${./cava-basic-configuration-expected.ini}
'';
}
1 change: 1 addition & 0 deletions tests/modules/programs/cava/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ cava-basic-configuration = ./cava-basic-configuration.nix; }

0 comments on commit 6045b68

Please sign in to comment.