diff --git a/modules/programs/amoco.nix b/modules/programs/amoco.nix new file mode 100644 index 000000000..c9a4c7c58 --- /dev/null +++ b/modules/programs/amoco.nix @@ -0,0 +1,38 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + types + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.amoco; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + options.programs.amoco = { + enable = mkEnableOption "amoco"; + package = mkPackageOption pkgs "amoco" { nullable = true; }; + config = mkOption { + type = with types; either str path; + default = ""; + description = '' + Config file for amoco as a Python configuration module. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + home.file.".config/amoco/config" = mkIf (cfg.config != "") { + source = if lib.isPath cfg.config then cfg.config else pkgs.writeText "amoco-config" cfg.config; + }; + }; +} diff --git a/tests/modules/programs/amoco/config b/tests/modules/programs/amoco/config new file mode 100644 index 000000000..248f5fb09 --- /dev/null +++ b/tests/modules/programs/amoco/config @@ -0,0 +1 @@ +print("No example config found!") diff --git a/tests/modules/programs/amoco/default.nix b/tests/modules/programs/amoco/default.nix new file mode 100644 index 000000000..625dfd753 --- /dev/null +++ b/tests/modules/programs/amoco/default.nix @@ -0,0 +1 @@ +{ amoco-settings = ./settings.nix; } diff --git a/tests/modules/programs/amoco/settings.nix b/tests/modules/programs/amoco/settings.nix new file mode 100644 index 000000000..865af8269 --- /dev/null +++ b/tests/modules/programs/amoco/settings.nix @@ -0,0 +1,14 @@ +{ + programs.amoco = { + enable = true; + config = '' + print("No example config found!") + ''; + }; + + nmt.script = '' + assertFileExists home-files/.config/amoco/config + assertFileContent home-files/.config/amoco/config \ + ${./config} + ''; +}