Compare commits

..

No commits in common. "e1321add05f32339d887314857e214717ae6288b" and "856b88321e5f19019332f8b60b729095c2260340" have entirely different histories.

5 changed files with 332 additions and 388 deletions

View file

@ -360,19 +360,6 @@ lib: {
## @type Attrs
port = lib.types.ints.u16;
## A type that allows a string value specifying a version number.
##
## @type Attrs
version = lib.types.create {
name = "Version";
description = "version";
check = value: let
parts = builtins.splitVersion value;
in
builtins.isString value && builtins.length parts > 0;
merge = lib.options.merge.equal;
};
## A type that allows a string value. The merged definitions must all be
## the same.
##
@ -1051,6 +1038,7 @@ lib: {
inherit initial final;
};
};
};
dag = {
## Create a type that allows a DAG (Directed Acyclic Graph) of a given type.
@ -1118,5 +1106,4 @@ lib: {
);
};
};
};
}

View file

@ -10,22 +10,22 @@
++ [
./src/export.nix
{
__file__ = ./default.nix;
__file__ = "broken";
# options.foundation = lib.options.create {
# type = lib.types.attrs.of lib.types.derivation;
# };
# config.foundation = foundation;
# config.packages.foundation =
# builtins.mapAttrs (name: package: {
# name = package.name;
config.packages.foundation =
builtins.mapAttrs (name: package: {
name = package.name;
# inherit package;
inherit package;
# meta = package.meta;
# })
# foundation;
meta = package.meta;
})
foundation;
}
];
};

View file

@ -8,10 +8,10 @@
},
"locked": {
"dir": "foundation",
"dirtyRev": "856b88321e5f19019332f8b60b729095c2260340-dirty",
"dirtyShortRev": "856b883-dirty",
"lastModified": 1718299377,
"narHash": "sha256-L6zriSSFi45uJ8u3HVsZ6iDHjNtQBB+aDWQfiReoLkM=",
"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": "856b88321e5f19019332f8b60b729095c2260340-dirty",
"dirtyShortRev": "856b883-dirty",
"lastModified": 1718299377,
"narHash": "sha256-L6zriSSFi45uJ8u3HVsZ6iDHjNtQBB+aDWQfiReoLkM=",
"dirtyRev": "9c29945531c58ad81f05cd1f4958c8894a733216-dirty",
"dirtyShortRev": "9c29945-dirty",
"lastModified": 1718255029,
"narHash": "sha256-fmrDe4GfvVfXZ9lzaOt+tgBUMFCsyKr0Dlnm8aQwAXs=",
"type": "git",
"url": "file:../?dir=lib"
},

View file

