summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-10-04 14:07:52 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-10-04 14:07:52 +0200
commit80bcb12e3691cd7a5e3b3c4ff45d1e61aa018598 (patch)
tree321ea210fdd5c67560b7bd6a11e11f7165cfdc70
parent9b5bdbca998c78ae31301eb216b265d4c163ba34 (diff)
parente0e9acdac072042f9272be7c2a4bdd346a895191 (diff)
Merge pull request #98 from matthiasbeyer/switch-integrate_alternative_nixpkgs_arg_parsing
switch: Ability to parse alternative nixpkgs from normal args
-rwxr-xr-xnix-script-switch.sh28
1 files changed, 18 insertions, 10 deletions
diff --git a/nix-script-switch.sh b/nix-script-switch.sh
index 749b929..158ff52 100755
--- a/nix-script-switch.sh
+++ b/nix-script-switch.sh
@@ -9,7 +9,7 @@ COMMAND="switch"
usage() {
cat <<EOS
- $(help_synopsis "${BASH_SOURCE[0]}" "[-h] [-q] [-c <command>] [-w <working directory>] [-- args...]")
+ $(help_synopsis "${BASH_SOURCE[0]}" "[-h] [-q] [-c <command>] [-w <working directory>]")
-c <command> Command for nixos-rebuild. See 'man nixos-rebuild' (default: switch)
-w <path> Path to your configuration git directory (default: '$RC_CONFIG')
@@ -19,6 +19,7 @@ usage() {
-f <tag-flags> Flags for git-tag (see 'git tag --help') (default: '$RC_SWITCH_DEFAULT_TAG_FLAGS')
-b Do not call nixos-rebuild at all.
-q Don't pass -Q to nixos-rebuild
+ -s <pkgs> Use these nixpkgs clone instead of channels
-h Show this help and exit
This command helps you rebuilding your system and keeping track
@@ -37,13 +38,6 @@ usage() {
# Verbosity is on here.
nix-script -v switch -c switch -w /home/me/config -n
- Everything after a double dash (--) will be passed to nixos-rebuild as
- additional parameters. For example:
-
- nix-script switch -c switch -- -I nixpkgs=/home/user/pkgs
-
- can be used to use your local clone of the nixpkgs repository.
-
$(help_rcvars \
"RC_CONFIG - Path of your system configuration (git) directory"\
"RC_NIXPKGS - Path of your nixpkgs clone" \
@@ -66,8 +60,9 @@ TAG_FLAGS="$RC_SWITCH_DEFAULT_TAG_FLAGS"
TAG_FLAGS_NIXPKGS="$RC_SWITCH_DEFAULT_TAG_FLAGS_NIXPKGS"
DONT_BUILD=
QUIET=1
+USE_ALTERNATIVE_SOURCE_NIXPKGS=0
-while getopts "c:w:t:nbp:f:qh" OPTION
+while getopts "c:w:t:nbp:f:qs:h" OPTION
do
case $OPTION in
c)
@@ -108,6 +103,13 @@ do
dbg "QUIET = $QUIET"
;;
+ s)
+ USE_ALTERNATIVE_SOURCE_NIXPKGS=1
+ ALTERNATIVE_SOURCE_NIXPKGS="$OPTARG"
+ dbg "USE_ALTERNATIVE_SOURCE_NIXPKGS = $USE_ALTERNATIVE_SOURCE_NIXPKGS"
+ dbg "ALTERNATIVE_SOURCE_NIXPKGS = $ALTERNATIVE_SOURCE_NIXPKGS"
+ ;;
+
h)
usage
exit 1
@@ -155,7 +157,13 @@ if [[ -z "$DONT_BUILD" ]]
then
__q="-Q"
[[ $QUIET -eq 0 ]] && __q=""
- explain sudo nixos-rebuild $__q $COMMAND $ARGS
+
+ __altnixpkgs=""
+ [[ $USE_ALTERNATIVE_SOURCE_NIXPKGS -eq 1 ]] && \
+ [[ -d "$ALTERNATIVE_SOURCE_NIXPKGS" ]] && \
+ __altnixpkgs="-I nixpkgs=$ALTERNATIVE_SOURCE_NIXPKGS"
+
+ explain sudo nixos-rebuild $__q $COMMAND $ARGS $__altnixpkgs
REBUILD_EXIT=$?
else
stdout "Do not call nixos-rebuild"