From 6d7db643bce729e0e441e666dfef7d9c2d889e7d Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Sun, 1 Feb 2026 10:52:59 +0100 Subject: [PATCH] feat: add dev host --- hosts/dev/configuration.nix | 65 ++++++++++++++++++++++++++++++++ hosts/dev/modules/dev-tools.nix | 36 ++++++++++++++++++ hosts/fw/dev | 1 + hosts/fw/modules/dev-microvm.nix | 61 ++++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 hosts/dev/configuration.nix create mode 100644 hosts/dev/modules/dev-tools.nix create mode 120000 hosts/fw/dev create mode 100644 hosts/fw/modules/dev-microvm.nix diff --git a/hosts/dev/configuration.nix b/hosts/dev/configuration.nix new file mode 100644 index 0000000..19d5363 --- /dev/null +++ b/hosts/dev/configuration.nix @@ -0,0 +1,65 @@ +{ config, lib, pkgs, ... }: + +let + # === CONFIGURABLE SETTINGS === + projectsDir = "projects"; # Relative to /home/dominik + + repositories = [ + { url = "gitea@git.cloonar.com:Cloonar/wohnservice-wien-typo3.git"; path = "projects/cloonar/wohnservice-wien"} + # Add repos here: { url = "git@..."; path = "relative/path"; } + ]; + # === END CONFIGURABLE === + + cloneScript = pkgs.writeShellScript "clone-repos" '' + set -eu + HOME_DIR="/home/dominik" + PROJECTS_DIR="$HOME_DIR/${projectsDir}" + + mkdir -p "$PROJECTS_DIR" + chown dominik:users "$PROJECTS_DIR" + + ${lib.concatMapStrings (repo: '' + if [ ! -d "$PROJECTS_DIR/${repo.path}" ]; then + ${pkgs.sudo}/bin/sudo -u dominik ${pkgs.git}/bin/git clone ${repo.url} "$PROJECTS_DIR/${repo.path}" || true + fi + '') repositories} + ''; +in +{ + imports = [ + ./modules/dev-tools.nix + ]; + + networking.hostName = "dev"; + system.stateVersion = "22.05"; + time.timeZone = "Europe/Vienna"; + + # User configuration + users.users.dominik = { + isNormalUser = true; + home = "/home/dominik"; + extraGroups = [ "wheel" "docker" ]; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN/2SAFm50kraB1fepAizox/QRXxB7WbqVbH+5OPalDT47VIJGNKOKhixQoqhABHxEoLxdf/C83wxlCVlPV9poLfDgVkA3Lyt5r3tSFQ6QjjOJAgchWamMsxxyGBedhKvhiEzcr/Lxytnoz3kjDG8fqQJwEpdqMmJoMUfyL2Rqp16u+FQ7d5aJtwO8EUqovhMaNO7rggjPpV/uMOg+tBxxmscliN7DLuP4EMTA/FwXVzcFNbOx3K9BdpMRAaSJt4SWcJO2cS2KHA5n/H+PQI7nz5KN3Yr/upJN5fROhi/SHvK39QOx12Pv7FCuWlc+oR68vLaoCKYhnkl3DnCfc7A7" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIRQuPqH5fdX3KEw7DXzWEdO3AlUn1oSmtJtHB71ICoH Generated By Termius" + ]; + }; + users.groups.users = {}; + + services.openssh.enable = true; + programs.zsh.enable = true; + users.defaultUserShell = pkgs.zsh; + + # Clone repos as dominik user on boot + systemd.services.clone-repos = { + description = "Clone configured git repositories"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = cloneScript; + RemainAfterExit = true; + }; + }; +} diff --git a/hosts/dev/modules/dev-tools.nix b/hosts/dev/modules/dev-tools.nix new file mode 100644 index 0000000..27e0bf8 --- /dev/null +++ b/hosts/dev/modules/dev-tools.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: +{ + nixpkgs.overlays = [ + (import ../../utils/overlays/packages.nix) + ]; + + environment.systemPackages = with pkgs; [ + # Development tools + ddev + docker-compose + git + git-lfs + + # PHP + php + + # Node.js + nodejs_22 + + # AI coding + claude-code + + # Utilities + jq + unzip + vim + wget + curl + htop + tmux + ]; + + # Docker for ddev + virtualisation.docker.enable = true; + users.users.dominik.extraGroups = [ "docker" ]; +} diff --git a/hosts/fw/dev b/hosts/fw/dev new file mode 120000 index 0000000..009de10 --- /dev/null +++ b/hosts/fw/dev @@ -0,0 +1 @@ +../dev \ No newline at end of file diff --git a/hosts/fw/modules/dev-microvm.nix b/hosts/fw/modules/dev-microvm.nix new file mode 100644 index 0000000..965141e --- /dev/null +++ b/hosts/fw/modules/dev-microvm.nix @@ -0,0 +1,61 @@ +{ lib, pkgs, config, ... }: +let + hostname = "dev"; +in +{ + microvm.vms.dev = { + config = { + imports = [ + ../dev/configuration.nix + ./network-prefix.nix + ]; + + networkPrefix = config.networkPrefix; + + microvm = { + mem = 4096; + vcpu = 2; + + shares = [ + { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "ro-store"; + proto = "virtiofs"; + } + { + source = "/var/lib/microvms/persist/dev"; + mountPoint = "/persist"; + tag = "persist"; + proto = "virtiofs"; + } + { + source = "/var/lib/microvms/persist/dev/home"; + mountPoint = "/home"; + tag = "home"; + proto = "virtiofs"; + } + ]; + + volumes = [{ + image = "rootfs.img"; + mountPoint = "/"; + size = 51200; + }]; + + interfaces = [{ + type = "tap"; + id = "vm-${hostname}"; + mac = "02:00:00:00:02:01"; + }]; + }; + + systemd.network.networks."10-lan" = { + matchConfig.PermanentMACAddress = "02:00:00:00:02:01"; + address = [ "${config.networkPrefix}.97.15/24" ]; + gateway = [ "${config.networkPrefix}.97.1" ]; + dns = [ "${config.networkPrefix}.97.1" ]; + }; + }; + }; +}