From 88a9d7a9ca476ba8d686a6e7427d0f176ebf13b1 Mon Sep 17 00:00:00 2001
From: Rob Vermaas <rob.vermaas@gmail.com>
Date: Tue, 30 Oct 2012 13:33:37 +0100
Subject: [PATCH] Added environment.promptInit to allow PS1 overriding. Would
 be nicer to be able to allow overriding via shellInit, however could not get
 that to work. For now this is a temporary solution which will not break
 anything.

---
 modules/programs/bash/bash.nix  | 18 +++++++++++++++++-
 modules/programs/bash/bashrc.sh |  9 +--------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/modules/programs/bash/bash.nix b/modules/programs/bash/bash.nix
index 441d30f1e9f..135d99ec437 100644
--- a/modules/programs/bash/bash.nix
+++ b/modules/programs/bash/bash.nix
@@ -25,9 +25,24 @@ let
     fi
   '';
 
-
   options = {
 
+    environment.promptInit =  mkOption {
+        default = ''
+          # Provide a nice prompt.
+          PROMPT_COLOR="1;31m"
+          let $UID && PROMPT_COLOR="1;32m"
+          PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
+          if test "$TERM" = "xterm"; then
+            PS1="\[\033]2;\h:\u:\w\007\]$PS1"
+          fi
+        '';
+        description = "
+          Script used to initialized shell prompt.
+        ";
+        type = with pkgs.lib.types; string;
+      };
+
     environment.shellInit = mkOption {
         default = "";
         example = ''export PATH=/godi/bin/:$PATH'';
@@ -65,6 +80,7 @@ in
         # configured properly.
          source = pkgs.substituteAll {
            src = ./bashrc.sh;
+           inherit (config.environment) promptInit;
            inherit initBashCompletion;
          };
          target = "bashrc";
diff --git a/modules/programs/bash/bashrc.sh b/modules/programs/bash/bashrc.sh
index 10a36ede2a3..3542b5f9fd4 100644
--- a/modules/programs/bash/bashrc.sh
+++ b/modules/programs/bash/bashrc.sh
@@ -19,14 +19,7 @@ if [ -z "$PS1" ]; then return; fi
 # Check the window size after every command.
 shopt -s checkwinsize
 
-# Provide a nice prompt.
-PROMPT_COLOR="1;31m"
-let $UID && PROMPT_COLOR="1;32m"
-PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
-if test "$TERM" = "xterm"; then
-    PS1="\[\033]2;\h:\u:\w\007\]$PS1"
-fi
-
+@promptInit@
 @initBashCompletion@
 
 # Some aliases.