@ -71,8 +71,7 @@ in {
};
license = lib.options.create {
type = lib.types.nullish config.lib.types.license;
default.value = null;
type = config.lib.types.license;
description = "The license for the package.";
};
@ -108,345 +107,362 @@ in {
};
};
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 = {
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 {
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.";
};
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.";
};
};
});
};
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;
});
});
};
builder = lib.types.submodule {
freeform = lib.types.any;
options = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
};
};
};
packages = {
generic = lib.types.attrs.of (lib.types.submodule ({name}: {
freeform = lib.types.attrs.of (lib.types.submodule [
lib'.types.package.generic'
]);
}));
# packages.<system>
targeted = lib.types.attrs.of (lib.types.submodule ({name}: let
system = name;
in {
# packages.<system>.<namespace>
freeform = lib.types.attrs.of (lib.types.submodule ({name}: let
namespace = name;
in {
# packages.<system>.<namespace>.<name>
freeform = lib.types.attrs.of (lib.types.submodule [
lib'.types.package.targeted'
{
config = {
namespace = namespace;
platform = {
build = system;
host = lib.modules.overrides.default system;
target = lib.modules.overrides.default system;
};
};
}
]);
}));
# packages.<system>.<cross>
options.cross = lib.attrs.generate lib'.systems.doubles.all (cross:
lib.options.create {
default.value = {};
# packages.<system>.<cross>.<namespace>
type = lib.types.attrs.of (lib.types.submodule (
{name}: let
namespace = name;
in {
# packages.<system>.<cross>.<namespace>.<name>
freeform = lib.types.attrs.of (lib.types.submodule [
lib'.types.package.targeted'
{
config = {
namespace = namespace;
platform = {
build = system;
host = cross;
target = lib.modules.overrides.default cross;
};
};
}
]);
}
));
});
}));
};
dependencies = {
generic = lib.types.attrs.of (lib.types.nullish lib'.types.package.generic);
targeted = lib.types.attrs.of (lib.types.nullish lib'.types.package.targeted);
};
package = {
generic = lib.types.submodule lib'.types.package.generic';
generic' = args @ {
name ? assert false; null,
config,
}: {
options = {
pname = lib.options.create {
type = lib.types.string;
default = {
text = "<name> or \"unknown\"";
value =
if args ? name
then args.name
else "unknown";
};
};
version = lib.options.create {
type = lib.types.nullish lib.types.version;
default.value = null;
};
meta = lib.options.create {
type = lib'.types.meta;
default.value = {
name = config.pname;
};
};
phases = lib.options.create {
type = lib.types.dag.of (
lib.types.either
lib.types.string
(lib.types.function lib.types.string)
);
default.value = {};
};
env = lib.options.create {
type = lib.types.attrs.of lib.types.string;
default.value = {};
};
builder = lib.options.create {
type = lib'.types.builder;
};
deps = {
build = {
only = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
build = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
host = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
target = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
};
host = {
only = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
host = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
target = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
};
target = {
only = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
target = lib.options.create {
type = lib'.types.dependencies.generic;
default.value = {};
};
};
};
versions = lib.options.create {
type = lib.types.attrs.of lib'.types.packages.generic;
default.value = {};
};
};
};
targeted = lib.types.submodule lib'.types.package.targeted';
targeted' = args @ {
name ? assert false; null,
config,
}: {
options = {
name = lib.options.create {
type = lib.types.string;
default = {
text = "\${namespace}-\${pname}-\${version} or \${pname}-\${version}";
value = let
namespace =
if config.namespace == null
then ""
else "${config.namespace}-";
version =
if config.version == null
then ""
else "-${config.version}";
in "${namespace}${config.pname}${version}";
};
};
namespace = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
};
pname = lib.options.create {
type = lib.types.string;
default = {
text = "<name> or \"unknown\"";
value =
if args ? name
then args.name
else "unknown";
};
};
version = lib.options.create {
type = lib.types.nullish lib.types.version;
default.value = null;
};
meta = lib.options.create {
type = lib'.types.meta;
default.value = {
name = config.pname;
};
};
platform = {
build = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
};
host = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
};
target = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
};
};
phases = lib.options.create {
type = lib.types.dag.of (
lib.types.either
lib.types.string
(lib.types.function lib.types.string)
);
default.value = {};
};
env = lib.options.create {
type = lib.types.attrs.of lib.types.string;
default.value = {};
};
builder = lib.options.create {
type = lib'.types.builder;
};
package = lib.options.create {
type = lib.types.derivation;
};
deps = {
build = {
only = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
build = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
host = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
target = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
};
host = {
only = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
host = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
target = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
};
target = {
only = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
target = lib.options.create {
type = lib'.types.dependencies.targeted;
default.value = {};
};
};
};
versions = lib.options.create {
type = lib.types.attrs.of lib'.types.packages.targeted;
default.value = {};
};
};
config = {
package = config.builder.build config;
description = "The function that creates the package derivation.";
};
};
};

View file

@ -6,81 +6,22 @@
doubles = lib'.systems.doubles.all;
generic = config.packages.generic;
getPackages = system:
builtins.mapAttrs
(
namespace: packages:
lib.attrs.filter
(name: package: builtins.elem system package.meta.platforms)
packages
);
targeted' = {
i686-linux =
getPackages "i686-linux" generic
// {
cross = {
x86_64-linux = getPackages "x86_64-linux" generic;
};
};
};
targeted = lib.attrs.generate lib'.systems.doubles.all (system:
getPackages system generic
// {
cross = lib.attrs.generate doubles (
host: getPackages host generic
);
});
generic = builtins.removeAttrs config.packages ["targeted"];
in {
includes = [
# ./aux/foundation.nix
];
options = {
packages = {
generic = lib.options.create {
type = lib'.types.packages.generic;
packages = lib.options.create {
default.value = {};
};
targeted = lib.options.create {
type = lib'.types.packages.targeted;
};
type = lib.types.attrs.of (lib.types.submodule {
freeform = lib.types.any;
});
};
};
config = {
packages = {
generic = {
example = {
x = {
meta.platforms = ["i686-linux" "x86_64-linux"];
version = "1.0.0";
builder.build = package:
derivation {
name = package.name;
builder = "/bin/sh";
system = package.platform.build;
};
phases = {
build = package: ''
make --build ${package.platform.build} --host ${package.platform.host}
'';
install = lib.dag.entry.after ["build"] ''
make install DESTDIR=$out
'';
};
};
};
};
inherit targeted;
};
packages.targeted.i686-linux = generic;
};
}