Skip to content

Commit

Permalink
nano: add nix syntax hightlight, nano module: provide default (#21912)
Browse files Browse the repository at this point in the history
this is awesome! thanks.
  • Loading branch information
gnidorah authored and qknight committed Jan 18, 2017
1 parent 5c7ecab commit 4a662e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 9 additions & 3 deletions nixos/modules/programs/nano.nix
@@ -1,4 +1,4 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:

let
cfg = config.programs.nano;
Expand All @@ -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"'') ];
};

}
15 changes: 13 additions & 2 deletions pkgs/applications/editors/nano/default.nix
@@ -1,4 +1,4 @@
{ stdenv, fetchurl
{ stdenv, fetchurl, fetchFromGitHub
, ncurses
, texinfo
, gettext ? null
Expand All @@ -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 {
Expand All @@ -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";
Expand Down

0 comments on commit 4a662e5

Please sign in to comment.