Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 3.44 KB

readme.md

File metadata and controls

45 lines (36 loc) · 3.44 KB

SPARKY probe repo

This is an example initial state of the SPARKY probe repo. This repo contains the JSON-NixOS-Configs of the probes, which are generated by the Webinterface, hardware-configurations and basic settings for the probes.

Structure of the repo

The repository consists of 4 main directories:

  • common
    • Contains common configurations that apply for all probes
  • hardware
    • Contains the hardware configurations for the different probe hardwares you may use
    • Pre-filled with hardware configurations for Fujitsu Futro S920 and NanoPi R2S
  • probes
    • Contains the probe configurations as JSON generated by the Webinterface
  • ztp-image
    • Contains configurations to create ZTP-Images for the differend probe hardwares

Common config

The common directory contains the following 3 nixfiles:

  • default.nix - some basic settings, you may change them as you want
  • environment.nix - SPARKY environment, insert your Tailnet IPs and URLs here
  • ùsers.nix - admin users on the probes, edit them as you want

Hardware configurations

To understand the structure of the hardware configurations, we should first take a look at the flake: The flake reads every .json file from the probes directory and every .nix file from the ztp-image directory for the basic configurations of the probes and the ZTP images. Each filename is split by an underscore in its hostname and its hardware profile (called "slug" in the webinterface). So for example, a probe with the filename probe01_s920.json will have the s920.nix from the hardware directory included in its NixOS closure. Additionally, the hardware profiles are mapped to system architectures (x86 and ARM) in the flake.

If you take a look at the s920 hardware profile, you can see that this is basically the output of the hardware-configuration.nix from nixos-generate-config with some hardware specific additions, e.g the bootloader location or that systemd boot is enabled.

Please note, that the r2s-sd hardware profile is only a dummy hardware profile, because the SD-Image has different hardware requirements than the installed probe itself, because it includes the basic SD-Image Module from the nixpkgs, which supports a wide variety of hardware.

Helper scripts

The repo includes the following two helper scripts:

  • build-ztp-image.sh - builds a ZTP image for a given hardware profile
  • generate-sd-mac.sh - used for the NanoPi R2S which don't have a unique MAC address so the MAC address for the probe (which is also used in ZTP) gets generated based of the serial number of the SD Card of the NanoPi and this script can gernerate such a MAC address for a SD-Card plugged in your computer for you

Setting up the repo

  • Once you have configured all settings described above to your needs, you can lock the flake and create a initial commit of this repo:
    • nix flake lock
    • git add .
    • git commit -m "initial commit"
  • Next, create a private repository in your GitLab and push your repo to there
  • Then, generate a SSH-Keypair and add the public key as a deploy key with write access to your GitLab project (this will be used later by the webinterface to push the probe configs to the repo)
    • ssh-keygen -t ed25519 -C sparky-web
  • Finally, create a access token with one year validity with developer rights and read-access to the API and the repository and write it down (will be used later by the probes to fetch the repo on pull based updates)