Unverified Commit 9ed29c65 authored by Angelo Bulfone's avatar Angelo Bulfone Committed by Angel Bulfone
Browse files

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.
parent b6eaf97c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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