diff options
author | Karel Kočí <cynerd@email.cz> | 2023-03-16 12:27:42 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2023-03-16 12:32:36 +0100 |
commit | df7fdb5bc098ebf2220235b2337a1517267ef04d (patch) | |
tree | fe1b104e73f853b214223b37277e53bf89b9c25f /nixos.nix | |
parent | 6f8f27349e074f2c9b6e7a359dad4f5656fc9db8 (diff) | |
download | shellrc-df7fdb5bc098ebf2220235b2337a1517267ef04d.tar.gz shellrc-df7fdb5bc098ebf2220235b2337a1517267ef04d.tar.bz2 shellrc-df7fdb5bc098ebf2220235b2337a1517267ef04d.zip |
Rework the whole NixOS and packages
This uses now primarilly overlays and also variable NIX_PROFILES to
chain-load shellrc from bashrc.d and zshrc.d.
Diffstat (limited to 'nixos.nix')
-rw-r--r-- | nixos.nix | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/nixos.nix b/nixos.nix new file mode 100644 index 0000000..77b272c --- /dev/null +++ b/nixos.nix @@ -0,0 +1,54 @@ +overlays: { + config, + lib, + pkgs, + ... +}: +with lib; let + cnf = config.programs.shellrc; + zshEnable = config.programs.zsh.enable; + + # Source all files in an appropriate shell directory in every profile + shellInit = dir: '' + for p in $NIX_PROFILES; do + for file in $p/etc/${dir}/*; do + [ -f "$file" ] || continue + . "$file" + done + done + ''; +in { + options = { + programs.shellrc = { + enable = mkOption { + type = types.bool; + default = true; + description = "If shellrc should be enabled."; + }; + desktop = mkOption { + type = types.bool; + default = false; + description = "If shellrc's desktop specific files should be used."; + }; + }; + }; + + config = mkMerge [ + { + nixpkgs.overlays = overlays; + + programs.bash.interactiveShellInit = shellInit "bashrc.d"; + programs.zsh.interactiveShellInit = mkIf zshEnable (shellInit "zshrc.d"); + } + (mkIf cnf.enable { + environment.systemPackages = + [pkgs.shellrc-bash] + ++ optional cnf.desktop pkgs.shellrc-desktop + ++ optional zshEnable pkgs.shellrc-zsh; + + # Disable default prompt as we have our own + programs.bash.promptInit = ""; + programs.zsh.promptInit = ""; # Disable default prompt as we have our own + }) + ]; +} |