lib: init formats subset

This commit is contained in:
Gabriel Arazas 2025-03-26 14:27:54 +08:00
parent ffafbe1b94
commit ba9e3c3066
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 25 additions and 0 deletions

View File

@ -15,6 +15,10 @@ in pkgs.lib.makeExtensible (self:
math = callLib ./math.nix;
xdg = callLib ./xdg.nix;
# Just like from its inspiration, this contains Nix-representable data
# formats and won't have any attributes exported at the top-level.
formats = callLib ./formats.nix;
# For future references, these are the only attributes that are going to be
# exported as part of nixpkgs overlay.
fetchers = callLib ./fetchers;

21
lib/formats.nix Normal file
View File

@ -0,0 +1,21 @@
{ lib, pkgs, self }:
{
# The gnome-session config files uses one from GLib. See the following link
# at <https://docs.gtk.org/glib/struct.KeyFile.html> for details about the
# keyfile formatting and possibly the Desktop Entry specification at
# <https://freedesktop.org/wiki/Specifications/desktop-entry-spec>.
glibKeyfile = {}: {
type = with lib.types;
let
valueType = oneOf [ bool float int str (listOf valueType) ] // {
description =
"GLib keyfile atom (bool, int, float, string, or a list of the previous atoms)";
};
in attrsOf (attrsOf valueType);
generate = name: value:
pkgs.callPackage
({ lib, writeText }: writeText name (lib.generators.toDconfINI value));
};
}