From 97c0427ebe14ede83dbdd81f4da29eea20beb975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Rivera?= Date: Thu, 23 Jul 2026 17:32:31 +0200 Subject: [PATCH] first basic config for nixos-anywhere --- configuration.nix | 36 ++++++++++++++++++++++++++++++++++++ disko.nix | 39 +++++++++++++++++++++++++++++++++++++++ flake.nix | 39 +++++++++++++++++++++++++++++++++++++++ home.nix | 5 +++++ users.nix | 7 +++++++ 5 files changed, 126 insertions(+) create mode 100644 configuration.nix create mode 100644 disko.nix create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 users.nix diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..ef75e95 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: + +{ + system.stateVersion = "26.05"; + + networking.hostName = "server"; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + services.openssh = { + enable = true; + + settings = { + PasswordAuthentication = false; + PermitRootLogin = "prohibit-password"; + }; + }; + + networking.firewall = { + enable = true; + + allowedTCPPorts = [ + 22 + 80 + 443 + ]; + }; + + environment.systemPackages = with pkgs; [ + git + vim + curl + wget + ]; +} diff --git a/disko.nix b/disko.nix new file mode 100644 index 0000000..c11c398 --- /dev/null +++ b/disko.nix @@ -0,0 +1,39 @@ +{ + disko.devices = { + disk = { + main = { + device = "/dev/sda"; + + type = "disk"; + + content = { + type = "gpt"; + + partitions = { + ESP = { + size = "512M"; + + type = "EF00"; + + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + + root = { + size = "100%"; + + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8777f40 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "Hetzner NixOS vps"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nixos-anywhere.url = "github:numtide/nixos-anywhere"; + + home-manager = { + url = "github:nix-community/home-manager/release-26.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, disko, home-manager, ... }: + { + nixosConfigurations.server = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + modules = [ + disko.nixosModules.disko + ./disko.nix + ./configuration.nix + ./users.nix + + home-manager.nixosModules.home-manager + + { + home-manager.users.root = import ./home.nix; + } + ]; + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..0933233 --- /dev/null +++ b/home.nix @@ -0,0 +1,5 @@ +{ + home.stateVersion = "26.05"; + + programs.bash.enable = true; +} diff --git a/users.nix b/users.nix new file mode 100644 index 0000000..a450f7e --- /dev/null +++ b/users.nix @@ -0,0 +1,7 @@ +{ + users.users.root = { + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC6WNm4YAQO85j0aNQkKSH7QnmhgzKA4hA2ggi6cDyKk" + ]; + }; +}