refactor(format): apply formatting
This commit is contained in:
parent
b414e151e6
commit
9315751220
|
@ -4,38 +4,45 @@ lib: {
|
|||
## Merge a list of option definitions into a single value.
|
||||
##
|
||||
## @type Location -> List Definition -> Any
|
||||
default = location: definitions: let
|
||||
default =
|
||||
location: definitions:
|
||||
let
|
||||
values = lib.options.getDefinitionValues definitions;
|
||||
first = builtins.elemAt values 0;
|
||||
mergedFunctions = x: lib.options.mergeDefault location (builtins.map (f: f x) values);
|
||||
mergedLists = builtins.concatLists values;
|
||||
mergedAttrs = builtins.foldl' lib.attrs.merge {} values;
|
||||
mergedAttrs = builtins.foldl' lib.attrs.merge { } values;
|
||||
mergedBools = builtins.any lib.bools.or false values;
|
||||
mergedStrings = lib.strings.concat values;
|
||||
in
|
||||
if builtins.length values == 1
|
||||
then builtins.elemAt values 0
|
||||
else if builtins.all builtins.isFunction values
|
||||
then mergedFunctions
|
||||
else if builtins.all builtins.isList values
|
||||
then mergedLists
|
||||
else if builtins.all builtins.isAttrs values
|
||||
then mergedAttrs
|
||||
else if builtins.all builtins.isBool values
|
||||
then mergedBools
|
||||
else if builtins.all lib.strings.isString values
|
||||
then mergedStrings
|
||||
else if builtins.all builtins.isInt values && builtins.all (x: x == first) values
|
||||
then first
|
||||
if builtins.length values == 1 then
|
||||
builtins.elemAt values 0
|
||||
else if builtins.all builtins.isFunction values then
|
||||
mergedFunctions
|
||||
else if builtins.all builtins.isList values then
|
||||
mergedLists
|
||||
else if builtins.all builtins.isAttrs values then
|
||||
mergedAttrs
|
||||
else if builtins.all builtins.isBool values then
|
||||
mergedBools
|
||||
else if builtins.all lib.strings.isString values then
|
||||
mergedStrings
|
||||
else if builtins.all builtins.isInt values && builtins.all (x: x == first) values then
|
||||
first
|
||||
# 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.
|
||||
##
|
||||
## @type Location -> Type -> List Definition
|
||||
definitions = location: type: definitions: let
|
||||
definitions =
|
||||
location: type: definitions:
|
||||
let
|
||||
identifier = lib.options.getIdentifier location;
|
||||
resolve = definition: let
|
||||
resolve =
|
||||
definition:
|
||||
let
|
||||
properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__ or "<unknown>"}`:" (
|
||||
lib.modules.apply.properties definition.value
|
||||
);
|
||||
|
@ -50,27 +57,27 @@ lib: {
|
|||
overridden = lib.modules.apply.overrides resolved;
|
||||
|
||||
values =
|
||||
if builtins.any (definition: lib.types.is "order" definition.value) overridden.values
|
||||
then lib.modules.apply.order overridden.values
|
||||
else overridden.values;
|
||||
if builtins.any (definition: lib.types.is "order" definition.value) overridden.values then
|
||||
lib.modules.apply.order overridden.values
|
||||
else
|
||||
overridden.values;
|
||||
|
||||
isDefined = values != [];
|
||||
isDefined = values != [ ];
|
||||
|
||||
invalid = builtins.filter (definition: !(type.check definition.value)) values;
|
||||
|
||||
merged =
|
||||
if isDefined
|
||||
then
|
||||
if builtins.all (definition: type.check definition.value) values
|
||||
then type.merge location values
|
||||
else 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.";
|
||||
if isDefined then
|
||||
if builtins.all (definition: type.check definition.value) values then
|
||||
type.merge location values
|
||||
else
|
||||
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.";
|
||||
|
||||
optional =
|
||||
if isDefined
|
||||
then {value = merged;}
|
||||
else {};
|
||||
in {
|
||||
optional = if isDefined then { value = merged; } else { };
|
||||
in
|
||||
{
|
||||
inherit
|
||||
isDefined
|
||||
values
|
||||
|
@ -87,25 +94,28 @@ lib: {
|
|||
## Merge multiple option declarations together.
|
||||
##
|
||||
## @type Location -> List Option
|
||||
declarations = location: options: let
|
||||
merge = result: option: let
|
||||
declarations =
|
||||
location: options:
|
||||
let
|
||||
merge =
|
||||
result: option:
|
||||
let
|
||||
mergedType = result.type.mergeType option.options.type.functor;
|
||||
isTypeMergeable = mergedType != null;
|
||||
shared = name: option.options ? ${name} && result ? ${name};
|
||||
typeSet = lib.attrs.when ((shared "type") && isTypeMergeable) {type = mergedType;};
|
||||
typeSet = lib.attrs.when ((shared "type") && isTypeMergeable) { type = mergedType; };
|
||||
files = result.declarations;
|
||||
serializedFiles = builtins.concatStringsSep " and " files;
|
||||
getSubModules = option.options.type.getSubModules or null;
|
||||
submodules =
|
||||
if getSubModules != null
|
||||
then
|
||||
if getSubModules != null then
|
||||
builtins.map (module: {
|
||||
__file__ = option.__file__;
|
||||
includes = [module];
|
||||
})
|
||||
getSubModules
|
||||
includes = [ module ];
|
||||
}) getSubModules
|
||||
++ result.options
|
||||
else result.options;
|
||||
else
|
||||
result.options;
|
||||
in
|
||||
if
|
||||
shared "default"
|
||||
|
@ -113,57 +123,65 @@ lib: {
|
|||
|| shared "description"
|
||||
|| shared "apply"
|
||||
|| (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
|
||||
option.options
|
||||
// result
|
||||
// {
|
||||
declarations = result.declarations ++ [option.__file__];
|
||||
declarations = result.declarations ++ [ option.__file__ ];
|
||||
options = submodules;
|
||||
}
|
||||
// typeSet;
|
||||
in
|
||||
builtins.foldl' merge {
|
||||
inherit location;
|
||||
declarations = [];
|
||||
options = [];
|
||||
}
|
||||
options;
|
||||
declarations = [ ];
|
||||
options = [ ];
|
||||
} options;
|
||||
|
||||
## Merge an option, only supporting a single unique definition.
|
||||
##
|
||||
## @type String -> Location -> List Definition -> Any
|
||||
unique = message: location: definitions: let
|
||||
unique =
|
||||
message: location: definitions:
|
||||
let
|
||||
identifier = lib.options.getIdentifier location;
|
||||
total = builtins.length definitions;
|
||||
first = builtins.elemAt definitions 0;
|
||||
in
|
||||
if total == 1
|
||||
then first.value
|
||||
else if total == 0
|
||||
then 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}";
|
||||
if total == 1 then
|
||||
first.value
|
||||
else if total == 0 then
|
||||
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}";
|
||||
|
||||
## Merge a single instance of an option.
|
||||
##
|
||||
## @type Location -> List Definition -> Any
|
||||
one = lib.options.merge.unique "";
|
||||
|
||||
equal = location: definitions: let
|
||||
equal =
|
||||
location: definitions:
|
||||
let
|
||||
identifier = lib.options.getIdentifier location;
|
||||
first = builtins.elemAt definitions 0;
|
||||
rest = builtins.tail definitions;
|
||||
merge = x: y:
|
||||
if x != y
|
||||
then builtins.throw "The option `${identifier}` has conflicting definitions:${lib.options.getDefinitions definitions}"
|
||||
else x;
|
||||
merge =
|
||||
x: y:
|
||||
if x != y then
|
||||
builtins.throw "The option `${identifier}` has conflicting definitions:${lib.options.getDefinitions definitions}"
|
||||
else
|
||||
x;
|
||||
merged = builtins.foldl' merge first rest;
|
||||
in
|
||||
if builtins.length definitions == 0
|
||||
then builtins.throw "Cannot merge unused option `${identifier}`."
|
||||
else if builtins.length definitions == 1
|
||||
then first.value
|
||||
else merged.value;
|
||||
if builtins.length definitions == 0 then
|
||||
builtins.throw "Cannot merge unused option `${identifier}`."
|
||||
else if builtins.length definitions == 1 then
|
||||
first.value
|
||||
else
|
||||
merged.value;
|
||||
};
|
||||
|
||||
## Check whether a value is an option.
|
||||
|
@ -174,16 +192,18 @@ lib: {
|
|||
## 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
|
||||
create = settings @ {
|
||||
create =
|
||||
settings@{
|
||||
type ? lib.types.unspecified,
|
||||
apply ? null,
|
||||
default ? {},
|
||||
default ? { },
|
||||
example ? null,
|
||||
visible ? null,
|
||||
internal ? null,
|
||||
writable ? null,
|
||||
description ? null,
|
||||
}: {
|
||||
}:
|
||||
{
|
||||
__type__ = "option";
|
||||
inherit
|
||||
type
|
||||
|
@ -200,7 +220,9 @@ lib: {
|
|||
## Create a sink option.
|
||||
##
|
||||
## @type @alias lib.options.create
|
||||
sink = settings: let
|
||||
sink =
|
||||
settings:
|
||||
let
|
||||
defaults = {
|
||||
internal = true;
|
||||
visible = false;
|
||||
|
@ -224,7 +246,9 @@ lib: {
|
|||
## Convert a list of option identifiers into a single identifier.
|
||||
##
|
||||
## @type List String -> String
|
||||
getIdentifier = location: let
|
||||
getIdentifier =
|
||||
location:
|
||||
let
|
||||
special = [
|
||||
# lib.types.attrs.of (lib.types.submodule {})
|
||||
"<name>"
|
||||
|
@ -233,26 +257,25 @@ lib: {
|
|||
# lib.types.function
|
||||
"<function body>"
|
||||
];
|
||||
escape = part:
|
||||
if builtins.elem part special
|
||||
then part
|
||||
else lib.strings.escape.nix.identifier part;
|
||||
escape = part: if builtins.elem part special then part else lib.strings.escape.nix.identifier part;
|
||||
in
|
||||
lib.strings.concatMapSep "." escape location;
|
||||
|
||||
## Get a string message of the definitions for an option.
|
||||
##
|
||||
## @type List Definition -> String
|
||||
getDefinitions = definitions: let
|
||||
serialize = definition: let
|
||||
valueWithRecursionLimit =
|
||||
lib.generators.withRecursion {
|
||||
getDefinitions =
|
||||
definitions:
|
||||
let
|
||||
serialize =
|
||||
definition:
|
||||
let
|
||||
valueWithRecursionLimit = lib.generators.withRecursion {
|
||||
limit = 10;
|
||||
throw = false;
|
||||
}
|
||||
definition.value;
|
||||
} definition.value;
|
||||
|
||||
eval = builtins.tryEval (lib.generators.pretty {} valueWithRecursionLimit);
|
||||
eval = builtins.tryEval (lib.generators.pretty { } valueWithRecursionLimit);
|
||||
|
||||
lines = lib.strings.split "\n" eval.value;
|
||||
linesLength = builtins.length lines;
|
||||
|
@ -263,24 +286,27 @@ lib: {
|
|||
value = builtins.concatStringsSep "\n " (firstFiveLines ++ ellipsis);
|
||||
|
||||
result =
|
||||
if !eval.success
|
||||
then ""
|
||||
else if linesLength > 1
|
||||
then ":\n " + value
|
||||
else ": " + value;
|
||||
in "\n- In `${definition.__file__}`${result}";
|
||||
if !eval.success then
|
||||
""
|
||||
else if linesLength > 1 then
|
||||
":\n " + value
|
||||
else
|
||||
": " + value;
|
||||
in
|
||||
"\n- In `${definition.__file__}`${result}";
|
||||
in
|
||||
lib.strings.concatMap serialize definitions;
|
||||
|
||||
## 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 }
|
||||
run = location: option: definitions: let
|
||||
run =
|
||||
location: option: definitions:
|
||||
let
|
||||
identifier = lib.options.getIdentifier location;
|
||||
|
||||
definitionsWithDefault =
|
||||
if option ? default && option.default ? value
|
||||
then
|
||||
if option ? default && option.default ? value then
|
||||
[
|
||||
{
|
||||
__file__ = builtins.head option.declarations;
|
||||
|
@ -288,28 +314,25 @@ lib: {
|
|||
}
|
||||
]
|
||||
++ definitions
|
||||
else definitions;
|
||||
else
|
||||
definitions;
|
||||
|
||||
merged =
|
||||
if option.writable or null == false && builtins.length definitionsWithDefault > 1
|
||||
then let
|
||||
separatedDefinitions =
|
||||
builtins.map (
|
||||
if option.writable or null == false && builtins.length definitionsWithDefault > 1 then
|
||||
let
|
||||
separatedDefinitions = builtins.map (
|
||||
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
|
||||
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 =
|
||||
if option.apply or null != null
|
||||
then option.apply merged.merged
|
||||
else merged.merged;
|
||||
value = if option.apply or null != null then option.apply merged.merged else merged.merged;
|
||||
in
|
||||
option
|
||||
// {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,39 +1,35 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
{ lib, config }:
|
||||
let
|
||||
cfg = config.builders.basic;
|
||||
|
||||
lib' = config.lib;
|
||||
|
||||
inherit (config) foundation;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config.builders = {
|
||||
basic = {
|
||||
executable = "${foundation.stage2-bash}/bin/bash";
|
||||
|
||||
build = package: let
|
||||
build =
|
||||
package:
|
||||
let
|
||||
phases = lib.dag.apply.defaults package.phases {
|
||||
unpack = lib.dag.entry.before ["patch"] "";
|
||||
unpack = lib.dag.entry.before [ "patch" ] "";
|
||||
|
||||
patch = lib.dag.entry.between ["configure"] ["unpack"] "";
|
||||
patch = lib.dag.entry.between [ "configure" ] [ "unpack" ] "";
|
||||
|
||||
configure = lib.dag.entry.between ["build"] ["patch"] "";
|
||||
configure = lib.dag.entry.between [ "build" ] [ "patch" ] "";
|
||||
|
||||
build = lib.dag.entry.between ["install"] ["configure"] "";
|
||||
build = lib.dag.entry.between [ "install" ] [ "configure" ] "";
|
||||
|
||||
install = lib.dag.entry.after ["build"] "";
|
||||
install = lib.dag.entry.after [ "build" ] "";
|
||||
};
|
||||
sorted = lib.dag.sort.topographic phases;
|
||||
|
||||
script =
|
||||
lib.strings.concatMapSep "\n" (
|
||||
entry:
|
||||
if builtins.isFunction entry.value
|
||||
then entry.value package
|
||||
else entry.value
|
||||
)
|
||||
sorted.result;
|
||||
script = lib.strings.concatMapSep "\n" (
|
||||
entry: if builtins.isFunction entry.value then entry.value package else entry.value
|
||||
) sorted.result;
|
||||
|
||||
system = package.platform.build.double;
|
||||
|
||||
|
@ -43,11 +39,12 @@ in {
|
|||
inherit (package) name;
|
||||
inherit script system;
|
||||
|
||||
passAsFile = ["script"];
|
||||
passAsFile = [ "script" ];
|
||||
|
||||
SHELL = cfg.executable;
|
||||
|
||||
PATH = let
|
||||
PATH =
|
||||
let
|
||||
bins = lib.paths.bin (
|
||||
(lib'.packages.dependencies.getPackages package.deps.build.host)
|
||||
++ [
|
||||
|
@ -57,7 +54,7 @@ in {
|
|||
);
|
||||
in
|
||||
builtins.concatStringsSep ":" (
|
||||
[bins] ++ (lib.lists.when (package.env ? PATH) [package.env.PATH])
|
||||
[ bins ] ++ (lib.lists.when (package.env ? PATH) [ package.env.PATH ])
|
||||
);
|
||||
|
||||
builder = cfg.executable;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# This file handles creating all of the exports for this project and is not
|
||||
# exported itself.
|
||||
{config}: let
|
||||
{ config }:
|
||||
let
|
||||
inherit (config) lib;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# freeform = lib.types.any;
|
||||
|
||||
config = {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
{ lib, config }:
|
||||
let
|
||||
in
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
in {
|
||||
config = {
|
||||
lib.options = {
|
||||
package = lib.options.create {
|
||||
|
|
|
@ -1,41 +1,48 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
{ lib, config }:
|
||||
let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config = {
|
||||
lib.packages = {
|
||||
dependencies = {
|
||||
getPackages = dependencies: let
|
||||
getPackages =
|
||||
dependencies:
|
||||
let
|
||||
available = builtins.filter (dependency: !(builtins.isNull dependency)) (
|
||||
builtins.attrValues dependencies
|
||||
);
|
||||
in
|
||||
builtins.map (dependency: dependency.package) available;
|
||||
|
||||
build = build': host': target':
|
||||
builtins.mapAttrs
|
||||
(name: dep: lib'.packages.build dep build' host' target');
|
||||
build =
|
||||
build': host': target':
|
||||
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
|
||||
};
|
||||
|
||||
getLatest = alias: let
|
||||
getLatest =
|
||||
alias:
|
||||
let
|
||||
versions = builtins.attrNames alias.versions;
|
||||
sorted = builtins.sort (lib.versions.gte) versions;
|
||||
in
|
||||
builtins.head sorted;
|
||||
|
||||
resolve = alias:
|
||||
if alias ? versions
|
||||
then
|
||||
resolve =
|
||||
alias:
|
||||
if alias ? versions then
|
||||
alias.versions.${config.preferences.packages.version}
|
||||
or (alias.versions.${lib'.packages.getLatest alias})
|
||||
else alias;
|
||||
else
|
||||
alias;
|
||||
|
||||
build = alias: build: host: target: let
|
||||
build =
|
||||
alias: build: host: target:
|
||||
let
|
||||
package = lib'.packages.resolve alias;
|
||||
|
||||
buildDependencies = build': host': target':
|
||||
buildDependencies =
|
||||
build': host': target':
|
||||
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
|
||||
|
||||
platform = {
|
||||
|
@ -45,12 +52,11 @@ in {
|
|||
};
|
||||
|
||||
withPlatform = lib.modules.run {
|
||||
modules =
|
||||
package.__modules__
|
||||
++ [
|
||||
modules = package.__modules__ ++ [
|
||||
lib'.types.package.children.submodule
|
||||
(
|
||||
{config}: {
|
||||
{ config }:
|
||||
{
|
||||
config = {
|
||||
__modules__ = package.__modules__;
|
||||
|
||||
|
@ -64,9 +70,7 @@ in {
|
|||
# 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.
|
||||
withDeps =
|
||||
withPlatform.config
|
||||
// {
|
||||
withDeps = withPlatform.config // {
|
||||
deps = {
|
||||
build = {
|
||||
only = buildDependencies build build build withPlatform.config.deps.build.only;
|
||||
|
@ -87,12 +91,11 @@ in {
|
|||
};
|
||||
|
||||
withPackage = lib.modules.run {
|
||||
modules =
|
||||
package.__modules__
|
||||
++ [
|
||||
modules = package.__modules__ ++ [
|
||||
lib'.types.package.children.submodule
|
||||
(
|
||||
{config}: {
|
||||
{ config }:
|
||||
{
|
||||
config = {
|
||||
__modules__ = package.__modules__;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,16 +1,17 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
{ lib, config }:
|
||||
let
|
||||
inherit (config) preferences builders;
|
||||
|
||||
lib' = config.lib;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config = {
|
||||
lib.types = {
|
||||
license = let
|
||||
license =
|
||||
let
|
||||
type = lib.types.submodule (
|
||||
{config}: {
|
||||
{ config }:
|
||||
{
|
||||
options = {
|
||||
name = {
|
||||
full = lib.options.create {
|
||||
|
@ -56,9 +57,7 @@ in {
|
|||
lib.types.either type (lib.types.list.of type);
|
||||
|
||||
platform =
|
||||
lib.types.coerce
|
||||
lib.types.string
|
||||
lib'.systems.withBuildInfo
|
||||
lib.types.coerce lib.types.string lib'.systems.withBuildInfo
|
||||
lib'.systems.types.platformWithBuildInfo;
|
||||
|
||||
builder = lib.types.submodule {
|
||||
|
@ -74,10 +73,14 @@ in {
|
|||
|
||||
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias);
|
||||
|
||||
dependencies = build: host: target: let
|
||||
dependencies =
|
||||
build: host: target:
|
||||
let
|
||||
initial = lib.types.raw;
|
||||
|
||||
transform = value: let
|
||||
transform =
|
||||
value:
|
||||
let
|
||||
package = lib'.packages.resolve value;
|
||||
in
|
||||
lib'.packages.build package build host target;
|
||||
|
@ -99,76 +102,78 @@ in {
|
|||
versions = lib.options.create {
|
||||
description = "Available versions of the package.";
|
||||
type = lib.types.attrs.of lib'.types.package;
|
||||
default.value = {};
|
||||
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;
|
||||
};
|
||||
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;
|
||||
merge =
|
||||
location: definitions:
|
||||
let
|
||||
normalized = builtins.map (definition: lib.lists.from.any (normalize definition.value)) definitions;
|
||||
in
|
||||
builtins.concatLists
|
||||
normalized;
|
||||
builtins.concatLists normalized;
|
||||
};
|
||||
|
||||
transform = location: value: let
|
||||
modules =
|
||||
lib.lists.from.any (normalize value);
|
||||
transform =
|
||||
location: value:
|
||||
let
|
||||
modules = lib.lists.from.any (normalize value);
|
||||
|
||||
result = lib.modules.run {
|
||||
prefix = location;
|
||||
modules =
|
||||
modules
|
||||
++ [submodule {config.__modules__ = modules;}];
|
||||
modules = modules ++ [
|
||||
submodule
|
||||
{ config.__modules__ = modules; }
|
||||
];
|
||||
};
|
||||
in
|
||||
result.config;
|
||||
|
||||
final = lib.types.raw;
|
||||
|
||||
deps = build: host: target:
|
||||
deps =
|
||||
build: host: target:
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
build = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the build environment.";
|
||||
type = lib'.types.dependencies build build build;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
build = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the build environment.";
|
||||
type = lib'.types.dependencies build build target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the host environment.";
|
||||
type = lib'.types.dependencies build host target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the target environment.";
|
||||
type = lib'.types.dependencies build target target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -176,19 +181,19 @@ in {
|
|||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the host environment.";
|
||||
type = lib'.types.dependencies host host host;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
description = "Dependencies which are executed in the host environment.";
|
||||
type = lib'.types.dependencies host host target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
|
||||
type = lib'.types.dependencies host target target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -196,33 +201,33 @@ in {
|
|||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the target environment.";
|
||||
type = lib'.types.dependencies target target target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
description = "Dependencies which are executed in the target environment.";
|
||||
type = lib'.types.dependencies target target target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
submodule = {config}: let
|
||||
submodule =
|
||||
{ config }:
|
||||
let
|
||||
build = config.platform.build;
|
||||
host = config.platform.host;
|
||||
target = config.platform.target;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
__modules__ = lib.options.create {
|
||||
description = "User specified modules for the package definition.";
|
||||
type = lib.types.list.of (initial
|
||||
// {
|
||||
merge = lib.options.merge.one;
|
||||
});
|
||||
type = lib.types.list.of (initial // { merge = lib.options.merge.one; });
|
||||
# writable = false;
|
||||
internal = true;
|
||||
default.value = [];
|
||||
default.value = [ ];
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
@ -271,7 +276,7 @@ in {
|
|||
platforms = lib.options.create {
|
||||
description = "The platforms the package supports.";
|
||||
type = lib.types.list.of lib.types.string;
|
||||
default.value = [];
|
||||
default.value = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -301,9 +306,7 @@ in {
|
|||
default = {
|
||||
text = "\${config.pname}-\${config.version}";
|
||||
value =
|
||||
if config.pname != null && config.version != null
|
||||
then "${config.pname}-${config.version}"
|
||||
else "";
|
||||
if config.pname != null && config.version != null then "${config.pname}-${config.version}" else "";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -327,13 +330,13 @@ in {
|
|||
phases = lib.options.create {
|
||||
description = "The phases for the package.";
|
||||
type = lib.types.dag.of lib.types.string;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
env = lib.options.create {
|
||||
description = "The environment for the package.";
|
||||
type = lib.types.attrs.of lib.types.string;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
};
|
||||
|
||||
package = lib.options.create {
|
||||
|
@ -345,7 +348,7 @@ in {
|
|||
deps = lib.options.create {
|
||||
description = "The dependencies for the package.";
|
||||
type = deps build host target;
|
||||
default.value = {};
|
||||
default.value = { };
|
||||
apply = value: {
|
||||
build = {
|
||||
only = lib'.packages.dependencies.build build build build value.build.only;
|
||||
|
@ -367,18 +370,14 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
type =
|
||||
(lib.types.coerceWithLocation initial transform final)
|
||||
// {
|
||||
type = (lib.types.coerceWithLocation initial transform final) // {
|
||||
name = "Package";
|
||||
description = "a package definition";
|
||||
};
|
||||
in
|
||||
type
|
||||
// {
|
||||
children =
|
||||
type.children
|
||||
// {
|
||||
children = type.children // {
|
||||
inherit submodule;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
{
|
||||
lib',
|
||||
config,
|
||||
}: let
|
||||
{ lib', config }:
|
||||
let
|
||||
inherit (config) builders packages;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config.packages.aux.a = {
|
||||
versions = {
|
||||
"latest" = {config}: {
|
||||
"latest" =
|
||||
{ config }:
|
||||
{
|
||||
config = {
|
||||
meta = {
|
||||
platforms = ["i686-linux"];
|
||||
platforms = [ "i686-linux" ];
|
||||
};
|
||||
|
||||
name = "${config.pname}-${config.version}";
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
{config}: let
|
||||
{ config }:
|
||||
let
|
||||
inherit (config) lib builders packages;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config.packages.aux.b = {
|
||||
versions = {
|
||||
"latest" = {config}: {
|
||||
"latest" =
|
||||
{ config }:
|
||||
{
|
||||
options = {
|
||||
custom = lib.options.create {
|
||||
type = lib.types.bool;
|
||||
};
|
||||
custom = lib.options.create { type = lib.types.bool; };
|
||||
};
|
||||
|
||||
config = {
|
||||
meta = {
|
||||
platforms = ["i686-linux"];
|
||||
platforms = [ "i686-linux" ];
|
||||
};
|
||||
|
||||
name = "${config.pname}-${config.version}";
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{config}: let
|
||||
{ config }:
|
||||
let
|
||||
inherit (config) lib;
|
||||
|
||||
doubles = lib.systems.doubles.all;
|
||||
|
||||
packages = builtins.removeAttrs config.packages ["cross"];
|
||||
in {
|
||||
packages = builtins.removeAttrs config.packages [ "cross" ];
|
||||
in
|
||||
{
|
||||
includes = [
|
||||
./foundation
|
||||
./aux/a.nix
|
||||
|
@ -22,7 +24,7 @@ in {
|
|||
lib.options.create {
|
||||
description = "The cross-compiled package set for the ${system} target.";
|
||||
type = lib.types.packages;
|
||||
default = {};
|
||||
default = { };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -45,9 +47,12 @@ in {
|
|||
builtins.mapAttrs (
|
||||
namespace:
|
||||
builtins.mapAttrs (
|
||||
name: alias: let
|
||||
setHost = package:
|
||||
package // {
|
||||
name: alias:
|
||||
let
|
||||
setHost =
|
||||
package:
|
||||
package
|
||||
// {
|
||||
__modules__ = package.__modules__ ++ [
|
||||
{
|
||||
config.platform = {
|
||||
|
@ -90,15 +95,12 @@ in {
|
|||
# .config
|
||||
# else package;
|
||||
|
||||
updated =
|
||||
alias
|
||||
// {
|
||||
updated = alias // {
|
||||
versions = builtins.mapAttrs (version: package: setHost package) alias.versions;
|
||||
};
|
||||
in
|
||||
updated
|
||||
)
|
||||
)
|
||||
packages
|
||||
) packages
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
lib',
|
||||
config,
|
||||
options,
|
||||
}: let
|
||||
inherit
|
||||
(config)
|
||||
}:
|
||||
let
|
||||
inherit (config)
|
||||
mirrors
|
||||
builders
|
||||
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||
|
@ -13,10 +13,13 @@
|
|||
foundation
|
||||
packages
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config.packages.foundation.binutils = {
|
||||
versions = {
|
||||
"latest" = {config}: {
|
||||
"latest" =
|
||||
{ config }:
|
||||
{
|
||||
options = {
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
|
@ -26,7 +29,7 @@ in {
|
|||
|
||||
config = {
|
||||
meta = {
|
||||
platforms = ["i686-linux"];
|
||||
platforms = [ "i686-linux" ];
|
||||
};
|
||||
|
||||
pname = "binutils";
|
||||
|
@ -58,7 +61,8 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
phases = let
|
||||
phases =
|
||||
let
|
||||
patches = [
|
||||
# Make binutils output deterministic by default.
|
||||
./patches/deterministic.patch
|
||||
|
@ -89,7 +93,8 @@ in {
|
|||
|
||||
"--disable-multilib"
|
||||
];
|
||||
in {
|
||||
in
|
||||
{
|
||||
unpack = ''
|
||||
tar xf ${config.src}
|
||||
cd binutils-${config.version}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
lib',
|
||||
config,
|
||||
options,
|
||||
}: {
|
||||
}:
|
||||
{
|
||||
includes = [
|
||||
./gcc
|
||||
./binutils
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
{
|
||||
config,
|
||||
options,
|
||||
}: let
|
||||
inherit
|
||||
(config)
|
||||
{ config, options }:
|
||||
let
|
||||
inherit (config)
|
||||
lib
|
||||
mirrors
|
||||
builders
|
||||
|
@ -12,13 +9,13 @@
|
|||
foundation
|
||||
packages
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config.packages.foundation.gcc = {
|
||||
versions = {
|
||||
"latest" = {
|
||||
config,
|
||||
meta,
|
||||
}: {
|
||||
"latest" =
|
||||
{ config, meta }:
|
||||
{
|
||||
options = {
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
|
@ -82,7 +79,7 @@ in {
|
|||
|
||||
config = {
|
||||
meta = {
|
||||
platforms = ["i686-linux"];
|
||||
platforms = [ "i686-linux" ];
|
||||
};
|
||||
|
||||
pname = "gcc";
|
||||
|
@ -107,17 +104,13 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
phases = let
|
||||
phases =
|
||||
let
|
||||
host = lib.systems.withBuildInfo config.platform.host;
|
||||
|
||||
mbits =
|
||||
if host.system.cpu.family == "x86"
|
||||
then
|
||||
if host.is64bit
|
||||
then "-m64"
|
||||
else "-m32"
|
||||
else "";
|
||||
in {
|
||||
mbits = if host.system.cpu.family == "x86" then if host.is64bit then "-m64" else "-m32" else "";
|
||||
in
|
||||
{
|
||||
unpack = ''
|
||||
# Unpack
|
||||
tar xf ${config.src}
|
||||
|
|
|
@ -3,22 +3,22 @@
|
|||
lib',
|
||||
config,
|
||||
options,
|
||||
}: let
|
||||
inherit
|
||||
(config)
|
||||
}:
|
||||
let
|
||||
inherit (config)
|
||||
mirrors
|
||||
builders
|
||||
# These are the upstream foundational packages exported from the Aux Foundation project.
|
||||
|
||||
foundation
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config.packages.foundation.linux-headers = {
|
||||
versions = {
|
||||
"latest" = {
|
||||
config,
|
||||
meta,
|
||||
}: {
|
||||
"latest" =
|
||||
{ config, meta }:
|
||||
{
|
||||
options = {
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
|
@ -28,7 +28,7 @@ in {
|
|||
|
||||
config = {
|
||||
meta = {
|
||||
platforms = ["i686-linux"];
|
||||
platforms = [ "i686-linux" ];
|
||||
};
|
||||
|
||||
pname = "linux-headers";
|
||||
|
|
Loading…
Reference in a new issue