diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2017-04-13 13:42:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 13:42:28 +0200 |
commit | 73c8797d169efffe2207b79615d4af6294cd097e (patch) | |
tree | 4d1f4dfc4e7a6914fc1e69e9ce212c83ff047ecb /nixos | |
parent | d3c737a080b20638394139948934557d081a6d0a (diff) | |
download | nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.tar nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.tar.gz nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.tar.bz2 nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.tar.lz nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.tar.xz nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.tar.zst nixpkgs-73c8797d169efffe2207b79615d4af6294cd097e.zip |
gce/create-gce.sh: rewrite using nix-shell shebang and bash (#24869)
* google-cloud-sdk: 150.0.0 -> 151.0.0 - gce/create-gce.sh: rewrite using nix-shell shebang and bash - allows to run the script without being the same directory - nix-shell install google-cloud-sdk - some shellcheck cleanups and scripting best practice - gce/create-gce.sh: do not clobber NIX_PATH: this allows NIX_PATH to be overwritten to build a different release - gce/create-gce.sh: remove legacy hydra option
Diffstat (limited to 'nixos')
-rwxr-xr-x | nixos/maintainers/scripts/gce/create-gce.sh | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/nixos/maintainers/scripts/gce/create-gce.sh b/nixos/maintainers/scripts/gce/create-gce.sh index 7f8a0d23027..ef1801fe54b 100755 --- a/nixos/maintainers/scripts/gce/create-gce.sh +++ b/nixos/maintainers/scripts/gce/create-gce.sh @@ -1,15 +1,23 @@ -#! /bin/sh -e +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p google-cloud-sdk -BUCKET_NAME=${BUCKET_NAME:-nixos-images} -export NIX_PATH=nixpkgs=../../../.. -export NIXOS_CONFIG=$(dirname $(readlink -f $0))/../../../modules/virtualisation/google-compute-image.nix -export TIMESTAMP=$(date +%Y%m%d%H%M) +set -euo pipefail + +BUCKET_NAME="${BUCKET_NAME:-nixos-images}" +TIMESTAMP="$(date +%Y%m%d%H%M)" +export TIMESTAMP nix-build '<nixpkgs/nixos>' \ - -A config.system.build.googleComputeImage --argstr system x86_64-linux -o gce --option extra-binary-caches http://hydra.nixos.org -j 10 + -A config.system.build.googleComputeImage \ + --arg configuration "{ imports = [ <nixpkgs/nixos/modules/virtualisation/google-compute-image.nix> ]; }" \ + --argstr system x86_64-linux \ + -o gce \ + -j 10 -img=$(echo gce/*.tar.gz) -if ! gsutil ls gs://${BUCKET_NAME}/$(basename $img); then - gsutil cp $img gs://${BUCKET_NAME}/$(basename $img) +img_path=$(echo gce/*.tar.gz) +img_name=$(basename "$img_path") +img_id=$(echo "$img_name" | sed 's|.raw.tar.gz$||;s|\.|-|g;s|_|-|g') +if ! gsutil ls "gs://${BUCKET_NAME}/$img_name"; then + gsutil cp "$img_path" "gs://${BUCKET_NAME}/$img_name" fi -gcloud compute images create $(basename $img .raw.tar.gz | sed 's|\.|-|' | sed 's|_|-|') --source-uri gs://${BUCKET_NAME}/$(basename $img) +gcloud compute images create "$img_id" --source-uri "gs://${BUCKET_NAME}/$img_name" |