posting: add module
posting: add news
This commit is contained in:
parent
a1fc9a1cc3
commit
f4d01c1d87
7 changed files with 178 additions and 0 deletions
12
modules/misc/news/2026/07/2026-07-08_22-43-29.nix
Normal file
12
modules/misc/news/2026/07/2026-07-08_22-43-29.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
time = "2026-07-08T20:43:23+00:00";
|
||||
condition = true;
|
||||
message = ''
|
||||
A new module is available: 'programs.posting'.
|
||||
|
||||
Posting is an open-source terminal-based API client for developing
|
||||
and testing APIs. The module supports configuration via
|
||||
`programs.posting.settings` and custom themes via
|
||||
`programs.posting.themes`.
|
||||
'';
|
||||
}
|
||||
97
modules/programs/posting.nix
Normal file
97
modules/programs/posting.nix
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.programs.posting;
|
||||
yamlFormat = pkgs.formats.yaml { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.hm.maintainers.reesilva ];
|
||||
|
||||
options.programs.posting = {
|
||||
enable = lib.mkEnableOption "Posting";
|
||||
|
||||
package = lib.mkPackageOption pkgs "posting" { nullable = true; };
|
||||
|
||||
settings = lib.mkOption {
|
||||
inherit (yamlFormat) type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
theme = "custom";
|
||||
layout = "horizontal";
|
||||
response = {
|
||||
prettify_json = false;
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/posting/config.yaml`.
|
||||
|
||||
See <https://posting.sh/guide/configuration/>
|
||||
for supported values.
|
||||
'';
|
||||
};
|
||||
|
||||
themes = lib.mkOption {
|
||||
type =
|
||||
with lib.types;
|
||||
attrsOf (oneOf [
|
||||
yamlFormat.type
|
||||
path
|
||||
lines
|
||||
]);
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
custom = {
|
||||
name = "custom";
|
||||
primary = "#4e78c4";
|
||||
secondary = "#f39c12";
|
||||
accent = "#e74c3c";
|
||||
background = "#0e1726";
|
||||
surface = "#17202a";
|
||||
error = "#e74c3c";
|
||||
success = "#2ecc71";
|
||||
warning = "#f1c40f";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Each theme is written to
|
||||
{file}`$XDG_DATA_HOME/posting/themes/NAME.yaml`.
|
||||
|
||||
See <https://posting.sh/guide/themes/>
|
||||
for more information.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."posting/config.yaml" = lib.mkIf (cfg.settings != { }) {
|
||||
source = yamlFormat.generate "posting-config.yaml" cfg.settings;
|
||||
};
|
||||
|
||||
xdg.dataFile = lib.mkIf (cfg.themes != { }) (
|
||||
lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "posting/themes/${name}.yaml" {
|
||||
source =
|
||||
if builtins.isPath value || lib.isStorePath value then
|
||||
value
|
||||
else if lib.isString value then
|
||||
pkgs.writeText "posting-theme-${name}.yaml" value
|
||||
else
|
||||
yamlFormat.generate "posting-theme-${name}.yaml" value;
|
||||
}
|
||||
) cfg.themes
|
||||
);
|
||||
};
|
||||
}
|
||||
39
tests/modules/programs/posting/configuration.nix
Normal file
39
tests/modules/programs/posting/configuration.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
programs.posting = {
|
||||
enable = true;
|
||||
settings = {
|
||||
animation = "basic";
|
||||
heading = {
|
||||
show_host = false;
|
||||
};
|
||||
layout = "horizontal";
|
||||
response = {
|
||||
prettify_json = false;
|
||||
};
|
||||
theme = "custom";
|
||||
};
|
||||
themes = {
|
||||
custom = {
|
||||
name = "custom";
|
||||
primary = "#4e78c4";
|
||||
secondary = "#f39c12";
|
||||
accent = "#e74c3c";
|
||||
background = "#0e1726";
|
||||
surface = "#17202a";
|
||||
error = "#e74c3c";
|
||||
success = "#2ecc71";
|
||||
warning = "#f1c40f";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/posting/config.yaml
|
||||
assertFileContent home-files/.config/posting/config.yaml \
|
||||
${./expected-config.yaml}
|
||||
|
||||
assertFileExists home-files/.local/share/posting/themes/custom.yaml
|
||||
assertFileContent home-files/.local/share/posting/themes/custom.yaml \
|
||||
${./expected-theme.yaml}
|
||||
'';
|
||||
}
|
||||
4
tests/modules/programs/posting/default.nix
Normal file
4
tests/modules/programs/posting/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
posting-empty-settings = ./empty-settings.nix;
|
||||
posting-configuration = ./configuration.nix;
|
||||
}
|
||||
10
tests/modules/programs/posting/empty-settings.nix
Normal file
10
tests/modules/programs/posting/empty-settings.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
programs.posting = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/posting/config.yaml
|
||||
assertPathNotExists home-files/.local/share/posting
|
||||
'';
|
||||
}
|
||||
7
tests/modules/programs/posting/expected-config.yaml
Normal file
7
tests/modules/programs/posting/expected-config.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
animation: basic
|
||||
heading:
|
||||
show_host: false
|
||||
layout: horizontal
|
||||
response:
|
||||
prettify_json: false
|
||||
theme: custom
|
||||
9
tests/modules/programs/posting/expected-theme.yaml
Normal file
9
tests/modules/programs/posting/expected-theme.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
accent: '#e74c3c'
|
||||
background: '#0e1726'
|
||||
error: '#e74c3c'
|
||||
name: custom
|
||||
primary: '#4e78c4'
|
||||
secondary: '#f39c12'
|
||||
success: '#2ecc71'
|
||||
surface: '#17202a'
|
||||
warning: '#f1c40f'
|
||||
Loading…
Add table
Add a link
Reference in a new issue