-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos: Support systemd-gpt-auto-root #282022
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,19 @@ in { | |
default = []; | ||
}; | ||
|
||
root = lib.mkOption { | ||
type = lib.types.enum [ "fstab" "gpt-auto" ]; | ||
default = "fstab"; | ||
example = "gpt-auto"; | ||
description = '' | ||
Controls how systemd will interpret the root FS in initrd. See | ||
{manpage}`kernel-command-line(7)`. NixOS currently does not | ||
allow specifying the root file system itself this | ||
way. Instead, the `fstab` value is used in order to interpret | ||
the root file system specified with the `fileSystems` option. | ||
''; | ||
}; | ||
|
||
emergencyAccess = mkOption { | ||
type = with types; oneOf [ bool (nullOr (passwdEntry str)) ]; | ||
description = lib.mdDoc '' | ||
|
@@ -342,7 +355,12 @@ in { | |
}; | ||
|
||
config = mkIf (config.boot.initrd.enable && cfg.enable) { | ||
assertions = map (name: { | ||
assertions = [ | ||
{ | ||
assertion = cfg.root == "fstab" -> any (fs: fs.mountPoint == "/") (builtins.attrValues config.fileSystems); | ||
message = "The ‘fileSystems’ option does not specify your root file system."; | ||
Comment on lines
+360
to
+361
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, and here's the other assertion. |
||
} | ||
] ++ map (name: { | ||
assertion = lib.attrByPath name (throw "impossible") config.boot.initrd == ""; | ||
message = '' | ||
systemd stage 1 does not support 'boot.initrd.${lib.concatStringsSep "." name}'. Please | ||
|
@@ -371,7 +389,12 @@ in { | |
"autofs" | ||
# systemd-cryptenroll | ||
] ++ lib.optional cfg.enableTpm2 "tpm-tis" | ||
++ lib.optional (cfg.enableTpm2 && !(pkgs.stdenv.hostPlatform.isRiscV64 || pkgs.stdenv.hostPlatform.isArmv7)) "tpm-crb"; | ||
++ lib.optional (cfg.enableTpm2 && !(pkgs.stdenv.hostPlatform.isRiscV64 || pkgs.stdenv.hostPlatform.isArmv7)) "tpm-crb" | ||
++ lib.optional cfg.package.withEfi "efivarfs"; | ||
ElvishJerricco marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be conditional on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lopsided98 If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There is no way to override There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We could have an option like Alternatively, we could have a new option like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From the docs on CONFIG_AUTOFS_FS:
I only see one |
||
|
||
boot.kernelParams = [ | ||
"root=${config.boot.initrd.systemd.root}" | ||
] ++ lib.optional (config.boot.resumeDevice != "") "resume=${config.boot.resumeDevice}"; | ||
|
||
boot.initrd.systemd = { | ||
initrdBin = [pkgs.bash pkgs.coreutils cfg.package.kmod cfg.package]; | ||
|
@@ -554,7 +577,5 @@ in { | |
serviceConfig.Type = "oneshot"; | ||
}; | ||
}; | ||
|
||
boot.kernelParams = lib.mkIf (config.boot.resumeDevice != "") [ "resume=${config.boot.resumeDevice}" ]; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
clevisLuksFallback | ||
clevisZfs | ||
clevisZfsFallback | ||
gptAutoRoot | ||
; | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
config.boot.initrd.systemd.enable
is set, there is no assertion. Ifconfig.boot.initrd.systemd.enable
is not set, there is an assertion when no "/" mountpoint is set.