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