From e0e9acdac072042f9272be7c2a4bdd346a895191 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 27 Sep 2015 11:32:09 +0200 Subject: switch: Ability to parse alternative nixpkgs from normal args --- nix-script-switch.sh | 28 ++++++++++++++++++---------- 1 file 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 <] [-w ] [-- args...]") + $(help_synopsis "${BASH_SOURCE[0]}" "[-h] [-q] [-c ] [-w ]") -c Command for nixos-rebuild. See 'man nixos-rebuild' (default: switch) -w Path to your configuration git directory (default: '$RC_CONFIG') @@ -19,6 +19,7 @@ usage() { -f 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 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" -- cgit v1.2.3