Skip to content

Commit

Permalink
feat(hosts): add hetzner vps
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenhoenle committed Jan 31, 2025
1 parent 012f125 commit 796f111
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

`nixos-rebuild switch --build-host root@mandalore --target-host root@mandalore --flake ".#mandalore"`

`nixos-rebuild switch --build-host root@vps --target-host root@vps --flake ".#vps"`

## Installation

`nix run github:nix-community/nixos-anywhere/1.3.0 -- --flake .#vps [email protected] --build-on-remote`

## Startup

`ssh root@<IP> -p 2222`
Expand Down
37 changes: 37 additions & 0 deletions disko-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02";
priority = 1;
};
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}
21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, nixpkgs-unstable, agenix, treefmt-nix, nixos-hardware, ... }:
outputs = { self, nixpkgs, nixpkgs-unstable, agenix, disko, treefmt-nix, nixos-hardware, ... }:
let
pkgs = system: import nixpkgs {
inherit system;
Expand Down Expand Up @@ -49,6 +53,7 @@
pkgs-unstable = pkgs-unstable host.system;
};
modules = [
disko.nixosModules.disko
agenix.nixosModules.default
{
_module.args.agenix = agenix.packages.${host.system}.default;
Expand Down
15 changes: 15 additions & 0 deletions hardware/hetzner-vm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ lib, 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 = [ ];
swapDevices = [ ];
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}
23 changes: 23 additions & 0 deletions hosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
nixosModules = [
./hardware/thinkcentre-m710q.nix
./modules/boot.nix
./modules/secrets.nix
{
networking.hostName = "mandalore";

Expand Down Expand Up @@ -33,4 +34,26 @@
}
];
}
{
name = "vps";
system = "x86_64-linux";
nixosModules = [
./hardware/hetzner-vm.nix
./disko-config.nix
{
networking.hostName = "vps";

services.nginx.enable = true;

boot.loader.grub.enable = true;

swapDevices = [{
device = "/var/lib/swapfile";
size = 4 * 1024;
}];

system.stateVersion = "24.11";
}
];
}
]
1 change: 0 additions & 1 deletion modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
./locales.nix
./networking.nix
./nix.nix
./secrets.nix
./users.nix
];
}

0 comments on commit 796f111

Please sign in to comment.