1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.boot.loader.raspberryPi;
7
8 builder = pkgs.substituteAll {
9 src = ./builder.sh;
10 isExecutable = true;
11 inherit (pkgs) bash;
12 path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
13 firmware = pkgs.raspberrypifw;
14 version = cfg.version;
15 };
16
17 platform = pkgs.stdenv.platform;
18
19in
20
21{
22 options = {
23
24 boot.loader.raspberryPi.enable = mkOption {
25 default = false;
26 type = types.bool;
27 description = ''
28 Whether to create files with the system generations in
29 <literal>/boot</literal>.
30 <literal>/boot/old</literal> will hold files from old generations.
31 '';
32 };
33
34 boot.loader.raspberryPi.version = mkOption {
35 default = 2;
36 type = types.enum [ 1 2 3 ];
37 description = ''
38 '';
39 };
40
41 };
42
43 config = mkIf config.boot.loader.raspberryPi.enable {
44 system.build.installBootLoader = builder;
45 system.boot.loader.id = "raspberrypi";
46 system.boot.loader.kernelFile = platform.kernelTarget;
47 };
48}