From 91daee72efc99b7336b7e545774e9e3c2a1910c8 Mon Sep 17 00:00:00 2001 From: Aguirre Matteo Date: Thu, 9 Oct 2025 16:14:21 -0300 Subject: [PATCH] amp: add module --- modules/programs/amp.nix | 61 +++++++++++++++++++++++++ tests/modules/programs/amp/config.yml | 11 +++++ tests/modules/programs/amp/default.nix | 1 + tests/modules/programs/amp/settings.nix | 40 ++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 modules/programs/amp.nix create mode 100644 tests/modules/programs/amp/config.yml create mode 100644 tests/modules/programs/amp/default.nix create mode 100644 tests/modules/programs/amp/settings.nix diff --git a/modules/programs/amp.nix b/modules/programs/amp.nix new file mode 100644 index 000000000..3d28fbb58 --- /dev/null +++ b/modules/programs/amp.nix @@ -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: . + ''; + }; + }; + + 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; + }; + }; +} diff --git a/tests/modules/programs/amp/config.yml b/tests/modules/programs/amp/config.yml new file mode 100644 index 000000000..4a9062767 --- /dev/null +++ b/tests/modules/programs/amp/config.yml @@ -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 diff --git a/tests/modules/programs/amp/default.nix b/tests/modules/programs/amp/default.nix new file mode 100644 index 000000000..fde5735ce --- /dev/null +++ b/tests/modules/programs/amp/default.nix @@ -0,0 +1 @@ +{ amp-settings = ./settings.nix; } diff --git a/tests/modules/programs/amp/settings.nix b/tests/modules/programs/amp/settings.nix new file mode 100644 index 000000000..aa8cdef34 --- /dev/null +++ b/tests/modules/programs/amp/settings.nix @@ -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} + ''; +}