diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-09-20 18:37:17 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-02-05 23:15:18 +0100 |
commit | fb051f0dece79d2ac28ad368d6e26289d780bc0a (patch) | |
tree | dfb93e77a3e052eec3f601855dbdedbfa780cf2c /nixos/modules | |
parent | 20087bd5534e115a1c7ddd5279610bc437c39046 (diff) |
nixos-{rebuild,container}: Use flakeref#attrpath syntax
This makes them consistent with the 'nix' command line.
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/installer/tools/nixos-rebuild.sh | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index 18088e4f9ea41..b681a170b6bd3 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -100,10 +100,6 @@ while [ "$#" -gt 0 ]; do flake="$1" shift 1 ;; - --config) - flakeAttr="nixosConfigurations.$1" - shift 1 - ;; *) echo "$0: unknown option \`$i'" exit 1 @@ -254,12 +250,20 @@ fi # For convenience, use the hostname as the default configuration to # build from the flake. -if [[ -n $flake && -z $flakeAttr ]]; then - hostname=$(cat /proc/sys/kernel/hostname) - if [[ -z $hostname ]]; then - hostname=default +if [[ -n $flake ]]; then + if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then + flake="${BASH_REMATCH[1]}" + flakeAttr="${BASH_REMATCH[2]}" + fi + if [[ -z $flakeAttr ]]; then + hostname=$(cat /proc/sys/kernel/hostname) + if [[ -z $hostname ]]; then + hostname=default + fi + flakeAttr="nixosConfigurations.\"$hostname\"" + else + flakeAttr="nixosConfigurations.\"$flakeAttr\"" fi - flakeAttr="nixosConfigurations.\"$hostname\"" fi # Resolve the flake. @@ -391,17 +395,13 @@ fi # or "boot"), or just build it and create a symlink "result" in the # current directory (for "build" and "test"). if [ -z "$rollback" ]; then - if [[ -z $flake ]]; then - echo "building the system configuration..." >&2 - else - echo "building the system configuration '$flake:$flakeAttr'..." >&2 - fi + echo "building the system configuration..." >&2 if [ "$action" = switch -o "$action" = boot ]; then if [[ -z $flake ]]; then pathToConfig="$(nixBuild '<nixpkgs/nixos>' --no-out-link -A system "${extraBuildFlags[@]}")" else outLink=$tmpDir/result - nix build "$flake:$flakeAttr.config.system.build.toplevel" --keep-going "${extraBuildFlags[@]}" --out-link $outLink + nix build "$flake#$flakeAttr.config.system.build.toplevel" --keep-going "${extraBuildFlags[@]}" --out-link $outLink pathToConfig="$(readlink -f $outLink)" fi copyToTarget "$pathToConfig" @@ -410,7 +410,7 @@ if [ -z "$rollback" ]; then if [[ -z $flake ]]; then pathToConfig="$(nixBuild '<nixpkgs/nixos>' -A system -k "${extraBuildFlags[@]}")" else - nix build "$flake:$flakeAttr.config.system.build.toplevel" --keep-going "${extraBuildFlags[@]}" + nix build "$flake#$flakeAttr.config.system.build.toplevel" --keep-going "${extraBuildFlags[@]}" pathToConfig="$(readlink -f ./result)" fi elif [ "$action" = build-vm ]; then |