name: CI

on:
  push:
    branches: ["main"]
  pull_request:

jobs:
  check:
    runs-on: nix
    env:
      PATH: "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin"
      NIXPKGS_ALLOW_UNFREE: "1"
    steps:
      - name: Checkout
        run: git clone https://git.cyperpunk.de/DerGrumpf/cyper-nix.git .

      - name: Format check
        run: nix fmt -- --ci
      
      - name: Nix flake check
        run: nix flake check --impure

      - name: Build NixOS configs (dry-run)
        run: |
          nix build .#nixosConfigurations.cyper-desktop.config.system.build.toplevel --dry-run
          nix build .#nixosConfigurations.cyper-controller.config.system.build.toplevel --dry-run
          nix build .#nixosConfigurations.cyper-proxy.config.system.build.toplevel --dry-run
          nix build .#nixosConfigurations.cyper-node-1.config.system.build.toplevel --dry-run
          nix build .#nixosConfigurations.cyper-node-2.config.system.build.toplevel --dry-run

