hitting stopping point with nixos-anywhere. not working on linode or hetzner

This commit is contained in:
Adriano Caloiaro 2024-12-01 08:25:24 -07:00
parent 8ac707da3b
commit 13684a8dbe
No known key found for this signature in database
GPG key ID: C2BC56DE73CE3F75
17 changed files with 3360 additions and 131 deletions

View file

@ -72,7 +72,7 @@ resource "hcloud_server_network" "sfos_network" {
resource "hcloud_network_subnet" "private_subnet" {
network_id = hcloud_network.sfos_private.id
type = "cloud"
network_zone = "us-east"
network_zone = "us-east" // See https://docs.hetzner.com/cloud/general/locations location names
ip_range = var.internal_cidr_block
}

View file

@ -24,18 +24,18 @@ locals {
# These are the private IP addresses that are assigned to each node
# We start at the buttom of the cidr range + 2 because 0 is not routable and 1 is reserved; hence "i + 2" below
node_private_ips = {
value = [for i in range(var.instance_count) : "${cidrhost(var.internal_cidr_range, i + 2)}"]
value = [for i in range(var.node_count) : "${cidrhost(var.internal_cidr_block, i + 2)}"]
}
}
resource "linode_instance" "sfos_nodes" {
count = var.instance_count
name = "sfos-${count.index}"
image = "linode/alpine3.11"
label = "sfos"
group = "sfos"
resource "linode_instance" "sfos" {
count = var.node_count
label = "sfos-${count.index}"
tags = ["sfos"]
region = var.compute_provider_region
type = var.compute_provider_node_type
authorized_keys = [linode_sshkey.sfos_admin.id]
image = "linode/ubuntu22.04"
authorized_keys = [linode_sshkey.sfos_admin.ssh_key]
}

View file

@ -0,0 +1,3 @@
output "ip_addresses" {
value = linode_instance.sfos.*.ipv4
}

View file

@ -0,0 +1 @@
/home/adriano/git/sfos/bootstrap/variables.tf

View file

@ -1,7 +1,7 @@
#cloud-config
users:
- name: sfos
groups: users, admin
groups: users, wheel, admin
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:

View file

@ -1,25 +1,31 @@
{lib, ...}: {
disko.devices = {
disk.disk1 = {
device = lib.mkDefault "/dev/sda";
content = {
type = "table";
format = "msdos";
partitions = [
{
part-type = "primary";
fs-type = "btrfs";
name = "root";
bootable = true;
content = {
type = "filesystem";
format = "btrfs";
extraArgs = ["-f" "-O block-group-tree"];
mountpoint = "/";
mountOptions = ["compress=zstd"];
};
}
];
{
type = "disk";
content = {
type = "gpt";
partitions = {
MBR = {
priority = 0;
size = "1M";
type = "EF02";
};
ESP = {
priority = 1;
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
priority = 2;
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};

View file

@ -199,11 +199,11 @@
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1732830318,
"narHash": "sha256-ZDtMCEfZsM8GLZichF4m+ANi+3e0ilhTuQZ0v1Sdj8Q=",
"lastModified": 1732896163,
"narHash": "sha256-eS0vSZT0ZUguR6Jf6CyupvDn4m+r/mgN6Vtg61ECYC0=",
"owner": "cachix",
"repo": "devenv",
"rev": "51abcb75d471a215c800937d4e30dc765d305c6d",
"rev": "2c928a199d56191d7a53f29ccafa56238c8ce4e5",
"type": "github"
},
"original": {
@ -362,15 +362,16 @@
]
},
"locked": {
"lastModified": 1732742778,
"narHash": "sha256-i+Uw8VOHzQe9YdNwKRbzvaPWLE07tYVqUDzSFTXhRgk=",
"lastModified": 1730135292,
"narHash": "sha256-CI27qHAbc3/tIe8sb37kiHNaeCqGxNimckCMj0lW5kg=",
"owner": "nix-community",
"repo": "disko",
"rev": "341482e2f4d888e3f60cae1c12c3df896e7230d8",
"rev": "ab58501b2341bc5e0fc88f2f5983a679b075ddf5",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "v1.9.0",
"repo": "disko",
"type": "github"
}
@ -792,11 +793,11 @@
"spectrum": "spectrum"
},
"locked": {
"lastModified": 1732633513,
"narHash": "sha256-6LmtOmeDpv9iHS8l0GNcppP11dKIJFMZLdFyxQ+qQBM=",
"lastModified": 1733003272,
"narHash": "sha256-ratU5qCcRuOojgPWM90gda4qrxukNqbyFi+kan2Ln04=",
"owner": "astro",
"repo": "microvm.nix",
"rev": "093ef734d3c37669860043a87dbf1c09fc6f5b38",
"rev": "e8d5f12b834a59187c7ec147a8952a0567f97939",
"type": "github"
},
"original": {
@ -995,6 +996,21 @@
"type": "github"
}
},
"nixos-facter-modules": {
"locked": {
"lastModified": 1732288619,
"narHash": "sha256-zSQ2cR+NRJfHUVfkv+O6Wi53wXfzX8KHiO8fRfnvc0M=",
"owner": "numtide",
"repo": "nixos-facter-modules",
"rev": "862648589993a96480c2255197a28feea712f68f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "nixos-facter-modules",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1732483221,
@ -1237,16 +1253,16 @@
},
"nixpkgs_8": {
"locked": {
"lastModified": 1732521221,
"narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=",
"lastModified": 1732824227,
"narHash": "sha256-fYNXgpu1AEeLyd3fQt4Ym0tcVP7cdJ8wRoqJ+CtTRyY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d",
"rev": "c71ad5c34d51dcbda4c15f44ea4e4aa6bb6ac1e9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
@ -1406,9 +1422,9 @@
"ess": "ess",
"flake-utils": "flake-utils_5",
"microvm": "microvm",
"nixos-facter-modules": "nixos-facter-modules",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_8",
"stable": "stable",
"systems": "systems_7"
}
},
@ -1428,22 +1444,6 @@
"url": "https://spectrum-os.org/git/spectrum"
}
},
"stable": {
"locked": {
"lastModified": 1732749044,
"narHash": "sha256-T38FQOg0BV5M8FN1712fovzNakSOENEYs+CSkg31C9Y=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0c5b4ecbed5b155b705336aa96d878e55acd8685",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,

View file

@ -7,13 +7,13 @@
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
stable.url = "github:NixOS/nixpkgs/nixos-24.05";
nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
systems.url = "github:nix-systems/default";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
devenv.url = "github:cachix/devenv";
disko = {
url = "github:nix-community/disko";
url = "github:nix-community/disko/v1.9.0";
inputs.nixpkgs.follows = "nixpkgs";
};
ess = {
@ -36,9 +36,9 @@
devenv,
disko,
microvm,
nixos-facter-modules,
nixpkgs,
self,
stable,
systems,
...
}: let
@ -122,22 +122,23 @@
}:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {inherit inputs outputs stable self;};
specialArgs = {inherit inputs outputs self;};
modules =
modules
++ [
disko.nixosModules.disko
./disko-config.nix
(import ./overlays)
agenix.nixosModules.default
{environment.systemPackages = [agenix.packages.${system}.default];}
disko.nixosModules.disko
{config.facter.reportPath = ./nixos/sfos-host-01/facter.json;}
./nixos/sfos-host-01/configuration.nix
nixos-facter-modules.nixosModules.facter
];
};
microvm-config = {modules}:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {inherit inputs outputs stable self;};
specialArgs = {inherit inputs outputs self;};
modules =
modules
++ [

View file

@ -1,25 +0,0 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp7s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

View file

@ -27,7 +27,7 @@ provider "tailscale" {
}
module "compute_provider" {
source = "./compute_providers/hetzner"
source = "./compute_providers/linode"
compute_provider_access_token = var.compute_provider_access_token
compute_provider_node_type = var.compute_provider_node_type
compute_provider_region = var.compute_provider_region

View file

@ -1,40 +1,71 @@
{config, ...}: {
{
config,
lib,
...
}: {
imports = [
../common/base-system.nix
../common/podman.nix
../common/incus.nix
./hardware-configuration.nix
../../modules/common/qemu.nix
./disko-config.nix
# ../../modules/common/qemu.nix
# ../common/base-system.nix
# ../../common/nix.nix
# ../common/podman.nix
# ../common/incus.nix
];
# boot.loader.grub.enable = true;
# boot.loader.systemd-boot.enable = lib.mkForce false;
# boot.loader.grub = {
# devices = ["/dev/sda"];
# extraEntries = ''
# search --set=root --fs-label disk-disk1-ESP
# '';
# };
# boot.loader.grub.device = "/dev/sda";
boot = {
supportedFilesystems = ["btrfs" "ntfs" "vfat" "ext4"];
loader.grub = {
enable = true;
forceInstall = true;
useOSProber = true;
# device = "/dev/sda";
extraGrubInstallArgs = ["--modules=nativedisk ahci pata part_gpt part_msdos diskfilter mdraid1x lvm ext2"];
fsIdentifier = "label";
# extraEntries = ''
# search --set=root --fs-label disk-disk1-ESP
# '';
};
};
users.users.sfos = {
isNormalUser = true;
extraGroups = ["wheel"];
initialPassword = "Test.123";
openssh.authorizedKeys.keys = [];
};
networking = {
hostName = "sfos-host-01";
# hostName = "sfos-01";
nftables.enable = true;
firewall = {
allowedTCPPorts = [22];
allowedUDPPorts = [config.services.tailscale.port];
interfaces.incusbr0.allowedTCPPorts = [
22
53
67
];
interfaces.incusbr0.allowedUDPPorts = [
53
67
];
# interfaces.incusbr0.allowedTCPPorts = [
# 22
# 53
# 67
# ];
# interfaces.incusbr0.allowedUDPPorts = [
# 53
# 67
# ];
};
};
sfos.incus = {
enable = true;
admin-users = ["sfos"];
};
services.openssh.enable = true;
# sfos.incus = {
# enable = true;
# admin-users = ["sfos"];
# };
services.tailscale.enable = true;
system.stateVersion = "24.05";
}

View file

@ -0,0 +1,306 @@
# Example to create a bios compatible gpt partition
{
disko.devices = {
disk = {
main = {
device = "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}
# {
# disko.devices = {
# disk = {
# main = {
# # When using disko-install, we will overwrite this value from the commandline
# device = "/dev/sda";
# type = "disk";
# content = {
# type = "gpt";
# partitions = {
# # MBR = {
# # type = "EF02"; # for grub MBR
# # size = "1M";
# # };
# boot = {
# # type = "EF00";
# size = "1024M";
# # priority = 1;
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot";
# mountOptions = ["umask=0077"];
# };
# };
# root = {
# size = "100%";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
# };
# };
# };
# };
# };
# };
# }
# {lib, ...}: {
# disko.devices = {
# disk.disk1 = {
# device = lib.mkDefault "/dev/sda";
# # type = "disk";
# content = {
# type = "table";
# format = "msdos";
# partitions = [
# {
# part-type = "primary";
# fs-type = "btrfs";
# name = "os";
# bootable = true;
# content = {
# type = "filesystem";
# format = "btrfs";
# extraArgs = ["-f"];
# mountpoint = "/";
# mountOptions = ["compress=zstd"];
# };
# }
# ];
# };
# };
# };
# }
# {
# disko.devices = {
# disk = {
# main = {
# type = "disk";
# device = "/dev/sda";
# content = {
# type = "gpt";
# partitions = {
# boot = {
# size = "5M";
# type = "EF02";
# priority = 1;
# };
# ESP = {
# size = "1024M";
# type = "EF00";
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot";
# };
# };
# root = {
# size = "100%";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
# };
# };
# };
# };
# };
# };
# }
# {
# disko.devices = {
# disk = {
# sda = {
# device = "/dev/sda";
# type = "disk";
# content = {
# type = "table";
# format = "msdos";
# partitions = [
# {
# name = "root";
# part-type = "primary";
# start = "1M";
# end = "100%";
# bootable = true;
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
# }
# ];
# };
# };
# };
# };
# }
# {lib, ...}: {
# disko.devices = {
# disk.disk1 = {
# device = lib.mkDefault "/dev/sda";
# type = "disk";
# content = {
# type = "gpt";
# partitions = {
# esp = {
# name = "ESP";
# size = "1024M";
# type = "EF00";
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot";
# };
# };
# root = {
# name = "root";
# size = "100%";
# content = {
# type = "lvm_pv";
# vg = "pool";
# };
# };
# };
# };
# };
# lvm_vg = {
# pool = {
# type = "lvm_vg";
# lvs = {
# root = {
# size = "100%FREE";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# mountOptions = [
# "defaults"
# ];
# };
# };
# };
# };
# };
# };
# }
# {
# disko.devices = {
# disk = {
# my-disk = {
# device = "/dev/sda";
# type = "disk";
# content = {
# type = "gpt";
# partitions = {
# boot = {
# name = "boot";
# size = "5M";
# type = "EF02";
# priority = 1;
# };
# esp = {
# name = "ESP";
# size = "1024M";
# type = "EF00";
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot";
# };
# };
# root = {
# size = "100%";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
# };
# };
# };
# };
# };
# };
# }
# {
# disko.devices = {
# disk = {
# main = {
# device = "/dev/sda";
# type = "disk";
# content = {
# type = "gpt";
# partitions = {
# boot = {
# size = "1M";
# type = "EF02"; # for grub MBR
# };
# root = {
# size = "100%";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
# };
# };
# };
# };
# };
# };
# }
# Example to create a bios compatible gpt partition
# {lib, ...}: {
# disko.devices = {
# disk.os = {
# device = lib.mkDefault "/dev/sda";
# type = "disk";
# content = {
# type = "gpt";
# partitions = {
# esp = {
# name = "ESP";
# size = "512M";
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot";
# };
# };
# root = {
# size = "100%";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
# };
# };
# };
# };
# };
# }

File diff suppressed because it is too large Load diff

View file

@ -1 +1,24 @@
{}
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s4.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

View file

@ -14,6 +14,8 @@ AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY>
TF_VAR_tailscale_auth_key=<TF_VAR_tailscale_auth_key>
# Access token for accessing your compute provider's provisioning API
# Below is hetzner
#export TF_VAR_compute_provider_access_token=<TF_VAR_compute_provider_access_token>
export TF_VAR_compute_provider_access_token=<TF_VAR_compute_provider_access_token>
# The SSH public key of the admin user who is able to SSH into created nodes
@ -24,6 +26,7 @@ export TF_VAR_admin_ssh_public_key=<TF_VAR_admin_ssh_public_key>
#######################################################################################################################
# The name your compute provider uses to refer to the type of compute resource/node you're creating, e.g Hetzner 'cpx21' for CPX21 server
# Linode types can be retrieved with: linode-cli linodes types
export TF_VAR_compute_provider_node_type=<TF_VAR_compute_provider_node_type>
# The region in which to create compute nodes

View file

@ -8,21 +8,21 @@
../../common/nix.nix
];
boot = {
initrd.systemd.enable = true;
tmp = {
cleanOnBoot = true;
useTmpfs = true;
};
# boot = {
# initrd.systemd.enable = true;
# tmp = {
# cleanOnBoot = true;
# useTmpfs = true;
# };
loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
configurationLimit = 20;
};
};
};
# loader = {
# efi.canTouchEfiVariables = true;
# systemd-boot = {
# enable = true;
# configurationLimit = 20;
# };
# };
# };
environment = {
systemPackages = with pkgs; [

File diff suppressed because it is too large Load diff