1{ config, lib, pkgs, ... }:
2
3let
4 cfg = config.programs.nano;
5 LF = "\n";
6in
7
8{
9 ###### interface
10
11 options = {
12 programs.nano = {
13
14 nanorc = lib.mkOption {
15 type = lib.types.lines;
16 default = "";
17 description = lib.mdDoc ''
18 The system-wide nano configuration.
19 See {manpage}`nanorc(5)`.
20 '';
21 example = ''
22 set nowrap
23 set tabstospaces
24 set tabsize 2
25 '';
26 };
27 syntaxHighlight = lib.mkOption {
28 type = lib.types.bool;
29 default = true;
30 description = lib.mdDoc "Whether to enable syntax highlight for various languages.";
31 };
32 };
33 };
34
35 ###### implementation
36
37 config = lib.mkIf (cfg.nanorc != "" || cfg.syntaxHighlight) {
38 environment.etc.nanorc.text = lib.concatStrings [ cfg.nanorc
39 (lib.optionalString cfg.syntaxHighlight ''${LF}include "${pkgs.nano}/share/nano/*.nanorc"'') ];
40 };
41
42}