mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
amber: add module
This commit is contained in:
parent
5f06ceafc6
commit
2b64e332a0
5 changed files with 116 additions and 0 deletions
70
modules/programs/amber.nix
Normal file
70
modules/programs/amber.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkIf
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
;
|
||||
|
||||
cfg = config.programs.amber;
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
options.programs.amber = {
|
||||
enable = mkEnableOption "amber";
|
||||
package = mkPackageOption pkgs "amber" { nullable = true; };
|
||||
ambsSettings = mkOption {
|
||||
inherit (tomlFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
column = true;
|
||||
binary = true;
|
||||
skipped = true;
|
||||
recursive = false;
|
||||
};
|
||||
description = ''
|
||||
Configuration settings for amber's ambs tool. All the available options can be found here:
|
||||
<https://github.com/dalance/amber?tab=readme-ov-file#configurable-value>.
|
||||
'';
|
||||
};
|
||||
ambrSettings = mkOption {
|
||||
inherit (tomlFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
regex = true;
|
||||
row = true;
|
||||
statistics = true;
|
||||
interactive = false;
|
||||
};
|
||||
description = ''
|
||||
Configuration settings for amber's ambr tool. All the available options can be found here:
|
||||
<https://github.com/dalance/amber?tab=readme-ov-file#configurable-value>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"Library/Preferences/com.github.dalance.amber"
|
||||
else
|
||||
".config/amber";
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
home.file."${configDir}/ambs.toml" = mkIf (cfg.ambsSettings != { }) {
|
||||
source = tomlFormat.generate "ambs.toml" cfg.ambsSettings;
|
||||
};
|
||||
home.file."${configDir}/ambr.toml" = mkIf (cfg.ambrSettings != { }) {
|
||||
source = tomlFormat.generate "ambr.toml" cfg.ambrSettings;
|
||||
};
|
||||
};
|
||||
}
|
||||
4
tests/modules/programs/amber/ambr.toml
Normal file
4
tests/modules/programs/amber/ambr.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
interactive = false
|
||||
regex = true
|
||||
row = true
|
||||
statistics = true
|
||||
4
tests/modules/programs/amber/ambs.toml
Normal file
4
tests/modules/programs/amber/ambs.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
binary = true
|
||||
column = true
|
||||
recursive = false
|
||||
skipped = true
|
||||
1
tests/modules/programs/amber/default.nix
Normal file
1
tests/modules/programs/amber/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ amber-settings = ./settings.nix; }
|
||||
37
tests/modules/programs/amber/settings.nix
Normal file
37
tests/modules/programs/amber/settings.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.amber = {
|
||||
enable = true;
|
||||
ambsSettings = {
|
||||
column = true;
|
||||
binary = true;
|
||||
skipped = true;
|
||||
recursive = false;
|
||||
};
|
||||
ambrSettings = {
|
||||
regex = true;
|
||||
row = true;
|
||||
statistics = true;
|
||||
interactive = false;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"Library/Preferences/com.github.dalance.amber"
|
||||
else
|
||||
".config/amber";
|
||||
in
|
||||
''
|
||||
assertFileExists "home-files/${configDir}/ambs.toml"
|
||||
assertFileContent "home-files/${configDir}/ambs.toml" \
|
||||
${./ambs.toml}
|
||||
|
||||
assertFileExists "home-files/${configDir}/ambr.toml"
|
||||
assertFileContent "home-files/${configDir}/ambr.toml" \
|
||||
${./ambr.toml}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue