summaryrefslogtreecommitdiffstats
path: root/nix-script
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-07-28 18:07:43 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-08-01 20:46:05 +0200
commita9d4b7f153158e25d13d47a69edd63e60008dc93 (patch)
tree7820161efbab3a6640e421afb59c08a79534d12c /nix-script
parentf1a4c31aaf91d8e54472568231027dc5ec774acd (diff)
Add support for configuration file
Diffstat (limited to 'nix-script')
-rwxr-xr-xnix-script22
1 files changed, 22 insertions, 0 deletions
diff --git a/nix-script b/nix-script
index 2fec7da..a28858e 100755
--- a/nix-script
+++ b/nix-script
@@ -4,6 +4,7 @@ usage() {
cat <<EOS >&2
$(help_synopsis "${BASE_SOURCE[0]}" "[options] <command> <commandoptions>")
+ --conf=<path> Path for alternative nix-script.rc file. Default: ~/.nix-script.rc
-l | --list-commands List all available commands
-v Be verbose
-d Debugging output (enables -v)
@@ -13,6 +14,7 @@ $(help_end)
EOS
}
+RC=~/.nix-script.rc
LIST_COMMANDS=0
VERBOSE=0
@@ -61,6 +63,13 @@ all_commands() {
for cmd
do
case $cmd in
+ --conf=*)
+ RC=$(echo $cmd | sed 's,^--conf\=,,')
+ dbg "RC = $RC"
+ [[ ! -e $RC ]] && stderr "RC file '$RC' does not exist" && exit 1
+ shift_one_more
+ ;;
+
"--list-commands" )
LIST_COMMANDS=1
shift_one_more
@@ -106,6 +115,19 @@ do
esac
done
+if [[ ! -f "$RC" ]]
+then
+ dbg "No configuration file, setting up (empty) default values"
+
+ RC_CONFIG=""
+ RC_NIXPKGS=""
+else
+ source $RC
+fi
+
+dbg "RC_CONFIG = '$RC_CONFIG'"
+dbg "RC_NIXPKGS = '$RC_NIXPKGS'"
+
if [ $LIST_COMMANDS -eq 1 ]
then
dbg "Listing commands"