From 8902ed72acf7222ec4c0f3523a7599c3c9fd6496 Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Sun, 7 Apr 2024 13:50:21 +0200 Subject: [PATCH] more hcloud stuff :3 --- flake.nix | 1 + hosts/ocelot/default.nix | 37 ++++++++++++++++++++--- hosts/ocelot/hardware-configuration.nix | 39 ------------------------- misc/nixos-infect | 2 +- profiles/base/default.nix | 3 +- profiles/hcloud/default.nix | 12 ++++++++ users/root/default.nix | 3 +- users/sammy/default.nix | 3 +- 8 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 hosts/ocelot/hardware-configuration.nix create mode 100644 profiles/hcloud/default.nix diff --git a/flake.nix b/flake.nix index 495ac97..11f2384 100644 --- a/flake.nix +++ b/flake.nix @@ -62,6 +62,7 @@ imports = [ ./hosts/${name} ./profiles/base ]; networking.hostName = name; + networking.domain = "cherrykitten.xyz"; home-manager.extraSpecialArgs = { inherit inputs outputs; diff --git a/hosts/ocelot/default.nix b/hosts/ocelot/default.nix index 3ba8718..ee53751 100644 --- a/hosts/ocelot/default.nix +++ b/hosts/ocelot/default.nix @@ -1,10 +1,39 @@ -{ ... }: { +{ lib, ... }: { imports = [ - ./hardware-configuration.nix ./gotosocial.nix + ../../profiles/hcloud ]; + fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; }; + + networking = { + nameservers = [ + "8.8.8.8" + ]; + defaultGateway = "172.31.1.1"; + defaultGateway6 = { + address = "fe80::1"; + interface = "eth0"; + }; + dhcpcd.enable = false; + usePredictableInterfaceNames = lib.mkForce false; + interfaces = { + eth0 = { + ipv4.addresses = [ + { address = "128.140.109.125"; prefixLength = 32; } + ]; + ipv6.addresses = [ + { address = "2a01:4f8:c2c:bd32::1"; prefixLength = 64; } + { address = "fe80::9400:3ff:fe24:677a"; prefixLength = 64; } + ]; + ipv4.routes = [{ address = "172.31.1.1"; prefixLength = 32; }]; + ipv6.routes = [{ address = "fe80::1"; prefixLength = 128; }]; + }; + + }; + }; + services.udev.extraRules = '' + ATTR{address}=="96:00:03:24:67:7a", NAME="eth0" + ''; - boot.tmp.cleanOnBoot = true; - zramSwap.enable = true; system.stateVersion = "23.11"; } diff --git a/hosts/ocelot/hardware-configuration.nix b/hosts/ocelot/hardware-configuration.nix deleted file mode 100644 index 4a04950..0000000 --- a/hosts/ocelot/hardware-configuration.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ modulesPath, lib, ... }: { - imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; - boot.loader.grub.device = "/dev/sda"; - boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ]; - boot.initrd.kernelModules = [ "nvme" ]; - fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; }; - - - networking = { - nameservers = [ - "8.8.8.8" - ]; - defaultGateway = "172.31.1.1"; - defaultGateway6 = { - address = "fe80::1"; - interface = "eth0"; - }; - dhcpcd.enable = false; - usePredictableInterfaceNames = lib.mkForce false; - interfaces = { - eth0 = { - ipv4.addresses = [ - { address = "128.140.109.125"; prefixLength = 32; } - ]; - ipv6.addresses = [ - { address = "2a01:4f8:c2c:bd32::1"; prefixLength = 64; } - { address = "fe80::9400:3ff:fe24:677a"; prefixLength = 64; } - ]; - ipv4.routes = [{ address = "172.31.1.1"; prefixLength = 32; }]; - ipv6.routes = [{ address = "fe80::1"; prefixLength = 128; }]; - }; - - }; - }; - services.udev.extraRules = '' - ATTR{address}=="96:00:03:24:67:7a", NAME="eth0" - ''; - -} diff --git a/misc/nixos-infect b/misc/nixos-infect index ed6a87b..9f82656 160000 --- a/misc/nixos-infect +++ b/misc/nixos-infect @@ -1 +1 @@ -Subproject commit ed6a87bc3a5e5c44cff4b30e5900b436b92ad9a1 +Subproject commit 9f826561fd578f38aded0962cfcfea70155c8536 diff --git a/profiles/base/default.nix b/profiles/base/default.nix index c1cfa97..29c7bab 100644 --- a/profiles/base/default.nix +++ b/profiles/base/default.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, inputs, ... }: { +{ lib, pkgs, inputs, ... }: { imports = [ ../../users/root ../../users/sammy @@ -7,7 +7,6 @@ deployment.tags = [ pkgs.stdenv.hostPlatform.system ]; deployment.targetUser = lib.mkDefault "sammy"; - deployment.targetHost = lib.mkDefault config.networking.fqdnOrHostName; nix = { settings = { diff --git a/profiles/hcloud/default.nix b/profiles/hcloud/default.nix new file mode 100644 index 0000000..c33f3d4 --- /dev/null +++ b/profiles/hcloud/default.nix @@ -0,0 +1,12 @@ +{ modulesPath, config, ... }: { + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; + + zramSwap.enable = true; + boot.tmp.cleanOnBoot = true; + boot.loader.grub.device = "/dev/sda"; + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ]; + boot.initrd.kernelModules = [ "nvme" ]; + + deployment.targetHost = (builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address; + deployment.tags = [ "hcloud" "hetzner" "cloud"]; +} diff --git a/users/root/default.nix b/users/root/default.nix index a30a479..caa2164 100644 --- a/users/root/default.nix +++ b/users/root/default.nix @@ -1,13 +1,12 @@ { pkgs, lib, ... }: { deployment.keys."root_password_hash" = { - destDir = "/nix/persist/keys"; keyCommand = [ "pass" "users/root/hashedPassword" ]; }; users.users.root = { shell = pkgs.fish; - hashedPasswordFile = lib.mkDefault "/nix/persist/keys/root_password_hash"; + hashedPasswordFile = lib.mkDefault "/run/keys/root_password_hash"; }; home-manager.users.root = import ./home.nix; diff --git a/users/sammy/default.nix b/users/sammy/default.nix index a317178..e3209ad 100644 --- a/users/sammy/default.nix +++ b/users/sammy/default.nix @@ -1,7 +1,6 @@ { pkgs, lib, ... }: { deployment.keys."sammy_password_hash" = { - destDir = "/nix/persist/keys"; keyCommand = [ "pass" "users/sammy/hashedPassword" ]; }; @@ -10,7 +9,7 @@ extraGroups = [ "networkmanager" "wheel" "docker" ]; shell = pkgs.fish; openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZyQSZw+pExsx2RXB+yxbaJGB9mtvudbQ/BP7E1yKvr openpgp:0x6068FEBB" ]; - hashedPasswordFile = lib.mkDefault "/nix/persist/keys/sammy_password_hash"; + hashedPasswordFile = lib.mkDefault "/run/keys/sammy_password_hash"; }; home-manager.users.sammy = import ./home.nix;