mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
numbat: add module
Numbat is a scientific calculator with full support for physical units.
This commit is contained in:
parent
563e1b6cb0
commit
ecb2162422
7 changed files with 115 additions and 0 deletions
7
modules/misc/news/2025-05-10_21-08-48.nix
Normal file
7
modules/misc/news/2025-05-10_21-08-48.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
time = "2025-05-11T01:08:48+00:00";
|
||||||
|
condition = true;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.numbat'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -208,6 +208,7 @@ let
|
||||||
./programs/nnn.nix
|
./programs/nnn.nix
|
||||||
./programs/noti.nix
|
./programs/noti.nix
|
||||||
./programs/notmuch.nix
|
./programs/notmuch.nix
|
||||||
|
./programs/numbat.nix
|
||||||
./programs/nushell.nix
|
./programs/nushell.nix
|
||||||
./programs/obs-studio.nix
|
./programs/obs-studio.nix
|
||||||
./programs/octant.nix
|
./programs/octant.nix
|
||||||
|
|
|
||||||
50
modules/programs/numbat.nix
Normal file
50
modules/programs/numbat.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -257,6 +257,7 @@ import nmtSrc {
|
||||||
./modules/programs/nix-init
|
./modules/programs/nix-init
|
||||||
./modules/programs/nix-your-shell
|
./modules/programs/nix-your-shell
|
||||||
./modules/programs/nnn
|
./modules/programs/nnn
|
||||||
|
./modules/programs/numbat
|
||||||
./modules/programs/nushell
|
./modules/programs/nushell
|
||||||
./modules/programs/oh-my-posh
|
./modules/programs/oh-my-posh
|
||||||
./modules/programs/onlyoffice
|
./modules/programs/onlyoffice
|
||||||
|
|
|
||||||
4
tests/modules/programs/numbat/default.nix
Normal file
4
tests/modules/programs/numbat/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
numbat-example-config = ./example-config.nix;
|
||||||
|
numbat-empty-config = ./empty-config.nix;
|
||||||
|
}
|
||||||
18
tests/modules/programs/numbat/empty-config.nix
Normal file
18
tests/modules/programs/numbat/empty-config.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/numbat"
|
||||||
|
else
|
||||||
|
".config/numbat";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
programs.numbat.enable = true;
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertPathNotExists 'home-files/${configDir}/config.toml'
|
||||||
|
'';
|
||||||
|
}
|
||||||
34
tests/modules/programs/numbat/example-config.nix
Normal file
34
tests/modules/programs/numbat/example-config.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/numbat"
|
||||||
|
else
|
||||||
|
".config/numbat";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
programs.numbat = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
settings = {
|
||||||
|
intro-banner = "short";
|
||||||
|
prompt = "> ";
|
||||||
|
exchange-rates.fetching-policy = "on-first-use";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists 'home-files/${configDir}/config.toml'
|
||||||
|
assertFileContent $(normalizeStorePaths 'home-files/${configDir}/config.toml') \
|
||||||
|
${builtins.toFile "expected.toml" ''
|
||||||
|
intro-banner = "short"
|
||||||
|
prompt = "> "
|
||||||
|
[exchange-rates]
|
||||||
|
fetching-policy = "on-first-use"
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue