diff options
| author | Maximilian Bosch <maximilian@mbosch.me> | 2023-09-21 00:05:35 +0200 |
|---|---|---|
| committer | Maximilian Bosch <maximilian@mbosch.me> | 2023-09-21 13:17:13 +0200 |
| commit | 11376df6d40c8fdbbd3c9a048b742dc032a88d15 (patch) | |
| tree | 721577cc368dc8fc2f80910f7d0556ff4c11315c /pkgs/development/python-modules/termplotlib/gnuplot-subprocess.patch | |
| parent | 0a71cf07a82eacd0a618fe7ba7016f7de5f5c2f5 (diff) | |
nixos/rust-motd: allow ordering sections by `priority`
Closes #234802
The problem here is that with e.g.
{
uptime.prefix = "Up";
banner.command = "hostname | figlet -f slant";
}
`banner` still appears before `uptime` in the final motd text because
Nix sorts attribute names alphabetically internally.
To work around this without breaking compatibility or losing the
property to override individual sections in other modules - e.g.
{
banner.color = mkForce "blue";
}
I decided to introduce an option `priority` here, similar to the
priority field for `nginx`[1] and with the same semantics (i.e. higher
value means lower priority).
Internally a bunch of env vars are generated, i.e. `env0` to `envN` for
`N` sections with each of them containing a declaration for the TOML,
i.e. `env0` contains `{ uptime.prefix = "Up"; }` and `env1` contains
`{ banner.command = "hostname | figlet -f slant"; }` if `uptime.priority`
is set to a value below 1000.
In this order, the declarations are concatenated together by `jq(1)`
which doesn't sort keys alphabetically which results in a JSON
representation with `uptime` before `banner`. This is finally piped to
`json2toml` which converts this into TOML for rust-motd.
[1] https://nixos.org/manual/nixos/unstable/options#opt-services.nginx.virtualHosts._name_.locations._name_.priority
Diffstat (limited to 'pkgs/development/python-modules/termplotlib/gnuplot-subprocess.patch')
0 files changed, 0 insertions, 0 deletions
