Compare commits
No commits in common. "7385b2195071116e808e97aa0e561d513da8f1d4" and "2be3111b2c0911f40b47fe0a1fb22b5f5188cf59" have entirely different histories.
7385b21950
...
2be3111b2c
|
@ -3,10 +3,10 @@
|
||||||
"lib": {
|
"lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "lib",
|
"dir": "lib",
|
||||||
"dirtyRev": "2be3111b2c0911f40b47fe0a1fb22b5f5188cf59-dirty",
|
"dirtyRev": "a707b0f06be6b36bcbfe88d0a9a5b9a803983a06-dirty",
|
||||||
"dirtyShortRev": "2be3111-dirty",
|
"dirtyShortRev": "a707b0f-dirty",
|
||||||
"lastModified": 1719251485,
|
"lastModified": 1719079124,
|
||||||
"narHash": "sha256-63NvfFVeTDITfNu60rmCUlaZtAeZUnvrIaOLSk9ScC8=",
|
"narHash": "sha256-4HwA3q5f7SUBmcXX9Vz9WsA9oHBQ/GiZTwE4iSVq9s8=",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:../?dir=lib"
|
"url": "file:../?dir=lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,9 @@ lib: {
|
||||||
## Merge a list of option definitions into a single value.
|
## Merge a list of option definitions into a single value.
|
||||||
##
|
##
|
||||||
## @type Location -> List Definition -> Any
|
## @type Location -> List Definition -> Any
|
||||||
default = location: definitions: let
|
default =
|
||||||
|
location: definitions:
|
||||||
|
let
|
||||||
values = lib.options.getDefinitionValues definitions;
|
values = lib.options.getDefinitionValues definitions;
|
||||||
first = builtins.elemAt values 0;
|
first = builtins.elemAt values 0;
|
||||||
mergedFunctions = x: lib.options.mergeDefault location (builtins.map (f: f x) values);
|
mergedFunctions = x: lib.options.mergeDefault location (builtins.map (f: f x) values);
|
||||||
|
@ -13,30 +15,35 @@ lib: {
|
||||||
mergedBools = builtins.any lib.bools.or false values;
|
mergedBools = builtins.any lib.bools.or false values;
|
||||||
mergedStrings = lib.strings.concat values;
|
mergedStrings = lib.strings.concat values;
|
||||||
in
|
in
|
||||||
if builtins.length values == 1
|
if builtins.length values == 1 then
|
||||||
then builtins.elemAt values 0
|
builtins.elemAt values 0
|
||||||
else if builtins.all builtins.isFunction values
|
else if builtins.all builtins.isFunction values then
|
||||||
then mergedFunctions
|
mergedFunctions
|
||||||
else if builtins.all builtins.isList values
|
else if builtins.all builtins.isList values then
|
||||||
then mergedLists
|
mergedLists
|
||||||
else if builtins.all builtins.isAttrs values
|
else if builtins.all builtins.isAttrs values then
|
||||||
then mergedAttrs
|
mergedAttrs
|
||||||
else if builtins.all builtins.isBool values
|
else if builtins.all builtins.isBool values then
|
||||||
then mergedBools
|
mergedBools
|
||||||
else if builtins.all lib.strings.isString values
|
else if builtins.all lib.strings.isString values then
|
||||||
then mergedStrings
|
mergedStrings
|
||||||
else if builtins.all builtins.isInt values && builtins.all (x: x == first) values
|
else if builtins.all builtins.isInt values && builtins.all (x: x == first) values then
|
||||||
then first
|
first
|
||||||
# TODO: Improve this error message to show the location and definitions for the option.
|
# TODO: Improve this error message to show the location and definitions for the option.
|
||||||
else builtins.throw "Cannot merge definitions.";
|
else
|
||||||
|
builtins.throw "Cannot merge definitions.";
|
||||||
|
|
||||||
## Merge multiple option definitions together.
|
## Merge multiple option definitions together.
|
||||||
##
|
##
|
||||||
## @type Location -> Type -> List Definition
|
## @type Location -> Type -> List Definition
|
||||||
definitions = location: type: definitions: let
|
definitions =
|
||||||
|
location: type: definitions:
|
||||||
|
let
|
||||||
identifier = lib.options.getIdentifier location;
|
identifier = lib.options.getIdentifier location;
|
||||||
resolve = definition: let
|
resolve =
|
||||||
properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__ or "<unknown>"}`:" (
|
definition:
|
||||||
|
let
|
||||||
|
properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__}`:" (
|
||||||
lib.modules.apply.properties definition.value
|
lib.modules.apply.properties definition.value
|
||||||
);
|
);
|
||||||
normalize = value: {
|
normalize = value: {
|
||||||
|
@ -50,27 +57,27 @@ lib: {
|
||||||
overridden = lib.modules.apply.overrides resolved;
|
overridden = lib.modules.apply.overrides resolved;
|
||||||
|
|
||||||
values =
|
values =
|
||||||
if builtins.any (definition: lib.types.is "order" definition.value) overridden.values
|
if builtins.any (definition: lib.types.is "order" definition.value) overridden.values then
|
||||||
then lib.modules.apply.order overridden.values
|
lib.modules.apply.order overridden.values
|
||||||
else overridden.values;
|
else
|
||||||
|
overridden.values;
|
||||||
|
|
||||||
isDefined = values != [ ];
|
isDefined = values != [ ];
|
||||||
|
|
||||||
invalid = builtins.filter (definition: !(type.check definition.value)) values;
|
invalid = builtins.filter (definition: !(type.check definition.value)) values;
|
||||||
|
|
||||||
merged =
|
merged =
|
||||||
if isDefined
|
if isDefined then
|
||||||
then
|
if builtins.all (definition: type.check definition.value) values then
|
||||||
if builtins.all (definition: type.check definition.value) values
|
type.merge location values
|
||||||
then type.merge location values
|
else
|
||||||
else builtins.throw "A definition for `${identifier}` is not of type `${type.description}`. Definition values:${lib.options.getDefinitions invalid}"
|
builtins.throw "A definition for `${identifier}` is not of type `${type.description}`. Definition values:${lib.options.getDefinitions invalid}"
|
||||||
else builtins.throw "The option `${identifier}` is used but not defined.";
|
else
|
||||||
|
builtins.throw "The option `${identifier}` is used but not defined.";
|
||||||
|
|
||||||
optional =
|
optional = if isDefined then { value = merged; } else { };
|
||||||
if isDefined
|
in
|
||||||
then {value = merged;}
|
{
|
||||||
else {};
|
|
||||||
in {
|
|
||||||
inherit
|
inherit
|
||||||
isDefined
|
isDefined
|
||||||
values
|
values
|
||||||
|
@ -87,8 +94,12 @@ lib: {
|
||||||
## Merge multiple option declarations together.
|
## Merge multiple option declarations together.
|
||||||
##
|
##
|
||||||
## @type Location -> List Option
|
## @type Location -> List Option
|
||||||
declarations = location: options: let
|
declarations =
|
||||||
merge = result: option: let
|
location: options:
|
||||||
|
let
|
||||||
|
merge =
|
||||||
|
result: option:
|
||||||
|
let
|
||||||
mergedType = result.type.mergeType option.options.type.functor;
|
mergedType = result.type.mergeType option.options.type.functor;
|
||||||
isTypeMergeable = mergedType != null;
|
isTypeMergeable = mergedType != null;
|
||||||
shared = name: option.options ? ${name} && result ? ${name};
|
shared = name: option.options ? ${name} && result ? ${name};
|
||||||
|
@ -97,15 +108,14 @@ lib: {
|
||||||
serializedFiles = builtins.concatStringsSep " and " files;
|
serializedFiles = builtins.concatStringsSep " and " files;
|
||||||
getSubModules = option.options.type.getSubModules or null;
|
getSubModules = option.options.type.getSubModules or null;
|
||||||
submodules =
|
submodules =
|
||||||
if getSubModules != null
|
if getSubModules != null then
|
||||||
then
|
|
||||||
builtins.map (module: {
|
builtins.map (module: {
|
||||||
__file__ = option.__file__;
|
__file__ = option.__file__;
|
||||||
includes = [ module ];
|
includes = [ module ];
|
||||||
})
|
}) getSubModules
|
||||||
getSubModules
|
|
||||||
++ result.options
|
++ result.options
|
||||||
else result.options;
|
else
|
||||||
|
result.options;
|
||||||
in
|
in
|
||||||
if
|
if
|
||||||
shared "default"
|
shared "default"
|
||||||
|
@ -113,7 +123,8 @@ lib: {
|
||||||
|| shared "description"
|
|| shared "description"
|
||||||
|| shared "apply"
|
|| shared "apply"
|
||||||
|| (shared "type" && !isTypeMergeable)
|
|| (shared "type" && !isTypeMergeable)
|
||||||
then builtins.throw "The option `${lib.options.getIdentifier location}` in `${option.__file__}` is already declared in ${serializedFiles}"
|
then
|
||||||
|
builtins.throw "The option `${lib.options.getIdentifier location}` in `${option.__file__}` is already declared in ${serializedFiles}"
|
||||||
else
|
else
|
||||||
option.options
|
option.options
|
||||||
// result
|
// result
|
||||||
|
@ -127,43 +138,50 @@ lib: {
|
||||||
inherit location;
|
inherit location;
|
||||||
declarations = [ ];
|
declarations = [ ];
|
||||||
options = [ ];
|
options = [ ];
|
||||||
}
|
} options;
|
||||||
options;
|
|
||||||
|
|
||||||
## Merge an option, only supporting a single unique definition.
|
## Merge an option, only supporting a single unique definition.
|
||||||
##
|
##
|
||||||
## @type String -> Location -> List Definition -> Any
|
## @type String -> Location -> List Definition -> Any
|
||||||
unique = message: location: definitions: let
|
unique =
|
||||||
|
message: location: definitions:
|
||||||
|
let
|
||||||
identifier = lib.options.getIdentifier location;
|
identifier = lib.options.getIdentifier location;
|
||||||
total = builtins.length definitions;
|
total = builtins.length definitions;
|
||||||
first = builtins.elemAt definitions 0;
|
first = builtins.elemAt definitions 0;
|
||||||
in
|
in
|
||||||
if total == 1
|
if total == 1 then
|
||||||
then first.value
|
first.value
|
||||||
else if total == 0
|
else if total == 0 then
|
||||||
then builtins.throw "Cannot merge unused option `${identifier}`.\n${message}"
|
builtins.throw "Cannot merge unused option `${identifier}`.\n${message}"
|
||||||
else builtins.throw "The option `${identifier}` is defined multiple times, but must be unique.\n${message}\nDefinitions:${lib.options.getDefinitions definitions}";
|
else
|
||||||
|
builtins.throw "The option `${identifier}` is defined multiple times, but must be unique.\n${message}\nDefinitions:${lib.options.getDefinitions definitions}";
|
||||||
|
|
||||||
## Merge a single instance of an option.
|
## Merge a single instance of an option.
|
||||||
##
|
##
|
||||||
## @type Location -> List Definition -> Any
|
## @type Location -> List Definition -> Any
|
||||||
one = lib.options.merge.unique "";
|
one = lib.options.merge.unique "";
|
||||||
|
|
||||||
equal = location: definitions: let
|
equal =
|
||||||
|
location: definitions:
|
||||||
|
let
|
||||||
identifier = lib.options.getIdentifier location;
|
identifier = lib.options.getIdentifier location;
|
||||||
first = builtins.elemAt definitions 0;
|
first = builtins.elemAt definitions 0;
|
||||||
rest = builtins.tail definitions;
|
rest = builtins.tail definitions;
|
||||||
merge = x: y:
|
merge =
|
||||||
if x != y
|
x: y:
|
||||||
then builtins.throw "The option `${identifier}` has conflicting definitions:${lib.options.getDefinitions definitions}"
|
if x != y then
|
||||||
else x;
|
builtins.throw "The option `${identifier}` has conflicting definitions:${lib.options.getDefinitions definitions}"
|
||||||
|
else
|
||||||
|
x;
|
||||||
merged = builtins.foldl' merge first rest;
|
merged = builtins.foldl' merge first rest;
|
||||||
in
|
in
|
||||||
if builtins.length definitions == 0
|
if builtins.length definitions == 0 then
|
||||||
then builtins.throw "Cannot merge unused option `${identifier}`."
|
builtins.throw "Cannot merge unused option `${identifier}`."
|
||||||
else if builtins.length definitions == 1
|
else if builtins.length definitions == 1 then
|
||||||
then first.value
|
first.value
|
||||||
else merged.value;
|
else
|
||||||
|
merged.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
## Check whether a value is an option.
|
## Check whether a value is an option.
|
||||||
|
@ -174,7 +192,8 @@ lib: {
|
||||||
## Create an option.
|
## Create an option.
|
||||||
##
|
##
|
||||||
## @type { type? :: String | Null, apply? :: (a -> b) | Null, default? :: { value :: a, text :: String }, example? :: String | Null, visible? :: Bool | Null, internal? :: Bool | Null, writable? :: Bool | Null, description? :: String | Null } -> Option a
|
## @type { type? :: String | Null, apply? :: (a -> b) | Null, default? :: { value :: a, text :: String }, example? :: String | Null, visible? :: Bool | Null, internal? :: Bool | Null, writable? :: Bool | Null, description? :: String | Null } -> Option a
|
||||||
create = settings @ {
|
create =
|
||||||
|
settings@{
|
||||||
type ? lib.types.unspecified,
|
type ? lib.types.unspecified,
|
||||||
apply ? null,
|
apply ? null,
|
||||||
default ? { },
|
default ? { },
|
||||||
|
@ -183,7 +202,8 @@ lib: {
|
||||||
internal ? null,
|
internal ? null,
|
||||||
writable ? null,
|
writable ? null,
|
||||||
description ? null,
|
description ? null,
|
||||||
}: {
|
}:
|
||||||
|
{
|
||||||
__type__ = "option";
|
__type__ = "option";
|
||||||
inherit
|
inherit
|
||||||
type
|
type
|
||||||
|
@ -200,7 +220,9 @@ lib: {
|
||||||
## Create a sink option.
|
## Create a sink option.
|
||||||
##
|
##
|
||||||
## @type @alias lib.options.create
|
## @type @alias lib.options.create
|
||||||
sink = settings: let
|
sink =
|
||||||
|
settings:
|
||||||
|
let
|
||||||
defaults = {
|
defaults = {
|
||||||
internal = true;
|
internal = true;
|
||||||
visible = false;
|
visible = false;
|
||||||
|
@ -224,7 +246,9 @@ lib: {
|
||||||
## Convert a list of option identifiers into a single identifier.
|
## Convert a list of option identifiers into a single identifier.
|
||||||
##
|
##
|
||||||
## @type List String -> String
|
## @type List String -> String
|
||||||
getIdentifier = location: let
|
getIdentifier =
|
||||||
|
location:
|
||||||
|
let
|
||||||
special = [
|
special = [
|
||||||
# lib.types.attrs.of (lib.types.submodule {})
|
# lib.types.attrs.of (lib.types.submodule {})
|
||||||
"<name>"
|
"<name>"
|
||||||
|
@ -233,24 +257,23 @@ lib: {
|
||||||
# lib.types.function
|
# lib.types.function
|
||||||
"<function body>"
|
"<function body>"
|
||||||
];
|
];
|
||||||
escape = part:
|
escape = part: if builtins.elem part special then part else lib.strings.escape.nix.identifier part;
|
||||||
if builtins.elem part special
|
|
||||||
then part
|
|
||||||
else lib.strings.escape.nix.identifier part;
|
|
||||||
in
|
in
|
||||||
lib.strings.concatMapSep "." escape location;
|
lib.strings.concatMapSep "." escape location;
|
||||||
|
|
||||||
## Get a string message of the definitions for an option.
|
## Get a string message of the definitions for an option.
|
||||||
##
|
##
|
||||||
## @type List Definition -> String
|
## @type List Definition -> String
|
||||||
getDefinitions = definitions: let
|
getDefinitions =
|
||||||
serialize = definition: let
|
definitions:
|
||||||
valueWithRecursionLimit =
|
let
|
||||||
lib.generators.withRecursion {
|
serialize =
|
||||||
|
definition:
|
||||||
|
let
|
||||||
|
valueWithRecursionLimit = lib.generators.withRecursion {
|
||||||
limit = 10;
|
limit = 10;
|
||||||
throw = false;
|
throw = false;
|
||||||
}
|
} definition.value;
|
||||||
definition.value;
|
|
||||||
|
|
||||||
eval = builtins.tryEval (lib.generators.pretty { } valueWithRecursionLimit);
|
eval = builtins.tryEval (lib.generators.pretty { } valueWithRecursionLimit);
|
||||||
|
|
||||||
|
@ -263,24 +286,27 @@ lib: {
|
||||||
value = builtins.concatStringsSep "\n " (firstFiveLines ++ ellipsis);
|
value = builtins.concatStringsSep "\n " (firstFiveLines ++ ellipsis);
|
||||||
|
|
||||||
result =
|
result =
|
||||||
if !eval.success
|
if !eval.success then
|
||||||
then ""
|
""
|
||||||
else if linesLength > 1
|
else if linesLength > 1 then
|
||||||
then ":\n " + value
|
":\n " + value
|
||||||
else ": " + value;
|
else
|
||||||
in "\n- In `${definition.__file__}`${result}";
|
": " + value;
|
||||||
|
in
|
||||||
|
"\n- In `${definition.__file__}`${result}";
|
||||||
in
|
in
|
||||||
lib.strings.concatMap serialize definitions;
|
lib.strings.concatMap serialize definitions;
|
||||||
|
|
||||||
## Run a set of definitions, calculating the resolved value and associated information.
|
## Run a set of definitions, calculating the resolved value and associated information.
|
||||||
##
|
##
|
||||||
## @type Location -> Option -> List Definition -> String & { value :: Any, highestPriority :: Int, isDefined :: Bool, files :: List String, definitions :: List Any, definitionsWithLocations :: List Definition }
|
## @type Location -> Option -> List Definition -> String & { value :: Any, highestPriority :: Int, isDefined :: Bool, files :: List String, definitions :: List Any, definitionsWithLocations :: List Definition }
|
||||||
run = location: option: definitions: let
|
run =
|
||||||
|
location: option: definitions:
|
||||||
|
let
|
||||||
identifier = lib.options.getIdentifier location;
|
identifier = lib.options.getIdentifier location;
|
||||||
|
|
||||||
definitionsWithDefault =
|
definitionsWithDefault =
|
||||||
if option ? default && option.default ? value
|
if option ? default && option.default ? value then
|
||||||
then
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
__file__ = builtins.head option.declarations;
|
__file__ = builtins.head option.declarations;
|
||||||
|
@ -288,28 +314,25 @@ lib: {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
++ definitions
|
++ definitions
|
||||||
else definitions;
|
else
|
||||||
|
definitions;
|
||||||
|
|
||||||
merged =
|
merged =
|
||||||
if option.writable or null == false && builtins.length definitionsWithDefault > 1
|
if option.writable or null == false && builtins.length definitionsWithDefault > 1 then
|
||||||
then let
|
let
|
||||||
separatedDefinitions =
|
separatedDefinitions = builtins.map (
|
||||||
builtins.map (
|
|
||||||
definition:
|
definition:
|
||||||
definition
|
definition
|
||||||
// {
|
// {
|
||||||
value = (lib.options.merge.definitions location option.type [ definition ]).merged;
|
value = (lib.options.merge.definitions location option.type [ definition ]).merged;
|
||||||
}
|
}
|
||||||
)
|
) definitionsWithDefault;
|
||||||
definitionsWithDefault;
|
|
||||||
in
|
in
|
||||||
builtins.throw "The option `${identifier}` is not writable, but is set more than once:${lib.options.getDefinitions separatedDefinitions}"
|
builtins.throw "The option `${identifier}` is not writable, but is set more than once:${lib.options.getDefinitions separatedDefinitions}"
|
||||||
else lib.options.merge.definitions location option.type definitionsWithDefault;
|
else
|
||||||
|
lib.options.merge.definitions location option.type definitionsWithDefault;
|
||||||
|
|
||||||
value =
|
value = if option.apply or null != null then option.apply merged.merged else merged.merged;
|
||||||
if option.apply or null != null
|
|
||||||
then option.apply merged.merged
|
|
||||||
else merged.merged;
|
|
||||||
in
|
in
|
||||||
option
|
option
|
||||||
// {
|
// {
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ lib: {
|
||||||
merge = location: definitions: let
|
merge = location: definitions: let
|
||||||
process = value:
|
process = value:
|
||||||
if initial.check value
|
if initial.check value
|
||||||
then transform value
|
then (builtins.trace "transforming...") transform value
|
||||||
else value;
|
else value;
|
||||||
normalize = definition: definition // {value = process definition.value;};
|
normalize = definition: definition // {value = process definition.value;};
|
||||||
normalized = builtins.map normalize definitions;
|
normalized = builtins.map normalize definitions;
|
||||||
|
@ -1068,43 +1068,6 @@ lib: {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
## Create a type that allows a value which is either the final type or is transformable
|
|
||||||
## to the final type.
|
|
||||||
##
|
|
||||||
## @type Attrs -> (Any -> Any) -> Attrs -> Attrs
|
|
||||||
coerceWithLocation = initial: transform: final: let
|
|
||||||
in
|
|
||||||
if initial.getSubModules != null
|
|
||||||
then builtins.throw "lib.types.coerceWithLocation's first argument may not have submodules, but got ${initial.description}"
|
|
||||||
else
|
|
||||||
lib.types.create {
|
|
||||||
name = "Coerce";
|
|
||||||
description = "${initial.description} that is transformed to ${final.description}";
|
|
||||||
fallback = final.fallback;
|
|
||||||
check = value: final.check value || (initial.check value && final.check (transform [] value));
|
|
||||||
merge = location: definitions: let
|
|
||||||
process = value:
|
|
||||||
if initial.check value
|
|
||||||
then transform location value
|
|
||||||
else value;
|
|
||||||
normalize = definition: definition // {value = process definition.value;};
|
|
||||||
normalized = builtins.map normalize definitions;
|
|
||||||
in
|
|
||||||
final.merge location normalized;
|
|
||||||
getSubOptions = final.getSubOptions;
|
|
||||||
getSubModules = final.getSubModules;
|
|
||||||
withSubModules = modules: lib.types.coerceWithLocation initial transform (final.withSubModules modules);
|
|
||||||
mergeType = x: y: null;
|
|
||||||
functor =
|
|
||||||
lib.types.functor "coerceWithLocation"
|
|
||||||
// {
|
|
||||||
wrapped = final;
|
|
||||||
};
|
|
||||||
children = {
|
|
||||||
inherit initial final;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
dag = {
|
dag = {
|
||||||
## Create a type that allows a DAG (Directed Acyclic Graph) of a given type.
|
## Create a type that allows a DAG (Directed Acyclic Graph) of a given type.
|
||||||
##
|
##
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "foundation",
|
"dir": "foundation",
|
||||||
"dirtyRev": "2be3111b2c0911f40b47fe0a1fb22b5f5188cf59-dirty",
|
"dirtyRev": "a707b0f06be6b36bcbfe88d0a9a5b9a803983a06-dirty",
|
||||||
"dirtyShortRev": "2be3111-dirty",
|
"dirtyShortRev": "a707b0f-dirty",
|
||||||
"lastModified": 1719251485,
|
"lastModified": 1719079124,
|
||||||
"narHash": "sha256-9G1TPBdlQNXCZf6A66bCT9m2vhodkSF+rDtqOVuFteY=",
|
"narHash": "sha256-hz9vVcHSvlq/W01UOh/GqPFUoH9DzCFB16n23oj7fnQ=",
|
||||||
"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": "2be3111b2c0911f40b47fe0a1fb22b5f5188cf59-dirty",
|
"dirtyRev": "a707b0f06be6b36bcbfe88d0a9a5b9a803983a06-dirty",
|
||||||
"dirtyShortRev": "2be3111-dirty",
|
"dirtyShortRev": "a707b0f-dirty",
|
||||||
"lastModified": 1719251485,
|
"lastModified": 1719079124,
|
||||||
"narHash": "sha256-9G1TPBdlQNXCZf6A66bCT9m2vhodkSF+rDtqOVuFteY=",
|
"narHash": "sha256-hz9vVcHSvlq/W01UOh/GqPFUoH9DzCFB16n23oj7fnQ=",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:../?dir=lib"
|
"url": "file:../?dir=lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,13 +83,7 @@ in {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
built
|
built // {inherit (package) meta;};
|
||||||
// {
|
|
||||||
inherit (package) meta;
|
|
||||||
extras = {
|
|
||||||
inherit package;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
# This file handles creating all of the exports for this project and is not
|
# This file handles creating all of the exports for this project and is not
|
||||||
# exported itself.
|
# exported itself.
|
||||||
{config}: let
|
{
|
||||||
inherit (config) lib;
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
|
lib' = config.lib;
|
||||||
in {
|
in {
|
||||||
# freeform = lib.types.any;
|
freeform = lib.types.any;
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
exports = {
|
exports = {
|
||||||
inherit lib;
|
lib = config.lib;
|
||||||
modules = import ./modules.nix;
|
modules = import ./modules.nix;
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
|
@ -22,14 +25,13 @@ in {
|
||||||
# };
|
# };
|
||||||
# }))
|
# }))
|
||||||
# .config;
|
# .config;
|
||||||
foundation-gcc = config.packages.foundation.gcc;
|
# foundation-gcc = config.packages.foundation.gcc;
|
||||||
# foundation-binutils = config.packages.foundation.binutils;
|
# foundation-binutils = config.packages.foundation.binutils;
|
||||||
# foundation-linux-headers = config.packages.foundation.linux-headers.versions.latest.extend {
|
# foundation-linux-headers = config.packages.foundation.linux-headers.versions.latest.extend {
|
||||||
# platform.host = lib.modules.overrides.force "x86_64-linux";
|
# platform.host = lib.modules.overrides.force "x86_64-linux";
|
||||||
# };
|
# };
|
||||||
# example-x = config.packages.example.x;
|
# example-x = config.packages.example.x;
|
||||||
cross-aux-a-x86_64-linux = config.packages.cross.x86_64-linux.aux.a;
|
# cross-example-x-x86_64-linux = config.packages.cross.x86_64-linux.example.x;
|
||||||
cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
lib',
|
||||||
config,
|
config,
|
||||||
}: let
|
}: {
|
||||||
lib' = config.lib;
|
|
||||||
in {
|
|
||||||
config = {
|
config = {
|
||||||
lib.packages = {
|
lib.packages = {
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
@ -21,70 +20,52 @@ in {
|
||||||
in
|
in
|
||||||
builtins.head sorted;
|
builtins.head sorted;
|
||||||
|
|
||||||
resolve = alias:
|
resolve = package:
|
||||||
if alias ? versions
|
if package ? versions
|
||||||
then
|
then
|
||||||
alias.versions.${config.preferences.packages.version}
|
package.versions.${config.preferences.packages.version}
|
||||||
or (alias.versions.${lib'.packages.getLatest alias})
|
or (package.versions.${lib'.packages.getLatest package})
|
||||||
else alias;
|
else package;
|
||||||
|
|
||||||
build = alias: build: host: target: let
|
build = package: build: host: target: let
|
||||||
package = lib'.packages.resolve alias;
|
resolved = lib'.packages.resolve package;
|
||||||
|
|
||||||
buildDependencies = build': host': target':
|
buildDependencies = build': host': target':
|
||||||
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
|
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
|
||||||
|
|
||||||
result = lib.modules.run {
|
result = resolved.extend (
|
||||||
modules =
|
|
||||||
package.__modules__
|
|
||||||
++ [
|
|
||||||
lib'.types.package.children.submodule
|
|
||||||
(
|
|
||||||
{config}: {
|
{config}: {
|
||||||
config = {
|
config = {
|
||||||
__modules__ = package.__modules__;
|
|
||||||
|
|
||||||
platform = {
|
platform = {
|
||||||
build = lib.modules.overrides.force build;
|
build = build;
|
||||||
host = lib.modules.overrides.force host;
|
host = host;
|
||||||
target = lib.modules.overrides.force target;
|
target = lib.modules.override 150 target;
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Not all platform information can be effectively handled via submodules. To handle
|
|
||||||
# the case where a user copies the resolved config over we need to ensure that
|
|
||||||
# dependencies are appropriately updated.
|
|
||||||
resolved =
|
|
||||||
result.config
|
|
||||||
// {
|
|
||||||
deps = {
|
deps = {
|
||||||
build = {
|
build = {
|
||||||
only = buildDependencies build build build package.deps.build.only;
|
only = buildDependencies build build build resolved.deps.build.only;
|
||||||
build = buildDependencies build build target package.deps.build.build;
|
build = buildDependencies build build target resolved.deps.build.build;
|
||||||
host = buildDependencies build host target package.deps.build.host;
|
host = buildDependencies build host target resolved.deps.build.host;
|
||||||
target = buildDependencies build target target package.deps.build.target;
|
target = buildDependencies build target target resolved.deps.build.target;
|
||||||
};
|
};
|
||||||
host = {
|
host = {
|
||||||
only = buildDependencies host host host package.deps.host.only;
|
only = buildDependencies host host host resolved.deps.host.only;
|
||||||
host = buildDependencies host host target package.deps.host.host;
|
host = buildDependencies host host target resolved.deps.host.host;
|
||||||
target = buildDependencies host target target package.deps.host.target;
|
target = buildDependencies host target target resolved.deps.host.target;
|
||||||
};
|
};
|
||||||
target = {
|
target = {
|
||||||
only = buildDependencies target target target package.deps.target.only;
|
only = buildDependencies target target target resolved.deps.target.only;
|
||||||
target = buildDependencies target target target package.deps.target.target;
|
target = buildDependencies target target target resolved.deps.target.target;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
package = config.builder.build config;
|
||||||
resolved
|
|
||||||
// {
|
|
||||||
package = resolved.builder.build resolved;
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,8 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
lib',
|
||||||
config,
|
config,
|
||||||
}: let
|
}: {
|
||||||
inherit (config) preferences builders;
|
|
||||||
|
|
||||||
lib' = config.lib;
|
|
||||||
in {
|
|
||||||
config = {
|
config = {
|
||||||
lib.types = {
|
lib.types = {
|
||||||
license = let
|
license = let
|
||||||
|
@ -55,12 +52,6 @@ in {
|
||||||
in
|
in
|
||||||
lib.types.either type (lib.types.list.of type);
|
lib.types.either type (lib.types.list.of type);
|
||||||
|
|
||||||
platform =
|
|
||||||
lib.types.coerce
|
|
||||||
lib.types.string
|
|
||||||
lib'.systems.withBuildInfo
|
|
||||||
lib'.systems.types.platformWithBuildInfo;
|
|
||||||
|
|
||||||
builder = lib.types.submodule {
|
builder = lib.types.submodule {
|
||||||
freeform = lib.types.any;
|
freeform = lib.types.any;
|
||||||
|
|
||||||
|
@ -72,93 +63,194 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias);
|
packages = lib.types.attrs.of (lib'.types.alias);
|
||||||
|
|
||||||
dependencies = build: host: target: let
|
alias = lib.types.attrs.of (
|
||||||
initial = lib.types.attrs.any;
|
lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
versions = lib.options.create {
|
||||||
|
description = "All available package versions.";
|
||||||
|
type = lib.types.attrs.of lib'.types.package.base;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
dependencies = lib.types.attrs.of (
|
||||||
|
lib.types.nullish (lib'.types.package.resolved)
|
||||||
|
);
|
||||||
|
|
||||||
|
package = {
|
||||||
|
resolved = let
|
||||||
|
initial =
|
||||||
|
lib.types.raw
|
||||||
|
// {
|
||||||
|
check = value:
|
||||||
|
!(value ? __merged__)
|
||||||
|
&& lib.types.raw.check
|
||||||
|
value;
|
||||||
|
};
|
||||||
|
|
||||||
transform = value: let
|
transform = value: let
|
||||||
package = lib'.packages.resolve value;
|
package = lib'.packages.resolve value;
|
||||||
in
|
packageSubmodule = package.extend (args: {
|
||||||
(builtins.trace "building dependency ${package.name}: build=${build.triple} host=${host.triple} target=${target.triple}")
|
options.__export__ = lib.options.create {
|
||||||
lib'.packages.build package build host target;
|
type = lib.types.raw;
|
||||||
in
|
default.value = {
|
||||||
lib.types.attrs.of (lib.types.coerce initial transform lib'.types.package);
|
inherit (args) options config;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
alias = lib.types.submodule {
|
config.__export__ = {
|
||||||
|
inherit (args) options config;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
type = lib'.types.package.base.withSubModules (lib'.types.package.base.getSubModules
|
||||||
|
++ [
|
||||||
|
(args: {
|
||||||
|
options.__export__ = lib.options.create {
|
||||||
|
type = lib.types.raw;
|
||||||
|
default.value = {
|
||||||
|
inherit (args) options config;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.__export__ = {
|
||||||
|
inherit (args) options config;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
typeSubmodule = lib.modules.run {
|
||||||
|
modules = type.getSubModules;
|
||||||
|
args = type.functor.payload.args;
|
||||||
|
};
|
||||||
|
|
||||||
|
getOptions = export: let
|
||||||
|
process = path: option:
|
||||||
|
if builtins.isAttrs option
|
||||||
|
then
|
||||||
|
if lib.types.is "option" option
|
||||||
|
then [
|
||||||
|
{
|
||||||
|
inherit path;
|
||||||
|
option = option;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
else
|
||||||
|
builtins.concatLists (
|
||||||
|
lib.attrs.mapToList
|
||||||
|
(name: value: process (path ++ [name]) value)
|
||||||
|
option
|
||||||
|
)
|
||||||
|
else [];
|
||||||
|
in
|
||||||
|
process [] export.options;
|
||||||
|
|
||||||
|
packageOptions = getOptions packageSubmodule.__export__;
|
||||||
|
typeOptions = getOptions typeSubmodule.config.__export__;
|
||||||
|
|
||||||
|
customOptions =
|
||||||
|
builtins.filter
|
||||||
|
(
|
||||||
|
packageOption:
|
||||||
|
builtins.all (typeOption: packageOption.path != typeOption.path) typeOptions
|
||||||
|
)
|
||||||
|
packageOptions;
|
||||||
|
|
||||||
|
packageOptionsIds = builtins.map (option: builtins.concatStringsSep "." option.path) packageOptions;
|
||||||
|
typeOptionsIds = builtins.map (option: builtins.concatStringsSep "." option.path) typeOptions;
|
||||||
|
customOptionsIds = builtins.map (option: builtins.concatStringsSep "." option.path) customOptions;
|
||||||
|
|
||||||
|
resolvedOptions =
|
||||||
|
builtins.foldl' (
|
||||||
|
resolved: option: let
|
||||||
|
first = builtins.head option.path;
|
||||||
|
generated = lib.attrs.set option.path option.option;
|
||||||
|
in
|
||||||
|
if first == "__export__" || first == "__module__" || first == "__merged__"
|
||||||
|
then resolved
|
||||||
|
else lib.attrs.mergeRecursive resolved generated
|
||||||
|
) {}
|
||||||
|
customOptions;
|
||||||
|
in
|
||||||
|
# (builtins.trace (builtins.deepSeq packageOptionsIds packageOptionsIds))
|
||||||
|
# (builtins.trace (builtins.deepSeq typeOptionsIds typeOptionsIds))
|
||||||
|
# (builtins.trace (builtins.deepSeq customOptionsIds customOptionsIds))
|
||||||
|
# (builtins.trace packageSubmodule.__export__.config)
|
||||||
|
(args: {
|
||||||
|
__file__ = packageSubmodule.__export__.config.__file__ or "virtual:tidepool/src/lib/types.nix";
|
||||||
|
|
||||||
|
options =
|
||||||
|
resolvedOptions
|
||||||
|
// {
|
||||||
|
__merged__ = lib.options.create {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default.value = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
builtins.removeAttrs package ["extend" "package" "platform"]
|
||||||
|
// {
|
||||||
|
platform = {
|
||||||
|
build = lib.modules.overrides.default package.platform.build.triple;
|
||||||
|
host = lib.modules.overrides.default package.platform.host.triple;
|
||||||
|
target = lib.modules.overrides.default package.platform.target.triple;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# // {
|
||||||
|
# builder =
|
||||||
|
# (builtins.trace "builder")
|
||||||
|
# (builtins.trace (args.config ? builder))
|
||||||
|
# lib.modules.alias
|
||||||
|
# packageSubmodule.__export__.options.builder;
|
||||||
|
# };
|
||||||
|
});
|
||||||
|
in
|
||||||
|
lib.types.coerce initial transform lib'.types.package.base;
|
||||||
|
|
||||||
|
base = lib.types.submodule (
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
meta,
|
||||||
|
}: {
|
||||||
options = {
|
options = {
|
||||||
stable = lib.options.create {
|
extend = lib.options.create {
|
||||||
description = "The stable version of the package.";
|
description = "Extend the package's submodules with additional configuration.";
|
||||||
type = lib.types.nullish lib'.types.package;
|
type = lib.types.function lib.types.raw;
|
||||||
};
|
default.value = value: let
|
||||||
|
result = meta.extend {
|
||||||
latest = lib.options.create {
|
|
||||||
description = "The latest version of the package.";
|
|
||||||
type = lib'.types.package;
|
|
||||||
};
|
|
||||||
|
|
||||||
versions = lib.options.create {
|
|
||||||
description = "Available versions of the package.";
|
|
||||||
type = lib.types.attrs.of lib'.types.package;
|
|
||||||
default.value = {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
package = let
|
|
||||||
normalize = value:
|
|
||||||
if builtins.isFunction value || builtins.isList value
|
|
||||||
then value
|
|
||||||
else if value ? __modules__
|
|
||||||
then value.__modules__
|
|
||||||
else {
|
|
||||||
config = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
initial = lib.types.create {
|
|
||||||
name = "PackageConfig";
|
|
||||||
description = "configuration for a package";
|
|
||||||
check = value: builtins.isFunction value || builtins.isAttrs value || builtins.isList value;
|
|
||||||
merge = location: definitions: let
|
|
||||||
normalized =
|
|
||||||
builtins.map
|
|
||||||
(definition: lib.lists.from.any (normalize definition.value))
|
|
||||||
definitions;
|
|
||||||
in
|
|
||||||
builtins.concatLists
|
|
||||||
normalized;
|
|
||||||
};
|
|
||||||
|
|
||||||
transform = location: value: let
|
|
||||||
modules =
|
modules =
|
||||||
lib.lists.from.any (normalize value);
|
if builtins.isAttrs value
|
||||||
|
then [{config = value;}]
|
||||||
result = lib.modules.run {
|
else lib.lists.from.any value;
|
||||||
prefix = location;
|
|
||||||
modules =
|
|
||||||
modules
|
|
||||||
++ [submodule {config.__modules__ = modules;}];
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
result.config;
|
result.config;
|
||||||
|
};
|
||||||
|
|
||||||
final = lib.types.attrs.any;
|
name = lib.options.create {
|
||||||
|
description = "The name of the package.";
|
||||||
|
type = lib.types.string;
|
||||||
|
default = {
|
||||||
|
text = "\${config.pname}-\${config.version}";
|
||||||
|
value =
|
||||||
|
if config.pname != null && config.version != null
|
||||||
|
then "${config.pname}-${config.version}"
|
||||||
|
else "";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
submodule = {config}: let
|
pname = lib.options.create {
|
||||||
build = config.platform.build;
|
description = "The program name for the package";
|
||||||
host = config.platform.host;
|
type = lib.types.nullish lib.types.string;
|
||||||
target = config.platform.target;
|
default.value = null;
|
||||||
in {
|
};
|
||||||
options = {
|
|
||||||
__modules__ = lib.options.create {
|
version = lib.options.create {
|
||||||
description = "User specified modules for the package definition.";
|
description = "The version for the package.";
|
||||||
type = lib.types.list.of (initial
|
type = lib.types.nullish lib.types.version;
|
||||||
// {
|
default.value = null;
|
||||||
merge = lib.options.merge.one;
|
|
||||||
});
|
|
||||||
# writable = false;
|
|
||||||
internal = true;
|
|
||||||
default.value = [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
@ -214,55 +306,57 @@ in {
|
||||||
platform = {
|
platform = {
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
description = "The build platform for the package.";
|
description = "The build platform for the package.";
|
||||||
type = lib'.types.platform;
|
type = lib.types.string;
|
||||||
default.value = lib'.systems.withBuildInfo "x86_64-linux";
|
default.value = "x86_64-linux";
|
||||||
|
apply = raw: let
|
||||||
|
system = lib'.systems.from.string raw;
|
||||||
|
x = lib'.systems.withBuildInfo raw;
|
||||||
|
in
|
||||||
|
x;
|
||||||
};
|
};
|
||||||
|
|
||||||
host = lib.options.create {
|
host = lib.options.create {
|
||||||
description = "The host platform for the package.";
|
description = "The host platform for the package.";
|
||||||
type = lib'.types.platform;
|
type = lib.types.string;
|
||||||
default.value = lib'.systems.withBuildInfo "x86_64-linux";
|
default.value = "x86_64-linux";
|
||||||
|
# apply = raw: let
|
||||||
|
# system = lib'.systems.from.string raw;
|
||||||
|
# in {
|
||||||
|
# inherit raw system;
|
||||||
|
|
||||||
|
# double = lib'.systems.into.double system;
|
||||||
|
# triple = lib'.systems.into.triple system;
|
||||||
|
# };
|
||||||
|
apply = raw: let
|
||||||
|
system = lib'.systems.from.string raw;
|
||||||
|
x = lib'.systems.withBuildInfo raw;
|
||||||
|
in
|
||||||
|
x;
|
||||||
};
|
};
|
||||||
|
|
||||||
target = lib.options.create {
|
target = lib.options.create {
|
||||||
description = "The target platform for the package.";
|
description = "The target platform for the package.";
|
||||||
type = lib'.types.platform;
|
|
||||||
default.value = lib'.systems.withBuildInfo "x86_64-linux";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
name = lib.options.create {
|
|
||||||
description = "The name of the package.";
|
|
||||||
type = lib.types.string;
|
type = lib.types.string;
|
||||||
default = {
|
default.value = "x86_64-linux";
|
||||||
text = "\${config.pname}-\${config.version}";
|
# apply = raw: let
|
||||||
value =
|
# system = lib'.systems.from.string raw;
|
||||||
if config.pname != null && config.version != null
|
# in {
|
||||||
then "${config.pname}-${config.version}"
|
# inherit raw system;
|
||||||
else "";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
pname = lib.options.create {
|
# double = lib'.systems.into.double system;
|
||||||
description = "The program name for the package";
|
# triple = lib'.systems.into.triple system;
|
||||||
type = lib.types.nullish lib.types.string;
|
# };
|
||||||
default.value = null;
|
apply = raw: let
|
||||||
|
system = lib'.systems.from.string raw;
|
||||||
|
x = lib'.systems.withBuildInfo raw;
|
||||||
|
in
|
||||||
|
x;
|
||||||
};
|
};
|
||||||
|
|
||||||
version = lib.options.create {
|
|
||||||
description = "The version for the package.";
|
|
||||||
type = lib.types.nullish lib.types.version;
|
|
||||||
default.value = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
builder = lib.options.create {
|
|
||||||
description = "The builder for the package.";
|
|
||||||
type = lib'.types.builder;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
phases = lib.options.create {
|
phases = lib.options.create {
|
||||||
description = "The phases for the package.";
|
description = "The phases for the package.";
|
||||||
type = lib.types.dag.of lib.types.string;
|
type = lib.types.dag.of (lib.types.either lib.types.string (lib.types.function lib.types.string));
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -272,35 +366,34 @@ in {
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
package = lib.options.create {
|
builder = lib.options.create {
|
||||||
description = "The built derivation.";
|
description = "The builder for the package.";
|
||||||
type = lib.types.derivation;
|
type = lib'.types.builder;
|
||||||
default.value = config.builder.build config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
deps = {
|
deps = {
|
||||||
build = {
|
build = {
|
||||||
only = lib.options.create {
|
only = lib.options.create {
|
||||||
description = "Dependencies which are only used in the build environment.";
|
description = "Dependencies which are only used in the build environment.";
|
||||||
type = lib'.types.dependencies build build build;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
description = "Dependencies which are created in the build environment and are executed in the build environment.";
|
description = "Dependencies which are created in the build environment and are executed in the build environment.";
|
||||||
type = lib'.types.dependencies build build target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
host = lib.options.create {
|
host = lib.options.create {
|
||||||
description = "Dependencies which are created in the build environment and are executed in the host environment.";
|
description = "Dependencies which are created in the build environment and are executed in the host environment.";
|
||||||
type = lib'.types.dependencies build host target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
target = lib.options.create {
|
target = lib.options.create {
|
||||||
description = "Dependencies which are created in the build environment and are executed in the target environment.";
|
description = "Dependencies which are created in the build environment and are executed in the target environment.";
|
||||||
type = lib'.types.dependencies build target target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -308,19 +401,19 @@ in {
|
||||||
host = {
|
host = {
|
||||||
only = lib.options.create {
|
only = lib.options.create {
|
||||||
description = "Dependencies which are only used in the host environment.";
|
description = "Dependencies which are only used in the host environment.";
|
||||||
type = lib'.types.dependencies host host host;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
host = lib.options.create {
|
host = lib.options.create {
|
||||||
description = "Dependencies which are executed in the host environment.";
|
description = "Dependencies which are executed in the host environment.";
|
||||||
type = lib'.types.dependencies host host target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
target = lib.options.create {
|
target = lib.options.create {
|
||||||
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
|
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
|
||||||
type = lib'.types.dependencies host target target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -328,34 +421,26 @@ in {
|
||||||
target = {
|
target = {
|
||||||
only = lib.options.create {
|
only = lib.options.create {
|
||||||
description = "Dependencies which are only used in the target environment.";
|
description = "Dependencies which are only used in the target environment.";
|
||||||
type = lib'.types.dependencies target target target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
target = lib.options.create {
|
target = lib.options.create {
|
||||||
description = "Dependencies which are executed in the target environment.";
|
description = "Dependencies which are executed in the target environment.";
|
||||||
type = lib'.types.dependencies target target target;
|
type = lib'.types.dependencies;
|
||||||
default.value = {};
|
default.value = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
type =
|
package = lib.options.create {
|
||||||
(lib.types.coerceWithLocation initial transform final)
|
description = "The built derivation.";
|
||||||
// {
|
type = lib.types.derivation;
|
||||||
name = "Package";
|
default.value = config.builder.build config;
|
||||||
description = "a package definition";
|
|
||||||
};
|
};
|
||||||
in
|
|
||||||
type
|
|
||||||
// {
|
|
||||||
children =
|
|
||||||
type.children
|
|
||||||
// {
|
|
||||||
inherit submodule;
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,8 +12,6 @@ in {
|
||||||
platforms = ["i686-linux"];
|
platforms = ["i686-linux"];
|
||||||
};
|
};
|
||||||
|
|
||||||
name = "${config.pname}-${config.version}";
|
|
||||||
|
|
||||||
pname = "a";
|
pname = "a";
|
||||||
version = "1.0.0";
|
version = "1.0.0";
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
{config}: let
|
{
|
||||||
inherit (config) lib builders packages;
|
lib',
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
|
inherit (config) builders packages;
|
||||||
in {
|
in {
|
||||||
config.packages.aux.b = {
|
config.packages.aux.b = {
|
||||||
versions = {
|
versions = {
|
||||||
"latest" = {config}: {
|
"latest" = {config}: {
|
||||||
options = {
|
options = {
|
||||||
custom = lib.options.create {
|
custom = lib'.options.create {
|
||||||
type = lib.types.bool;
|
type = lib'.types.bool;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,8 +18,6 @@ in {
|
||||||
platforms = ["i686-linux"];
|
platforms = ["i686-linux"];
|
||||||
};
|
};
|
||||||
|
|
||||||
name = "${config.pname}-${config.version}";
|
|
||||||
|
|
||||||
custom = true;
|
custom = true;
|
||||||
|
|
||||||
pname = "b";
|
pname = "b";
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
{config}: let
|
{
|
||||||
inherit (config) lib;
|
lib,
|
||||||
|
lib',
|
||||||
doubles = lib.systems.doubles.all;
|
config,
|
||||||
|
}: let
|
||||||
|
doubles = lib'.systems.doubles.all;
|
||||||
|
|
||||||
packages = builtins.removeAttrs config.packages ["cross"];
|
packages = builtins.removeAttrs config.packages ["cross"];
|
||||||
in {
|
in {
|
||||||
|
@ -15,13 +17,13 @@ in {
|
||||||
packages = lib.options.create {
|
packages = lib.options.create {
|
||||||
description = "The package set.";
|
description = "The package set.";
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
freeform = lib.types.packages;
|
freeform = lib.types.attrs.of (lib.types.submodule {freeform = lib'.types.alias;});
|
||||||
|
|
||||||
options.cross = lib.attrs.generate doubles (
|
options.cross = lib.attrs.generate doubles (
|
||||||
system:
|
system:
|
||||||
lib.options.create {
|
lib.options.create {
|
||||||
description = "The cross-compiled package set for the ${system} target.";
|
description = "The cross-compiled package set for the ${system} target.";
|
||||||
type = lib.types.packages;
|
type = lib'.types.packages;
|
||||||
default = {};
|
default = {};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -47,48 +49,38 @@ in {
|
||||||
builtins.mapAttrs (
|
builtins.mapAttrs (
|
||||||
name: alias: let
|
name: alias: let
|
||||||
setHost = package:
|
setHost = package:
|
||||||
package // {
|
if package != {}
|
||||||
__modules__ = package.__modules__ ++ [
|
then
|
||||||
{
|
(package.extend (
|
||||||
config.platform = {
|
{config}: {
|
||||||
host = lib.modules.override 5 system;
|
config = {
|
||||||
target = lib.modules.override 5 system;
|
platform = {
|
||||||
|
host = lib.modules.overrides.force system;
|
||||||
|
target = lib.modules.overrides.default system;
|
||||||
|
};
|
||||||
|
|
||||||
|
deps = {
|
||||||
|
build = {
|
||||||
|
only = setHost package.deps.build.only;
|
||||||
|
build = setHost package.deps.build.build;
|
||||||
|
host = setHost package.deps.build.host;
|
||||||
|
target = setHost package.deps.build.target;
|
||||||
|
};
|
||||||
|
host = {
|
||||||
|
only = setHost package.deps.host.only;
|
||||||
|
host = setHost package.deps.host.host;
|
||||||
|
target = setHost package.deps.host.target;
|
||||||
|
};
|
||||||
|
target = {
|
||||||
|
only = setHost package.deps.target.only;
|
||||||
|
target = setHost package.deps.target.target;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
))
|
||||||
};
|
.config
|
||||||
# if package != {}
|
else package;
|
||||||
# then
|
|
||||||
# (package.extend (
|
|
||||||
# {config}: {
|
|
||||||
# config = {
|
|
||||||
# platform = {
|
|
||||||
# host = lib.modules.overrides.force system;
|
|
||||||
# target = lib.modules.overrides.default system;
|
|
||||||
# };
|
|
||||||
|
|
||||||
# deps = {
|
|
||||||
# build = {
|
|
||||||
# only = setHost package.deps.build.only;
|
|
||||||
# build = setHost package.deps.build.build;
|
|
||||||
# host = setHost package.deps.build.host;
|
|
||||||
# target = setHost package.deps.build.target;
|
|
||||||
# };
|
|
||||||
# host = {
|
|
||||||
# only = setHost package.deps.host.only;
|
|
||||||
# host = setHost package.deps.host.host;
|
|
||||||
# target = setHost package.deps.host.target;
|
|
||||||
# };
|
|
||||||
# target = {
|
|
||||||
# only = setHost package.deps.target.only;
|
|
||||||
# target = setHost package.deps.target.target;
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
# }
|
|
||||||
# ))
|
|
||||||
# .config
|
|
||||||
# else package;
|
|
||||||
|
|
||||||
updated =
|
updated =
|
||||||
alias
|
alias
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
{
|
{
|
||||||
|
lib,
|
||||||
|
lib',
|
||||||
config,
|
config,
|
||||||
options,
|
options,
|
||||||
}: let
|
}:
|
||||||
inherit
|
let
|
||||||
(config)
|
inherit (config)
|
||||||
lib
|
|
||||||
mirrors
|
mirrors
|
||||||
builders
|
builders
|
||||||
# These are the upstream foundational packages exported from the Aux Foundation project.
|
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||||
|
|
||||||
foundation
|
foundation
|
||||||
packages
|
|
||||||
;
|
;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
config.packages.foundation.gcc = {
|
config.packages.foundation.gcc = {
|
||||||
versions = {
|
versions = {
|
||||||
"latest" = {
|
"latest" =
|
||||||
config,
|
{ config, meta }:
|
||||||
meta,
|
{
|
||||||
}: {
|
|
||||||
options = {
|
options = {
|
||||||
src = lib.options.create {
|
src = lib.options.create {
|
||||||
type = lib.types.derivation;
|
type = lib.types.derivation;
|
||||||
|
@ -91,7 +91,28 @@ in {
|
||||||
builder = builders.basic;
|
builder = builders.basic;
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
PATH = lib.paths.bin [
|
PATH =
|
||||||
|
let
|
||||||
|
gcc =
|
||||||
|
if
|
||||||
|
config.platform.build.triple == config.platform.host.triple
|
||||||
|
# If we're on the same system then we can use the existing GCC instance.
|
||||||
|
then
|
||||||
|
foundation.stage2-gcc
|
||||||
|
# Otherwise we are going to need a cross-compiler.
|
||||||
|
else
|
||||||
|
# TODO: Create a gcc-cross package.
|
||||||
|
(meta.extend (args: {
|
||||||
|
config = {
|
||||||
|
platform = {
|
||||||
|
build = config.platform.build.triple;
|
||||||
|
host = config.platform.build.triple;
|
||||||
|
target = lib.modules.override.force config.platform.host.triple;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})).config.package;
|
||||||
|
in
|
||||||
|
lib.paths.bin [
|
||||||
foundation.stage2-gcc
|
foundation.stage2-gcc
|
||||||
foundation.stage2-binutils
|
foundation.stage2-binutils
|
||||||
foundation.stage2-gnumake
|
foundation.stage2-gnumake
|
||||||
|
@ -107,17 +128,13 @@ in {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
phases = let
|
phases =
|
||||||
host = lib.systems.withBuildInfo config.platform.host;
|
let
|
||||||
|
host = lib'.systems.withBuildInfo config.platform.host;
|
||||||
|
|
||||||
mbits =
|
mbits = if host.system.cpu.family == "x86" then if host.is64bit then "-m64" else "-m32" else "";
|
||||||
if host.system.cpu.family == "x86"
|
in
|
||||||
then
|
{
|
||||||
if host.is64bit
|
|
||||||
then "-m64"
|
|
||||||
else "-m32"
|
|
||||||
else "";
|
|
||||||
in {
|
|
||||||
unpack = lib.dag.entry.before [ "patch" ] ''
|
unpack = lib.dag.entry.before [ "patch" ] ''
|
||||||
# Unpack
|
# Unpack
|
||||||
tar xf ${config.src}
|
tar xf ${config.src}
|
||||||
|
@ -141,7 +158,9 @@ in {
|
||||||
|
|
||||||
configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''
|
configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''
|
||||||
# Configure
|
# Configure
|
||||||
export CC="gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CC="gcc -Wl,-dynamic-linker -march=${
|
||||||
|
host.gcc.arch or host.system.cpu.family
|
||||||
|
} ${mbits} -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
||||||
|
|
Loading…
Reference in a new issue