From dad9f06515b6ec7e432fcccc56165d83fddd9c13 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Mon, 11 Aug 2025 20:56:07 +0200 Subject: [PATCH] run successfully local deploy --- Makefile | 2 +- flake.nix | 49 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 545529d..b965dca 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ local-dev-shell: local-deploy: @echo "🏠 Deploying local workshop environment..." - sudo nixos-rebuild switch --flake .#workshop-local + sudo nixos-rebuild switch --impure --flake .#workshop-local @echo "✅ Local containers running!" local-ssh: diff --git a/flake.nix b/flake.nix index 9f8036d..4a44158 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,6 @@ format = "iso"; modules = [ ({ pkgs, ... }: { - # WiFi and NetworkManager networking.networkmanager.enable = true; systemd.services.workshop-wifi = { wantedBy = [ "multi-user.target" ]; @@ -35,42 +34,45 @@ ''; }; - # Auto-login and shell setup services.getty.autologinUser = "workshop"; users.users.workshop = { isNormalUser = true; shell = pkgs.zsh; }; - # Zsh shell with helper functions programs.zsh = { enable = true; interactiveShellInit = '' echo "🍪 CODE CRISPIES Workshop Environment" echo "📶 WiFi: CODE_CRISPIES_GUEST (auto-connecting...)" echo "📡 Available servers:" - ${builtins.concatStringsSep "\n" (map (name: - "echo \" - ${name}.codecrispi.es\"" - ) participantNames)} + ${builtins.concatStringsSep "\n" (map (name: "echo \" - ${name}.codecrispi.es\"") participantNames)} echo "" echo "💡 Commands: connect | recipes | help" connect() { + [ -z "$1" ] && { echo "Usage: connect "; return 1; } + echo "🔗 Connecting to $1.codecrispi.es..." ssh -o StrictHostKeyChecking=no workshop@$1.codecrispi.es } - # ... other helper functions (recipes, help) ... + + recipes() { + echo "🍪 Featured Co-op Cloud Recipes: (wordpress, nextcloud, hedgedoc...)" + echo "Browse all 100+ recipes: https://recipes.coopcloud.tech" + } + + help() { + echo "💡 Commands: connect | recipes | help" + } ''; }; - # Base packages and auto-start terminal environment.systemPackages = with pkgs; [ openssh curl git networkmanager ]; services.xserver = { enable = true; - displayManager.autoLogin = { - enable = true; - user = "workshop"; - }; - desktopManager.xfce.enable = true; # A lightweight desktop + displayManager.autoLogin.enable = true; + displayManager.autoLogin.user = "workshop"; + desktopManager.xfce.enable = true; displayManager.sessionCommands = "${pkgs.xfce.xfce4-terminal}/bin/xfce4-terminal &"; }; }) @@ -79,13 +81,26 @@ # -------------------------------------------------------------------------------- # 2. LOCAL DEVELOPMENT ENVIRONMENT (NixOS Containers) - # `sudo nixos-rebuild switch --flake .#workshop-local` + # `make local-deploy` # -------------------------------------------------------------------------------- nixosConfigurations.workshop-local = nixpkgs.lib.nixosSystem { inherit system; modules = [ - ({ pkgs, ... }: { - # Define 15 participant containers + # Dynamically import the configuration for the current host machine. + ( + let + # Read the hostname and remove the trailing newline. + hostname = builtins.replaceStrings [ "\n" ] [ "" ] (builtins.readFile "/etc/hostname"); + in + # Build the correct path to the configuration file. + /etc/nixos/hosts/${hostname}/configuration.nix + ) + + # Your container definitions are then added on top of the host config. + ({ pkgs, config, ... }: { + # Set this to your host's NixOS version (e.g., "23.11", "24.05") + system.stateVersion = "25.05"; + containers = builtins.listToAttrs (map (i: let participantNum = toString i; @@ -99,7 +114,7 @@ hostAddress = "192.168.100.1"; localAddress = ipAddr; config = { - # Container config from your local/flake.nix + system.stateVersion = "24.05"; virtualisation.docker.enable = true; environment.systemPackages = with pkgs; [ docker git curl ]; services.openssh.enable = true;