diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index a159df7f..e75541d9 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -317,6 +317,12 @@ github = "nurelin"; githubId = 5276274; }; + omernaveedxyz = { + name = "Omer Naveed"; + email = "omer@omernaveed.dev"; + github = "omernaveedxyz"; + githubId = 112912585; + }; otavio = { email = "otavio.salvador@ossystems.com.br"; github = "otavio"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index c13b0b8f..98e9c2be 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1363,6 +1363,14 @@ in A new module is available: 'programs.sftpman'. ''; } + + { + time = "2023-12-29T08:22:40+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'programs.bemenu'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 96a9b0b8..1dbb0460 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -63,6 +63,7 @@ let ./programs/bat.nix ./programs/bacon.nix ./programs/beets.nix + ./programs/bemenu.nix ./programs/borgmatic.nix ./programs/bottom.nix ./programs/boxxy.nix diff --git a/modules/programs/bemenu.nix b/modules/programs/bemenu.nix new file mode 100644 index 00000000..3cfd0002 --- /dev/null +++ b/modules/programs/bemenu.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.bemenu; + +in { + meta.maintainers = [ hm.maintainers.omernaveedxyz ]; + + options.programs.bemenu = { + enable = mkEnableOption "bemenu"; + + package = mkPackageOption pkgs "bemenu" { }; + + settings = mkOption { + type = with types; attrsOf (oneOf [ str int bool ]); + default = { }; + example = literalExpression '' + { + line-height = 28; + prompt = "open"; + ignorecase = true; + fb = "#1e1e2e"; + ff = "#cdd6f4"; + nb = "#1e1e2e"; + nf = "#cdd6f4"; + tb = "#1e1e2e"; + hb = "#1e1e2e"; + tf = "#f38ba8"; + hf = "#f9e2af"; + af = "#cdd6f4"; + ab = "#1e1e2e"; + } + ''; + description = + "Configuration options for bemenu. See {manpage}`bemenu(1)`."; + }; + }; + + config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "programs.bemenu" pkgs platforms.linux) ]; + + home.packages = [ cfg.package ]; + + home.sessionVariables = mkIf (cfg.settings != { }) { + BEMENU_OPTS = cli.toGNUCommandLineShell { } cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index c7b7892c..77dcbe0f 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -181,6 +181,7 @@ import nmt { ./modules/programs/autorandr ./modules/programs/awscli ./modules/programs/beets # One test relies on services.mpd + ./modules/programs/bemenu ./modules/programs/borgmatic ./modules/programs/boxxy ./modules/programs/firefox diff --git a/tests/modules/programs/bemenu/basic-configuration.nix b/tests/modules/programs/bemenu/basic-configuration.nix new file mode 100644 index 00000000..3284975c --- /dev/null +++ b/tests/modules/programs/bemenu/basic-configuration.nix @@ -0,0 +1,26 @@ +{ + programs.bemenu = { + enable = true; + settings = { + line-height = 28; + prompt = "open"; + ignorecase = true; + fb = "#1e1e2e"; + ff = "#cdd6f4"; + nb = "#1e1e2e"; + nf = "#cdd6f4"; + tb = "#1e1e2e"; + hb = "#1e1e2e"; + tf = "#f38ba8"; + hf = "#f9e2af"; + af = "#cdd6f4"; + ab = "#1e1e2e"; + }; + }; + + nmt.script = '' + assertFileExists home-path/etc/profile.d/hm-session-vars.sh + assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ + "export BEMENU_OPTS=\"'--ab' '#1e1e2e' '--af' '#cdd6f4' '--fb' '#1e1e2e' '--ff' '#cdd6f4' '--hb' '#1e1e2e' '--hf' '#f9e2af' '--ignorecase' '--line-height' '28' '--nb' '#1e1e2e' '--nf' '#cdd6f4' '--prompt' 'open' '--tb' '#1e1e2e' '--tf' '#f38ba8'\"" + ''; +} diff --git a/tests/modules/programs/bemenu/default.nix b/tests/modules/programs/bemenu/default.nix new file mode 100644 index 00000000..8ae2849e --- /dev/null +++ b/tests/modules/programs/bemenu/default.nix @@ -0,0 +1,4 @@ +{ + bemenu-empty-configuration = ./empty-configuration.nix; + bemenu-basic-configuration = ./basic-configuration.nix; +} diff --git a/tests/modules/programs/bemenu/empty-configuration.nix b/tests/modules/programs/bemenu/empty-configuration.nix new file mode 100644 index 00000000..5e56d9ed --- /dev/null +++ b/tests/modules/programs/bemenu/empty-configuration.nix @@ -0,0 +1,9 @@ +{ + programs.bemenu = { enable = true; }; + + nmt.script = '' + assertFileExists home-path/etc/profile.d/hm-session-vars.sh + assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh \ + "export BEMENU_OPTS" + ''; +}