numbat: add module

Numbat is a scientific calculator with full support for physical units.
This commit is contained in:
Alex Hamilton 2025-05-10 20:21:35 -04:00 committed by Austin Horstman
parent 563e1b6cb0
commit ecb2162422
7 changed files with 115 additions and 0 deletions

View file

@ -0,0 +1,50 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib) mkIf;
cfg = config.programs.numbat;
tomlFormat = pkgs.formats.toml { };
configDir =
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/numbat"
else
"${config.xdg.configHome}/numbat";
in
{
meta.maintainers = with lib.hm.maintainers; [
Aehmlo
];
options.programs.numbat = {
enable = lib.mkEnableOption "Numbat";
package = lib.mkPackageOption pkgs "numbat" { nullable = true; };
settings = lib.mkOption {
type = tomlFormat.type;
default = { };
example = {
intro-banner = "short";
prompt = "> ";
exchange-rates.fetching-policy = "on-first-use";
};
description = ''
Options to add to {file}`config.toml`. See
<https://numbat.dev/doc/cli-customization.html#configuration> for options.
'';
};
};
config = mkIf cfg.enable {
home.packages = mkIf (cfg.package != null) [ cfg.package ];
home.file."${configDir}/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "numbat-config" cfg.settings;
};
};
}