From 3f1be6935903c61065f7036f312f574585c9cfe8 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Fri, 24 Jul 2020 17:15:55 +0200 Subject: nushell: add module (#1333) --- modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/nushell.nix | 68 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 modules/programs/nushell.nix (limited to 'modules') diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3009ae7bb32..608fcc2b21e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1604,6 +1604,13 @@ in A new module is available: 'programs.ne' ''; } + + { + time = "2020-07-24T15:03:11+00:00"; + message = '' + A new module is available: 'programs.nushell'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index a7054f38179..6d24cb6724c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -95,6 +95,7 @@ let (loadModule ./programs/newsboat.nix { }) (loadModule ./programs/noti.nix { }) (loadModule ./programs/notmuch.nix { }) + (loadModule ./programs/nushell.nix { }) (loadModule ./programs/obs-studio.nix { }) (loadModule ./programs/offlineimap.nix { }) (loadModule ./programs/opam.nix { }) diff --git a/modules/programs/nushell.nix b/modules/programs/nushell.nix new file mode 100644 index 00000000000..1eb42f9515c --- /dev/null +++ b/modules/programs/nushell.nix @@ -0,0 +1,68 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.nushell; + + configFile = config: + pkgs.runCommand "config.toml" { + buildInputs = [ pkgs.remarshal ]; + preferLocalBuild = true; + allowSubstitutes = false; + } '' + remarshal -if json -of toml \ + < ${pkgs.writeText "config.json" (builtins.toJSON config)} \ + > $out + ''; + +in { + meta.maintainers = [ maintainers.Philipp-M ]; + + options.programs.nushell = { + enable = mkEnableOption "nushell"; + + package = mkOption { + type = types.package; + default = pkgs.nushell; + defaultText = literalExample "pkgs.nushell"; + description = "The package to use for nushell."; + }; + + settings = mkOption { + type = with types; + let + prim = oneOf [ bool int str ]; + primOrPrimAttrs = either prim (attrsOf prim); + entry = either prim (listOf primOrPrimAttrs); + entryOrAttrsOf = t: either entry (attrsOf t); + entries = entryOrAttrsOf (entryOrAttrsOf entry); + in attrsOf entries // { description = "Nushell configuration"; }; + default = { }; + example = literalExample '' + { + edit_mode = "vi"; + startup = [ "alias la [] { ls -a }" "alias e [msg] { echo $msg }" ]; + key_timeout = 10; + completion_mode = "circular"; + no_auto_pivot = true; + } + ''; + description = '' + Configuration written to + ~/.config/nushell/config.toml. + + See for the full list + of options. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + xdg.configFile."nu/config.toml" = + mkIf (cfg.settings != { }) { source = configFile cfg.settings; }; + }; +} -- cgit v1.2.3