Compare commits

..

No commits in common. "93157512205af050b96e9f84ce7d90f425906c51" and "af571a03a4c37f98e44aa4ab37d499a7ffc0c77c" have entirely different histories.

15 changed files with 2325 additions and 2372 deletions

View file

@ -4,45 +4,38 @@ 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 = default = location: definitions: let
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);
mergedLists = builtins.concatLists 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; 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 then if builtins.length values == 1
builtins.elemAt values 0 then builtins.elemAt values 0
else if builtins.all builtins.isFunction values then else if builtins.all builtins.isFunction values
mergedFunctions then mergedFunctions
else if builtins.all builtins.isList values then else if builtins.all builtins.isList values
mergedLists then mergedLists
else if builtins.all builtins.isAttrs values then else if builtins.all builtins.isAttrs values
mergedAttrs then mergedAttrs
else if builtins.all builtins.isBool values then else if builtins.all builtins.isBool values
mergedBools then mergedBools
else if builtins.all lib.strings.isString values then else if builtins.all lib.strings.isString values
mergedStrings then mergedStrings
else if builtins.all builtins.isInt values && builtins.all (x: x == first) values then else if builtins.all builtins.isInt values && builtins.all (x: x == first) values
first then 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 else builtins.throw "Cannot merge definitions.";
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 = definitions = location: type: definitions: let
location: type: definitions:
let
identifier = lib.options.getIdentifier location; identifier = lib.options.getIdentifier location;
resolve = resolve = definition: let
definition:
let
properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__ or "<unknown>"}`:" ( properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__ or "<unknown>"}`:" (
lib.modules.apply.properties definition.value lib.modules.apply.properties definition.value
); );
@ -57,27 +50,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 then if builtins.any (definition: lib.types.is "order" definition.value) overridden.values
lib.modules.apply.order overridden.values then lib.modules.apply.order overridden.values
else else overridden.values;
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 then if isDefined
if builtins.all (definition: type.check definition.value) values then then
type.merge location values if builtins.all (definition: type.check definition.value) values
else then type.merge location values
builtins.throw "A definition for `${identifier}` is not of type `${type.description}`. Definition values:${lib.options.getDefinitions invalid}" else builtins.throw "A definition for `${identifier}` is not of type `${type.description}`. Definition values:${lib.options.getDefinitions invalid}"
else else builtins.throw "The option `${identifier}` is used but not defined.";
builtins.throw "The option `${identifier}` is used but not defined.";
optional = if isDefined then { value = merged; } else { }; optional =
in if isDefined
{ then {value = merged;}
else {};
in {
inherit inherit
isDefined isDefined
values values
@ -94,28 +87,25 @@ lib: {
## Merge multiple option declarations together. ## Merge multiple option declarations together.
## ##
## @type Location -> List Option ## @type Location -> List Option
declarations = declarations = location: options: let
location: options: merge = result: option: let
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};
typeSet = lib.attrs.when ((shared "type") && isTypeMergeable) { type = mergedType; }; typeSet = lib.attrs.when ((shared "type") && isTypeMergeable) {type = mergedType;};
files = result.declarations; files = result.declarations;
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 then if getSubModules != null
then
builtins.map (module: { builtins.map (module: {
__file__ = option.__file__; __file__ = option.__file__;
includes = [ module ]; includes = [module];
}) getSubModules })
getSubModules
++ result.options ++ result.options
else else result.options;
result.options;
in in
if if
shared "default" shared "default"
@ -123,65 +113,57 @@ lib: {
|| shared "description" || shared "description"
|| shared "apply" || shared "apply"
|| (shared "type" && !isTypeMergeable) || (shared "type" && !isTypeMergeable)
then then builtins.throw "The option `${lib.options.getIdentifier location}` in `${option.__file__}` is already declared in ${serializedFiles}"
builtins.throw "The option `${lib.options.getIdentifier location}` in `${option.__file__}` is already declared in ${serializedFiles}"
else else
option.options option.options
// result // result
// { // {
declarations = result.declarations ++ [ option.__file__ ]; declarations = result.declarations ++ [option.__file__];
options = submodules; options = submodules;
} }
// typeSet; // typeSet;
in in
builtins.foldl' merge { builtins.foldl' merge {
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 = unique = message: location: definitions: let
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 then if total == 1
first.value then first.value
else if total == 0 then else if total == 0
builtins.throw "Cannot merge unused option `${identifier}`.\n${message}" then builtins.throw "Cannot merge unused option `${identifier}`.\n${message}"
else else builtins.throw "The option `${identifier}` is defined multiple times, but must be unique.\n${message}\nDefinitions:${lib.options.getDefinitions definitions}";
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 = equal = location: definitions: let
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 = merge = x: y:
x: y: if x != y
if x != y then then builtins.throw "The option `${identifier}` has conflicting definitions:${lib.options.getDefinitions definitions}"
builtins.throw "The option `${identifier}` has conflicting definitions:${lib.options.getDefinitions definitions}" else x;
else
x;
merged = builtins.foldl' merge first rest; merged = builtins.foldl' merge first rest;
in in
if builtins.length definitions == 0 then if builtins.length definitions == 0
builtins.throw "Cannot merge unused option `${identifier}`." then builtins.throw "Cannot merge unused option `${identifier}`."
else if builtins.length definitions == 1 then else if builtins.length definitions == 1
first.value then first.value
else else merged.value;
merged.value;
}; };
## Check whether a value is an option. ## Check whether a value is an option.
@ -192,18 +174,16 @@ 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 = create = settings @ {
settings@{
type ? lib.types.unspecified, type ? lib.types.unspecified,
apply ? null, apply ? null,
default ? { }, default ? {},
example ? null, example ? null,
visible ? null, visible ? null,
internal ? null, internal ? null,
writable ? null, writable ? null,
description ? null, description ? null,
}: }: {
{
__type__ = "option"; __type__ = "option";
inherit inherit
type type
@ -220,9 +200,7 @@ lib: {
## Create a sink option. ## Create a sink option.
## ##
## @type @alias lib.options.create ## @type @alias lib.options.create
sink = sink = settings: let
settings:
let
defaults = { defaults = {
internal = true; internal = true;
visible = false; visible = false;
@ -246,9 +224,7 @@ 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 = getIdentifier = location: let
location:
let
special = [ special = [
# lib.types.attrs.of (lib.types.submodule {}) # lib.types.attrs.of (lib.types.submodule {})
"<name>" "<name>"
@ -257,25 +233,26 @@ lib: {
# lib.types.function # lib.types.function
"<function body>" "<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 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 = getDefinitions = definitions: let
definitions: serialize = definition: let
let valueWithRecursionLimit =
serialize = lib.generators.withRecursion {
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);
lines = lib.strings.split "\n" eval.value; lines = lib.strings.split "\n" eval.value;
linesLength = builtins.length lines; linesLength = builtins.length lines;
@ -286,27 +263,24 @@ lib: {
value = builtins.concatStringsSep "\n " (firstFiveLines ++ ellipsis); value = builtins.concatStringsSep "\n " (firstFiveLines ++ ellipsis);
result = result =
if !eval.success then if !eval.success
"" then ""
else if linesLength > 1 then else if linesLength > 1
":\n " + value then ":\n " + value
else else ": " + value;
": " + value; in "\n- In `${definition.__file__}`${result}";
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 = run = location: option: definitions: let
location: option: definitions:
let
identifier = lib.options.getIdentifier location; identifier = lib.options.getIdentifier location;
definitionsWithDefault = definitionsWithDefault =
if option ? default && option.default ? value then if option ? default && option.default ? value
then
[ [
{ {
__file__ = builtins.head option.declarations; __file__ = builtins.head option.declarations;
@ -314,25 +288,28 @@ lib: {
} }
] ]
++ definitions ++ definitions
else else definitions;
definitions;
merged = merged =
if option.writable or null == false && builtins.length definitionsWithDefault > 1 then if option.writable or null == false && builtins.length definitionsWithDefault > 1
let then let
separatedDefinitions = builtins.map ( separatedDefinitions =
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 else lib.options.merge.definitions location option.type definitionsWithDefault;
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 in
option option
// { // {

File diff suppressed because it is too large Load diff

View file

@ -1,35 +1,39 @@
{ lib, config }: {
let lib,
config,
}: let
cfg = config.builders.basic; cfg = config.builders.basic;
lib' = config.lib; lib' = config.lib;
inherit (config) foundation; inherit (config) foundation;
in in {
{
config.builders = { config.builders = {
basic = { basic = {
executable = "${foundation.stage2-bash}/bin/bash"; executable = "${foundation.stage2-bash}/bin/bash";
build = build = package: let
package:
let
phases = lib.dag.apply.defaults package.phases { 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; sorted = lib.dag.sort.topographic phases;
script = lib.strings.concatMapSep "\n" ( script =
entry: if builtins.isFunction entry.value then entry.value package else entry.value lib.strings.concatMapSep "\n" (
) sorted.result; entry:
if builtins.isFunction entry.value
then entry.value package
else entry.value
)
sorted.result;
system = package.platform.build.double; system = package.platform.build.double;
@ -39,12 +43,11 @@ in
inherit (package) name; inherit (package) name;
inherit script system; inherit script system;
passAsFile = [ "script" ]; passAsFile = ["script"];
SHELL = cfg.executable; SHELL = cfg.executable;
PATH = PATH = let
let
bins = lib.paths.bin ( bins = lib.paths.bin (
(lib'.packages.dependencies.getPackages package.deps.build.host) (lib'.packages.dependencies.getPackages package.deps.build.host)
++ [ ++ [
@ -54,7 +57,7 @@ in
); );
in in
builtins.concatStringsSep ":" ( 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; builder = cfg.executable;

View file

@ -1,10 +1,8 @@
# 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 }: {config}: let
let
inherit (config) lib; inherit (config) lib;
in in {
{
# freeform = lib.types.any; # freeform = lib.types.any;
config = { config = {
@ -26,7 +24,6 @@ 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;
# 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";
# }; # };

View file

@ -1,7 +1,8 @@
{ lib, config }:
let
in
{ {
lib,
config,
}: let
in {
config = { config = {
lib.options = { lib.options = {
package = lib.options.create { package = lib.options.create {

View file

@ -1,48 +1,41 @@
{ lib, config }:
let
lib' = config.lib;
in
{ {
lib,
config,
}: let
lib' = config.lib;
in {
config = { config = {
lib.packages = { lib.packages = {
dependencies = { dependencies = {
getPackages = getPackages = dependencies: let
dependencies:
let
available = builtins.filter (dependency: !(builtins.isNull dependency)) ( available = builtins.filter (dependency: !(builtins.isNull dependency)) (
builtins.attrValues dependencies builtins.attrValues dependencies
); );
in in
builtins.map (dependency: dependency.package) available; builtins.map (dependency: dependency.package) available;
build = build = build': host': target':
build': host': target': builtins.mapAttrs
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target'); (name: dep: lib'.packages.build dep build' host' target');
}; };
getLatest = getLatest = alias: let
alias:
let
versions = builtins.attrNames alias.versions; versions = builtins.attrNames alias.versions;
sorted = builtins.sort (lib.versions.gte) versions; sorted = builtins.sort (lib.versions.gte) versions;
in in
builtins.head sorted; builtins.head sorted;
resolve = resolve = alias:
alias: if alias ? versions
if alias ? versions then then
alias.versions.${config.preferences.packages.version} alias.versions.${config.preferences.packages.version}
or (alias.versions.${lib'.packages.getLatest alias}) or (alias.versions.${lib'.packages.getLatest alias})
else else alias;
alias;
build = build = alias: build: host: target: let
alias: build: host: target:
let
package = lib'.packages.resolve alias; package = lib'.packages.resolve alias;
buildDependencies = buildDependencies = build': host': target':
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');
platform = { platform = {
@ -52,11 +45,12 @@ in
}; };
withPlatform = lib.modules.run { withPlatform = lib.modules.run {
modules = package.__modules__ ++ [ modules =
package.__modules__
++ [
lib'.types.package.children.submodule lib'.types.package.children.submodule
( (
{ config }: {config}: {
{
config = { config = {
__modules__ = package.__modules__; __modules__ = package.__modules__;
@ -70,7 +64,9 @@ in
# Not all platform information can be effectively handled via submodules. To handle # 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 # the case where a user copies the resolved config over we need to ensure that
# dependencies are appropriately updated. # dependencies are appropriately updated.
withDeps = withPlatform.config // { withDeps =
withPlatform.config
// {
deps = { deps = {
build = { build = {
only = buildDependencies build build build withPlatform.config.deps.build.only; only = buildDependencies build build build withPlatform.config.deps.build.only;
@ -91,11 +87,12 @@ in
}; };
withPackage = lib.modules.run { withPackage = lib.modules.run {
modules = package.__modules__ ++ [ modules =
package.__modules__
++ [
lib'.types.package.children.submodule lib'.types.package.children.submodule
( (
{ config }: {config}: {
{
config = { config = {
__modules__ = package.__modules__; __modules__ = package.__modules__;

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,16 @@
{ lib, config }: {
let lib,
config,
}: let
inherit (config) preferences builders; inherit (config) preferences builders;
lib' = config.lib; lib' = config.lib;
in in {
{
config = { config = {
lib.types = { lib.types = {
license = license = let
let
type = lib.types.submodule ( type = lib.types.submodule (
{ config }: {config}: {
{
options = { options = {
name = { name = {
full = lib.options.create { full = lib.options.create {
@ -57,7 +56,9 @@ in
lib.types.either type (lib.types.list.of type); lib.types.either type (lib.types.list.of type);
platform = platform =
lib.types.coerce lib.types.string lib'.systems.withBuildInfo lib.types.coerce
lib.types.string
lib'.systems.withBuildInfo
lib'.systems.types.platformWithBuildInfo; lib'.systems.types.platformWithBuildInfo;
builder = lib.types.submodule { builder = lib.types.submodule {
@ -73,14 +74,10 @@ in
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias); packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias);
dependencies = dependencies = build: host: target: let
build: host: target:
let
initial = lib.types.raw; initial = lib.types.raw;
transform = transform = value: let
value:
let
package = lib'.packages.resolve value; package = lib'.packages.resolve value;
in in
lib'.packages.build package build host target; lib'.packages.build package build host target;
@ -102,78 +99,76 @@ in
versions = lib.options.create { versions = lib.options.create {
description = "Available versions of the package."; description = "Available versions of the package.";
type = lib.types.attrs.of lib'.types.package; type = lib.types.attrs.of lib'.types.package;
default.value = { }; default.value = {};
}; };
}; };
}; };
package = package = let
let normalize = value:
normalize = if builtins.isFunction value || builtins.isList value
value: then value
if builtins.isFunction value || builtins.isList value then else if value ? __modules__
value then value.__modules__
else if value ? __modules__ then else {
value.__modules__ config = value;
else };
{ config = value; };
initial = lib.types.create { initial = lib.types.create {
name = "PackageConfig"; name = "PackageConfig";
description = "configuration for a package"; description = "configuration for a package";
check = value: builtins.isFunction value || builtins.isAttrs value || builtins.isList value; check = value: builtins.isFunction value || builtins.isAttrs value || builtins.isList value;
merge = merge = location: definitions: let
location: definitions: normalized =
let builtins.map
normalized = builtins.map (definition: lib.lists.from.any (normalize definition.value)) definitions; (definition: lib.lists.from.any (normalize definition.value))
definitions;
in in
builtins.concatLists normalized; builtins.concatLists
normalized;
}; };
transform = transform = location: value: let
location: value: modules =
let lib.lists.from.any (normalize value);
modules = lib.lists.from.any (normalize value);
result = lib.modules.run { result = lib.modules.run {
prefix = location; prefix = location;
modules = modules ++ [ modules =
submodule modules
{ config.__modules__ = modules; } ++ [submodule {config.__modules__ = modules;}];
];
}; };
in in
result.config; result.config;
final = lib.types.raw; final = lib.types.raw;
deps = deps = build: host: target:
build: host: target:
lib.types.submodule { lib.types.submodule {
options = { options = {
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 build build build;
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 build build target;
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 build host target;
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 build target target;
default.value = { }; default.value = {};
}; };
}; };
@ -181,19 +176,19 @@ in
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 host host host;
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 host host target;
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 host target target;
default.value = { }; default.value = {};
}; };
}; };
@ -201,33 +196,33 @@ in
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 target target target;
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 target target target;
default.value = { }; default.value = {};
}; };
}; };
}; };
}; };
submodule = submodule = {config}: let
{ config }:
let
build = config.platform.build; build = config.platform.build;
host = config.platform.host; host = config.platform.host;
target = config.platform.target; target = config.platform.target;
in in {
{
options = { options = {
__modules__ = lib.options.create { __modules__ = lib.options.create {
description = "User specified modules for the package definition."; 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; # writable = false;
internal = true; internal = true;
default.value = [ ]; default.value = [];
}; };
meta = { meta = {
@ -276,7 +271,7 @@ in
platforms = lib.options.create { platforms = lib.options.create {
description = "The platforms the package supports."; description = "The platforms the package supports.";
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
default.value = [ ]; default.value = [];
}; };
}; };
@ -306,7 +301,9 @@ in
default = { default = {
text = "\${config.pname}-\${config.version}"; text = "\${config.pname}-\${config.version}";
value = 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 "";
}; };
}; };
@ -330,13 +327,13 @@ in
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.string;
default.value = { }; default.value = {};
}; };
env = lib.options.create { env = lib.options.create {
description = "The environment for the package."; description = "The environment for the package.";
type = lib.types.attrs.of lib.types.string; type = lib.types.attrs.of lib.types.string;
default.value = { }; default.value = {};
}; };
package = lib.options.create { package = lib.options.create {
@ -348,7 +345,7 @@ in
deps = lib.options.create { deps = lib.options.create {
description = "The dependencies for the package."; description = "The dependencies for the package.";
type = deps build host target; type = deps build host target;
default.value = { }; default.value = {};
apply = value: { apply = value: {
build = { build = {
only = lib'.packages.dependencies.build build build build value.build.only; only = lib'.packages.dependencies.build build build build value.build.only;
@ -370,14 +367,18 @@ in
}; };
}; };
type = (lib.types.coerceWithLocation initial transform final) // { type =
(lib.types.coerceWithLocation initial transform final)
// {
name = "Package"; name = "Package";
description = "a package definition"; description = "a package definition";
}; };
in in
type type
// { // {
children = type.children // { children =
type.children
// {
inherit submodule; inherit submodule;
}; };
}; };

View file

@ -1,16 +1,15 @@
{ lib', config }:
let
inherit (config) builders packages;
in
{ {
lib',
config,
}: let
inherit (config) builders packages;
in {
config.packages.aux.a = { config.packages.aux.a = {
versions = { versions = {
"latest" = "latest" = {config}: {
{ config }:
{
config = { config = {
meta = { meta = {
platforms = [ "i686-linux" ]; platforms = ["i686-linux"];
}; };
name = "${config.pname}-${config.version}"; name = "${config.pname}-${config.version}";

View file

@ -1,20 +1,18 @@
{ config }: {config}: let
let
inherit (config) lib builders packages; inherit (config) lib builders packages;
in in {
{
config.packages.aux.b = { config.packages.aux.b = {
versions = { versions = {
"latest" = "latest" = {config}: {
{ config }:
{
options = { options = {
custom = lib.options.create { type = lib.types.bool; }; custom = lib.options.create {
type = lib.types.bool;
};
}; };
config = { config = {
meta = { meta = {
platforms = [ "i686-linux" ]; platforms = ["i686-linux"];
}; };
name = "${config.pname}-${config.version}"; name = "${config.pname}-${config.version}";

View file

@ -1,12 +1,10 @@
{ config }: {config}: let
let
inherit (config) lib; inherit (config) lib;
doubles = lib.systems.doubles.all; doubles = lib.systems.doubles.all;
packages = builtins.removeAttrs config.packages [ "cross" ]; packages = builtins.removeAttrs config.packages ["cross"];
in in {
{
includes = [ includes = [
./foundation ./foundation
./aux/a.nix ./aux/a.nix
@ -24,7 +22,7 @@ in
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,12 +45,9 @@ in
builtins.mapAttrs ( builtins.mapAttrs (
namespace: namespace:
builtins.mapAttrs ( builtins.mapAttrs (
name: alias: name: alias: let
let setHost = package:
setHost = package // {
package:
package
// {
__modules__ = package.__modules__ ++ [ __modules__ = package.__modules__ ++ [
{ {
config.platform = { config.platform = {
@ -95,12 +90,15 @@ in
# .config # .config
# else package; # else package;
updated = alias // { updated =
alias
// {
versions = builtins.mapAttrs (version: package: setHost package) alias.versions; versions = builtins.mapAttrs (version: package: setHost package) alias.versions;
}; };
in in
updated updated
) )
) packages )
packages
); );
} }

View file

@ -3,9 +3,9 @@
lib', lib',
config, config,
options, options,
}: }: let
let inherit
inherit (config) (config)
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.
@ -13,13 +13,10 @@ let
foundation foundation
packages packages
; ;
in in {
{
config.packages.foundation.binutils = { config.packages.foundation.binutils = {
versions = { versions = {
"latest" = "latest" = {config}: {
{ config }:
{
options = { options = {
src = lib.options.create { src = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -29,7 +26,7 @@ in
config = { config = {
meta = { meta = {
platforms = [ "i686-linux" ]; platforms = ["i686-linux"];
}; };
pname = "binutils"; pname = "binutils";
@ -61,8 +58,7 @@ in
]; ];
}; };
phases = phases = let
let
patches = [ patches = [
# Make binutils output deterministic by default. # Make binutils output deterministic by default.
./patches/deterministic.patch ./patches/deterministic.patch
@ -93,8 +89,7 @@ in
"--disable-multilib" "--disable-multilib"
]; ];
in in {
{
unpack = '' unpack = ''
tar xf ${config.src} tar xf ${config.src}
cd binutils-${config.version} cd binutils-${config.version}

View file

@ -3,8 +3,7 @@
lib', lib',
config, config,
options, options,
}: }: {
{
includes = [ includes = [
./gcc ./gcc
./binutils ./binutils

View file

@ -1,6 +1,9 @@
{ config, options }: {
let config,
inherit (config) options,
}: let
inherit
(config)
lib lib
mirrors mirrors
builders builders
@ -9,13 +12,13 @@ let
foundation foundation
packages packages
; ;
in in {
{
config.packages.foundation.gcc = { config.packages.foundation.gcc = {
versions = { versions = {
"latest" = "latest" = {
{ config, meta }: config,
{ meta,
}: {
options = { options = {
src = lib.options.create { src = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -79,7 +82,7 @@ in
config = { config = {
meta = { meta = {
platforms = [ "i686-linux" ]; platforms = ["i686-linux"];
}; };
pname = "gcc"; pname = "gcc";
@ -104,13 +107,17 @@ in
]; ];
}; };
phases = phases = let
let
host = lib.systems.withBuildInfo config.platform.host; host = lib.systems.withBuildInfo config.platform.host;
mbits = if host.system.cpu.family == "x86" then if host.is64bit then "-m64" else "-m32" else ""; mbits =
in if host.system.cpu.family == "x86"
{ then
if host.is64bit
then "-m64"
else "-m32"
else "";
in {
unpack = '' unpack = ''
# Unpack # Unpack
tar xf ${config.src} tar xf ${config.src}

View file

@ -3,22 +3,22 @@
lib', lib',
config, config,
options, options,
}: }: let
let inherit
inherit (config) (config)
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
; ;
in in {
{
config.packages.foundation.linux-headers = { config.packages.foundation.linux-headers = {
versions = { versions = {
"latest" = "latest" = {
{ config, meta }: config,
{ meta,
}: {
options = { options = {
src = lib.options.create { src = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -28,7 +28,7 @@ in
config = { config = {
meta = { meta = {
platforms = [ "i686-linux" ]; platforms = ["i686-linux"];
}; };
pname = "linux-headers"; pname = "linux-headers";