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;
|
||||
|
||||
{
|
||||
imports = [
|
||||
./fish
|
||||
./xonsh
|
||||
./zsh
|
||||
];
|
||||
options.shell = let
|
||||
shellNameEnum = lib.types.enum shellNames;
|
||||
in {
|
||||
defaultShell = lib.mkOption {
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue