Nixos rebuild results in: failed to synthesize error

I was just setting up an attic binary cache server and after my most recent attempt to rebuild I started to get this error:

restarting sysinit-reactivation.target
restarting the following units: nix-daemon.service
> Adding configuration to bootloader
failed to synthesize: failed to read /nix/store/vc8ppvvxmzzih3nr7z4a3j5d9j311fgl-test-40ants-system-20230214-git/nixos-version: No such file or directory (os error 2)
Traceback (most recent call last):
  File "/nix/store/hxgnlpi6yg5175md5d73sv4agbn3bc6v-systemd-boot/bin/systemd-boot", line 435, in <module>
    main()
  File "/nix/store/hxgnlpi6yg5175md5d73sv4agbn3bc6v-systemd-boot/bin/systemd-boot", line 418, in main
    install_bootloader(args)
  File "/nix/store/hxgnlpi6yg5175md5d73sv4agbn3bc6v-systemd-boot/bin/systemd-boot", line 365, in install_bootloader
    remove_old_entries(gens)
  File "/nix/store/hxgnlpi6yg5175md5d73sv4agbn3bc6v-systemd-boot/bin/systemd-boot", line 243, in remove_old_entries
    bootspec = get_bootspec(gen.profile, gen.generation)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hxgnlpi6yg5175md5d73sv4agbn3bc6v-systemd-boot/bin/systemd-boot", line 124, in get_bootspec
    boot_json_str = run(
                    ^^^^
  File "/nix/store/hxgnlpi6yg5175md5d73sv4agbn3bc6v-systemd-boot/bin/systemd-boot", line 58, in run
    return subprocess.run(cmd, check=True, text=True, stdout=stdout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/zv1kaq7f1q20x62kbjv6pfjygw5jmwl6-python3-3.12.7/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/nix/store/x4xjgi14iq922j5hab6bmcpgm3233n2i-bootspec-1.0.0/bin/synthesize', '--version', '1', '/nix/var/nix/profiles/system-1089-link', '/de
v/stdout']' returned non-zero exit status 1.
Failed to install bootloader

If I look in /nix/var/nix/profiles/system-1089-link indeed there is no nixos-version file and oddly it seems to be a store path related to 40ants some lisp CI tool, not an actual system profile like all the other links in /nix/var/nix/profiles:

...
lrwxrwxrwx - root root 14 12月 12:43 system-1088-link -> /nix/store/0hxjxcfqybhc91r2y1z35d6l7rsj3g4v-nixos-system-onyx-24.11.20241207.e2605d0
lrwxrwxrwx - root root 14 12月 13:16 system-1089-link -> /nix/store/vc8ppvvxmzzih3nr7z4a3j5d9j311fgl-test-40ants-system-20230214-git
lrwxrwxrwx - root root 14 12月 13:20 system-1090-link -> /nix/store/m7av37gbyrhz1ab4a2irk89kl4843h3y-nixos-system-onyx-24.11.20241207.e2605d0
...

Deleting the wacky profile link unsurprisingly fixes the problem, but I’m mostly curious if someone knows how this possibly could’ve happened and how to avoid it? The only thing I have been doing is setting up a private attic server, and tested pushing the flake config binaries to it, etc.

I guess worth noting I’m using nh os switch ., not nixos-rebuild, for rebuilds.