OSShells, refactor shells to single option
This commit is contained in:
parent
db7f132f6e
commit
55bfb8a4fb
7 changed files with 54 additions and 57 deletions
|
|
@ -1,9 +1,29 @@
|
||||||
{ ... }:
|
{ config, pkgs, lib, ... }: let
|
||||||
|
fs = lib.fileset;
|
||||||
|
shellFilter = {name, ...}: name == "shell.nix";
|
||||||
|
shellImports = fs.toList (fs.fileFilter shellFilter ./.);
|
||||||
|
shellNames = map (
|
||||||
|
path: let
|
||||||
|
splitPath = lib.strings.splitString "/" path;
|
||||||
|
splitPathLen = builtins.length splitPath;
|
||||||
|
in builtins.elemAt splitPath (splitPathLen - 2)
|
||||||
|
) shellImports;
|
||||||
|
in {
|
||||||
|
imports = shellImports;
|
||||||
|
|
||||||
{
|
options.shell = let
|
||||||
imports = [
|
shellNameEnum = lib.types.enum shellNames;
|
||||||
./fish
|
in {
|
||||||
./xonsh
|
defaultShell = lib.mkOption {
|
||||||
./zsh
|
type = shellNameEnum;
|
||||||
];
|
};
|
||||||
|
enabledShells = lib.mkOption {
|
||||||
|
type = lib.types.listOf shellNameEnum;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
users.defaultUserShell = pkgs."${config.shell.defaultShell}";
|
||||||
|
environment.shells = map (shell: pkgs."${shell}") config.shell.enabledShells;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
fish.enable = lib.mkEnableOption "Enables fish";
|
|
||||||
fish.setDefault = lib.mkEnableOption
|
|
||||||
"Sets fish as the default user's shell";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf config.fish.enable {
|
|
||||||
programs.fish.enable = true;
|
|
||||||
users.defaultUserShell = lib.mkIf config.fish.setDefault pkgs.fish;
|
|
||||||
environment.shells = with pkgs; [ fish ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
7
nixosModules/apps/shells/fish/shell.nix
Normal file
7
nixosModules/apps/shells/fish/shell.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkIf (config.shell.defaultShell == "fish") {
|
||||||
|
programs.fish.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
xonsh.enable = lib.mkEnableOption "Enables xonsh";
|
|
||||||
xonsh.setDefault = lib.mkEnableOption
|
|
||||||
"Sets xonsh as the default user's shell";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf config.xonsh.enable {
|
|
||||||
programs.xonsh.enable = true;
|
|
||||||
users.defaultUserShell = lib.mkIf config.xonsh.setDefault pkgs.xonsh;
|
|
||||||
environment.shells = with pkgs; [ xonsh ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
7
nixosModules/apps/shells/xonsh/shell.nix
Normal file
7
nixosModules/apps/shells/xonsh/shell.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkIf (config.shell.defaultShell == "xonsh") {
|
||||||
|
programs.xonsh.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
zsh.enable = lib.mkEnableOption "Enables zsh";
|
|
||||||
zsh.setDefault = lib.mkEnableOption "Sets zsh as the default user's shell";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf config.zsh.enable {
|
|
||||||
programs.zsh = {
|
|
||||||
enable = true;
|
|
||||||
enableCompletion = true;
|
|
||||||
autosuggestions.enable = true;
|
|
||||||
histFile = "$HOME/.config/zsh/history";
|
|
||||||
histSize = 2000;
|
|
||||||
};
|
|
||||||
users.defaultUserShell = lib.mkIf config.zsh.setDefault pkgs.zsh;
|
|
||||||
environment.shells = with pkgs; [ zsh ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
13
nixosModules/apps/shells/zsh/shell.nix
Normal file
13
nixosModules/apps/shells/zsh/shell.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkIf (config.shell.defaultShell == "zsh") {
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
enableCompletion = true;
|
||||||
|
autosuggestions.enable = true;
|
||||||
|
histFile = "$HOME/.config/zsh/history";
|
||||||
|
histSize = 2000;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue