Added stuff
This commit is contained in:
1 parent
47dd9a1137
commit
7a249c596a
4 files changed
+87
-2
No files matched your search
@@ -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'
|
||||
```
|
||||
@@ -13,6 +13,7 @@
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
python = pkgs.python312.withPackages (ps: [ ps.click ]);
|
||||
gcp = nixos-generators.nixosGenerate {
|
||||
system = "x86_64-linux";
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
|
||||
packages.gcp = gcp;
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [ pkgs.google-cloud-sdk ];
|
||||
buildInputs = [ pkgs.google-cloud-sdk python ];
|
||||
shellHook = ''
|
||||
export PROJECT_ID="all-dressed-programming"
|
||||
export BUCKET_NAME="nautilus-plus"
|
||||
|
||||
+26
-1
@@ -5,7 +5,7 @@
|
||||
system.stateVersion = "23.11";
|
||||
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.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;
|
||||
|
||||
};
|
||||
|
||||
@@ -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()
|
||||
Reference in new issue
Block a user