@@ -38,36 +38,36 @@ fn ensureFilesystemState(
3838}
3939
4040fn installGeneration (
41- allocator : std.mem.Allocator ,
41+ arena_alloc : std.mem.Allocator ,
4242 known_files : * StringSet ,
4343 spec : * const BootSpecV1 ,
4444 generation : u32 ,
4545 esp : std.fs.Dir ,
4646 args : * const Args ,
4747) ! void {
48- var entry_contents_list = std .ArrayList (u8 ).init (allocator );
48+ var entry_contents_list = std .ArrayList (u8 ).init (arena_alloc );
4949
5050 const linux_target_filename = try std .fmt .allocPrint (
51- allocator ,
51+ arena_alloc ,
5252 "{s}-{s}" ,
5353 .{ path .basename (path .dirname (spec .kernel ).? ), path .basename (spec .kernel ) },
5454 );
5555
56- const linux_target = try path .join (allocator , &.{
56+ const linux_target = try path .join (arena_alloc , &.{
5757 "EFI" ,
5858 "nixos" ,
5959 linux_target_filename ,
6060 });
6161
6262 const full_linux_path = try path .join (
63- allocator ,
63+ arena_alloc ,
6464 &.{ args .efi_sys_mount_point , linux_target },
6565 );
6666
6767 if (! utils .pathExists (esp , linux_target )) {
6868 if (! args .dry_run ) {
6969 try signFile (
70- allocator ,
70+ arena_alloc ,
7171 args .private_key ,
7272 args .public_key ,
7373 spec .kernel ,
@@ -83,18 +83,18 @@ fn installGeneration(
8383 const initrd_target = b : {
8484 if (spec .initrd ) | initrd | {
8585 const initrd_target_filename = try std .fmt .allocPrint (
86- allocator ,
86+ arena_alloc ,
8787 "{s}-{s}" ,
8888 .{ path .basename (path .dirname (initrd ).? ), path .basename (initrd ) },
8989 );
9090
91- const initrd_target = try path .join (allocator , &.{
91+ const initrd_target = try path .join (arena_alloc , &.{
9292 "EFI" ,
9393 "nixos" ,
9494 initrd_target_filename ,
9595 });
9696
97- const full_initrd_path = try path .join (allocator , &.{
97+ const full_initrd_path = try path .join (arena_alloc , &.{
9898 path .sep_str ,
9999 args .efi_sys_mount_point ,
100100 initrd_target ,
@@ -103,7 +103,7 @@ fn installGeneration(
103103 if (! utils .pathExists (esp , initrd_target )) {
104104 if (! args .dry_run ) {
105105 try signFile (
106- allocator ,
106+ arena_alloc ,
107107 args .private_key ,
108108 args .public_key ,
109109 spec .initrd .? ,
@@ -122,18 +122,18 @@ fn installGeneration(
122122 }
123123 };
124124
125- const kernel_params_without_init = try std .mem .join (allocator , " " , spec .kernel_params );
125+ const kernel_params_without_init = try std .mem .join (arena_alloc , " " , spec .kernel_params );
126126
127127 const kernel_params = try std .fmt .allocPrint (
128- allocator ,
128+ arena_alloc ,
129129 "init={s} {s}" ,
130130 .{ spec .init , kernel_params_without_init },
131131 );
132132
133133 const sub_name = if (spec .name ) | name |
134- try std .fmt .allocPrint (allocator , " ({s})" , .{name })
134+ try std .fmt .allocPrint (arena_alloc , " ({s})" , .{name })
135135 else
136- try allocator .alloc (u8 , 0 );
136+ try arena_alloc .alloc (u8 , 0 );
137137
138138 try entry_contents_list .writer ().print ("title {s}{s}\n " , .{ spec .label , sub_name });
139139 try entry_contents_list .writer ().print ("version {s}\n " , .{spec .label });
@@ -145,30 +145,30 @@ fn installGeneration(
145145 const entry_contents = try entry_contents_list .toOwnedSlice ();
146146
147147 const sub_entry_name = if (spec .name ) | name |
148- try std .fmt .allocPrint (allocator , "-specialisation-{s}" , .{name })
148+ try std .fmt .allocPrint (arena_alloc , "-specialisation-{s}" , .{name })
149149 else
150- try allocator .alloc (u8 , 0 );
150+ try arena_alloc .alloc (u8 , 0 );
151151
152152 const entry_name = try std .fmt .allocPrint (
153- allocator ,
153+ arena_alloc ,
154154 "nixos-generation-{d}{s}" ,
155155 .{ generation , sub_entry_name },
156156 );
157157
158158 const entry_filename_with_counters = try std .fmt .allocPrint (
159- allocator ,
159+ arena_alloc ,
160160 "{s}+{d}-0.conf" ,
161161 .{ entry_name , args .max_tries },
162162 );
163163
164- const entry_path = try path .join (allocator , &.{
164+ const entry_path = try path .join (arena_alloc , &.{
165165 "loader" ,
166166 "entries" ,
167167 entry_filename_with_counters ,
168168 });
169169
170170 var entries_dir = try esp .openDir (
171- entry_path ,
171+ "loader/entries" ,
172172 .{ .iterate = true },
173173 );
174174 defer entries_dir .close ();
@@ -183,7 +183,7 @@ fn installGeneration(
183183
184184 if (std .mem .eql (u8 , existing_entry .name , entry_name )) {
185185 std .log .debug ("entry {s} already installed" , .{entry_name });
186- const known_entry = try path .join (allocator , &.{
186+ const known_entry = try path .join (arena_alloc , &.{
187187 path .sep_str ,
188188 args .efi_sys_mount_point ,
189189 "loader" ,
@@ -249,7 +249,7 @@ pub fn main() !void {
249249 var arena = std .heap .ArenaAllocator .init (std .heap .page_allocator );
250250 defer arena .deinit ();
251251
252- const allocator = arena .allocator ();
252+ const arena_alloc = arena .allocator ();
253253
254254 const params = comptime clap .parseParamsComptime (
255255 \\-h, --help Display this help and exit.
@@ -315,7 +315,7 @@ pub fn main() !void {
315315 }
316316
317317 if (args .dry_run ) {
318- std .log .warn ("running a dry run, no filesystem changes will occur" , .{});
318+ std .log .warn ("in dry run mode , no filesystem changes will occur" , .{});
319319 }
320320
321321 const esp = try std .fs .cwd ().openDir (args .efi_sys_mount_point , .{
@@ -333,7 +333,7 @@ pub fn main() !void {
333333 );
334334 defer nixos_system_profile_dir .close ();
335335
336- var known_files = StringSet .init (allocator );
336+ var known_files = StringSet .init (arena_alloc );
337337
338338 var it = nixos_system_profile_dir .iterate ();
339339 while (try it .next ()) | entry | {
@@ -355,23 +355,23 @@ pub fn main() !void {
355355 }
356356 };
357357
358- const boot_json_path = try path .join (allocator , &.{
358+ const boot_json_path = try path .join (arena_alloc , &.{
359359 entry .name ,
360360 "boot.json" ,
361361 });
362362
363363 var boot_json_file = try nixos_system_profile_dir .openFile (boot_json_path , .{});
364364 defer boot_json_file .close ();
365365
366- const boot_json_contents = try boot_json_file .readToEndAlloc (allocator , 8192 );
366+ const boot_json_contents = try boot_json_file .readToEndAlloc (arena_alloc , 8192 );
367367
368- const boot_json = BootJson .parse (allocator , boot_json_contents ) catch | err | {
368+ const boot_json = BootJson .parse (arena_alloc , boot_json_contents ) catch | err | {
369369 std .log .err ("failed to parse bootspec boot.json: {any}" , .{err });
370370 continue ;
371371 };
372372
373373 try installGeneration (
374- allocator ,
374+ arena_alloc ,
375375 & known_files ,
376376 & boot_json .spec ,
377377 generation ,
@@ -381,7 +381,7 @@ pub fn main() !void {
381381 if (boot_json .specialisations ) | specialisations | {
382382 for (specialisations ) | s | {
383383 try installGeneration (
384- allocator ,
384+ arena_alloc ,
385385 & known_files ,
386386 & s ,
387387 generation ,
@@ -392,12 +392,12 @@ pub fn main() !void {
392392 }
393393
394394 if (std .mem .eql (u8 , boot_json .spec .toplevel , args .default_nixos_system_closure )) {
395- const loader_conf_path = try path .join (allocator , &.{
395+ const loader_conf_path = try path .join (arena_alloc , &.{
396396 "loader" ,
397397 "loader.conf" ,
398398 });
399399
400- const loader_conf_contents = try std .fmt .allocPrint (allocator ,
400+ const loader_conf_contents = try std .fmt .allocPrint (arena_alloc ,
401401 \\timeout {d}
402402 \\default nixos-generation-{d}
403403 , .{ args .timeout , generation });
@@ -414,6 +414,6 @@ pub fn main() !void {
414414 }
415415 }
416416
417- try cleanupDir (allocator , & known_files , esp , "EFI/nixos" , & args );
418- try cleanupDir (allocator , & known_files , esp , "loader/entries" , & args );
417+ try cleanupDir (arena_alloc , & known_files , esp , "EFI/nixos" , & args );
418+ try cleanupDir (arena_alloc , & known_files , esp , "loader/entries" , & args );
419419}
0 commit comments