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:
parent
83301ca787
commit
3f1be69359
8 changed files with 120 additions and 0 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -78,6 +78,9 @@
|
|||
|
||||
/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/opam.nix @marsam
|
||||
|
|
|
@ -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'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 { })
|
||||
|
|
68
modules/programs/nushell.nix
Normal file
68
modules/programs/nushell.nix
Normal 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; };
|
||||
};
|
||||
}
|
|
@ -56,6 +56,7 @@ import nmt {
|
|||
./modules/programs/ne
|
||||
./modules/programs/neomutt
|
||||
./modules/programs/newsboat
|
||||
./modules/programs/nushell
|
||||
./modules/programs/qutebrowser
|
||||
./modules/programs/readline
|
||||
./modules/programs/powerline-go
|
||||
|
|
1
tests/modules/programs/nushell/default.nix
Normal file
1
tests/modules/programs/nushell/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ nushell-settings = ./settings.nix; }
|
5
tests/modules/programs/nushell/settings-expected.toml
Normal file
5
tests/modules/programs/nushell/settings-expected.toml
Normal 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 }"]
|
34
tests/modules/programs/nushell/settings.nix
Normal file
34
tests/modules/programs/nushell/settings.nix
Normal 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}
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue