Commit 91d7c58a2621

Vincent Demeester <vincent@sbr.pm>
2025-11-13 12:18:32
Some cleanups
- Remove `bin/` - Remove `tools/k8s.infra` - Remove some inputs Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 5213838
bin/__dispatch.sh
@@ -1,28 +0,0 @@
-#!/usr/bin/env bash
-# This script dispatches invocations transparently to programs instantiated from
-# Nix.
-#
-# To add a new tool, insert it into the case statement below by setting `attr`
-# to the key in nixpkgs which represents the program you want to run.
-set -ueo pipefail
-
-readonly REPO_ROOT=$(dirname "$0")/..
-TARGET_TOOL=$(basename "$0")
-
-case "${TARGET_TOOL}" in
-    bus)
-        attr="tools.bus"
-        ;;
-    k8s.infra)
-        attr="tools.k8s_infra"
-        ;;
-    *)
-        echo "The tool '${TARGET_TOOL}' is currently not installed in this repository."
-        exit 1
-        ;;
-esac
-
-result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}")
-PATH="${result}/bin:$PATH"
-
-exec "${TARGET_TOOL}" "${@}"
bin/bus
@@ -1,1 +0,0 @@
-__dispatch.sh
\ No newline at end of file
bin/k8s.infra
@@ -1,1 +0,0 @@
-__dispatch.sh
\ No newline at end of file
tools/k8s.infra/default.nix
@@ -1,27 +0,0 @@
-{ pkgs, ... }:
-
-pkgs.stdenv.mkDerivation {
-  name = "k8s.infra";
-  src = ./.;
-  phases = [
-    "installPhase"
-    "fixupPhase"
-  ];
-  buildInputs = with pkgs; [
-    makeWrapper
-  ];
-  installPhase = ''
-    mkdir -p $out $out/bin
-    cp $src/k8s.infra.sh $out/bin/k8s.infra
-
-    wrapProgram "$out/bin/k8s.infra" --prefix PATH : ${
-      pkgs.lib.makeBinPath [
-        pkgs.nixos-generators
-        pkgs.virtmanager
-        pkgs.libguestfs-with-appliance
-        pkgs.qemu
-        pkgs.libvirt
-      ]
-    }
-  '';
-}
tools/k8s.infra/k8s.infra.sh
@@ -1,118 +0,0 @@
-#!/usr/bin/env bash
-# univ: update niv (and generate a nice commit)
-
-# TODO: Maybe rewrite this in Python..
-
-# TODO libguestfs-with-appliance
-# TODO create images with qemu-img and virt-format --format=qcow2 --filesystem=ext4 -a vdisk1.qcow2
-# TODO Create xml by hand instead of virt-install
-
-set -euo pipefail
-
-# export QEMU_URI=qemu+ssh://vincent@wakasu.home/system
-# virt-install --connect=${QEMU_URI} \
-#              --name="ocp4-bootstrap" --vcpus=4 --ram=8192 \
-#              --disk path=/var/lib/libvirt/images/ocp-bootstrap.qcow2,bus=virtio,size=120 \
-#              --boot menu=on --print-xml > ocp4-bootstrap.xml
-# virsh --connect=${QEMU_URI} \
-    #       define --file ocp4-bootstrap.xml
-
-HOST=${HOST:-wakasu.home}
-QEMU_URI="qemu+ssh://${HOST}/system"
-RSYNC_COMMAND="rsync -avzHXShPse ssh --progress"
-VIRSH_COMMAND="virsh --connect=${QEMU_URI}"
-NODES=(
-    k8sn1
-    k8sn2
-    k8sn3
-)
-
-build() {
-    for n in ${NODES[@]}; do
-        logs=$(mktemp)
-        output=$(mktemp)
-        echo "Build ${n} node (logs: ${logs})…"
-        nixos-generate -I nixpkgs=channel:nixos-21.05 -f qcow -c ./systems/hosts/${n}.nix 2>${logs} 1>${output}
-        echo "Resize ${n} image"
-        qemu-img create -f qcow2 -o preallocation=metadata ${n}.qcow2 40G
-        virt-resize --expand /dev/vda1 $(cat ${output} | tr -d '\n') ${n}.qcow2
-        echo "Syncthing image to ${HOST}…"
-        ${RSYNC_COMMAND} ${n}.qcow2 root@${HOST}:/var/lib/libvirt/images/${n}.qcow2
-        echo "Remove ${n} (local) image"
-        rm -f ${n}.qcow2
-    done
-}
-
-delete() {
-    for n in ${NODES[@]}; do
-        echo "Delete ${n} node…"
-        ${VIRSH_COMMAND} list | grep ${n} && {
-            ${VIRSH_COMMAND} destroy ${n}
-        } || {
-            echo "skipping, not present…"
-        }
-        ${VIRSH_COMMAND} undefine ${n} --remove-all-storage || echo "Failed to erase.. might not exists"
-    done
-}
-
-# Bootstrap the cluster, assuming images are built and synced
-bootstrap() {
-    echo "Bootstrap k8s cluster on ${HOST}"
-    k8sn1_mac="52:54:00:dd:a3:30"
-    k8sn2_mac="52:54:00:dd:a3:31"
-    k8sn3_mac="52:54:00:dd:a3:32"
-    folder=$(mktemp -d)
-    for n in ${NODES[@]}; do
-        mac_addr=${n}_mac
-        virt-install --connect=${QEMU_URI} \
-                     --name="${n}" --vcpus=4 --ram=8192 \
-                     --network bridge=br1,mac.address=${!mac_addr} \
-                     --disk path=/var/lib/libvirt/images/${n}.qcow2,bus=virtio,size=10 \
-                     --disk path=/var/lib/libvirt/images/${n}-data.qcow2,bus=virtio,size=40 \
-                     --print-xml > ${folder}/${n}.xml
-        echo "Node ${n} : ${folder}/${n}.xml"
-        ${VIRSH_COMMAND} define --file ${folder}/${n}.xml
-    done
-    # Start the nodes
-    for n in ${NODES[@]}; do
-        ${VIRSH_COMMAND} start ${n}
-    done
-    # Wait for.. long time..
-    # Not sure how to ensure k8s is running on the master
-    token=$(ssh root@k8sn1.home cat /var/lib/kubernetes/secrets/apitoken.secret)
-    echo $token | ssh root@k8sn2.home nixos-kubernetes-node-join
-    echo $token | ssh root@k8sn3.home nixos-kubernetes-node-join
-    mkdir -p $HOME/.kube
-    # TODO: Copy cluster-admin configuration and sed the certs
-    scp root@k8sn1.home:/etc/kubernetes/cluster-admin.kubeconfig $HOME/home.cluster-admin.config
-}
-
-status() {
-    echo "TBD: display the status of the cluster"
-}
-
-main() {
-    set +u
-    ARG=$1
-    set -u
-    case ${ARG} in
-        "build")
-            build
-            ;;
-        "delete")
-            delete
-            ;;
-        "bootstrap")
-            bootstrap
-            ;;
-        "status")
-            status
-            ;;
-        *)
-            echo "No such subcommand"
-            exit 1
-            ;;
-    esac
-}
-
-main $@
flake.lock
@@ -150,27 +150,6 @@
         "type": "github"
       }
     },
