aboutsummaryrefslogtreecommitdiff
path: root/nixos.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos.nix')
-rw-r--r--nixos.nix54
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
+ })
+ ];
+}