qalculate: init module

This commit is contained in:
Miles Wirht
2026-04-23 18:27:29 -04:00
committed by GitHub
parent e09259dd2e
commit 5a9efa93c5
6 changed files with 124 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
{
time = "2026-04-22T17:29:21+00:00";
condition = true;
message = ''
A new module is available: 'programs.qalculate'. Qalculate! is a
multi-purpose desktop calculator that is simple to use but
provides power and versatility normally reserved for complicated
math packages.
'';
}

View File

@@ -0,0 +1,69 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.qalculate;
iniFormat = pkgs.formats.ini { };
in
{
meta.maintainers = [ lib.maintainers.philocalyst ];
options.programs.qalculate = {
enable = lib.mkEnableOption "Qalculate!, a multi-purpose desktop calculator";
package = lib.mkPackageOption pkgs "libqalculate" {
nullable = true;
example = "pkgs.qalculate-gtk";
};
settings = lib.mkOption {
inherit (iniFormat) type;
default = { };
example = lib.literalExpression ''
{
General = {
precision = 10;
colorize = 1;
save_mode_on_exit = 1;
save_definitions_on_exit = 0;
};
Mode = {
angle_unit = 1;
number_base = 10;
min_deci = 0;
max_deci = -1;
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/qalculate/qalc.cfg`.
Settings are organized into two INI sections:
- `General` persistence and display preferences (e.g.
`save_mode_on_exit`, `colorize`, `precision`).
- `Mode` active calculator settings that mirror the options
accepted by the {command}`set` command in an interactive
{command}`qalc` session (e.g. `angle_unit`, `number_base`,
`min_deci`).
See {manpage}`qalc(1)` for the full list of available settings
and their accepted values.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."qalculate/qalc.cfg" = lib.mkIf (cfg.settings != { }) {
source = iniFormat.generate "qalc.cfg" cfg.settings;
};
};
}

View File

@@ -0,0 +1,4 @@
{
qalculate-empty-settings = ./qalculate-empty-settings.nix;
qalculate-with-settings = ./qalculate-with-settings.nix;
}

View File

@@ -0,0 +1,10 @@
{
programs.qalculate = {
enable = true;
settings = { };
};
nmt.script = ''
assertPathNotExists home-files/.config/qalculate/qalc.cfg
'';
}

View File

@@ -0,0 +1,8 @@
[General]
colorize=1
precision=10
save_mode_on_exit=1
[Mode]
angle_unit=1
number_base=10

View File

@@ -0,0 +1,23 @@
{
programs.qalculate = {
enable = true;
settings = {
General = {
colorize = 1;
precision = 10;
save_mode_on_exit = 1;
};
Mode = {
angle_unit = 1;
number_base = 10;
};
};
};
nmt.script = ''
assertFileExists home-files/.config/qalculate/qalc.cfg
assertFileContent \
home-files/.config/qalculate/qalc.cfg \
${./qalculate-with-settings-expected}
'';
}