Skip to content

Commit

Permalink
contianer: Only check visible roles in assertion
Browse files Browse the repository at this point in the history
The assertion broke evaluation when trying to evaluate a role
which is deprecated with mkRemovedOptionModule
  • Loading branch information
leona-ya committed Dec 8, 2023
1 parent 3551c95 commit f8fa627
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions nixos/infrastructure/container.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

let
fclib = config.fclib;

# Only check "visible" roles, skipping roles that are marked as removed by
# `mkRemovedOptionModule` or manually set to `visible = false`.
# The `tryEval` is needed because visiting the role option throws an error if
# the option is declared by `mkRemovedOptionModule`.
visibleFCRoles = (lib.filterAttrs
(n: v: (builtins.tryEval v.enable.visible or true).value)
config.flyingcircus.roles);
in
{
config = lib.mkMerge [
Expand All @@ -18,7 +26,7 @@ in
# the option is declared by `mkRemovedOptionModule`.
(lib.filterAttrs
(n: v: (builtins.tryEval v.enable.visible or true).value)
config.flyingcircus.roles);
visibleFCRoles);
}

(lib.mkIf (config.flyingcircus.infrastructureModule == "container") {
Expand All @@ -30,7 +38,7 @@ in
{ assertion = if (v.enable or false) then
(v.supportsContainers or true) else true;
message = "role ${n} does not support containers";
}) config.flyingcircus.roles;
}) visibleFCRoles;

boot.isContainer = true;

Expand Down

0 comments on commit f8fa627

Please sign in to comment.