diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 05d55b67..bcaa6e48 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -299,6 +299,12 @@ github = "nurelin"; githubId = 5276274; }; + otavio = { + email = "otavio.salvador@ossystems.com.br"; + github = "otavio"; + githubId = 25278; + name = "Otavio Salvador"; + }; pltanton = { name = "pltanton"; email = "plotnikovanton@gmail.com"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e2b29cde..34d2aad1 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1221,6 +1221,15 @@ in A new module is available: 'programs.eza'. ''; } + + { + time = "2023-09-18T11:44:11+00:00"; + message = '' + A new module is available: 'programs.rio'. + + Rio is a hardware-accelerated GPU terminal emulator powered by WebGPU. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 9f1bd376..944d3d5b 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -178,6 +178,7 @@ let ./programs/qutebrowser.nix ./programs/rbw.nix ./programs/readline.nix + ./programs/rio.nix ./programs/ripgrep.nix ./programs/rofi-pass.nix ./programs/rofi.nix diff --git a/modules/programs/rio.nix b/modules/programs/rio.nix new file mode 100644 index 00000000..6d66c99d --- /dev/null +++ b/modules/programs/rio.nix @@ -0,0 +1,52 @@ +{ lib, pkgs, config, ... }: +let + cfg = config.programs.rio; + + settingsFormat = pkgs.formats.toml { }; + + inherit (pkgs.stdenv.hostPlatform) isDarwin; +in { + options.programs.rio = { + enable = lib.mkEnableOption null // { + description = lib.mdDoc '' + Enable Rio, a terminal built to run everywhere, as a native desktop applications by + Rust/WebGPU or even in the browsers powered by WebAssembly/WebGPU. + ''; + }; + + package = lib.mkPackageOption pkgs "rio" { }; + + settings = lib.mkOption { + type = settingsFormat.type; + default = { }; + description = '' + Configuration written to $XDG_CONFIG_HOME/rio/config.toml on Linux or + $HOME/Library/Application Support/rio/config.toml on Darwin. See + for options. + ''; + }; + }; + meta.maintainers = [ lib.maintainers.otavio ]; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + home.packages = [ cfg.package ]; + } + + # Only manage configuration if not empty + (lib.mkIf (cfg.settings != { } && !isDarwin) { + xdg.configFile."rio/config.toml".source = if lib.isPath cfg.settings then + cfg.settings + else + settingsFormat.generate "rio.toml" cfg.settings; + }) + + (lib.mkIf (cfg.settings != { } && isDarwin) { + home.file."Library/Application Support/rio/config.toml".source = + if lib.isPath cfg.settings then + cfg.settings + else + settingsFormat.generate "rio.toml" cfg.settings; + }) + ]); +} diff --git a/tests/default.nix b/tests/default.nix index 178bee05..ecbbd726 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -124,6 +124,7 @@ import nmt { ./modules/programs/qcal ./modules/programs/qutebrowser ./modules/programs/readline + ./modules/programs/rio ./modules/programs/ripgrep ./modules/programs/rtx ./modules/programs/sagemath diff --git a/tests/modules/programs/rio/default.nix b/tests/modules/programs/rio/default.nix new file mode 100644 index 00000000..a6aba7fe --- /dev/null +++ b/tests/modules/programs/rio/default.nix @@ -0,0 +1,4 @@ +{ + rio-example-settings = ./example-settings.nix; + rio-empty-settings = ./empty-settings.nix; +} diff --git a/tests/modules/programs/rio/empty-settings.nix b/tests/modules/programs/rio/empty-settings.nix new file mode 100644 index 00000000..064fc98f --- /dev/null +++ b/tests/modules/programs/rio/empty-settings.nix @@ -0,0 +1,11 @@ +_: + +{ + programs.rio.enable = true; + + test.stubs.rio = { }; + + nmt.script = '' + assertPathNotExists home-files/.config/rio + ''; +} diff --git a/tests/modules/programs/rio/example-settings.nix b/tests/modules/programs/rio/example-settings.nix new file mode 100644 index 00000000..f3e116f0 --- /dev/null +++ b/tests/modules/programs/rio/example-settings.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +let + inherit (pkgs.stdenv.hostPlatform) isDarwin; + + path = if isDarwin then + "Library/Application Support/rio/config.toml" + else + ".config/rio/config.toml"; + + expected = pkgs.writeText "rio-expected.toml" '' + cursor = "_" + padding-x = 0 + performance = "Low" + ''; +in { + programs.rio = { + enable = true; + package = config.lib.test.mkStubPackage { }; + + settings = { + cursor = "_"; + performance = "Low"; + padding-x = 0; + }; + }; + + nmt.script = '' + assertFileExists home-files/"${path}" + assertFileContent home-files/"${path}" '${expected}' + ''; +}