1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

nushell: add module (#1333)

This commit is contained in:
Philipp Mildenberger 2020-07-24 17:15:55 +02:00 committed by GitHub
parent 83301ca787
commit 3f1be69359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -78,6 +78,9 @@
/modules/programs/noti.nix @marsam /modules/programs/noti.nix @marsam
/modules/programs/nushell.nix @Philipp-M
/tests/modules/programs/nushell @Philipp-M
/modules/programs/obs-studio.nix @adisbladis /modules/programs/obs-studio.nix @adisbladis
/modules/programs/opam.nix @marsam /modules/programs/opam.nix @marsam

View file

@ -1604,6 +1604,13 @@ in
A new module is available: 'programs.ne' A new module is available: 'programs.ne'
''; '';
} }
{
time = "2020-07-24T15:03:11+00:00";
message = ''
A new module is available: 'programs.nushell'.
'';
}
]; ];
}; };
} }

View file

@ -95,6 +95,7 @@ let
(loadModule ./programs/newsboat.nix { }) (loadModule ./programs/newsboat.nix { })
(loadModule ./programs/noti.nix { }) (loadModule ./programs/noti.nix { })
(loadModule ./programs/notmuch.nix { }) (loadModule ./programs/notmuch.nix { })
(loadModule ./programs/nushell.nix { })
(loadModule ./programs/obs-studio.nix { }) (loadModule ./programs/obs-studio.nix { })
(loadModule ./programs/offlineimap.nix { }) (loadModule ./programs/offlineimap.nix { })
(loadModule ./programs/opam.nix { }) (loadModule ./programs/opam.nix { })

View file

@ -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; };
};
}

View file

@ -56,6 +56,7 @@ import nmt {
./modules/programs/ne ./modules/programs/ne
./modules/programs/neomutt ./modules/programs/neomutt
./modules/programs/newsboat ./modules/programs/newsboat
./modules/programs/nushell
./modules/programs/qutebrowser ./modules/programs/qutebrowser
./modules/programs/readline ./modules/programs/readline
./modules/programs/powerline-go ./modules/programs/powerline-go

View file

@ -0,0 +1 @@
{ nushell-settings = ./settings.nix; }

View file

@ -0,0 +1,5 @@
completion_mode = "circular"
edit_mode = "vi"
key_timeout = 10
no_auto_pivot = true
startup = ["alias la [] { ls -a }", "alias e [msg] { echo $msg }"]

View file

@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.nushell = {
enable = true;
settings = mkMerge [
{
edit_mode = "vi";
startup = [ "alias la [] { ls -a }" ];
completion_mode = "circular";
key_timeout = 10;
}
{
startup = [ "alias e [msg] { echo $msg }" ];
no_auto_pivot = true;
}
];
};
nixpkgs.overlays =
[ (self: super: { nushell = pkgs.writeScriptBin "dummy-nushell" ""; }) ];
nmt.script = ''
assertFileContent \
home-files/.config/nu/config.toml \
${./settings-expected.toml}
'';
};
}