diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-09-27 11:32:09 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-09-27 11:47:48 +0200 |
commit | e0e9acdac072042f9272be7c2a4bdd346a895191 (patch) | |
tree | dbfe6ed424b2f06271f21e1ed34c4b2c3371d252 | |
parent | e27c36908e61b267330e063ae11f5efdfed70626 (diff) |
switch: Ability to parse alternative nixpkgs from normal args
-rwxr-xr-x | nix-script-switch.sh | 28 |
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" |