feat(user:shell): add system modules for zsh/bash user shell configuration
This commit is contained in:
parent
48c0e8e005
commit
ea1c418c73
7 changed files with 53 additions and 34 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
systemModules.user = {
|
systemModules.user = {
|
||||||
ooks.enable = true;
|
ooks.enable = true;
|
||||||
shell.fish.enable = true;
|
shell = "fish";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemModules.hardware = {
|
systemModules.hardware = {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
systemModules.user = {
|
systemModules.user = {
|
||||||
ooks.enable = true;
|
ooks.enable = true;
|
||||||
shell.fish.enable = true;
|
shell = "fish";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemModules.hardware = {
|
systemModules.hardware = {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
systemModules = {
|
systemModules = {
|
||||||
user = {
|
user = {
|
||||||
ooks.enable = true;
|
ooks.enable = true;
|
||||||
shell.fish.enable = true;
|
shell = "fish";
|
||||||
};
|
};
|
||||||
hardware = {
|
hardware = {
|
||||||
cpu.type = "intel";
|
cpu.type = "intel";
|
||||||
|
|
|
||||||
17
system/modules/user/shell/bash/default.nix
Normal file
17
system/modules/user/shell/bash/default.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib, config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
userShell = config.systemModules.user.shell;
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
config = mkIf (userShell == "bash") {
|
||||||
|
users.users.ooks.shell = pkgs.bash;
|
||||||
|
programs.bash = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
environment.pathsToLink = ["/share/bash-completion"];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,40 +1,19 @@
|
||||||
{ lib, config, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.systemModules.user.shell;
|
inherit (lib) types mkOption;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./fish
|
./fish
|
||||||
# ./bash
|
./bash
|
||||||
# ./zsh
|
./zsh
|
||||||
];
|
];
|
||||||
|
|
||||||
options.systemModules.user.shell = {
|
options.systemModules.user.shell = mkOption {
|
||||||
fish = {
|
type = types.enum ["fish" "zsh" "bash"];
|
||||||
enable = lib.mkEnableOption "Enable fish as the user shell";
|
default = "zsh";
|
||||||
};
|
description = "The user shell to use. Select from 'zsh' 'bash' 'fish'";
|
||||||
zsh = {
|
|
||||||
enable = lib.mkEnableOption "Enable zsh as the user shell";
|
|
||||||
};
|
|
||||||
bash = {
|
|
||||||
enable = lib.mkEnableOption "Enable bash as the user shell";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
assertions = [
|
|
||||||
{
|
|
||||||
assertion =
|
|
||||||
(lib.length (lib.filter (x: x) [
|
|
||||||
cfg.fish.enable or false
|
|
||||||
cfg.zsh.enable or false
|
|
||||||
cfg.bash.enable or false
|
|
||||||
]) <= 1);
|
|
||||||
message = "Only one user shell can be active in the configuration";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.systemModules.user.shell.fish;
|
inherit (lib) mkIf;
|
||||||
|
userShell = config.systemModules.user.shell;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = mkIf (userShell == "fish") {
|
||||||
users.users.ooks.shell = pkgs.fish;
|
users.users.ooks.shell = pkgs.fish;
|
||||||
programs.fish = {
|
programs.fish = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
22
system/modules/user/shell/zsh/default.nix
Normal file
22
system/modules/user/shell/zsh/default.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{ lib, config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
userShell = config.systemModules.user.shell;
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
config = mkIf (userShell == "zsh") {
|
||||||
|
users.users.ooks.shell = pkgs.zsh;
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
enableCompletion = true;
|
||||||
|
syntaxHighlighting.enable = true;
|
||||||
|
autosuggestions = {
|
||||||
|
enable = true;
|
||||||
|
async = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
environment.pathsToLink = ["/share/zsh"];
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue