forked from auxolotl/labs
fix: correct broken submodules
This commit is contained in:
parent
9c29945531
commit
856b88321e
|
@ -3,10 +3,10 @@
|
|||
"lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"dirtyRev": "f24f0876a9103c7adb8120ce9709fb90c73f2a7c-dirty",
|
||||
"dirtyShortRev": "f24f087-dirty",
|
||||
"lastModified": 1718105966,
|
||||
"narHash": "sha256-L68G29+bPmwZSERg3VYXdfont/w+mssmWnrs6tyBijk=",
|
||||
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
|
||||
"dirtyShortRev": "9c29945-dirty",
|
||||
"lastModified": 1718255029,
|
||||
"narHash": "sha256-iPMsyNszFA+EzjtIpjmu9EAG7zdjLbuugLtfa64dJos=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=lib"
|
||||
},
|
||||
|
|
|
@ -187,7 +187,7 @@ lib: {
|
|||
in
|
||||
withFreeform (withMeta base);
|
||||
}
|
||||
else builtins.throw "Module `${key}` has unsupported attribute(s): ${invalidKeys}";
|
||||
else builtins.throw "Module `${key}` (${file}) has unsupported attribute(s): ${invalidKeys}";
|
||||
|
||||
## Convert a module that is either a function or an attribute set into
|
||||
## a resolved attribute set. If the module was a function then it will
|
||||
|
@ -428,7 +428,7 @@ lib: {
|
|||
matched = lib.options.run location option definitions';
|
||||
unmatched = [];
|
||||
}
|
||||
else builtins.throw "The option `${lib.options.getIdentifier location}` in module `${(builtins.head optionDeclarations).__file__}` does not support nested options."
|
||||
else builtins.throw "The option `${lib.options.getIdentifier location}` in module `${(builtins.head optionDeclarations).__file__}` would be a parent of the following options, but its type `${(builtins.head optionDeclarations).options.type.description or "<no description>"}` does not support nested options."
|
||||
else process location declarations definitions
|
||||
)
|
||||
declarationsByName;
|
||||
|
@ -611,7 +611,7 @@ lib: {
|
|||
collected =
|
||||
collect
|
||||
(args.path or "")
|
||||
(modules ++ [internal])
|
||||
([internal] ++ modules)
|
||||
(
|
||||
{
|
||||
inherit options config;
|
||||
|
@ -625,7 +625,8 @@ lib: {
|
|||
// args
|
||||
);
|
||||
in
|
||||
lib.modules.combine prefix (lib.lists.reverse collected);
|
||||
lib.modules.combine
|
||||
prefix (lib.lists.reverse collected);
|
||||
|
||||
options = merged.matched;
|
||||
|
||||
|
|
|
@ -423,5 +423,36 @@ in {
|
|||
};
|
||||
in
|
||||
evaluated.config.aux.message == expected;
|
||||
|
||||
"submodules" = let
|
||||
expected = "Hello, World!";
|
||||
evaluated = lib.modules.run {
|
||||
modules = [
|
||||
{
|
||||
options = {
|
||||
aux = lib.options.create {
|
||||
default.value = {
|
||||
message = "hi";
|
||||
};
|
||||
type = lib.types.attrs.of (lib.types.submodule ({name}: {
|
||||
# freeform = lib.types.any;
|
||||
options.message = lib.options.create {
|
||||
type = lib.types.string;
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
config = {
|
||||
aux = {
|
||||
x = {
|
||||
message = "Hello, World!";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
evaluated.config.aux.x.message == expected;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -750,7 +750,13 @@ lib: {
|
|||
description ? null,
|
||||
}: let
|
||||
getModules = builtins.map (
|
||||
definition: {
|
||||
definition:
|
||||
if builtins.isAttrs definition
|
||||
then {
|
||||
__file__ = definition.__file__;
|
||||
config = definition.value;
|
||||
}
|
||||
else {
|
||||
__file__ = definition.__file__;
|
||||
includes = [definition.value];
|
||||
}
|
||||
|
@ -762,9 +768,6 @@ lib: {
|
|||
modules =
|
||||
[
|
||||
{
|
||||
options.__module__.args.dynamic.name = lib.options.create {
|
||||
type = lib.types.string;
|
||||
};
|
||||
config.__module__.args.dynamic.name = lib.modules.overrides.default "<name>";
|
||||
}
|
||||
]
|
||||
|
@ -989,7 +992,7 @@ lib: {
|
|||
## @type List Attrs -> Attrs
|
||||
one = types: let
|
||||
first = builtins.elemAt types 0;
|
||||
rest = lib.lists.tail types;
|
||||
rest = builtins.tail types;
|
||||
in
|
||||
if types == []
|
||||
then builtins.throw "lib.types.one must be given at least one type"
|
||||
|
|
|
@ -10,21 +10,24 @@
|
|||
++ [
|
||||
./src/export.nix
|
||||
{
|
||||
__file__ = ./default.nix;
|
||||
__file__ = "broken";
|
||||
|
||||
options.packages.aux = {
|
||||
foundation = lib.options.create {
|
||||
type = lib.types.attrs.of lib.types.package;
|
||||
internal = true;
|
||||
description = "The foundational packages used to construct the larger package set.";
|
||||
};
|
||||
};
|
||||
# options.foundation = lib.options.create {
|
||||
# type = lib.types.attrs.of lib.types.derivation;
|
||||
# };
|
||||
|
||||
config.packages.aux = {
|
||||
foundation = foundation;
|
||||
};
|
||||
# config.foundation = foundation;
|
||||
config.packages.foundation =
|
||||
builtins.mapAttrs (name: package: {
|
||||
name = package.name;
|
||||
|
||||
inherit package;
|
||||
|
||||
meta = package.meta;
|
||||
})
|
||||
foundation;
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
result.config.exported
|
||||
result.config
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
},
|
||||
"locked": {
|
||||
"dir": "foundation",
|
||||
"dirtyRev": "cd12786be17a611976b44fbba3e245eca512535f-dirty",
|
||||
"dirtyShortRev": "cd12786-dirty",
|
||||
"lastModified": 1718199069,
|
||||
"narHash": "sha256-H2Mkyp9BPDPte+E++uIG2N/vGtcS3H9Q7tM3fOOEXT0=",
|
||||
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
|
||||
"dirtyShortRev": "9c29945-dirty",
|
||||
"lastModified": 1718255029,
|
||||
"narHash": "sha256-fmrDe4GfvVfXZ9lzaOt+tgBUMFCsyKr0Dlnm8aQwAXs=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=foundation"
|
||||
},
|
||||
|
@ -24,10 +24,10 @@
|
|||
"lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"dirtyRev": "cd12786be17a611976b44fbba3e245eca512535f-dirty",
|
||||
"dirtyShortRev": "cd12786-dirty",
|
||||
"lastModified": 1718199069,
|
||||
"narHash": "sha256-H2Mkyp9BPDPte+E++uIG2N/vGtcS3H9Q7tM3fOOEXT0=",
|
||||
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
|
||||
"dirtyShortRev": "9c29945-dirty",
|
||||
"lastModified": 1718255029,
|
||||
"narHash": "sha256-fmrDe4GfvVfXZ9lzaOt+tgBUMFCsyKr0Dlnm8aQwAXs=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=lib"
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
lib,
|
||||
config,
|
||||
}: let
|
||||
cfg = config.exports.modules;
|
||||
cfg = config.exports;
|
||||
|
||||
type = lib.types.one [
|
||||
lib.types.path
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
config,
|
||||
lib,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
options = {
|
||||
exports.packages = lib.options.create {
|
||||
|
@ -14,6 +15,8 @@ in {
|
|||
};
|
||||
|
||||
config = {
|
||||
exported.packages = {};
|
||||
exported.packages = {
|
||||
# i686-linux = config.packages.foundation;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -107,7 +107,164 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
package = lib.types.submodule ({config}: {
|
||||
package = {
|
||||
base = lib.types.submodule ({config}: {
|
||||
freeform = lib.types.any;
|
||||
|
||||
options = {
|
||||
name = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = {
|
||||
value = "${config.pname}-${config.version or "unknown"}";
|
||||
text = "\${config.pname}-\${config.version}";
|
||||
};
|
||||
description = "The name of the package.";
|
||||
};
|
||||
|
||||
pname = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The name of the package.";
|
||||
};
|
||||
|
||||
version = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The version of the package.";
|
||||
};
|
||||
|
||||
meta = lib.options.create {
|
||||
type = lib'.types.meta;
|
||||
default = {
|
||||
text = "{ name = <package>.pname; }";
|
||||
value = {
|
||||
name = config.pname;
|
||||
};
|
||||
};
|
||||
description = "The metadata for the package.";
|
||||
};
|
||||
|
||||
env = lib.options.create {
|
||||
type = lib.types.attrs.of lib.types.string;
|
||||
default.value = {};
|
||||
description = "Environment variables for the package's builder to use.";
|
||||
};
|
||||
|
||||
phases = lib.options.create {
|
||||
type = lib.types.dag.of (
|
||||
lib.types.either
|
||||
lib.types.string
|
||||
(lib.types.function lib.types.string)
|
||||
);
|
||||
default.value = {};
|
||||
description = "Phases for the package's builder to use.";
|
||||
};
|
||||
|
||||
platform = {
|
||||
build = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The platform the package is built on.";
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The platform the package is run on.";
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The platform the package generates code for.";
|
||||
};
|
||||
};
|
||||
|
||||
builder = lib.options.create {
|
||||
type = lib'.types.builder;
|
||||
description = "The builder for the package.";
|
||||
};
|
||||
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
default = {
|
||||
value = config.builder.build config.builder config;
|
||||
text = "<derivation>";
|
||||
};
|
||||
description = "The package derivation.";
|
||||
};
|
||||
|
||||
deps = {
|
||||
build = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are only used in the build environment.";
|
||||
};
|
||||
|
||||
build = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are created in the build environment and are run in the build environment.";
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are created in the build environment and are run in the host environment.";
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are created in the build environment and are run in the target environment.";
|
||||
};
|
||||
};
|
||||
|
||||
host = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are only used in the host environment.";
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are run in the host environment.";
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are run in the host environment which produces code for the target environment.";
|
||||
};
|
||||
};
|
||||
|
||||
target = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are only used in the target environment.";
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies;
|
||||
default.value = {};
|
||||
description = "Dependencies which are run in the target environment.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
versions = lib.options.create {
|
||||
type = lib.types.attrs.of lib'.types.package;
|
||||
default.value = {};
|
||||
description = "Available versions of the package.";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
targeted = lib.types.submodule ({config}: {
|
||||
freeform = lib.types.any;
|
||||
|
||||
options = {
|
||||
|
@ -259,13 +416,46 @@ in {
|
|||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
dependencies = lib.types.attrs.of (lib.types.nullish lib'.types.package);
|
||||
|
||||
packages = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.types.nullish lib'.types.package;
|
||||
packages = {
|
||||
base = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib'.types.package.base;
|
||||
|
||||
# options =
|
||||
# builtins.foldl' (result: system: {
|
||||
# "${system}" = lib.options.create {
|
||||
# type = lib'.types.packages.targeted;
|
||||
# default.value = {};
|
||||
# description = "Packages for the architecture `${system}`";
|
||||
# };
|
||||
# }) {}
|
||||
# lib'.systems.doubles.all;
|
||||
});
|
||||
|
||||
targeted = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.types.nullish lib'.types.package.targeted;
|
||||
|
||||
options = {
|
||||
cross = lib.options.create {
|
||||
type = lib'.types.packages.cross;
|
||||
default.value = {};
|
||||
description = "Cross-compiled packages targeting another architecture.";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
# Cross-compiled packages are accessed via
|
||||
# packages.cross.<platform>.<namespace>.<name>
|
||||
cross = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.types.nullish lib'.types.package.targeted;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
builder = lib.types.submodule {
|
||||
freeform = lib.types.any;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
exports = ./exports;
|
||||
lib = ./lib;
|
||||
packages = ./packages;
|
||||
}
|
||||
|
|
|
@ -3,19 +3,10 @@
|
|||
config,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
# configure = namespace: packages:
|
||||
# builtins.mapAttrs
|
||||
# (key: package: let
|
||||
# name =
|
||||
# if package.pname != null && package.version != null
|
||||
# then "${package.pname}-${package.version}"
|
||||
# else key;
|
||||
# in {
|
||||
# name = lib.modules.overrides.default name;
|
||||
# package = lib.modules.overrides.default (package.builder package);
|
||||
# })
|
||||
# packages;
|
||||
# configs = builtins.mapAttrs configure config.packages;
|
||||
|
||||
doubles = lib'.systems.doubles.all;
|
||||
|
||||
generic = builtins.removeAttrs config.packages ["targeted"];
|
||||
in {
|
||||
includes = [
|
||||
# ./aux/foundation.nix
|
||||
|
@ -23,9 +14,14 @@ in {
|
|||
|
||||
options = {
|
||||
packages = lib.options.create {
|
||||
type = lib'.types.packages;
|
||||
default.value = {};
|
||||
type = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.types.any;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
# config = lib.modules.merge configs;
|
||||
config = {
|
||||
packages.targeted.i686-linux = generic;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue