nixos/limine: Fix reading generations and specialisations

Previously, all generations for the primary system profile
read their data from the currently active one rather than
their own path, and specialisations in general all used
their parent bootspec rather than their own. This fixes both issues.

This commit still uses the parent path's build date for
specialisations, but this is more minor issue and the times
shouldn't be meaningfully different in most cases anyways.
This commit is contained in:
Angelo Bulfone 2025-03-19 00:32:09 -07:00 committed by Angel Bulfone
parent b6eaf97c69
commit 9ed29c65a4
No known key found for this signature in database
GPG key ID: 23AC71B9B52809FB

View file

@ -29,10 +29,12 @@ def config(*path: List[str]) -> Optional[Any]:
def get_system_path(profile: str = 'system', gen: Optional[str] = None, spec: Optional[str] = None) -> str:
basename = f'{profile}-{gen}-link' if gen is not None else profile
profiles_dir = '/nix/var/nix/profiles'
if profile == 'system':
result = os.path.join('/nix', 'var', 'nix', 'profiles', 'system')
result = os.path.join(profiles_dir, basename)
else:
result = os.path.join('/nix', 'var', 'nix', 'profiles', 'system-profiles', profile + f'-{gen}-link' if gen is not None else '')
result = os.path.join(profiles_dir, 'system-profiles', basename)
if spec is not None:
result = os.path.join(result, 'specialisation', spec)
@ -169,8 +171,8 @@ def generate_config_entry(profile: str, gen: str) -> str:
boot_spec = bootjson_to_bootspec(boot_json)
entry = config_entry(2, boot_spec, f'Generation {gen}', time)
for spec in boot_spec.specialisations:
entry += config_entry(2, boot_spec, f'Generation {gen}, Specialisation {spec}', str(time))
for spec, spec_boot_spec in boot_spec.specialisations.items():
entry += config_entry(2, spec_boot_spec, f'Generation {gen}, Specialisation {spec}', str(time))
return entry