1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-23 10:19:48 +01:00

fnott: remove global properties generation

Rationale:

As of release 1.1.2[1], the configuration ini file supports
declaration of the `[main]` header as an alternative to global
properties by enumerating all sections and mapping each to the
respective parsing function. Global properties will still be parsed
correctly by fnott however generation adds unnecessary complexity to
the module. This commit removes the need for global properties
generation.

Changes:

- Fixed the FIXME at L118.

- Cleaned up unneeded let bindings.

- Changed the generation method to use the `pkgs.formats.ini` from
  pkgs-lib instead of the raw `generators` library. This was done for
  consistency and clarity as the `pkgs.formats.ini` is still required
  for type declaration and uses `generators` internally.

- Removed `global-properties` testcase.

- Updated `example-settings` testcase.

[1] - https://codeberg.org/dnkl/fnott/releases/tag/1.1.2
This commit is contained in:
polykernel 2021-10-14 23:39:01 -04:00 committed by Robert Helgesson
parent da8a78eec9
commit 46a69810cb
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
5 changed files with 7 additions and 48 deletions

View file

@ -8,15 +8,7 @@ let
concatStringsSep' = sep: list:
concatStringsSep sep (filter (x: x != "") list);
mkKeyValue = generators.mkKeyValueDefault { } "=";
genINI = generators.toINI { };
iniFormatType = with types;
let
iniAtom = types.nullOr (types.oneOf [ bool int float str ]) // {
description = "INI atom (null, bool, int, float or string)";
};
in attrsOf (attrsOf iniAtom);
iniFormat = pkgs.formats.ini { };
in {
options = {
services.fnott = {
@ -58,7 +50,7 @@ in {
};
settings = mkOption {
type = iniFormatType;
type = iniFormat.type;
default = { };
description = ''
Configuration written to
@ -114,14 +106,7 @@ in {
};
};
xdg.configFile."fnott/fnott.ini" = {
# FIXME: Remove after next version release (https://codeberg.org/dnkl/fnott/pulls/24).
text = concatStringsSep' "\n" [
(optionalString (cfg.settings ? main) ''
${concatStringsSep "\n" (mapAttrsToList mkKeyValue cfg.settings.main)}
'')
(genINI (removeAttrs cfg.settings [ "main" ]))
];
};
xdg.configFile."fnott/fnott.ini".source =
iniFormat.generate "fnott.ini" cfg.settings;
};
}

View file

@ -1,5 +1,4 @@
{
fnott-example-settings = ./example-settings.nix;
fnott-global-properties = ./global-properties.nix;
fnott-systemd-user-service = ./systemd-user-service.nix;
}

View file

@ -1,6 +1,7 @@
notification-margin=5
[low]
timeout=5
title-color=ffffff
title-font=Dina:weight=bold:slant=italic
[main]
notification-margin=5

View file

@ -1,2 +0,0 @@
max-icon-size=32
notification-margin=5

View file

@ -1,24 +0,0 @@
{ config, lib, pkgs, ... }:
# FIXME: Deprecate on next version release of fnott (https://codeberg.org/dnkl/fnott/pulls/24).
{
config = {
services.fnott = {
enable = true;
package = config.lib.test.mkStubPackage { };
settings = {
main = {
max-icon-size = 32;
notification-margin = 5;
};
};
};
nmt.script = ''
assertFileContent \
home-files/.config/fnott/fnott.ini \
${./global-properties-expected.ini}
'';
};
}