mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 22:57:55 +00:00
scripts: init
This commit is contained in:
parent
8e462418e3
commit
918d450134
@ -161,6 +161,7 @@ nixos-config
|
||||
├── lib/
|
||||
├── modules/
|
||||
├── pkgs/
|
||||
├── scripts/
|
||||
├── secrets/
|
||||
├── shells/
|
||||
├── templates/
|
||||
@ -183,6 +184,9 @@ For more information, see the link:./modules/README.adoc[related documentation].
|
||||
* link:./pkgs/[`./pkgs/`] contains my custom packages.
|
||||
It is exported in the flakes at `outputs.packages` compiled through various systems.
|
||||
|
||||
* link:./scripts/[./scripts/] contains various scripts for various purposes.
|
||||
Should be self-explanatory.
|
||||
|
||||
* link:./secrets/[`./secrets/`] contains my secrets managed with link:https://github.com/mozilla/sops[sops] and link:https://github.com/Mic92/sops-nix[sops-nix].
|
||||
|
||||
* link:./shells/[`./shells/`] contains my development shells for interacting with the usual type of projects.
|
||||
|
58
scripts/generate-and-upload-gce-image
Executable file
58
scripts/generate-and-upload-gce-image
Executable file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p google-cloud-sdk
|
||||
#
|
||||
# This is a modified script `nixos/maintainers/scripts/gce/create-gce.sh' from
|
||||
# `nixpkgs'.
|
||||
#
|
||||
# Licensed under MIT license
|
||||
# Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
||||
# 2022 Gabriel Arazas
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
BUCKET_NAME="${BUCKET_NAME:-foodogsquared-operating-system-images-dumping-ground}"
|
||||
TIMESTAMP="$(date +%Y%m%d%H%M)"
|
||||
PACKAGE=plover-gce
|
||||
DIRECTORY=gce-image
|
||||
export TIMESTAMP
|
||||
|
||||
nix build ".#$PACKAGE" -o "$DIRECTORY"
|
||||
|
||||
img_path=$(echo "$DIRECTORY"/*.tar.gz)
|
||||
img_name=${IMAGE_NAME:-$(basename "$img_path")}
|
||||
img_id=$(echo "$img_name" | sed 's|.raw.tar.gz$||;s|\.|-|g;s|_|-|g')
|
||||
img_family=$(echo "$img_id" | cut -d - -f1-4)
|
||||
|
||||
if ! gsutil ls "gs://${BUCKET_NAME}/$img_name"; then
|
||||
gsutil cp "$img_path" "gs://${BUCKET_NAME}/$img_name"
|
||||
|
||||
gcloud compute images create \
|
||||
"$img_id" \
|
||||
--source-uri "gs://${BUCKET_NAME}/$img_name" \
|
||||
--family="$img_family"
|
||||
|
||||
gcloud compute images add-iam-policy-binding \
|
||||
"$img_id" \
|
||||
--member='allAuthenticatedUsers' \
|
||||
--role='roles/compute.imageUser'
|
||||
fi
|
||||
|
||||
# vi:ft=bash
|
Loading…
Reference in New Issue
Block a user