@@ -85,18 +85,18 @@ def copy_from_profile(profile: Optional[str], generation: int, specialisation: O
8585 return efi_file_path
8686
8787
88- def describe_generation (generation_dir : str ) -> str :
88+ def describe_generation (profile : Optional [ str ], generation : int , specialisation : Optional [ str ] ) -> str :
8989 try :
90- with open ("%s/ nixos-version" % generation_dir ) as f :
90+ with open (profile_path ( profile , generation , specialisation , " nixos-version") ) as f :
9191 nixos_version = f .read ()
9292 except IOError :
9393 nixos_version = "Unknown"
9494
95- kernel_dir = os .path .dirname (os . path . realpath ( "%s/ kernel" % generation_dir ))
95+ kernel_dir = os .path .dirname (profile_path ( profile , generation , specialisation , " kernel" ))
9696 module_dir = glob .glob ("%s/lib/modules/*" % kernel_dir )[0 ]
9797 kernel_version = os .path .basename (module_dir )
9898
99- build_time = int (os .path .getctime (generation_dir ))
99+ build_time = int (os .path .getctime (system_dir ( profile , generation , specialisation ) ))
100100 build_date = datetime .datetime .fromtimestamp (build_time ).strftime ('%F' )
101101
102102 description = "@distroName@ {}, Linux Kernel {}, Built on {}" .format (
@@ -131,19 +131,18 @@ def write_entry(profile: Optional[str], generation: int, specialisation: Optiona
131131 "or renamed a file in `boot.initrd.secrets`" , file = sys .stderr )
132132 entry_file = "@efiSysMountPoint@/loader/entries/%s" % (
133133 generation_conf_filename (profile , generation , specialisation ))
134- generation_dir = os .readlink (system_dir (profile , generation , specialisation ))
135134 tmp_path = "%s.tmp" % (entry_file )
136- kernel_params = "init=%s/init " % generation_dir
135+ kernel_params = "init=%s " % profile_path ( profile , generation , specialisation , "init" )
137136
138- with open ("%s/ kernel-params" % ( generation_dir )) as params_file :
137+ with open (profile_path ( profile , generation , specialisation , " kernel-params" )) as params_file :
139138 kernel_params = kernel_params + params_file .read ()
140139 with open (tmp_path , 'w' ) as f :
141140 f .write (BOOT_ENTRY .format (title = title ,
142141 generation = generation ,
143142 kernel = kernel ,
144143 initrd = initrd ,
145144 kernel_params = kernel_params ,
146- description = describe_generation (generation_dir )))
145+ description = describe_generation (profile , generation , specialisation )))
147146 if machine_id is not None :
148147 f .write ("machine-id %s\n " % machine_id )
149148 os .rename (tmp_path , entry_file )
@@ -296,7 +295,7 @@ def main() -> None:
296295 remove_old_entries (gens )
297296 for gen in gens :
298297 try :
299- is_default = os .readlink ( system_dir (* gen )) == args .default_config
298+ is_default = os .path . dirname ( profile_path (* gen , "init" )) == args .default_config
300299 write_entry (* gen , machine_id , current = is_default )
301300 for specialisation in get_specialisations (* gen ):
302301 write_entry (* specialisation , machine_id , current = is_default )
0 commit comments