-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
lib.nix
32 lines (31 loc) · 1.2 KB
/
lib.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
lib,
options,
}: let
# See https://github.com/NixOS/nixpkgs/commit/ccb85a53b6a496984073227fd8c4d4c58889f421
# This commit changed the type of `system.build` from a lazy attribute set to
# a submodule. Prior to this commit, it doesn't make sense to qualify, e.g.
# the `system.build.kexec_tarball` definition with `lib.mkForce`, as this
# would result in setting the (final/resolved) value of
# `system.build.kexec_tarball` to something like:
# {
# _type = "override";
# content = <...>;
# priority = 50;
# }
# However, since this commit, `system.build.kexec_tarball` *must* be defined
# using `lib.mkForce`; otherwise, Nix bails out with a complaint about
# `system.build.kexec_tarball` being defined in multiple locations.
systemBuildIsSubmodule = options.system.build.type.name == "submodule";
optionsLookSane = lib.hasAttrByPath ["system" "build" "type" "name"] options;
in
assert (lib.assertMsg optionsLookSane "`options' must be the NixOS module `options' argument"); {
maybe =
{
mkForce = lib.id;
mkOverride = _: lib.id;
}
// (lib.optionalAttrs systemBuildIsSubmodule {
inherit (lib) mkForce mkOverride;
});
}