diff options
author | Philipp Mildenberger <philipp.mildenberger@student.uibk.ac.at> | 2020-07-24 17:15:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-24 17:15:55 +0200 |
commit | 3f1be6935903c61065f7036f312f574585c9cfe8 (patch) | |
tree | 1b2eb2ed3e49defd7dc393b222d84f65bbaab3d0 /modules/programs/nushell.nix | |
parent | 83301ca7871b67beb3940134efc00ecc31061981 (diff) |
nushell: add module (#1333)
Diffstat (limited to 'modules/programs/nushell.nix')
-rw-r--r-- | modules/programs/nushell.nix | 68 |
1 files changed, 68 insertions, 0 deletions
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 + <filename>~/.config/nushell/config.toml</filename>. + </para><para> + See <link xlink:href="https://www.nushell.sh/book/en/configuration.html" /> 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; }; + }; +} |