From 65bcfaccc5584e3c04ac883dc0501faf1ec9025f Mon Sep 17 00:00:00 2001 From: Michael Forster Date: Sun, 29 May 2022 18:53:49 +0200 Subject: [PATCH] micro: add module This adds initial bare-bones support for the `micro` editor. --- .github/CODEOWNERS | 3 ++ modules/lib/maintainers.nix | 6 ++++ modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/programs/micro.nix | 43 ++++++++++++++++++++++++ tests/default.nix | 1 + tests/modules/programs/micro/default.nix | 1 + tests/modules/programs/micro/micro.nix | 24 +++++++++++++ 8 files changed, 86 insertions(+) create mode 100644 modules/programs/micro.nix create mode 100644 tests/modules/programs/micro/default.nix create mode 100644 tests/modules/programs/micro/micro.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fe4a326e1..96015153b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -158,6 +158,9 @@ /modules/programs/mcfly.nix @marsam +/modules/programs/micro.nix @MForster +/tests/modules/programs/micro @MForster + /modules/programs/mpv.nix @tadeokondrak @thiagokokada /tests/modules/programs/mpv @thiagokokada diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 17fc44076..fec5c0342 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -107,6 +107,12 @@ github = "matrss"; githubId = 9308656; }; + mforster = { + name = "Michael Forster"; + email = "email@michael-forster.de"; + github = "MForster"; + githubId = 4067975; + }; mifom = { name = "mifom"; email = "mifom@users.noreply.github.com"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 98bfa9828..fd8ca1bc8 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -561,6 +561,13 @@ in A new module is available: 'programs.mujmap'. ''; } + + { + time = "2022-06-24T17:18:32+00:00"; + message = '' + A new module is available: 'programs.micro'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d494d63b7..363e127bf 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -106,6 +106,7 @@ let ./programs/mbsync.nix ./programs/mcfly.nix ./programs/mercurial.nix + ./programs/micro.nix ./programs/mpv.nix ./programs/msmtp.nix ./programs/mu.nix diff --git a/modules/programs/micro.nix b/modules/programs/micro.nix new file mode 100644 index 000000000..f2f8b6bf7 --- /dev/null +++ b/modules/programs/micro.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.micro; + + jsonFormat = pkgs.formats.json { }; + +in { + meta.maintainers = [ hm.maintainers.mforster ]; + + options = { + programs.micro = { + enable = mkEnableOption "micro, a terminal-based text editor"; + + settings = mkOption { + type = jsonFormat.type; + default = { }; + example = literalExpression '' + { + autosu = false; + cursorline = false; + } + ''; + description = '' + Configuration written to + $XDG_CONFIG_HOME/micro/settings.json. See + + for supported values. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.micro ]; + + xdg.configFile."micro/settings.json".source = + jsonFormat.generate "micro-settings" cfg.settings; + }; +} diff --git a/tests/default.nix b/tests/default.nix index a0093f087..3c6cc6543 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -75,6 +75,7 @@ import nmt { ./modules/programs/lieer ./modules/programs/man ./modules/programs/mbsync + ./modules/programs/micro ./modules/programs/mpv ./modules/programs/mu ./modules/programs/mujmap diff --git a/tests/modules/programs/micro/default.nix b/tests/modules/programs/micro/default.nix new file mode 100644 index 000000000..984b9fa63 --- /dev/null +++ b/tests/modules/programs/micro/default.nix @@ -0,0 +1 @@ +{ micro = ./micro.nix; } diff --git a/tests/modules/programs/micro/micro.nix b/tests/modules/programs/micro/micro.nix new file mode 100644 index 000000000..92ab90e83 --- /dev/null +++ b/tests/modules/programs/micro/micro.nix @@ -0,0 +1,24 @@ +{ ... }: + +{ + programs.micro = { + enable = true; + + settings = { + autosu = false; + cursorline = false; + }; + }; + + test.stubs.micro = { }; + + nmt.script = '' + assertFileContent home-files/.config/micro/settings.json \ + ${builtins.toFile "micro-expected-settings.json" '' + { + "autosu": false, + "cursorline": false + } + ''} + ''; +}