Compare commits

..

1 commit

Author SHA1 Message Date
isabel roses e068db6843
feat: inital support for x86_64-linux 2024-06-13 22:37:53 +01:00
12 changed files with 180 additions and 1670 deletions

View file

@ -3,10 +3,10 @@
"lib": {
"locked": {
"dir": "lib",
"dirtyRev": "856b88321e5f19019332f8b60b729095c2260340-dirty",
"dirtyShortRev": "856b883-dirty",
"lastModified": 1718299377,
"narHash": "sha256-qsSV+ty3XdEOlxJr5/1ZGheyjDAIu3xWtFxVs1+rDKA=",
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
"dirtyShortRev": "9c29945-dirty",
"lastModified": 1718255029,
"narHash": "sha256-cyVYhw84W1s8u305BJR0YoNtdvCuRCd5DT+G3v3Lo4E=",
"type": "git",
"url": "file:../?dir=lib"
},

View file

@ -187,7 +187,7 @@ lib: {
in
withFreeform (withMeta base);
}
else builtins.throw "Module `${key}` (${file}) has unsupported attribute(s): ${invalidKeys}";
else builtins.throw "Module `${key}` 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__}` 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 builtins.throw "The option `${lib.options.getIdentifier location}` in module `${(builtins.head optionDeclarations).__file__}` does not support nested options."
else process location declarations definitions
)
declarationsByName;
@ -611,7 +611,7 @@ lib: {
collected =
collect
(args.path or "")
([internal] ++ modules)
(modules ++ [internal])
(
{
inherit options config;
@ -625,8 +625,7 @@ lib: {
// args
);
in
lib.modules.combine
prefix (lib.lists.reverse collected);
lib.modules.combine prefix (lib.lists.reverse collected);
options = merged.matched;

View file

@ -423,36 +423,5 @@ 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;
};
}

View file

@ -750,16 +750,10 @@ lib: {
description ? null,
}: let
getModules = builtins.map (
definition:
if builtins.isAttrs definition
then {
__file__ = definition.__file__;
config = definition.value;
}
else {
__file__ = definition.__file__;
includes = [definition.value];
}
definition: {
__file__ = definition.__file__;
includes = [definition.value];
}
);
base = lib.modules.run {
@ -768,6 +762,9 @@ lib: {
modules =
[
{
options.__module__.args.dynamic.name = lib.options.create {
type = lib.types.string;
};
config.__module__.args.dynamic.name = lib.modules.overrides.default "<name>";
}
]
@ -992,7 +989,7 @@ lib: {
## @type List Attrs -> Attrs
one = types: let
first = builtins.elemAt types 0;
rest = builtins.tail types;
rest = lib.lists.tail types;
in
if types == []
then builtins.throw "lib.types.one must be given at least one type"

View file

@ -10,24 +10,21 @@
++ [
./src/export.nix
{
__file__ = "broken";
__file__ = ./default.nix;
# options.foundation = lib.options.create {
# type = lib.types.attrs.of lib.types.derivation;
# };
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.";
};
};
# config.foundation = foundation;
config.packages.foundation =
builtins.mapAttrs (name: package: {
name = package.name;
inherit package;
meta = package.meta;
})
foundation;
config.packages.aux = {
foundation = foundation;
};
}
];
};
in
result.config
result.config.exported

View file

@ -8,10 +8,10 @@
},
"locked": {
"dir": "foundation",
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
"dirtyShortRev": "9c29945-dirty",
"lastModified": 1718255029,
"narHash": "sha256-fmrDe4GfvVfXZ9lzaOt+tgBUMFCsyKr0Dlnm8aQwAXs=",
"dirtyRev": "cd12786be17a611976b44fbba3e245eca512535f-dirty",
"dirtyShortRev": "cd12786-dirty",
"lastModified": 1718199069,
"narHash": "sha256-H2Mkyp9BPDPte+E++uIG2N/vGtcS3H9Q7tM3fOOEXT0=",
"type": "git",
"url": "file:../?dir=foundation"
},
@ -24,10 +24,10 @@
"lib": {
"locked": {
"dir": "lib",
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
"dirtyShortRev": "9c29945-dirty",
"lastModified": 1718255029,
"narHash": "sha256-fmrDe4GfvVfXZ9lzaOt+tgBUMFCsyKr0Dlnm8aQwAXs=",
"dirtyRev": "cd12786be17a611976b44fbba3e245eca512535f-dirty",
"dirtyShortRev": "cd12786-dirty",
"lastModified": 1718199069,
"narHash": "sha256-H2Mkyp9BPDPte+E++uIG2N/vGtcS3H9Q7tM3fOOEXT0=",
"type": "git",
"url": "file:../?dir=lib"
},

View file

@ -2,7 +2,7 @@
lib,
config,
}: let
cfg = config.exports;
cfg = config.exports.modules;
type = lib.types.one [
lib.types.path

View file

@ -2,7 +2,6 @@
config,
lib,
}: let
lib' = config.lib;
in {
options = {
exports.packages = lib.options.create {
@ -15,8 +14,6 @@ in {
};
config = {
exported.packages = {
# i686-linux = config.packages.foundation;
};
exported.packages = {};
};
}

File diff suppressed because it is too large Load diff

View file

@ -107,354 +107,164 @@ in {
};
};
package = {
base = lib.types.submodule ({config}: {
freeform = lib.types.any;
package = lib.types.submodule ({config}: {
freeform = lib.types.any;
options = {
name = lib.options.create {
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.string;
default = {
value = "${config.pname}-${config.version or "unknown"}";
text = "\${config.pname}-\${config.version}";
description = "The platform the package is built on.";
};
host = lib.options.create {
type = lib.types.string;
description = "The platform the package is run on.";
};
target = lib.options.create {
type = lib.types.string;
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.";
};
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.";
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.nullish lib.types.string;
default.value = null;
description = "The platform the package is run on.";
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.nullish lib.types.string;
default.value = null;
description = "The platform the package generates code for.";
type = lib'.types.dependencies;
default.value = {};
description = "Dependencies which are created in the build environment and are run in the target environment.";
};
};
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 = {
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.string;
description = "The platform the package is built on.";
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.string;
description = "The platform the package is run on.";
type = lib'.types.dependencies;
default.value = {};
description = "Dependencies which are run in the host environment.";
};
target = lib.options.create {
type = lib.types.string;
description = "The platform the package generates code for.";
type = lib'.types.dependencies;
default.value = {};
description = "Dependencies which are run in the host environment which produces code for the target environment.";
};
};
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.";
};
target = {
only = lib.options.create {
type = lib'.types.dependencies;
default.value = {};
description = "Dependencies which are only used 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 = lib.options.create {
type = lib'.types.dependencies;
default.value = {};
description = "Dependencies which are run in 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.";
};
};
});
};
versions = lib.options.create {
type = lib.types.attrs.of lib'.types.package;
default.value = {};
description = "Available versions of the package.";
};
};
});
dependencies = lib.types.attrs.of (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;
});
});
};
packages = lib.types.attrs.of (lib.types.submodule {
freeform = lib.types.nullish lib'.types.package;
});
builder = lib.types.submodule {
freeform = lib.types.any;

View file

@ -1,5 +1,4 @@
{
exports = ./exports;
lib = ./lib;
packages = ./packages;
}

View file

@ -3,10 +3,19 @@
config,
}: let
lib' = config.lib;
doubles = lib'.systems.doubles.all;
generic = builtins.removeAttrs config.packages ["targeted"];
# 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;
in {
includes = [
# ./aux/foundation.nix
@ -14,14 +23,9 @@ in {
options = {
packages = lib.options.create {
default.value = {};
type = lib.types.attrs.of (lib.types.submodule {
freeform = lib.types.any;
});
type = lib'.types.packages;
};
};
config = {
packages.targeted.i686-linux = generic;
};
# config = lib.modules.merge configs;
}