Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rio: add module #4118

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@
github = "nurelin";
githubId = 5276274;
};
otavio = {
email = "[email protected]";
github = "otavio";
githubId = 25278;
name = "Otavio Salvador";
};
pltanton = {
name = "pltanton";
email = "[email protected]";
Expand Down
9 changes: 9 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
otavio marked this conversation as resolved.
Show resolved Hide resolved

Rio is a hardware-accelerated GPU terminal emulator powered by WebGPU.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions modules/programs/rio.nix
Original file line number Diff line number Diff line change
@@ -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 <filename>$XDG_CONFIG_HOME/rio/config.toml</filename> on Linux or
<filename>$HOME/Library/Application Support/rio/config.toml</filename> on Darwin. See
<link xlink:href="https://raphamorim.io/rio/docs/#configuration-file"/> 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 =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe xdg.configFile does that automatically ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? it doesn't seem to be the case. Can you point me the source code where this is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the code and let the tests run and it failed. So it doesn't work indeed.

zsh-session-variables: OK
rio-example-settings: FAILED
Expected home-files/Library/Application Support/rio/config.toml to exist but it was not found.
For further reference please introspect /nix/store/ph3drnq8yckanhmkqz1jp0gmgj4l7nsg-nmt-report-rio-example-settings

if lib.isPath cfg.settings then
cfg.settings
else
settingsFormat.generate "rio.toml" cfg.settings;
})
]);
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/modules/programs/rio/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
rio-example-settings = ./example-settings.nix;
rio-empty-settings = ./empty-settings.nix;
}
11 changes: 11 additions & 0 deletions tests/modules/programs/rio/empty-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_:

{
programs.rio.enable = true;

test.stubs.rio = { };

nmt.script = ''
assertPathNotExists home-files/.config/rio
'';
}
32 changes: 32 additions & 0 deletions tests/modules/programs/rio/example-settings.nix
Original file line number Diff line number Diff line change
@@ -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}'
'';
}