1 { config, lib, pkgs, ... }:
7 inherit (pkgs.stdenv.hostPlatform) efiArch;
9 format = pkgs.formats.ini { };
18 description = "Name of the UKI";
21 version = lib.mkOption {
22 type = lib.types.nullOr lib.types.str;
23 default = config.system.image.version;
24 defaultText = lib.literalExpression "config.system.image.version";
25 description = "Version of the image or generation the UKI belongs to";
28 tries = lib.mkOption {
29 type = lib.types.nullOr lib.types.ints.unsigned;
32 Number of boot attempts before this UKI is considered bad.
34 If no tries are specified (the default) automatic boot assessment remains inactive.
36 See documentation on [Automatic Boot Assessment](https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT/) and
37 [boot counting](https://uapi-group.org/specifications/specs/boot_loader_specification/#boot-counting)
42 settings = lib.mkOption {
45 The configuration settings for ukify. These control what the UKI
46 contains and how it is built.
50 configFile = lib.mkOption {
51 type = lib.types.path;
53 The configuration file passed to {manpage}`ukify(1)` to create the UKI.
55 By default this configuration file is created from {option}`boot.uki.settings`.
60 system.boot.loader.ukiFile = lib.mkOption {
63 description = "Name of the UKI file";
70 boot.uki.name = lib.mkOptionDefault (if config.system.image.id != null then
71 config.system.image.id
77 Linux = lib.mkOptionDefault "${config.boot.kernelPackages.kernel}/${config.system.boot.loader.kernelFile}";
78 Initrd = lib.mkOptionDefault "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}";
79 Cmdline = lib.mkOptionDefault "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}";
80 Stub = lib.mkOptionDefault "${pkgs.systemd}/lib/systemd/boot/efi/linux${efiArch}.efi.stub";
81 Uname = lib.mkOptionDefault "${config.boot.kernelPackages.kernel.modDirVersion}";
82 OSRelease = lib.mkOptionDefault "@${config.system.build.etc}/etc/os-release";
83 # This is needed for cross compiling.
84 EFIArch = lib.mkOptionDefault efiArch;
85 } // lib.optionalAttrs (config.hardware.deviceTree.enable && config.hardware.deviceTree.name != null) {
86 DeviceTree = lib.mkOptionDefault "${config.hardware.deviceTree.package}/${config.hardware.deviceTree.name}";
90 boot.uki.configFile = lib.mkOptionDefault (format.generate "ukify.conf" cfg.settings);
92 system.boot.loader.ukiFile =
94 name = config.boot.uki.name;
95 version = config.boot.uki.version;
96 versionInfix = if version != null then "_${version}" else "";
97 triesInfix = if cfg.tries != null then "+${builtins.toString cfg.tries}" else "";
99 name + versionInfix + triesInfix + ".efi";
101 system.build.uki = pkgs.runCommand config.system.boot.loader.ukiFile { } ''
103 ${pkgs.buildPackages.systemdUkify}/lib/systemd/ukify build \
104 --config=${cfg.configFile} \
105 --output="$out/${config.system.boot.loader.ukiFile}"
108 meta.maintainers = with lib.maintainers; [ nikstur ];