feat(user:shell): add system modules for zsh/bash user shell configuration

This commit is contained in:
ooks-io 2024-04-14 19:41:53 +12:00
parent 48c0e8e005
commit ea1c418c73
7 changed files with 53 additions and 34 deletions

View file

@ -10,7 +10,7 @@
systemModules.user = {
ooks.enable = true;
shell.fish.enable = true;
shell = "fish";
};
systemModules.hardware = {

View file

@ -11,7 +11,7 @@
systemModules.user = {
ooks.enable = true;
shell.fish.enable = true;
shell = "fish";
};
systemModules.hardware = {

View file

@ -12,7 +12,7 @@
systemModules = {
user = {
ooks.enable = true;
shell.fish.enable = true;
shell = "fish";
};
hardware = {
cpu.type = "intel";

View 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"];
};
}

View file

@ -1,40 +1,19 @@
{ lib, config, ... }:
{ lib, ... }:
let
cfg = config.systemModules.user.shell;
inherit (lib) types mkOption;
in
{
imports = [
./fish
# ./bash
# ./zsh
./bash
./zsh
];
options.systemModules.user.shell = {
fish = {
enable = lib.mkEnableOption "Enable fish as the user shell";
};
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";
}
];
options.systemModules.user.shell = mkOption {
type = types.enum ["fish" "zsh" "bash"];
default = "zsh";
description = "The user shell to use. Select from 'zsh' 'bash' 'fish'";
};
}

View file

@ -1,11 +1,12 @@
{ pkgs, lib, config, ... }:
let
cfg = config.systemModules.user.shell.fish;
inherit (lib) mkIf;
userShell = config.systemModules.user.shell;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (userShell == "fish") {
users.users.ooks.shell = pkgs.fish;
programs.fish = {
enable = true;

View 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"];
};
}