Added stuff

This commit is contained in:
didier committed 2024-10-25 06:43:41 -04:00
1 parent 47dd9a1137
commit 7a249c596a
4 files changed
+87 -2

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# Nixos on GCP
```
img_path=$(echo result/*.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)
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'
```
+2 -1
View File
@@ -13,6 +13,7 @@
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python312.withPackages (ps: [ ps.click ]);
gcp = nixos-generators.nixosGenerate { gcp = nixos-generators.nixosGenerate {
system = "x86_64-linux"; system = "x86_64-linux";
@@ -26,7 +27,7 @@
packages.gcp = gcp; packages.gcp = gcp;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.google-cloud-sdk ]; buildInputs = [ pkgs.google-cloud-sdk python ];
shellHook = '' shellHook = ''
export PROJECT_ID="all-dressed-programming" export PROJECT_ID="all-dressed-programming"
export BUCKET_NAME="nautilus-plus" export BUCKET_NAME="nautilus-plus"
+26 -1
View File
@@ -5,7 +5,7 @@
system.stateVersion = "23.11"; system.stateVersion = "23.11";
boot.kernel.sysctl."net.ipv4.ip_forward" = true; boot.kernel.sysctl."net.ipv4.ip_forward" = true;
networking.nameservers = [ "8.8.8.8" ]; # Todo: include? "169.254.169.254"]; networking.nameservers = [ "8.8.8.8" ];
virtualisation.containers.enable = true; virtualisation.containers.enable = true;
virtualisation.docker = { virtualisation.docker = {
@@ -27,6 +27,31 @@
}; };
}; };
users.extraUsers.didier = {
createHome = true;
isNormalUser = true;
home = "/home/didier";
description = "didier";
group = "users";
extraGroups = [ "wheel" ];
useDefaultShell = true;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILtqtELim0nDxVG0j/IJc/ZcWYfFBCay8fVIw/16ieDy didier.amyot@all-dressed-programming.com"
];
};
environment.systemPackages = with pkgs; [
vim
wget
vim
git
htop
curl
bat
ripgrep
helix
];
services.openssh.settings.PasswordAuthentication = false; services.openssh.settings.PasswordAuthentication = false;
}; };
+49
View File
@@ -0,0 +1,49 @@
from pathlib import Path
import sys
import click
from subprocess import check_call
def index_of(str, char, cnt):
for i, char_ in enumerate(str):
if char == char_:
cnt -= 1
if cnt == 0:
return i
return -1
@click.command()
@click.option('--file', required=True, type=click.Path(exists=True,
dir_okay=False,
resolve_path=True,
path_type=Path))
@click.option('--bucket-name', envvar='BUCKET_NAME')
def main(file, bucket_name):
"""Upload the gce cloud image."""
img_id = file.name[:file.name.index('.raw.tar.gz')].replace('.', '-').replace('_', '-')
img_family = 'nixos-image-24-11'
s3_loc = f"gs://{bucket_name}/{file.name}"
cmd = [
'gsutil', 'cp', file, s3_loc
]
check_call(cmd)
cmd = [
'gcloud', 'compute','images','create', img_id,
'--source-uri', s3_loc, '--family', img_family
]
# check_call(cmd)
# print(' '.join(cmd))
# return
cmd = [
'gcloud', 'compute', 'images', 'add-iam-policy-binding',
img_id, "--member", 'allAuthenticatedUsers', "--role", 'roles/compute.imageUser'
]
check_call(cmd)
if __name__ == '__main__':
main()