1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11
12 generationsDirBuilder = pkgs.replaceVarsWith {
13 src = ./generations-dir-builder.sh;
14 isExecutable = true;
15 replacements = {
16 inherit (pkgs) bash;
17 path = lib.makeBinPath [
18 pkgs.coreutils
19 pkgs.gnused
20 pkgs.gnugrep
21 ];
22 inherit (config.boot.loader.generationsDir) copyKernels;
23 };
24 };
25
26in
27
28{
29 options = {
30
31 boot.loader.generationsDir = {
32
33 enable = mkOption {
34 default = false;
35 type = types.bool;
36 description = ''
37 Whether to create symlinks to the system generations under
38 `/boot`. When enabled,
39 `/boot/default/kernel`,
40 `/boot/default/initrd`, etc., are updated to
41 point to the current generation's kernel image, initial RAM
42 disk, and other bootstrap files.
43
44 This optional is not necessary with boot loaders such as GNU GRUB
45 for which the menu is updated to point to the latest bootstrap
46 files. However, it is needed for U-Boot on platforms where the
47 boot command line is stored in flash memory rather than in a
48 menu file.
49 '';
50 };
51
52 copyKernels = mkOption {
53 default = false;
54 type = types.bool;
55 description = ''
56 Whether to copy the necessary boot files into /boot, so
57 /nix/store is not needed by the boot loader.
58 '';
59 };
60
61 };
62
63 };
64
65 config = mkIf config.boot.loader.generationsDir.enable {
66
67 system.build.installBootLoader = generationsDirBuilder;
68 system.boot.loader.id = "generationsDir";
69 system.boot.loader.kernelFile = pkgs.stdenv.hostPlatform.linux-kernel.target;
70
71 };
72}