mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
qalculate: init module
This commit is contained in:
10
modules/misc/news/2026/04/2026-04-22_17-29-21.nix
Normal file
10
modules/misc/news/2026/04/2026-04-22_17-29-21.nix
Normal 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.
|
||||
'';
|
||||
}
|
||||
69
modules/programs/qalculate.nix
Normal file
69
modules/programs/qalculate.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
4
tests/modules/programs/qalculate/default.nix
Normal file
4
tests/modules/programs/qalculate/default.nix
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
qalculate-empty-settings = ./qalculate-empty-settings.nix;
|
||||
qalculate-with-settings = ./qalculate-with-settings.nix;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
programs.qalculate = {
|
||||
enable = true;
|
||||
settings = { };
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/qalculate/qalc.cfg
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
[General]
|
||||
colorize=1
|
||||
precision=10
|
||||
save_mode_on_exit=1
|
||||
|
||||
[Mode]
|
||||
angle_unit=1
|
||||
number_base=10
|
||||
23
tests/modules/programs/qalculate/qalculate-with-settings.nix
Normal file
23
tests/modules/programs/qalculate/qalculate-with-settings.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user