OSShells, refactor shells to single option

This commit is contained in:
Julia Lange 2024-11-29 01:53:13 -08:00
parent db7f132f6e
commit 55bfb8a4fb
Signed by: Julia
SSH key fingerprint: SHA256:KI8YxpkPRbnDRkXPgCuQCVz181++Vy7NAvmQj8alOhM
7 changed files with 54 additions and 57 deletions

View file

@ -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;
};
}