From 4949081d1ee37ebb1ca9fbef289955d85aace405 Mon Sep 17 00:00:00 2001 From: Feliche-Demian Netliukh Date: Sat, 22 Feb 2025 16:23:01 +0000 Subject: [PATCH] jqp: add module (#5716) --- modules/misc/news.nix | 9 +++++ modules/modules.nix | 1 + modules/programs/jqp.nix | 33 +++++++++++++++++++ tests/default.nix | 1 + .../programs/jqp/basic-configuration.nix | 14 ++++++++ .../programs/jqp/basic-configuration.yaml | 2 ++ tests/modules/programs/jqp/default.nix | 1 + 7 files changed, 61 insertions(+) create mode 100644 modules/programs/jqp.nix create mode 100644 tests/modules/programs/jqp/basic-configuration.nix create mode 100644 tests/modules/programs/jqp/basic-configuration.yaml create mode 100644 tests/modules/programs/jqp/default.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index d3327978..0f89efb5 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -2094,6 +2094,15 @@ in { Dockerfile-like syntax for fast builds and simplicity. ''; } + + { + time = "2025-02-22T16:53:20+00:00"; + message = '' + A new module is available: 'programs.jqp'. + + A TUI playground for experimentingn with `jq`. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 3d078942..76158944 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -140,6 +140,7 @@ let ./programs/java.nix ./programs/jetbrains-remote.nix ./programs/jq.nix + ./programs/jqp.nix ./programs/jujutsu.nix ./programs/joshuto.nix ./programs/joplin-desktop.nix diff --git a/modules/programs/jqp.nix b/modules/programs/jqp.nix new file mode 100644 index 00000000..94fc8357 --- /dev/null +++ b/modules/programs/jqp.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.programs.jqp; + + yamlFormat = pkgs.formats.yaml { }; +in { + options.programs.jqp = { + enable = lib.mkEnableOption "jqp, jq playground"; + + package = lib.mkPackageOption pkgs "jqp" { }; + + settings = lib.mkOption { + type = yamlFormat.type; + default = { }; + example = { + theme = { + name = "monokai"; + chromaStyleOverrides = { kc = "#009900 underline"; }; + }; + }; + description = "Jqp configuration"; + }; + }; + config = lib.mkIf cfg.enable { + home = { + packages = [ cfg.package ]; + + file.".jqp.yaml" = lib.mkIf (cfg.settings != { }) { + source = yamlFormat.generate "jqp-config" cfg.settings; + }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index b11e19ca..6d3dbfd9 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -171,6 +171,7 @@ in import nmtSrc { ./modules/programs/irssi ./modules/programs/jujutsu ./modules/programs/joplin-desktop + ./modules/programs/jqp ./modules/programs/k9s ./modules/programs/kakoune ./modules/programs/khal diff --git a/tests/modules/programs/jqp/basic-configuration.nix b/tests/modules/programs/jqp/basic-configuration.nix new file mode 100644 index 00000000..23b79310 --- /dev/null +++ b/tests/modules/programs/jqp/basic-configuration.nix @@ -0,0 +1,14 @@ +{ + programs = { + jqp = { + enable = true; + settings = { theme.name = "catppuccin-frappe"; }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.jqp.yaml + assertFileContent home-files/.jqp.yaml \ + ${./basic-configuration.yaml} + ''; +} diff --git a/tests/modules/programs/jqp/basic-configuration.yaml b/tests/modules/programs/jqp/basic-configuration.yaml new file mode 100644 index 00000000..57f74423 --- /dev/null +++ b/tests/modules/programs/jqp/basic-configuration.yaml @@ -0,0 +1,2 @@ +theme: + name: catppuccin-frappe diff --git a/tests/modules/programs/jqp/default.nix b/tests/modules/programs/jqp/default.nix new file mode 100644 index 00000000..3ab8e24c --- /dev/null +++ b/tests/modules/programs/jqp/default.nix @@ -0,0 +1 @@ +{ jqp-basic-configuration = ./basic-configuration.nix; }