mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
asciinema: Add module to configure package
Enabling and defining minimal config file example;
```nix
{
programs.asciinema = {
enable = true;
settings = {
session.idle_time_limit = 2;
};
};
}
```
... _Should_ result in output `~/.config/asciinema/config.toml` of;
```toml
[session]
idle_time_limit = 2
```
Co-authored-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
dd2b0f7492
commit
bd92e8ee4a
4 changed files with 159 additions and 0 deletions
14
modules/misc/news/2025/10/2025-10-02_19-36-31.nix
Normal file
14
modules/misc/news/2025/10/2025-10-02_19-36-31.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
time = "2025-10-03T02:36:31+00:00";
|
||||||
|
condition = true;
|
||||||
|
message = ''
|
||||||
|
A new module is available: `programs.asciinema`
|
||||||
|
|
||||||
|
`asciinema` is a tool for recording, replaying, publishing, and live
|
||||||
|
streaming terminal session.
|
||||||
|
|
||||||
|
This module enables declaring configuration via `.settings`, check the
|
||||||
|
official documentation for details;
|
||||||
|
https://docs.asciinema.org/manual/cli/quick-start/
|
||||||
|
'';
|
||||||
|
}
|
||||||
82
modules/programs/asciinema.nix
Normal file
82
modules/programs/asciinema.nix
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
mkPackageOption
|
||||||
|
;
|
||||||
|
|
||||||
|
formatter = pkgs.formats.toml { };
|
||||||
|
|
||||||
|
cfg = config.programs.asciinema;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = [
|
||||||
|
lib.maintainers.S0AndS0
|
||||||
|
];
|
||||||
|
|
||||||
|
options.programs.asciinema = {
|
||||||
|
enable = mkEnableOption "Enable installing asciinema and writing configuration file";
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "asciinema" {
|
||||||
|
nullable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
inherit (formatter) type;
|
||||||
|
|
||||||
|
default = { };
|
||||||
|
|
||||||
|
example = {
|
||||||
|
server.url = "https://asciinema.example.com";
|
||||||
|
|
||||||
|
session = {
|
||||||
|
command = "/run/current-system/sw/bin/bash -l";
|
||||||
|
capture_input = true;
|
||||||
|
capture_env = "SHELL,TERM,USER";
|
||||||
|
idle_time_limit = 2;
|
||||||
|
pause_key = "^p";
|
||||||
|
add_marker_key = "^x";
|
||||||
|
prefix_key = "^a";
|
||||||
|
};
|
||||||
|
|
||||||
|
playback = {
|
||||||
|
speed = 2;
|
||||||
|
pause_key = "^p";
|
||||||
|
step_key = "s";
|
||||||
|
next_marker_key = "m";
|
||||||
|
};
|
||||||
|
|
||||||
|
notifications = {
|
||||||
|
enable = false;
|
||||||
|
command = ''tmux display-message "$TEXT"'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
description = ''
|
||||||
|
Declare-able configurations for asciinema written to
|
||||||
|
{file}`$XDG_CONFIG_HOME/asciinema/config.toml`.
|
||||||
|
|
||||||
|
|
||||||
|
Check official docs for available configurations;
|
||||||
|
https://docs.asciinema.org/manual/cli/configuration/v3/#config-file
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
xdg.configFile."asciinema/config.toml" = mkIf (cfg.settings != { }) {
|
||||||
|
source = formatter.generate "asciinema_config.toml" cfg.settings;
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = mkIf (cfg.package != null) [
|
||||||
|
cfg.package
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
3
tests/modules/programs/asciinema/default.nix
Normal file
3
tests/modules/programs/asciinema/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
asciinema-settings = ./settings.nix;
|
||||||
|
}
|
||||||
60
tests/modules/programs/asciinema/settings.nix
Normal file
60
tests/modules/programs/asciinema/settings.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
programs.asciinema = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
server.url = "https://asciinema.example.com";
|
||||||
|
|
||||||
|
session = {
|
||||||
|
command = "/run/current-system/sw/bin/bash -l";
|
||||||
|
capture_input = true;
|
||||||
|
capture_env = "SHELL,TERM,USER";
|
||||||
|
idle_time_limit = 2;
|
||||||
|
pause_key = "^p";
|
||||||
|
add_marker_key = "^x";
|
||||||
|
prefix_key = "^a";
|
||||||
|
};
|
||||||
|
|
||||||
|
playback = {
|
||||||
|
speed = 2;
|
||||||
|
pause_key = "^p";
|
||||||
|
step_key = "s";
|
||||||
|
next_marker_key = "m";
|
||||||
|
};
|
||||||
|
|
||||||
|
notifications = {
|
||||||
|
enable = false;
|
||||||
|
command = ''tmux display-message "$TEXT"'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
## TODO: check that `command` quote escaping doesn't break things
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/asciinema/config.toml
|
||||||
|
assertFileContent home-files/.config/asciinema/config.toml \
|
||||||
|
${builtins.toFile "expected.asciinema_config.toml" ''
|
||||||
|
[notifications]
|
||||||
|
command = "tmux display-message \"$TEXT\""
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
[playback]
|
||||||
|
next_marker_key = "m"
|
||||||
|
pause_key = "^p"
|
||||||
|
speed = 2
|
||||||
|
step_key = "s"
|
||||||
|
|
||||||
|
[server]
|
||||||
|
url = "https://asciinema.example.com"
|
||||||
|
|
||||||
|
[session]
|
||||||
|
add_marker_key = "^x"
|
||||||
|
capture_env = "SHELL,TERM,USER"
|
||||||
|
capture_input = true
|
||||||
|
command = "/run/current-system/sw/bin/bash -l"
|
||||||
|
idle_time_limit = 2
|
||||||
|
pause_key = "^p"
|
||||||
|
prefix_key = "^a"
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue