about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/programs/nano.nix
blob: 10fa2a0dfbcdfb5ec3c7ed97557ab0f39021b734 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{ config, lib, pkgs, ... }:

let
  cfg = config.programs.nano;
in

{
  options = {
    programs.nano = {
      enable = lib.mkEnableOption "nano, a small user-friendly console text editor" // {
        default = true;
      };

      package = lib.mkPackageOption pkgs "nano" { };

      nanorc = lib.mkOption {
        type = lib.types.lines;
        default = "";
        description = ''
          The system-wide nano configuration.
          See {manpage}`nanorc(5)`.
        '';
        example = ''
          set nowrap
          set tabstospaces
          set tabsize 2
        '';
      };

      syntaxHighlight = lib.mkOption {
        type = lib.types.bool;
        default = true;
        description = "Whether to enable syntax highlight for various languages.";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    environment = {
      etc.nanorc.text = (lib.optionalString cfg.syntaxHighlight ''
        # load syntax highlighting files
        include "${cfg.package}/share/nano/*.nanorc"
        include "${cfg.package}/share/nano/extra/*.nanorc"
      '') + cfg.nanorc;
      systemPackages = [ cfg.package ];
    };
  };
}