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": { "lib": {
"locked": { "locked": {
"dir": "lib", "dir": "lib",
"dirtyRev": "856b88321e5f19019332f8b60b729095c2260340-dirty", "dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
"dirtyShortRev": "856b883-dirty", "dirtyShortRev": "9c29945-dirty",
"lastModified": 1718299377, "lastModified": 1718255029,
"narHash": "sha256-qsSV+ty3XdEOlxJr5/1ZGheyjDAIu3xWtFxVs1+rDKA=", "narHash": "sha256-cyVYhw84W1s8u305BJR0YoNtdvCuRCd5DT+G3v3Lo4E=",
"type": "git", "type": "git",
"url": "file:../?dir=lib" "url": "file:../?dir=lib"
}, },

View file

@ -187,7 +187,7 @@ lib: {
in in
withFreeform (withMeta base); 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 ## 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 ## 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'; matched = lib.options.run location option definitions';
unmatched = []; 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 else process location declarations definitions
) )
declarationsByName; declarationsByName;
@ -611,7 +611,7 @@ lib: {
collected = collected =
collect collect
(args.path or "") (args.path or "")
([internal] ++ modules) (modules ++ [internal])
( (
{ {
inherit options config; inherit options config;
@ -625,8 +625,7 @@ lib: {
// args // args
); );
in in
lib.modules.combine lib.modules.combine prefix (lib.lists.reverse collected);
prefix (lib.lists.reverse collected);
options = merged.matched; options = merged.matched;

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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