1
0
Fork 0

Create working Hetzner NixOS install

This commit is contained in:
Ethan Reece 2025-02-21 23:16:37 -06:00
parent 7e20cace41
commit 7400cecd8e
Signed by: me
GPG key ID: 198E9EB433DB1B28
3 changed files with 21 additions and 5 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
*.tfstate.backup
*.tfstate.*.backup
.terraform.lock.hcl
result

View file

@ -1,6 +1,6 @@
# OpenTofu server configuration
This is an experimental configuration for my Hetzner VPS using OpenTofu and Nix.
This is an experimental configuration for my Hetzner VPS using OpenTofu and Nix, based on [NixOS/nixos-wiki-infra on Github](https://github.com/NixOS/nixos-wiki-infra).
## How to use
@ -8,5 +8,10 @@ Copy `.env.example` to `.env` and fill in the values.
To generate a token with Hetzner, go to the project and click `Security -> API Tokens`.
Run `nix develop` to access a shell where OpenTofu is accessible.
For cross-compiling, you will need to add a builder by visiting the following resources:
- https://nix.dev/tutorials/nixos/distributed-builds-setup.html
- https://nix.dev/manual/nix/2.25/advanced-topics/distributed-builds
Run `nix develop` at the root of the project directory to access a shell where OpenTofu is accessible.
In the `targets` directory, go to the system and run the corresponding shell files to make modifications.

View file

@ -12,11 +12,14 @@ in
imports = [
self.nixosModules.hcloud
];
users.users.root.openssh.authorizedKeys.keys = nixosVars.ssh_keys;
users.users.root = {
openssh.authorizedKeys.keys = nixosVars.ssh_keys;
initialPassword = "nixos";
};
system.stateVersion = "23.11";
networking = {
hostName = "vpn";
hostName = "nixos-vpn";
};
services.openssh = {
@ -24,7 +27,14 @@ in
settings.PasswordAuthentication = false;
};
services.cloud-init.enable = lib.mkForce false;
boot.supportedFilesystems = ["btrfs"];
environment.systemPackages = [pkgs.btrfs-progs];
environment.systemPackages = [
pkgs.btrfs-progs
pkgs.shadow
pkgs.vim
pkgs.speedtest-cli
];
}