aboutsummaryrefslogtreecommitdiff
path: root/modules/grub2/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/grub2/default.nix')
-rw-r--r--modules/grub2/default.nix61
1 files changed, 27 insertions, 34 deletions
diff --git a/modules/grub2/default.nix b/modules/grub2/default.nix
index bc8280dec26e..8066d3ac5a17 100644
--- a/modules/grub2/default.nix
+++ b/modules/grub2/default.nix
@@ -4,29 +4,28 @@ with lib;
let
cfg = config.grub2;
- payloadName = if cfg.asSecondaryPayload then
- "img/grub2"
- else
- "fallback/payload";
+ payloadName =
+ if cfg.asSecondaryPayload then "img/grub2" else "fallback/payload";
- configText = (readFile ./files/grub.cfg) +
- cfg.extraConfig +
- (optionalString (cfg.scanDevices) (readFile ./files/grub-scan.cfg)) +
- (optionalString (cfg.users != {}) (
- (concatStringsSep "\n" (mapAttrsToList (n: u: ''
- ${if u.passwordIsHashed then "password_pbkdf2" else "password"} ${n} ${u.password}
- '') cfg.users)) + ''
- set superusers="${concatStringsSep " " (attrNames (filterAttrs (n: u: u.superuser) cfg.users))}"
- export superusers
- ''
- )) +
- (optionalString cfg.generateSecondaryPayloadEntries (
- concatMapStrings (n: ''
- menuentry '${removePrefix "img/" n}' {
- chainloader (cbfsdisk)/${n}
- }
- '') (filter (hasPrefix "img/") (attrNames config.corenix.extraFiles))
- ));
+ configText = (readFile ./files/grub.cfg) + cfg.extraConfig
+ + (optionalString (cfg.scanDevices) (readFile ./files/grub-scan.cfg))
+ + (optionalString (cfg.users != { }) ((concatStringsSep "\n" (mapAttrsToList
+ (n: u: ''
+ ${
+ if u.passwordIsHashed then "password_pbkdf2" else "password"
+ } ${n} ${u.password}
+ '') cfg.users)) + ''
+ set superusers="${
+ concatStringsSep " "
+ (attrNames (filterAttrs (n: u: u.superuser) cfg.users))
+ }"
+ export superusers
+ '')) + (optionalString cfg.generateSecondaryPayloadEntries
+ (concatMapStrings (n: ''
+ menuentry '${removePrefix "img/" n}' {
+ chainloader (cbfsdisk)/${n}
+ }
+ '') (filter (hasPrefix "img/") (attrNames config.corenix.extraFiles))));
userOpts = { ... }: {
options = {
@@ -34,9 +33,7 @@ let
type = types.bool;
default = true;
};
- password = mkOption {
- type = types.str;
- };
+ password = mkOption { type = types.str; };
passwordIsHashed = mkOption {
type = types.bool;
default = true;
@@ -71,13 +68,11 @@ in {
default = "";
};
- configFile = mkOption {
- type = types.path;
- };
+ configFile = mkOption { type = types.path; };
users = mkOption {
type = types.attrsOf (types.submodule userOpts);
- default = {};
+ default = { };
};
font = mkOption {
@@ -95,11 +90,9 @@ in {
type = "payload";
src = "${pkgs.coreboot-payload-grub2}/default_payload.elf";
};
- "font.pf2".src = (
- pkgs.runCommand "font.pf2" {
- buildInputs = with pkgs; [ grub2 ];
- } "grub-mkfont --range=0x20-0x7E,0x2501-0x251F,0x2191-0x2193 --size=14 -o $out ${cfg.font}"
- );
+ "font.pf2".src =
+ (pkgs.runCommand "font.pf2" { buildInputs = with pkgs; [ grub2 ]; }
+ "grub-mkfont --range=0x20-0x7E,0x2501-0x251F,0x2191-0x2193 --size=14 -o $out ${cfg.font}");
"etc/grub.cfg".src = cfg.configFile;
"background.png".src = ./files/background.png;
};