Skip to content

Commit

Permalink
feat: added CI configs
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-roux-404 committed May 22, 2024
1 parent 3bec1d0 commit 423e81d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-nixos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:

- name: Build
id: build
run: .#nixosConfigurations.x86_64-linux.contabo
run: nix build .#nixosConfigurations.x86_64-linux.contabo

- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: nixos-k3s-paas-${{ steps.vars.outputs.sha_short }}
tag_name: nixos-${{ steps.vars.outputs.sha_short }}
token: "${{ secrets.GITHUB_TOKEN }}"
generate_release_notes: true
files: |
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ bootstrap:
build:
@$(BUILDER_EXEC) nix build .#nixosConfigurations.aarch64-darwin.default --system aarch64-linux $(ARGS)

build-x86:
@$(BUILDER_EXEC) nix build .#nixosConfigurations.x86_64-darwin.default --system x86_64-linux $(ARGS)

#### Terraform

TF_ROOT_DIRS := $(wildcard tf-root-*) .
Expand All @@ -32,4 +35,4 @@ $(TF_ROOT_DIRS_DESTROY):
@$(eval DIR:=$(subst -destroy,,$@))
@terraform -chdir=$(DIR) destroy -auto-approve $(ARGS)

.PHONY: build bootstrap init $(TF_ROOT_DIRS) $(TF_ROOT_DIRS_DESTROY) $(TF_ROOT_DIRS_INIT)
.PHONY: build build-x86 bootstrap init $(TF_ROOT_DIRS) $(TF_ROOT_DIRS_DESTROY) $(TF_ROOT_DIRS_INIT)
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@

# Need a bare darwinConfigurations.builder started before building this one.
builder-docker = self.darwinConfigurations.builder.override {
specialArgs = {
linux-builder-config = ./nixos-darwin/linux-builder-docker.nix;
extraModules = singleton {
nix.linux-builder.config = ./nixos-darwin/linux-builder-docker.nix;
};
};

Expand Down
3 changes: 0 additions & 3 deletions nixos-darwin/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
pkgs,
config,
linux-builder-config ? ({ pkgs, ... }: {}),
... }:
{
programs.fish.enable = true;
Expand Down Expand Up @@ -101,8 +100,6 @@
maxJobs = 8;
package = pkgs.darwin.linux-builder-x86_64;
ephemeral = true;
config = linux-builder-config;
systems = [ "aarch64-linux" "x86_64-linux" ];
};
nix.configureBuildUsers = true;
services.nix-daemon.enable = true;
Expand Down
4 changes: 1 addition & 3 deletions nixos-darwin/linux-builder-docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, ... }: {
{ pkgs, lib, ... }: {
virtualisation.docker.enable = true;
virtualisation.docker.daemon.settings = {
hosts = [ "tcp://0.0.0.0:2375" ];
Expand All @@ -8,8 +8,6 @@
{ from = "host"; guest.port = 22; host.port = 31022; }
{ from = "host"; guest.port = 2375; host.port = 2375; }
];
virtualisation.rosetta.enable = true;
nix.settings.extra-platforms = [ "x86_64-linux" ];
security.sudo.wheelNeedsPassword = false;
users.users.builder.extraGroups = lib.mkForce [ "docker" "wheel" ];
}
2 changes: 1 addition & 1 deletion nixos-options/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
certs = lib.mkOption {
default = [{
url = "https://localhost:15000/intermediates/0";
sha256 = "1vcm965pnkv24vgqg85qg8bjw10a5wr8rrnahm50yphak6jgxcmx";
sha256 = "06fpbiljbzmcnfsxnr92p7mhm6i4yglbhj5q7csw2pcsklw68z8n";
}];
type = lib.types.listOf (lib.types.attrs);
description = "Ca url to fetch and trust (need to be impure)";
Expand Down
39 changes: 20 additions & 19 deletions tf-root-contabo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ resource "tailscale_tailnet_key" "k3s_paas_node" {
description = "VM instance key"
}

# resource "contabo_image" "paas_instance_qcow2" {
# name = "k3s"
# image_url = var.image_url
# os_type = "Linux"
# version = var.ubuntu_release_info.iso_version_tag
# description = "Generated PaaS vm image with packer"
# }
resource "contabo_image" "paas_instance_qcow2" {
name = "k3s"
image_url = var.image_url
os_type = "Linux"
version = var.ubuntu_release_info.iso_version_tag
description = "Generated PaaS vm image with packer"
}

data "contabo_instance" "paas_instance" {
id = var.contabo_instance
Expand All @@ -64,15 +64,16 @@ resource "gandi_livedns_record" "www" {
data.contabo_instance.paas_instance.ip_config[0].v4[0].ip
]
}
# resource "contabo_instance" "paas_instance" {
# existing_instance_id = var.contabo_instance
# display_name = "nixos-k3s-paas"
# image_id = contabo_image.paas_instance_qcow2.id
# ssh_keys = [contabo_secret.paas_instance_ssh_key.id]
# user_data = sensitive(templatefile(
# "${path.root}/user-data.yaml.tmpl",
# {
# tailscale_key = tailscale_tailnet_key.k3s_paas_node.key
# }
# ))
# }

resource "contabo_instance" "paas_instance" {
existing_instance_id = var.contabo_instance
display_name = "nixos-k3s-paas"
image_id = contabo_image.paas_instance_qcow2.id
ssh_keys = [contabo_secret.paas_instance_ssh_key.id]
user_data = sensitive(templatefile(
"${path.root}/user-data.yaml.tmpl",
{
tailscale_key = tailscale_tailnet_key.k3s_paas_node.key
}
))
}
5 changes: 5 additions & 0 deletions tf-root-contabo/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ variable "gandi_token" {
variable "gandi_dnssec_public_key" {
type = string
}

variable "image_url" {
type = string
default = "https://github.com/loic-roux-404/k3s-paas/releases/download/nixos-a665502/nixos.qcow2"
}

0 comments on commit 423e81d

Please sign in to comment.