nano: add nix syntax hightlight, nano module: provide default (#21912)

this is awesome! thanks.
This commit is contained in:
gnidorah 2017-01-18 14:05:30 +03:00 committed by Joachim Schiele
parent 5c7ecab75c
commit 4a662e5206
2 changed files with 22 additions and 5 deletions

View file

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.programs.nano;
@ -20,16 +20,22 @@ in
example = ''
set nowrap
set tabstospaces
set tabsize 4
set tabsize 2
'';
};
syntaxHighlight = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to enable syntax highlight for various languages.";
};
};
};
###### implementation
config = lib.mkIf (cfg.nanorc != "") {
environment.etc."nanorc".text = cfg.nanorc;
environment.etc."nanorc".text = lib.concatStrings [ cfg.nanorc
(lib.optionalString cfg.syntaxHighlight ''include "${pkgs.nano}/share/nano/*.nanorc"'') ];
};
}

View file

@ -1,4 +1,4 @@
{ stdenv, fetchurl
{ stdenv, fetchurl, fetchFromGitHub
, ncurses
, texinfo
, gettext ? null
@ -10,7 +10,14 @@ assert enableNls -> (gettext != null);
with stdenv.lib;
stdenv.mkDerivation rec {
let
nixSyntaxHighlight = fetchFromGitHub {
owner = "seitz";
repo = "nanonix";
rev = "17e0de65e1cbba3d6baa82deaefa853b41f5c161";
sha256 = "1g51h65i31andfs2fbp1v3vih9405iknqn11fzywjxji00kjqv5s";
};
in stdenv.mkDerivation rec {
name = "nano-${version}";
version = "2.7.3";
src = fetchurl {
@ -30,6 +37,10 @@ stdenv.mkDerivation rec {
substituteInPlace src/text.c --replace "__time_t" "time_t"
'';
postInstall = ''
cp ${nixSyntaxHighlight}/nix.nanorc $out/share/nano/
'';
meta = {
homepage = http://www.nano-editor.org/;
description = "A small, user-friendly console text editor";