-    "code-cursor-nix": {
-      "inputs": {
-        "flake-utils": "flake-utils_2",
-        "nixpkgs": [
-          "nixpkgs"
-        ]
-      },
-      "locked": {
-        "lastModified": 1762765789,
-        "narHash": "sha256-Br2F/t+mHkOhK2M0ss+5v0gv4hNCQjn02tK54ixZbAY=",
-        "owner": "jacopone",
-        "repo": "code-cursor-nix",
-        "rev": "f5e3accd755e7c8c5dcdffee7dd76a4cac80c80b",
-        "type": "github"
-      },
-      "original": {
-        "owner": "jacopone",
-        "repo": "code-cursor-nix",
-        "type": "github"
-      }
-    },
     "copilot-cli": {
       "inputs": {
         "nixpkgs": [
@@ -489,24 +468,6 @@
         "type": "github"
       }
     },
-    "flake-utils_2": {
-      "inputs": {
-        "systems": "systems_4"
-      },
-      "locked": {
-        "lastModified": 1731533236,
-        "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
-        "owner": "numtide",
-        "repo": "flake-utils",
-        "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
-        "type": "github"
-      },
-      "original": {
-        "owner": "numtide",
-        "repo": "flake-utils",
-        "type": "github"
-      }
-    },
     "gitignore": {
       "inputs": {
         "nixpkgs": [
@@ -845,42 +806,6 @@
         "type": "github"
       }
     },
-    "nixlib": {
-      "locked": {
-        "lastModified": 1736643958,
-        "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=",
-        "owner": "nix-community",
-        "repo": "nixpkgs.lib",
-        "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181",
-        "type": "github"
-      },
-      "original": {
-        "owner": "nix-community",
-        "repo": "nixpkgs.lib",
-        "type": "github"
-      }
-    },
-    "nixos-generators": {
-      "inputs": {
-        "nixlib": "nixlib",
-        "nixpkgs": [
-          "nixpkgs"
-        ]
-      },
-      "locked": {
-        "lastModified": 1751903740,
-        "narHash": "sha256-PeSkNMvkpEvts+9DjFiop1iT2JuBpyknmBUs0Un0a4I=",
-        "owner": "nix-community",
-        "repo": "nixos-generators",
-        "rev": "032decf9db65efed428afd2fa39d80f7089085eb",
-        "type": "github"
-      },
-      "original": {
-        "owner": "nix-community",
-        "repo": "nixos-generators",
-        "type": "github"
-      }
-    },
     "nixos-hardware": {
       "locked": {
         "lastModified": 1762847253,
@@ -1123,7 +1048,6 @@
         "chapeau-rouge": "chapeau-rouge",
         "chick-group": "chick-group",
         "claude-code": "claude-code",
-        "code-cursor-nix": "code-cursor-nix",
         "copilot-cli": "copilot-cli",
         "dagger": "dagger",
         "disko": "disko",
@@ -1134,7 +1058,6 @@
         "lanzaboote": "lanzaboote",
         "niri": "niri",
         "nix-github-actions": "nix-github-actions_4",
-        "nixos-generators": "nixos-generators",
         "nixos-hardware": "nixos-hardware",
         "nixos-raspberrypi": "nixos-raspberrypi",
         "nixpkgs": "nixpkgs_3",
@@ -1230,21 +1153,6 @@
         "type": "github"
       }
     },
-    "systems_4": {
-      "locked": {
-        "lastModified": 1681028828,
-        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
-        "owner": "nix-systems",
-        "repo": "default",
-        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
-        "type": "github"
-      },
-      "original": {
-        "owner": "nix-systems",
-        "repo": "default",
-        "type": "github"
-      }
-    },
     "xwayland-satellite-stable": {
       "flake": false,
       "locked": {
flake.nix
@@ -328,11 +328,6 @@
       repo = "chapeau-rouge";
       inputs.nixpkgs.follows = "nixpkgs";
     };
-    # Used to generate NixOS images for other platforms
-    nixos-generators = {
-      url = "github:nix-community/nixos-generators";
-      inputs.nixpkgs.follows = "nixpkgs";
-    };
     agenix.url = "github:ryantm/agenix";
     agenix.inputs.nixpkgs.follows = "nixpkgs";
     agenix-25_05.url = "github:ryantm/agenix";
@@ -352,9 +347,6 @@
 
     nixos-raspberrypi.url = "github:nvmd/nixos-raspberrypi/develop";
 
-    code-cursor-nix.url = "github:jacopone/code-cursor-nix";
-    code-cursor-nix.inputs.nixpkgs.follows = "nixpkgs";
-
     claude-code.url = "github:sadjow/claude-code-nix";
     claude-code.inputs.nixpkgs.follows = "nixpkgs";