diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dfed87a..c7ae2db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,23 +27,23 @@ jobs: - uses: actions/checkout@v6 - run: nix build --print-build-logs .#homeConfigurations.samueles.activationPackage - hm-docker-x86: + hm-sandbox-amd64: runs-on: ubuntu-24.04 steps: - uses: cachix/install-nix-action@v31 - uses: actions/checkout@v6 - run: nix build --print-build-logs .#homeConfigurations.agent-amd64.activationPackage - hm-docker-arm: + hm-ubuntu: runs-on: ubuntu-24.04-arm steps: - uses: cachix/install-nix-action@v31 - uses: actions/checkout@v6 - - run: nix build --print-build-logs .#homeConfigurations.agent-arm64.activationPackage + - run: nix build --print-build-logs .#homeConfigurations."admin@ubuntu".activationPackage - hm-tart: + hm-tahoe-vanilla: runs-on: macos-26 steps: - uses: cachix/install-nix-action@v31 - uses: actions/checkout@v6 - - run: nix build --print-build-logs .#homeConfigurations.admin.activationPackage + - run: nix build --print-build-logs .#homeConfigurations."admin@tahoe-vanilla".activationPackage diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 7de9041..8b808f0 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -55,7 +55,7 @@ jobs: name: flake.lock - run: nix build --print-build-logs .#homeConfigurations.samueles.activationPackage - hm-docker-x86: + hm-sandbox-amd64: needs: lock runs-on: ubuntu-24.04 steps: @@ -66,7 +66,7 @@ jobs: name: flake.lock - run: nix build --print-build-logs .#homeConfigurations.agent-amd64.activationPackage - hm-docker-arm: + hm-ubuntu: needs: lock runs-on: ubuntu-24.04-arm steps: @@ -75,9 +75,9 @@ jobs: - uses: actions/download-artifact@v8 with: name: flake.lock - - run: nix build --print-build-logs .#homeConfigurations.agent-arm64.activationPackage + - run: nix build --print-build-logs .#homeConfigurations."admin@ubuntu".activationPackage - hm-tart: + hm-tahoe-vanilla: needs: lock runs-on: macos-26 steps: @@ -86,7 +86,7 @@ jobs: - uses: actions/download-artifact@v8 with: name: flake.lock - - run: nix build --print-build-logs .#homeConfigurations.admin.activationPackage + - run: nix build --print-build-logs .#homeConfigurations."admin@tahoe-vanilla".activationPackage pr: needs: @@ -94,9 +94,9 @@ jobs: - nixos - hm-nixos - hm-macos - - hm-docker-x86 - - hm-docker-arm - - hm-tart + - hm-sandbox-amd64 + - hm-ubuntu + - hm-tahoe-vanilla runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 289e459..0000000 --- a/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu -ARG TARGETARCH -RUN apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y curl git sudo xz-utils -RUN useradd -m -s /bin/bash agent-${TARGETARCH} \ - && usermod -aG sudo agent-${TARGETARCH} \ - && echo "agent-${TARGETARCH} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/agent \ - && chmod 0440 /etc/sudoers.d/agent \ - && mkdir -m 0755 /nix \ - && chown agent-${TARGETARCH} /nix -USER agent-${TARGETARCH} -RUN curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --no-daemon \ - && mkdir -p ~/.config/nix \ - && echo 'experimental-features = nix-command flakes' > ~/.config/nix/nix.conf -ENV USER=agent-${TARGETARCH} -ENV PATH=/home/agent-${TARGETARCH}/.nix-profile/bin:$PATH -RUN git clone https://github.com/samestep/env.git ~/github/samestep/env \ - && ln -fsT ~/github/samestep/env ~/.config/home-manager \ - && nix run ~/github/samestep/env#home-manager -- switch -b backup diff --git a/README.md b/README.md index 0b50976..30a5695 100644 --- a/README.md +++ b/README.md @@ -49,20 +49,9 @@ ln -s ~/github/samestep/env ~/.config/home-manager nix run ~/github/samestep/env#home-manager switch ``` -## Docker ([x86](docker-x86) and [ARM](docker-arm)) +## [libvirt](sandbox-amd64) -This repo also contains dedicated Home Manager configs for use in an Ubuntu Docker container; for instance: - -```sh -docker build . -t agent -docker create agent sleep infinity -``` - -Then in VS Code, start the container and [attach to it](https://code.visualstudio.com/docs/devcontainers/attach-container). - -## [libvirt](docker-x86) - -The Docker configs can also be used for virtual machines. First make sure you have [virt-manager](https://virt-manager.org/), virt-viewer, and the [libvirt NSS module](https://libvirt.org/nss.html) installed, as they are in this repo's NixOS config. Then make sure you've started the `default` network: +This config can also be used for x86 Linux virtual machines on Linux. First make sure you have [virt-manager](https://virt-manager.org/), virt-viewer, and the [libvirt NSS module](https://libvirt.org/nss.html) installed, as they are in this repo's NixOS config. Then make sure you've started the `default` network: ```sh virsh -c qemu:///system net-start default @@ -176,41 +165,42 @@ And run this repo's script to generate `~/.ssh/tailnet`: tailnet ``` -## [Lima](docker-arm) +## [Tart (Linux)](ubuntu) -Similarly, the ARM Linux config can be used for a Linux virtual machine on macOS, via [Lima](https://lima-vm.io/) which comes with the host-side macOS config in this repo. First create the VM: +This config can be used for ARM Linux virtual machines on macOS, via [Tart](https://tart.run/) which comes with the host-side macOS config in this repo. First, download an Ubuntu image: -- The username and home directory location must be set to match what this Home Manager config expects. -- Lima mounts the host-side home directory to the same path in the VM by default, so we disable that for security purposes. -- By default Lima only gives the VM [user-mode networking](https://lima-vm.io/docs/config/network/user-v2/) (a userspace TCP/IP stack on the host), and SSH reaches the VM via a port forward through that stack, which adds enough per-packet latency to make interactive SSH typing lag. We add a [`vzNAT`](https://lima-vm.io/docs/config/network/vmnet/) interface so the VM also gets a real IP on Apple's `vmnet` network (the same `192.168.64.0/24` network, and mechanism, that Tart uses), reachable directly from the host. SSH straight to that IP to get the low-latency path. This requires `vmType: vz`, which is the default on Apple Silicon. -- Nested virtualization is necessary for KVM to be available inside the VM. +```sh +tart clone ghcr.io/cirruslabs/ubuntu:latest ubuntu +``` + +By default, Tart doesn't give the VM all CPU cores, and only gives 8 GiB of RAM and 50 GB of disk space, so adjust those as appropriate: ```sh -limactl start --name sandbox-arm64 --cpus 18 --memory 32 --disk 2000 --set '.user.name = "agent-arm64" | .user.home = "/home/agent-arm64" | .mounts = [] | .networks = [{"vzNAT": true}] | .nestedVirtualization = true' template:ubuntu +tart set ubuntu --cpu 18 --memory 32768 --disk-size 2000 ``` -Then configure it to start automatically in the background: +Start up the VM: ```sh -limactl autostart enable sandbox-arm64 +tart run --no-graphics ubuntu ``` -Enable Lima's SSH setup: +Leave that running and, in a different terminal, give the VM your public SSH key give the VM your public SSH key so you don't need to type the password each time you connect: ```sh -echo 'Include ~/.lima/*/ssh.config' >> ~/.ssh/config +ssh-copy-id admin@$(tart ip ubuntu) ``` -Then SSH into the new VM. The `lima-sandbox-arm64` alias enabled by the previous command is fine for things like Git remotes, but laggy for interactive SSH, so use the following command instead: +While adding the SSH key, you will need to type the password, which is `admin`. Then SSH into the VM: ```sh -ssh -i ~/.lima/_config/user agent-arm64@lima-sandbox-arm64.local +ssh admin@$(tart ip ubuntu) ``` -That command will start squawking after a reboot unless you run the following in the VM: +Avoid ten-second hangs by enabling Ubuntu to resolve the local hostname: ```sh -echo 'ssh_deletekeys: false' | sudo tee /etc/cloud/cloud.cfg.d/99-keep-ssh-host-keys.cfg +echo "127.0.1.1 $(hostname)" | sudo tee -a /etc/hosts ``` Next, install Nix: @@ -219,7 +209,13 @@ Next, install Nix: sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --daemon ``` -Clone this repo: +Enable [flakes][]: + +```sh +echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf +``` + +After installing Nix you'll need to log back out and back in. Then clone this repo: ```sh git clone https://github.com/samestep/env.git ~/github/samestep/env @@ -228,7 +224,7 @@ git clone https://github.com/samestep/env.git ~/github/samestep/env Make a symlink for Home Manager: ```sh -ln -fsT ~/github/samestep/env ~/.config/home-manager +mkdir -p ~/.config && ln -fsT ~/github/samestep/env ~/.config/home-manager ``` And activate the config: @@ -246,7 +242,7 @@ curl -fsSL https://tailscale.com/install.sh | sh Connect to the tailnet: ```sh -sudo tailscale up --ssh --hostname=sandbox-arm64 +sudo tailscale up --ssh --hostname=ubuntu ``` And run this repo's script to generate `~/.ssh/tailnet`: @@ -255,15 +251,15 @@ And run this repo's script to generate `~/.ssh/tailnet`: tailnet ``` -## [Tart](tart) +## [Tart (macOS)](tahoe-vanilla) -This config can be used for macOS VMs created with [Tart](https://tart.run/), which comes with the host-side macOS config in this repo. First, download a macOS image: +This config can be used for macOS VMs, again using [Tart](https://tart.run/). First, download a macOS image: ```sh tart clone ghcr.io/cirruslabs/macos-tahoe-vanilla:latest tahoe-vanilla ``` -By default, Tart doesn't give the VM all CPU cores, and only gives 8 GiB of RAM and 50 GB of disk space, so adjust those as appropriate: +Expand the provided CPU cores, RAM, and disk space: ```sh tart set tahoe-vanilla --cpu 18 --memory 16384 --disk-size 1000 @@ -317,13 +313,13 @@ Now shut down the VM again and reboot it once more, this time without graphics: tart run --no-graphics tahoe-vanilla ``` -Leave that running and, in a different terminal, give the VM your public SSH key give the VM your public SSH key so you don't need to type the password each time you connect: +In a different terminal, give the VM your public SSH key, using the password `admin`: ```sh ssh-copy-id admin@$(tart ip tahoe-vanilla) ``` -While adding the SSH key, you will need to type the password, which is `admin`. Then SSH into the VM: +Then SSH into the VM: ```sh ssh admin@$(tart ip tahoe-vanilla) diff --git a/agent.md b/agent.md index a0f0165..9731cd5 100644 --- a/agent.md +++ b/agent.md @@ -37,7 +37,7 @@ ssh sandbox-amd64 For the `aarch64-linux` VM: ```sh -ssh sandbox-arm64 +ssh ubuntu ``` For the `aarch64-darwin` VM: diff --git a/bin/tailnet.py b/bin/tailnet.py index 059f1c0..7cd170f 100644 --- a/bin/tailnet.py +++ b/bin/tailnet.py @@ -3,7 +3,7 @@ import subprocess from pathlib import Path -HOSTS = ["sandbox-amd64", "sandbox-arm64", "tahoe-vanilla"] +HOSTS = ["sandbox-amd64", "ubuntu", "tahoe-vanilla"] def main(): diff --git a/docker-arm/home-manager/home.nix b/docker-arm/home-manager/home.nix deleted file mode 100644 index 2f02fc3..0000000 --- a/docker-arm/home-manager/home.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ ... }: -{ - home = { - # # https://nix-community.github.io/home-manager/release-notes.xhtml - stateVersion = "25.11"; - - username = "agent-arm64"; - homeDirectory = "/home/agent-arm64"; - }; - - programs.bash.enable = true; # Necessary for aliases and Starship to work. -} diff --git a/flake.nix b/flake.nix index 2da4404..dfe8578 100644 --- a/flake.nix +++ b/flake.nix @@ -109,21 +109,6 @@ commaOverlay npc.overlays.default moss.overlays.default - (final: prev: { - lima = - assert final.lib.assertMsg (final.lib.versionOlder prev.lima.version "2.2.0") - "Nixpkgs now ships Lima ${prev.lima.version} (>= 2.2.0); check if this fix is merged: https://github.com/lima-vm/lima/pull/5088"; - prev.lima.overrideAttrs (old: { - version = "2.2.0-unstable-2026-07-02"; - src = final.fetchFromGitHub { - owner = "resker"; - repo = "lima"; - rev = "f14b343a14f38490a76b9bac144fce1a3cf43d0b"; - hash = "sha256-eyvz7XbZKUVQZdSVmDmYlHQSCKFE23OeIH4N4hNDg3M="; - }; - vendorHash = "sha256-nwNDuE76fVncegDKI/Fztpc30NX8/shNbSfzkrwTPDk="; - }); - }) ]; }; modules = [ @@ -148,10 +133,10 @@ nix-index-database.homeModules.default ./modules/base.nix ./modules/yolo.nix - ./docker-x86/home-manager/home.nix + ./sandbox-amd64/home-manager/home.nix ]; }; - "agent-arm64" = home-manager.lib.homeManagerConfiguration { + "admin@ubuntu" = home-manager.lib.homeManagerConfiguration { pkgs = import nixpkgs { system = "aarch64-linux"; overlays = [ @@ -164,10 +149,10 @@ nix-index-database.homeModules.default ./modules/base.nix ./modules/yolo.nix - ./docker-arm/home-manager/home.nix + ./ubuntu/home-manager/home.nix ]; }; - "admin" = home-manager.lib.homeManagerConfiguration { + "admin@tahoe-vanilla" = home-manager.lib.homeManagerConfiguration { pkgs = import nixpkgs { system = "aarch64-darwin"; overlays = [ @@ -180,7 +165,7 @@ nix-index-database.homeModules.default ./modules/base.nix ./modules/yolo.nix - ./tart/home-manager/home.nix + ./tahoe-vanilla/home-manager/home.nix ]; }; }; diff --git a/macos/home-manager/home.nix b/macos/home-manager/home.nix index 6bf877a..f5fd3ba 100644 --- a/macos/home-manager/home.nix +++ b/macos/home-manager/home.nix @@ -18,7 +18,6 @@ packages = [ pkgs.gh - pkgs.lima pkgs.tart ]; diff --git a/modules/vscode.nix b/modules/vscode.nix index 0e5288e..c2cda9d 100644 --- a/modules/vscode.nix +++ b/modules/vscode.nix @@ -17,12 +17,8 @@ vscode.llvm-vs-code-extensions.vscode-clangd vscode.mkhl.direnv vscode.moss-lang.moss-vscode - vscode.ms-azuretools.vscode-containers - vscode.ms-azuretools.vscode-docker vscode.ms-python.python vscode.ms-python.vscode-pylance - vscode.ms-vscode-remote.remote-containers - vscode.ms-vscode-remote.remote-ssh vscode.ms-vscode.cmake-tools vscode.myriad-dreamin.tinymist vscode.ocamllabs.ocaml-platform diff --git a/docker-x86/home-manager/home.nix b/sandbox-amd64/home-manager/home.nix similarity index 73% rename from docker-x86/home-manager/home.nix rename to sandbox-amd64/home-manager/home.nix index 28ba0d3..96224ff 100644 --- a/docker-x86/home-manager/home.nix +++ b/sandbox-amd64/home-manager/home.nix @@ -1,7 +1,7 @@ { ... }: { home = { - # # https://nix-community.github.io/home-manager/release-notes.xhtml + # https://nix-community.github.io/home-manager/release-notes.xhtml stateVersion = "25.11"; username = "agent-amd64"; diff --git a/ssh/config b/ssh/config index c0f093d..aa213af 100644 --- a/ssh/config +++ b/ssh/config @@ -3,8 +3,8 @@ Include tailnet Host sandbox-amd64 User agent-amd64 -Host sandbox-arm64 - User agent-arm64 +Host ubuntu + User ubuntu Host tahoe-vanilla User admin diff --git a/tart/home-manager/home.nix b/tahoe-vanilla/home-manager/home.nix similarity index 100% rename from tart/home-manager/home.nix rename to tahoe-vanilla/home-manager/home.nix diff --git a/ubuntu/home-manager/home.nix b/ubuntu/home-manager/home.nix new file mode 100644 index 0000000..d556901 --- /dev/null +++ b/ubuntu/home-manager/home.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + home = { + # https://nix-community.github.io/home-manager/release-notes.xhtml + stateVersion = "26.05"; + + username = "admin"; + homeDirectory = "/home/admin"; + }; + + programs.bash.enable = true; # Necessary for aliases and Starship to work. +}