mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
amp: add module
This commit is contained in:
parent
d305eece82
commit
91daee72ef
4 changed files with 113 additions and 0 deletions
61
modules/programs/amp.nix
Normal file
61
modules/programs/amp.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkIf
|
||||||
|
mkEnableOption
|
||||||
|
mkPackageOption
|
||||||
|
mkOption
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.programs.amp;
|
||||||
|
yamlFormat = pkgs.formats.yaml { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||||
|
options.programs.amp = {
|
||||||
|
enable = mkEnableOption "amp";
|
||||||
|
package = mkPackageOption pkgs "amp" { nullable = true; };
|
||||||
|
settings = mkOption {
|
||||||
|
inherit (yamlFormat) type;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
theme = "solarized_dark";
|
||||||
|
tab_width = 2;
|
||||||
|
soft_tabs = true;
|
||||||
|
line_wrapping = true;
|
||||||
|
open_mode.exclusions = [
|
||||||
|
"**/.git"
|
||||||
|
"**/.svn"
|
||||||
|
];
|
||||||
|
line_length_guide = [
|
||||||
|
80
|
||||||
|
100
|
||||||
|
];
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration settings for amp. All the details can be
|
||||||
|
found here: <https://amp.rs/docs/configuration/>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
configPath =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/amp"
|
||||||
|
else
|
||||||
|
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/amp";
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
home.file."${configPath}/config.yml" = mkIf (cfg.settings != { }) {
|
||||||
|
source = yamlFormat.generate "amp-config.yml" cfg.settings;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
11
tests/modules/programs/amp/config.yml
Normal file
11
tests/modules/programs/amp/config.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
line_length_guide:
|
||||||
|
- 80
|
||||||
|
- 100
|
||||||
|
line_wrapping: true
|
||||||
|
open_mode:
|
||||||
|
exclusions:
|
||||||
|
- '**/.git'
|
||||||
|
- '**/.svn'
|
||||||
|
soft_tabs: true
|
||||||
|
tab_width: 2
|
||||||
|
theme: solarized_dark
|
||||||
1
tests/modules/programs/amp/default.nix
Normal file
1
tests/modules/programs/amp/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ amp-settings = ./settings.nix; }
|
||||||
40
tests/modules/programs/amp/settings.nix
Normal file
40
tests/modules/programs/amp/settings.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.amp = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
theme = "solarized_dark";
|
||||||
|
tab_width = 2;
|
||||||
|
soft_tabs = true;
|
||||||
|
line_wrapping = true;
|
||||||
|
open_mode.exclusions = [
|
||||||
|
"**/.git"
|
||||||
|
"**/.svn"
|
||||||
|
];
|
||||||
|
line_length_guide = [
|
||||||
|
80
|
||||||
|
100
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script =
|
||||||
|
let
|
||||||
|
configPath =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/amp"
|
||||||
|
else
|
||||||
|
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/amp";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
assertFileExists "home-files/${configPath}/config.yml"
|
||||||
|
assertFileContent "home-files/${configPath}/config.yml" \
|
||||||
|
${./config.yml}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue