wip: working gcc stage1, stage2, stage3

This commit is contained in:
Jake Hamilton 2025-08-28 04:06:51 -07:00
parent 8fe3a90993
commit 8b9b072d56
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
22 changed files with 1312 additions and 645 deletions

View file

@ -4,6 +4,8 @@ let
inherit (config) lib packages;
inherit (config.internal.packages) foundation;
pretty = lib.generators.pretty {};
in
{
config.builders = {
@ -21,21 +23,24 @@ in
hooks = lib.packages.hooks.create dependencies context;
resolvePhases = phases:
if builtins.isFunction phases then
phases context
else
phases;
phasesWithHooks =
let
all = lib.lists.flatten [
hooks.build.only
hooks.build.build
hooks.build.host
hooks.build.target
hooks.host.only
hooks.host.host
hooks.host.target
hooks.target.only
hooks.target.target
];
in
builtins.foldl' (final: defaults: lib.dag.apply.defaults final defaults) package.phases all;
builtins.foldl' (final: defaults: lib.dag.apply.defaults final (resolvePhases defaults)) (resolvePhases package.phases) all;
phases = lib.dag.apply.defaults phasesWithHooks {
unpack = lib.dag.entry.before [ "patch" ] "";
@ -66,14 +71,11 @@ in
PATH =
let
bins = lib.paths.bin (
(lib.packages.dependencies.get dependencies.build.only)
++ (lib.packages.dependencies.get dependencies.build.build)
(lib.packages.dependencies.get dependencies.build.build)
++ (lib.packages.dependencies.get dependencies.build.host)
++ (lib.packages.dependencies.get dependencies.build.target)
++ (lib.packages.dependencies.get dependencies.host.only)
++ (lib.packages.dependencies.get dependencies.host.host)
++ (lib.packages.dependencies.get dependencies.host.target)
++ (lib.packages.dependencies.get dependencies.target.only)
++ (lib.packages.dependencies.get dependencies.target.target)
++ [
foundation.stage2-bash
@ -82,8 +84,8 @@ in
);
in
builtins.concatStringsSep ":" (
(lib.lists.when (package.env ? PATH) [ package.env.PATH ])
++ [ bins ]
[ bins ]
++ (lib.lists.when (package.env ? PATH) [ package.env.PATH ])
);
builder = cfg.executable;
@ -118,8 +120,18 @@ in
};
};
in
# (builtins.trace "build: ${package.name} -> build=${package.platform.build.triple} host=${package.platform.host.triple} target=${package.platform.target.triple}")
result;
if sorted ? result then
result
else
builtins.throw ''
${pretty phases}
[Aux Tidepool] Phases for `${lib.options.getIdentifier [ "packages" package.namespace package.id "versions" package.version ]}` have a cycle.
Review the phases printed above and resolve the cycle to proceed.
TIP: This can happen when you have two of the same dependency added as different dependencies
such as `build.build` and `build.host`.
'';
};
};
}

View file

@ -32,7 +32,6 @@ in
let
deps = {
build = {
only = getPropagatedDependencies dependency.deps.build.only ++ process dependency.deps.build.only;
build =
getPropagatedDependencies dependency.deps.build.build ++ process dependency.deps.build.build;
host = getPropagatedDependencies dependency.deps.build.host ++ process dependency.deps.build.host;
@ -40,27 +39,22 @@ in
getPropagatedDependencies dependency.deps.build.target ++ process dependency.deps.build.target;
};
host = {
only = getPropagatedDependencies dependency.deps.host.only ++ process dependency.deps.host.only;
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
target =
getPropagatedDependencies dependency.deps.host.target ++ process dependency.deps.host.target;
};
target = {
only = getPropagatedDependencies dependency.deps.target.only ++ process dependency.deps.target.only;
target =
getPropagatedDependencies dependency.deps.target.target ++ process dependency.deps.target.target;
};
};
in
lib.lists.flatten [
deps.build.only
deps.build.build
deps.build.host
deps.build.target
deps.host.only
deps.host.host
deps.host.target
deps.target.only
deps.target.target
];
@ -70,18 +64,15 @@ in
in
{
build = {
only = builtins.attrValues package.deps.build.only ++ process package.deps.build.only;
build = builtins.attrValues package.deps.build.build ++ process package.deps.build.build;
host = builtins.attrValues package.deps.build.host ++ process package.deps.build.host;
target = builtins.attrValues package.deps.build.target ++ process package.deps.build.target;
};
host = {
only = builtins.attrValues package.deps.host.only ++ process package.deps.host.only;
host = builtins.attrValues package.deps.host.host ++ process package.deps.host.host;
target = builtins.attrValues package.deps.host.target ++ process package.deps.host.target;
};
target = {
only = builtins.attrValues package.deps.target.only ++ process package.deps.target.only;
target = builtins.attrValues package.deps.target.target ++ process package.deps.target.target;
};
};
@ -110,14 +101,11 @@ in
target = lib.options.create {
description = "The dependency target that is being generated.";
type = lib.types.enum [
"build.only"
"build.build"
"build.host"
"build.target"
"host.only"
"host.host"
"host.target"
"target.only"
"target.target"
];
writable = false;
@ -141,10 +129,6 @@ in
in
{
build = {
only = process [
"build"
"only"
];
build = process [
"build"
"build"
@ -159,10 +143,6 @@ in
];
};
host = {
only = process [
"host"
"only"
];
host = process [
"host"
"host"
@ -197,9 +177,12 @@ in
(
dependency:
let
getHooks = dependency.hooks or (lib.fp.const { });
getHooks =
(builtins.trace dependency.name)
(builtins.trace dependency.hooks)
dependency.hooks or (lib.fp.const { });
in
getHooks ctx
dependency.hooks ctx
)
dependencies;
in
@ -207,10 +190,6 @@ in
in
{
build = {
only = process [
"build"
"only"
];
build = process [
"build"
"build"
@ -225,10 +204,6 @@ in
];
};
host = {
only = process [
"host"
"only"
];
host = process [
"host"
"host"
@ -239,10 +214,6 @@ in
];
};
target = {
only = process [
"target"
"only"
];
target = process [
"target"
"target"
@ -272,6 +243,14 @@ in
let
package = lib.packages.resolve alias;
identifier = lib.options.getIdentifier [
"packages"
package.namespace
package.id
"versions"
package.version
];
platform = {
build = lib.modules.override 75 build;
host = lib.modules.override 75 host;
@ -298,27 +277,42 @@ in
];
};
withDependencyErrorContext = prefix: deps:
builtins.mapAttrs
(name: value:
builtins.addErrorContext
"📦 [Aux Tidepool] while resolving dependency `${lib.options.getIdentifier (["deps"] ++ prefix ++ [name])}` for `${identifier}`."
value
) deps;
# 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 // {
deps = {
build = {
only = lib.packages.dependencies.build build build build withPlatform.config.deps.build.only;
build = lib.packages.dependencies.build build build host withPlatform.config.deps.build.build;
host = lib.packages.dependencies.build build host target withPlatform.config.deps.build.host;
target = lib.packages.dependencies.build build target target withPlatform.config.deps.build.target;
build =
lib.packages.dependencies.build build build build
(withDependencyErrorContext ["build" "build"] withPlatform.config.deps.build.build);
host =
lib.packages.dependencies.build build build host
(withDependencyErrorContext ["build" "host"] withPlatform.config.deps.build.host);
target =
lib.packages.dependencies.build build build target
(withDependencyErrorContext ["build" "target"] withPlatform.config.deps.build.target);
};
host = {
only = lib.packages.dependencies.build host host host withPlatform.config.deps.host.only;
host = lib.packages.dependencies.build host host target withPlatform.config.deps.host.host;
target = lib.packages.dependencies.build host target target withPlatform.config.deps.host.target;
host =
lib.packages.dependencies.build build host host
(withDependencyErrorContext ["host" "host"] withPlatform.config.deps.host.host);
target =
lib.packages.dependencies.build build host target
(withDependencyErrorContext ["host" "target"] withPlatform.config.deps.host.target);
};
target = {
only = lib.packages.dependencies.build target target target withPlatform.config.deps.target.only;
target =
lib.packages.dependencies.build target target target
withPlatform.config.deps.target.target;
lib.packages.dependencies.build build target target
(withDependencyErrorContext ["target" "target"] withPlatform.config.deps.target.target);
};
};
};
@ -338,29 +332,34 @@ in
inherit platform;
deps = lib.modules.overrides.force withDeps.deps;
deps =
lib.modules.overrides.force withDeps.deps;
package = lib.modules.overrides.force (withDeps.builder.build withDeps);
package =
(builtins.addErrorContext "📦 [Aux Tidepool] while building package ${package.name}")
(lib.modules.override 0 (withDeps.builder.build withDeps));
};
}
)
];
};
isSupported = lib.packages.supports package build host target;
support = lib.packages.supports withPlatform.config build host target;
buildSystem = lib.systems.withBuildInfo build;
hostSystem = lib.systems.withBuildInfo host;
targetSystem = lib.systems.withBuildInfo target;
result =
if !support.compatible then
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` does not support the platform build=${buildSystem.double}, host=${hostSystem.double}, target=${targetSystem.double}."
else if support.broken then
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` is marked as broken and cannot be built."
else
withPackage.config;
in
if isSupported then
withPackage.config
else
builtins.throw "Package `${
lib.options.getIdentifier [
"packages"
package.namespace
package.id
"versions"
package.version
]
}` does not support the platform build=${build.double}, host=${host.double}, target=${target.double}";
builtins.addErrorContext "📦 [Aux Tidepool] while building package `${identifier}` for platform build=${buildSystem.double}, host=${hostSystem.double}, target=${targetSystem.double}."
result;
supports = alias: build: host: target:
let
@ -375,25 +374,13 @@ in
platform.host.double == hostSystem.double &&
platform.target.double == targetSystem.double)
package.platforms;
in
builtins.length matches > 0;
in {
compatible =
(config.preferences.packages.allow.incompatible && builtins.length matches == 0)
|| builtins.length matches > 0;
create = namespace: name: alias: {
${namespace} = {
${name} = lib.modules.merge [
alias
{
versions = builtins.mapAttrs
(version: package: {
id = lib.modules.overrides.default name;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
})
alias.versions;
}
];
broken = !config.preferences.packages.allow.broken && package.meta.broken;
};
};
};
};
}

View file

@ -81,7 +81,7 @@ in
settings = lib.options.create {
description = "The settings for the builder.";
type = lib.types.attrs.of lib.types.option;
default.value = {};
default.value = { };
};
};
});
@ -91,7 +91,7 @@ in
normalize =
value:
if builtins.isNull value then
{}
{ }
else if builtins.isPath value then
{ includes = [ value ]; }
else if builtins.isFunction value || builtins.isList value then
@ -111,26 +111,32 @@ in
transform =
value:
let
result = builtins.mapAttrs (
namespace: aliases:
builtins.mapAttrs (
id: alias:
alias
// {
versions = builtins.mapAttrs (version: package: {
__modules__ = (lib.lists.from.any (normalize package)) ++ [
{
config = {
id = lib.modules.overrides.default id;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
};
}
];
}) alias.versions;
}
) aliases
) value;
result = builtins.mapAttrs
(
namespace: aliases:
builtins.mapAttrs
(
id: alias:
alias
// {
versions = builtins.mapAttrs
(version: package: {
__modules__ = (lib.lists.from.any (normalize package)) ++ [
{
config = {
id = lib.modules.overrides.default id;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
};
}
];
})
alias.versions;
}
)
aliases
)
value;
in
result;
@ -170,8 +176,8 @@ in
description = "package artifact";
};
in
lib.types.nullish (
lib.types.withCheck
lib.types.nullish (
lib.types.withCheck
base
(value:
value ? package
@ -183,7 +189,7 @@ in
&& value ? extras
&& builtins.isAttrs value.extras
)
);
);
dependencies =
build: host: target:
@ -211,8 +217,8 @@ in
let
default = config.${global.config.preferences.packages.version};
in
default.extend
or (builtins.throw "Package \"${name}\" does not have a ${global.config.preferences.packages.version} release.");
default.extend
or (builtins.throw "Package \"${name}\" does not have a ${global.config.preferences.packages.version} release.");
};
stable = lib.options.create {
@ -242,7 +248,7 @@ in
normalize =
value:
if builtins.isNull value then
{}
{ }
else if builtins.isPath value then
{ includes = [ value ]; }
else if builtins.isFunction value || builtins.isList value then
@ -289,9 +295,11 @@ in
merge =
location: definitions:
let
modules = builtins.concatMap (
definition: lib.lists.from.any (normalize definition.value)
) definitions;
modules = builtins.concatMap
(
definition: lib.lists.from.any (normalize definition.value)
)
definitions;
result = lib.modules.run {
prefix = location;
@ -314,61 +322,43 @@ in
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 = { };
};
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;
type = lib.types.dependencies build build build;
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;
type = lib.types.dependencies build build host;
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;
type = lib.types.dependencies build build target;
default.value = { };
};
};
host = {
only = lib.options.create {
description = "Dependencies which are only used in the host environment.";
type = lib.types.dependencies host host host;
default.value = { };
};
host = lib.options.create {
description = "Dependencies which are executed in the host environment.";
type = lib.types.dependencies host host target;
type = lib.types.dependencies build host host;
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;
type = lib.types.dependencies build host target;
default.value = { };
};
};
target = {
only = lib.options.create {
description = "Dependencies which are only used in the target environment.";
type = lib.types.dependencies target target target;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are executed in the target environment.";
type = lib.types.dependencies target target target;
type = lib.types.dependencies build target target;
default.value = { };
};
};
@ -376,10 +366,10 @@ in
};
submodule =
{
config,
meta,
name,
{ config
, meta
, name
,
}:
let
build = config.platform.build;
@ -565,13 +555,13 @@ in
let
initial =
lib.types.withCheck
lib.types.raw
(value:
let
builder = global.config.builders.${value.name} or null;
in
if builder == null then
builtins.throw "Builder `${
lib.types.raw
(value:
let
builder = global.config.builders.${value.name} or null;
in
if builder == null then
builtins.throw "Builder `${
lib.options.getIdentifier [
"builders"
value.name
@ -585,15 +575,15 @@ in
config.version
]
}` is used but not defined."
else
value ? name &&
value ? build
);
else
value ? name &&
value ? build
);
transform = value:
if value ? settings.__type__ then
value // {
settings = {};
settings = { };
}
else
value;
@ -603,11 +593,12 @@ in
(value:
let
builder = global.config.builders.${value.name} or null;
results = lib.attrs.mapToList (name: option:
if option.type.check value.settings.${name} then
true
else
builtins.throw "The option `${
results = lib.attrs.mapToList
(name: option:
if option.type.check value.settings.${name} then
true
else
builtins.throw "The option `${
lib.options.getIdentifier [
"packages"
config.namespace
@ -619,18 +610,19 @@ in
name
]
}` is not of type ${option.type.description}."
) builder.settings;
)
builder.settings;
checked = builtins.foldl' (acc: result: builtins.seq result acc) true results;
in
if value ? settings.__type__ then
false
else
checked
if value ? settings.__type__ then
false
else
checked
);
coerced = lib.types.coerce initial transform final;
in
coerced;
coerced;
};
src = lib.options.create {
@ -648,12 +640,12 @@ in
package = lib.options.create {
description = "The built derivation.";
type = lib.types.derivation;
default.value = (builtins.trace "building: ${config.name}") config.builder.build config;
default.value = config.builder.build config;
};
phases = lib.options.create {
description = "The phases for the package.";
type = lib.types.dag.of lib.types.string;
type = lib.types.either (lib.types.dag.of lib.types.string) (lib.types.function lib.types.dag.of lib.types.string);
default.value = { };
};
@ -681,19 +673,16 @@ in
default.value = { };
apply = value: {
build = {
only = lib.packages.dependencies.build build build build value.build.only;
build = lib.packages.dependencies.build build build target value.build.build;
host = lib.packages.dependencies.build build host target value.build.host;
target = lib.packages.dependencies.build build target target value.build.target;
build = lib.packages.dependencies.build build build build value.build.build;
host = lib.packages.dependencies.build build build host value.build.host;
target = lib.packages.dependencies.build build build target value.build.target;
};
host = {
only = lib.packages.dependencies.build host host host value.host.only;
host = lib.packages.dependencies.build host host target value.host.host;
target = lib.packages.dependencies.build host target target value.host.target;
host = lib.packages.dependencies.build build host host value.host.host;
target = lib.packages.dependencies.build build host target value.host.target;
};
target = {
only = lib.packages.dependencies.build target target target value.target.only;
target = lib.packages.dependencies.build target target target value.target.target;
target = lib.packages.dependencies.build build target target value.target.target;
};
};
};

View file

@ -11,17 +11,19 @@ in
config = {
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
deps.build.host = {
deps.host.host = {
inherit (packages.aux) b;
};
phases = {
install = ''
echo "a with b: ${config.deps.build.host.b.package.system}" > $out
echo "a with b: ${config.deps.host.host.b.platform.host.double}" > $out
'';
};
};

View file

@ -13,6 +13,12 @@ in
};
config = {
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
custom = true;
builder = builders.basic;
@ -31,7 +37,9 @@ in
"foundation:cflags" = [ "-I $AUX_B/include" ];
};
hooks = ctx: { "aux:b:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_B=${config.package}''; };
hooks = ctx: {
"aux:b:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_B=${config.package}'';
};
phases = {
install = ''

View file

@ -13,6 +13,13 @@ in
};
config = {
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "i686-linux"; target = "x86_64-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
custom = true;
builder = builders.basic;
@ -21,7 +28,9 @@ in
"foundation:cflags" = [ "-I $AUX_C/include" ];
};
hooks = ctx: { "aux:c:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_C=${config.package}''; };
hooks = ctx: {
"aux:c:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_C=${config.package}'';
};
phases = {
install = ''

View file

@ -5,16 +5,34 @@ let
doubles = lib.systems.doubles.all;
packages = lib.attrs.filter
(
name: value: !(builtins.elem name doubles) && name != "context" && name != "platforms"
)
(name: value:
!(builtins.elem name doubles)
&& name != "context"
&& name != "platforms")
config.packages;
builtPlatforms = lib.attrs.generate doubles (build:
lib.attrs.generate doubles (host:
lib.attrs.generate doubles (target:
builtins.mapAttrs (namespace: aliases:
builtins.mapAttrs (id: alias: {
stable = (lib.packages.build alias.stable build host target).package;
latest = (lib.packages.build alias.latest build host target).package;
versions = builtins.mapAttrs (version: entry:
(lib.packages.build entry build host target).package
) alias.versions;
}) aliases
) packages
)
)
);
allPlatformOptions = lib.attrs.generate doubles (
build:
lib.options.create {
description = "Packages which are built on the ${build} system.";
default.value = { };
default.value = {};
type = lib.types.submodule {
freeform = lib.types.platforms.build;
@ -31,74 +49,6 @@ let
lib.options.create {
description = "Packages which are cross-compiled for the ${target} system.";
type = lib.types.platforms.target;
default.value =
let
builtPlatforms =
let
builtNamespaces = builtins.mapAttrs
(
namespace: aliases:
let
builtAliases = builtins.mapAttrs
(
id: alias:
let
produce =
path:
let
entry = lib.attrs.select path null alias;
matches = builtins.partition
(platform:
platform.build.double == build &&
platform.host.double == host &&
platform.target.double == target)
entry.platforms;
in
if entry == null || !(entry ? extend) then
null
else if builtins.length matches.right > 0 then
(lib.packages.build entry build host target).package
else
null;
in
{
stable = produce [ "stable" ];
latest = produce [ "latest" ];
versions = builtins.mapAttrs
(
version: alias:
produce [
"versions"
version
]
)
alias.versions;
}
)
aliases;
filteredAliases = lib.attrs.filter (name: value:
let
entries = builtins.filter
(entry: entry != null)
([value.latest value.stable] ++ (builtins.attrValues value.versions));
isValid = value != null && entries != [];
in
isValid
) builtAliases;
in
filteredAliases
)
packages;
filteredNamespaces = lib.attrs.filter
(name: value: value != {})
builtNamespaces;
in
filteredNamespaces;
in
builtPlatforms;
}
);
};
@ -107,25 +57,6 @@ let
};
}
);
builtPlatforms =
builtins.mapAttrs (build: hosts:
builtins.mapAttrs (host: targets:
builtins.mapAttrs (target: namespaces:
builtins.mapAttrs (namespace: aliases:
lib.attrs.filter (id: alias:
let
entries = builtins.filter
(entry: entry != null)
([alias.latest alias.stable] ++ (builtins.attrValues alias.versions));
isValid = alias != null && entries != [];
in
isValid
) aliases
) namespaces
) targets
) hosts
) config.internal.packages.platforms;
in
{
includes = [
@ -137,7 +68,7 @@ in
internal.packages.platforms = lib.options.create {
description = "The built versions of packages for each platform.";
internal = true;
default.value = {};
default.value = { };
type = lib.types.submodule {
options = allPlatformOptions;
};
@ -152,7 +83,7 @@ in
options = {
platforms = lib.options.create {
description = "The built versions of packages which are available.";
default.value = builtPlatforms;
default.value = config.internal.packages.platforms;
type = lib.types.attrs.of lib.types.platforms.build;
};
@ -176,6 +107,24 @@ in
];
default.value = "latest";
};
allow = {
incompatible = lib.options.create {
description = "Whether to allow building packages that are not compatible with the required architecture.";
type = lib.types.bool;
default.value = false;
};
broken = lib.options.create {
description = "Whether to allow building packages that are marked as broken.";
type = lib.types.bool;
default.value = false;
};
};
};
};
config = {
internal.packages.platforms = builtPlatforms;
};
}

View file

@ -2,10 +2,10 @@
{
config.packages.foundation.binutils = {
stable = config.packages.foundation.binutils.versions."2.41-bootstrap";
latest = config.packages.foundation.binutils.versions."2.41";
latest = config.packages.foundation.binutils.versions."2.41-stage1";
versions = {
"2.41" = ./versions/2.41.nix;
"2.41-stage1" = ./versions/2.41-stage1.nix;
"2.41-bootstrap" = ./versions/2.41-bootstrap.nix;
};
};

View file

@ -0,0 +1,199 @@
{ config, global }:
let
inherit (global) lib packages builders mirrors;
inherit (global.internal.packages) foundation;
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross =
config.platform.build.double != config.platform.host.double
&& config.platform.host.double == config.platform.target.double;
version = lib.strings.removeSuffix "-stage1" config.version;
patches = [
../patches/2.41-deterministic.patch
];
configureFlags = lib.lists.when (!isCross) [
"LDFLAGS=--static"
] ++ [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries.
"--with-lib-path=:"
"--disable-multilib"
];
in
{
config = {
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
homepage = "https://www.gnu.org/software/binutils";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "i686-linux"; target = "x86_64-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/binutils/binutils-${version}.tar.xz";
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
deps = {
build = {
build = {
gnumake = if isBootstrapped then
packages.foundation.gnumake.versions."4.4.1-bootstrap"
else
packages.foundation.gnumake.latest;
gnused = if isBootstrapped then
packages.foundation.gnused.versions."4.9-bootstrap"
else
packages.foundation.gnused.latest;
gnugrep = if isBootstrapped then
packages.foundation.gnugrep.versions."3.11-bootstrap"
else
packages.foundation.gnugrep.latest;
gnupatch = if isBootstrapped then
packages.foundation.gnupatch.versions."2.7-bootstrap"
else
packages.foundation.gnupatch.latest;
gawk = if isBootstrapped then
packages.foundation.gawk.versions."5.2.2-bootstrap"
else
packages.foundation.gawk.latest;
diffutils = if isBootstrapped then
packages.foundation.diffutils.versions."3.10-bootstrap"
else
packages.foundation.diffutils.latest;
findutils = if isBootstrapped then
packages.foundation.findutils.versions."4.9.0-bootstrap"
else
packages.foundation.findutils.latest;
gnutar = if isBootstrapped then
packages.foundation.gnutar.versions."1.35-bootstrap"
else
packages.foundation.gnutar.latest;
gzip = if isBootstrapped then
packages.foundation.gzip.versions."1.13-bootstrap"
else
packages.foundation.gzip.latest;
bzip2 = if isBootstrapped then
packages.foundation.bzip2.versions."1.0.8-bootstrap"
else
packages.foundation.bzip2.latest;
xz = if isBootstrapped then
packages.foundation.xz.versions."5.4.3-bootstrap"
else
packages.foundation.xz.latest;
gcc = if isBootstrapped then
packages.foundation.gcc.versions."13.2.0-bootstrap"
else
packages.foundation.gcc.latest;
binutils = if isBootstrapped then
packages.foundation.binutils.versions."2.41-bootstrap"
else
packages.foundation.binutils.latest.extend {
platform = {
build = lib.modules.overrides.force "i686-linux";
};
};
};
host = {
binutils = if isBootstrapped then
packages.foundation.binutils.versions."2.41-bootstrap"
else
packages.foundation.binutils.latest.extend {
platform = {
build = lib.modules.overrides.force "i686-linux";
};
};
};
target = {
# binutils = if isBootstrapped then
# packages.foundation.binutils.versions."2.41-bootstrap"
# else
# packages.foundation.binutils.latest.extend {
# platform = {
# build = lib.modules.overrides.force "i686-linux";
# };
# };
};
};
};
phases = {
unpack = ''
tar xf ${config.src}
cd binutils-${version}
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
'';
configure = ''
bash ./configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install-strip
'';
};
};
}

View file

@ -1,164 +0,0 @@
{ config, global }:
let
inherit (global) lib packages builders mirrors;
inherit (global.internal.packages) foundation;
# Stages as referred to in LFS:
# https://www.linuxfromscratch.org/lfs/view/development/partintro/toolchaintechnotes.html
isStage1 = config.platform.build.double == config.platform.host.double && config.platform.host.double != config.platform.target.double;
isStage2 = config.platform.build.double != config.platform.host.double && config.platform.host.double != config.platform.target.double;
isStage3 = config.platform.build.double != config.platform.host.double && config.platform.host.double == config.platform.target.double;
isStage4 = config.platform.build.double == config.platform.host.double && config.platform.host.double == config.platform.target.double;
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isFullyBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross = config.platform.build.double != config.platform.host.double;
patches = [
../patches/2.41-deterministic.patch
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-sysroot=/"
"--enable-deterministic-archives"
"--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries.
"--with-lib-path=:"
"--disable-multilib"
];
in
{
config = {
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
homepage = "https://www.gnu.org/software/binutils";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "i686-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/binutils/binutils-${config.version}.tar.xz";
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
deps = {
build = {
only = {
inherit (packages.foundation)
diffutils
findutils
gawk
gnugrep
gnumake
gnupatch
gnused
gnutar
xz;
};
host = {
binutils = if isFullyBootstrapped then
packages.foundation.binutils.versions."2.41-bootstrap"
else if isStage4 then
packages.foundation.binutils.versions."2.41".extend {
platform = {
build = lib.modules.force "i686-linux";
};
}
else if isStage3 then
packages.foundation.binutils.versions."2.41".extend {
platform = {
build = lib.modules.force "i686-linux";
host = lib.modules.force "i686-linux";
};
}
else if isStage2 then
packages.foundation.binutils.versions."2.41".extend {
platform = {
build = lib.modules.force "i686-linux";
host = lib.modules.force "i686-linux";
};
}
else if isStage1 then
packages.foundation.binutils.versions."2.41".extend {
platform = {
build = lib.modules.force "i686-linux";
host = lib.modules.force "i686-linux";
};
}
else
builtins.throw "Unsupported stage for binutils: build=${config.platform.build.double}, host=${config.platform.host.double}, target=${config.platform.target.double}";
gcc =
if isFullyBootstrapped then
if config.platform.target.double == config.platform.host.double then
packages.foundation.gcc.versions."13.2.0-bootstrap"
else
packages.foundation.gcc.versions."13.2.0-stage1"
else
packages.foundation.gcc.versions."13.2.0";
};
};
};
env = {
CFLAGS = "-O2 -static -fno-pie";
LDFLAGS = "--static -no-pie";
};
phases = {
unpack = ''
tar xf ${config.src}
cd binutils-${config.version}
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
'';
configure = ''
echo "build: ${config.platform.build.double} host: ${config.platform.host.double} target: ${config.platform.target.double}"
echo "int main() { return 0; }" > dummy.c
gcc -o dummy dummy.c
readelf -l ./dummy | sed -n '/INTERP/,+2p'
./dummy
bash ./configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install-strip
'';
};
};
}

View file

@ -2,8 +2,10 @@
{
config.packages.foundation.bzip2 = {
stable = config.packages.foundation.bzip2.versions."1.0.8-bootstrap";
latest = config.packages.foundation.bzip2.versions."1.0.8";
versions = {
"1.0.8" = ./versions/1.0.8.nix;
"1.0.8-bootstrap" = ./versions/1.0.8-bootstrap.nix;
};
};

View file

@ -0,0 +1,72 @@
{ config, global }:
let
inherit (global) lib packages builders mirrors;
inherit (global.internal.packages) foundation;
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
prefix = lib.strings.when
(config.platform.build.triple != config.platform.target.triple)
"${config.platform.target.triple}-";
in {
config = {
meta = {
description = "High-quality data compression program.";
homepage = "https://www.sourceware.org/bzip2";
license = lib.licenses.bsdOriginal;
};
platforms = [
{ build = "x86_64-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
src = builtins.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${config.version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
};
deps = {
build = {
build = {
inherit (packages.foundation)
gnumake
gnutar
gzip;
};
host = {
inherit (packages.foundation)
binutils
gcc;
};
};
};
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
cd bzip2-${config.version}
'';
build = ''
# Build
make \
-j $NIX_BUILD_CORES \
CFLAGS=-static \
bzip2 bzip2recover
'';
install = ''
# Install
make install -j $NIX_BUILD_CORES PREFIX=$out
'';
};
};
}

View file

@ -0,0 +1,39 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Commands for showing the differences between files (diff, cmp, etc.).";
homepage = "https://www.gnu.org/software/diffutils";
license = lib.licenses.gpl3Only;
};
platforms = [
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
src = builtins.fetchurl {
url = "${config.aux.mirrors.gnu}/diffutils/diffutils-${config.version}.tar.xz";
sha256 = "kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
};
deps = {
build = {
inherit (packages.foundation)
gnumake
gnused
gnugrep
gnutar
gawk
xz
diffutils
findutils;
};
};
};
}

View file

@ -1,10 +1,18 @@
{ config }:
# Stages as referred to in LFS:
# https://www.linuxfromscratch.org/lfs/view/development/partintro/toolchaintechnotes.html
# isStage1 = config.platform.build.double == config.platform.host.double && config.platform.host.double != config.platform.target.double;
# isStage2 = config.platform.build.double != config.platform.host.double && config.platform.host.double != config.platform.target.double;
# isStage3 = config.platform.build.double != config.platform.host.double && config.platform.host.double == config.platform.target.double;
# isStage4 = config.platform.build.double == config.platform.host.double && config.platform.host.double == config.platform.target.double;
{
config.packages.foundation.gcc = {
stable = config.packages.foundation.gcc.versions."13.2.0-bootstrap";
latest = config.packages.foundation.gcc.versions."13.2.0-stage2";
latest = config.packages.foundation.gcc.versions."13.2.0-stage3";
versions = {
"13.2.0-stage4" = ./versions/13.2.0-stage4.nix;
"13.2.0-stage3" = ./versions/13.2.0-stage3.nix;
"13.2.0-stage2" = ./versions/13.2.0-stage2.nix;
"13.2.0-stage1" = ./versions/13.2.0-stage1.nix;
"13.2.0-bootstrap" = ./versions/13.2.0-bootstrap.nix;

View file

@ -20,5 +20,18 @@ in {
derivation = foundation.stage2-gcc;
};
};
hooks = ctx: {
"aux:gcc:env" = lib.dag.entry.before [ "unpack" ] ''
export CC='gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so'
export CXX='g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
};
};
}

View file

@ -1,3 +1,4 @@
# gcc-newlib
{ config, global }:
let
@ -7,47 +8,50 @@ let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isFullyBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
version = lib.strings.removeSuffix "-stage1" config.version;
prefix = if config.platform.build.triple != config.platform.target.triple
then "${config.platform.target.triple}-"
else "";
prefix = lib.strings.when
(config.platform.build.triple != config.platform.target.triple)
"${config.platform.target.triple}-";
arch =
if config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux" then
"i686-linux"
else
"x86_64-linux";
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.build.host.glibc.package}/lib/ld-linux${
lib.strings.when (
(lib.systems.withBuildInfo config.platform.target).isx86
&& (lib.systems.withBuildInfo config.platform.target).is64bit
) "-x86-64"
}.so.2"
"-B${config.deps.build.host.glibc.package}/lib"
"-static"
"-no-pie"
];
configureFlags = [
"LDFLAGS=--static"
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-native-system-header-dir=/include"
"--with-sysroot=${foundation.stage1-musl}"
"--with-as=${config.deps.build.target.binutils.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.target.binutils.package}/bin/${prefix}ld"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--disable-plugin"
"CFLAGS=-static"
"CXXFLAGS=-static"
"LDFLAGS=-static"
"--disable-libssp"
"--disable-libvtv"
"--disable-libstdcxx"
"--disable-libquadmath"
"--disable-threads"
"--disable-decimal-float"
"--disable-shared"
"--disable-libmudflap"
"--disable-libgomp"
"--disable-libatomic"
"--without-headers"
"--with-newlib"
];
in
{
@ -159,67 +163,32 @@ in
deps = {
build = {
only = {
inherit (packages.foundation)
bzip2
diffutils
findutils
gawk
gnugrep
gnumake
gnupatch
gnused
gnutar
gzip
xz;
binutilsBuild = packages.foundation.binutils.versions."2.41".extend {
platform = {
target = lib.modules.overrides.force config.platform.build;
};
};
binutilsTarget = packages.foundation.binutils.versions."2.41".extend {
platform = {
target = lib.modules.overrides.force config.platform.target;
};
};
gcc =
if isFullyBootstrapped then
packages.foundation.gcc.versions."13.2.0-bootstrap"
else
packages.foundation.gcc.versions."13.2.0".extend {
platform = {
build = lib.modules.overrides.force "i686-linux";
host = lib.modules.overrides.force "i686-linux";
};
};
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
};
host = {
glibc = packages.foundation.glibc.versions."2.38".extend {
platform = {
build = lib.modules.overrides.force config.platform.build;
host = lib.modules.overrides.force config.platform.build;
target = lib.modules.overrides.force config.platform.target;
};
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
};
env = {
CC = "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
CXX = "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
LIBRARY_PATH = "${foundation.stage1-musl}/lib";
};
hooks = context: {
hooks = ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/${prefix}gcc ${builtins.concatStringsSep " " gccFlags}'
export CXX='${config.package}/bin/${prefix}g++ ${builtins.concatStringsSep " " gccFlags}'
export CC='${config.package}/bin/${prefix}gcc'
export CXX='${config.package}/bin/${prefix}g++'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
@ -247,27 +216,32 @@ in
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
'';
configure = ''
echo "--configure: ${builtins.concatStringsSep " " configureFlags}"
ls -la ${config.deps.build.build.binutils.package}/bin
ls -la ${config.deps.build.build.gcc.package}/bin
# Configure
bash ./configure ${builtins.concatStringsSep " " configureFlags}
mkdir build
cd build
bash ../configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
# Build
make -j $NIX_BUILD_CORES V=1 all-gcc
make -j $NIX_BUILD_CORES V=1
'';
install = ''
# Install
${lib.strings.when ((lib.systems.withBuildInfo config.platform.host).is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install-gcc
make -j $NIX_BUILD_CORES install
'';
};
};

View file

@ -1,3 +1,4 @@
# gcc-cross
{ config, global }:
let
@ -7,25 +8,32 @@ let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isFullyBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
version = lib.strings.removeSuffix "-stage2" config.version;
prefix = lib.strings.when
(config.platform.build.triple != config.platform.target.triple)
"${config.platform.target.triple}-";
arch =
if config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux" then
"i686-linux"
else
"x86_64-linux";
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
# "-Wl,-dynamic-linker"
# "-Wl,${config.deps.build.host.glibc.package}/lib/ld-linux${
# lib.strings.when (
# (lib.systems.withBuildInfo config.platform.target).isx86
# && (lib.systems.withBuildInfo config.platform.target).is64bit
# ) "-x86-64"
# }.so.2"
# "-B${config.deps.build.host.glibc.package}/lib"
# "-static"
# "-no-pie"
"-Wl,-dynamic-linker"
"-Wl,${config.deps.target.target.glibc.package}/lib/ld-linux${
lib.strings.when
(config.platform.target.isx86 && config.platform.target.is64bit)
"-x86-64"
}.so.2"
"-B${config.deps.target.target.glibc.package}/lib"
];
configureFlags = [
@ -33,17 +41,17 @@ let
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-native-system-header-dir=/include"
"--with-sysroot=${foundation.stage1-musl}"
"--with-as=${config.deps.build.target.binutils.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.target.binutils.package}/bin/${prefix}ld"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--disable-plugin"
"CFLAGS=-static"
"CXXFLAGS=-static"
"LDFLAGS=-static"
"--with-headers=${config.deps.target.target.glibc.package}/include"
"--with-build-sysroot=/"
# "--with-sysroot=${config.deps.target.target.glibc.package}"
"--with-native-system-header-dir=${config.deps.target.target.glibc.package}/include"
"--with-build-time-tools=${config.deps.build.target.binutils.package}/bin"
];
in
{
@ -111,7 +119,7 @@ in
};
platforms = [
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
{ build = "i686-linux"; host = "i686-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
@ -155,56 +163,45 @@ in
deps = {
build = {
only = {
inherit (packages.foundation)
bzip2
diffutils
findutils
gawk
gnugrep
gnumake
gnupatch
gnused
gnutar
gzip
xz;
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
};
# binutilsBuild = packages.foundation.binutils.versions."2.41".extend {
# platform = {
# target = lib.modules.overrides.force config.platform.build;
# };
# };
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
binutilsHost = packages.foundation.binutils.versions."2.41".extend {
platform = {
target = lib.modules.overrides.force config.platform.host;
};
};
gcc = packages.foundation.gcc.versions."13.2.0-stage1".extend {
platform = {
build = lib.modules.overrides.force "i686-linux";
host = lib.modules.overrides.force "i686-linux";
target = lib.modules.overrides.force config.platform.host;
};
};
target = {
target = {
glibc = packages.foundation.glibc.latest;
};
};
};
env = {
CC = "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
CXX = "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
LIBRARY_PATH = "${foundation.stage1-musl}/lib";
PATH = "${config.deps.build.only.binutilsHost.package}/${config.platform.host.triple}/bin";
CC = "gcc -Wl,-dynamic-linker";
CXX = "g++ -Wl,-dynamic-linker";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.target.target.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.target.target.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.target.target.glibc.package}/lib";
};
hooks = context: {
hooks = lib.modules.override 0 (ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/gcc ${builtins.concatStringsSep " " gccFlags}'
export CXX='${config.package}/bin/g++ ${builtins.concatStringsSep " " gccFlags}'
export CC='${config.package}/bin/${prefix}gcc ${builtins.concatStringsSep " " gccFlags}'
export CXX='${config.package}/bin/${prefix}g++ ${builtins.concatStringsSep " " gccFlags}'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
@ -212,7 +209,7 @@ in
alias gcc='$CC'
alias g++='$CXX'
'';
};
});
phases = {
unpack = ''
@ -232,35 +229,36 @@ in
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
'';
configure = ''
echo $PATH
ls -la ${config.deps.build.only.gcc.package}/bin
echo "int main() { return 0; }" > dummy.c
gcc -o dummy dummy.c
ls -l dummy
exit 1
# Configure
bash ./configure ${builtins.concatStringsSep " " configureFlags}
mkdir build
cd build
echo PATH=$PATH
# TODO(vlinkz) Hack to fix missing crti.o and crtn.o. Figure out how to properly find their paths.
mkdir gcc
ln -sv ${config.deps.target.target.glibc.package}/lib/{crti.o,crtn.o} gcc
mkdir -p x86_64-unknown-linux-gnu/libstdc++-v3/src
ln -sv ${config.deps.target.target.glibc.package}/lib/{crti.o,crtn.o} x86_64-unknown-linux-gnu/libstdc++-v3/src
bash ../configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
# Build
make -j $NIX_BUILD_CORES V=1 all-gcc
make -j $NIX_BUILD_CORES V=1 all
'';
install = ''
# Install
${lib.strings.when ((lib.systems.withBuildInfo config.platform.host).is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install-gcc
make -j $NIX_BUILD_CORES install
'';
};
};

View file

@ -0,0 +1,259 @@
# gcc-bootstrap
{ config, global }:
let
inherit (global) lib packages builders mirrors;
inherit (global.internal.packages) foundation;
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
version = lib.strings.removeSuffix "-stage3" config.version;
prefix = lib.strings.when
(config.platform.build.triple != config.platform.target.triple)
"${config.platform.target.triple}-";
arch =
if config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux" then
"i686-linux"
else
"x86_64-linux";
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (
(lib.systems.withBuildInfo config.platform.target).isx86
&& (lib.systems.withBuildInfo config.platform.target).is64bit
) "-x86-64"
}.so.2"
"-B${config.deps.host.host.glibc.package}/lib"
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
# Pretend we're native even though we're not
"--build=${config.platform.target.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.target.binutils.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.target.binutils.package}/bin/${prefix}ld"
"--enable-languages=c,c++"
"--disable-lto"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-native-system-header-dir=${config.deps.host.host.glibc.package}/include"
"--with-gxx-include-dir=${builtins.placeholder "out"}/include/c++/${config.version}/"
"--with-build-sysroot=/"
];
in
{
options = {
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.derivation;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
};
config = {
meta = {
description = "GNU Compiler Collection.";
homepage = "https://gcc.gnu.org";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build = {
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
host = {
host = {
glibc = packages.foundation.glibc.latest;
};
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.package}/lib/ld-linux-x86-64.so.2";
LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.host.host.glibc.package}/lib";
};
hooks = lib.modules.override 0 (ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/gcc ${builtins.concatStringsSep " " gccFlags}'
export CXX='${config.package}/bin/g++ ${builtins.concatStringsSep " " gccFlags}'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
});
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
cd gcc-${version}
ln -s ../gmp-${config.gmp.version} gmp
ln -s ../mpfr-${config.mpfr.version} mpfr
ln -s ../mpc-${config.mpc.version} mpc
ln -s ../isl-${config.isl.version} isl
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
'';
configure = ''
# Configure
mkdir build
cd build
bash ../configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
# Build
make -j $NIX_BUILD_CORES V=1
'';
install = ''
# Install
${lib.strings.when ((lib.systems.withBuildInfo config.platform.host).is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install
'';
};
};
}

View file

@ -0,0 +1,264 @@
# gcc-native
{ config, global }:
let
inherit (global) lib packages builders mirrors;
inherit (global.internal.packages) foundation;
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
version = lib.strings.removeSuffix "-stage4" config.version;
prefix = lib.strings.when
(config.platform.build.triple != config.platform.target.triple)
"${config.platform.target.triple}-";
arch =
if config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux" then
"i686-linux"
else
"x86_64-linux";
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (
(lib.systems.withBuildInfo config.platform.target).isx86
&& (lib.systems.withBuildInfo config.platform.target).is64bit
) "-x86-64"
}.so.2"
"-B${config.deps.host.host.glibc.package}/lib"
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--enable-languages=c,c++"
"--disable-lto"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-build-sysroot=/"
"--with-native-system-header-dir=${config.deps.host.host.glibc.package}/include"
];
in
{
options = {
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.derivation;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
};
config = {
meta = {
description = "GNU Compiler Collection.";
homepage = "https://gcc.gnu.org";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "x86_64-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
platform = lib.modules.override 1 {
build = arch;
};
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build = {
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41";
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage3";
};
target = {
binutils = packages.foundation.binutils.versions."2.41";
};
};
host = {
host = {
glibc = packages.foundation.glibc;
};
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${
"${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (config.platform.target.isx86 && config.platform.target.is64bit) "-x86-64"
}.so.2"
}";
LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
};
hooks = lib.modules.override 0 (ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/gcc ${builtins.concatStringsSep " " gccFlags}'
export CXX='${config.package}/bin/g++ ${builtins.concatStringsSep " " gccFlags}'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
});
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
cd gcc-${version}
ln -s ../gmp-${config.gmp.version} gmp
ln -s ../mpfr-${config.mpfr.version} mpfr
ln -s ../mpc-${config.mpc.version} mpc
ln -s ../isl-${config.isl.version} isl
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
'';
configure = ''
# Configure
mkdir build
cd build
bash ../configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
# Build
make -j $NIX_BUILD_CORES V=1
'';
install = ''
# Install
${lib.strings.when ((lib.systems.withBuildInfo config.platform.host).is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install
'';
};
};
}

View file

@ -7,9 +7,11 @@ let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isFullyBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross = config.platform.build.double != config.platform.host.double;
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
config = {
@ -20,8 +22,7 @@ in
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "i686-linux"; target = "x86_64-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
@ -33,38 +34,29 @@ in
deps = {
build = {
only = {
inherit (packages.foundation)
bison
diffutils
findutils
gawk
gnugrep
gnumake
gnupatch
gnused
gnutar
gzip
python
xz;
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
python = packages.foundation.python.versions."3.12.0-bootstrap";
bison = packages.foundation.bison.versions."3.8.2-bootstrap";
};
host = {
inherit (packages.foundation) linux-headers;
binutils =
if isFullyBootstrapped then
packages.foundation.binutils.versions."2.41-bootstrap"
else
packages.foundation.binutils.versions."2.41";
gcc =
if isFullyBootstrapped then
packages.foundation.gcc.versions."13.2.0-bootstrap"
else if config.platform.build.double == "i686-linux" then
packages.foundation.gcc.versions."13.2.0-stage1"
else
packages.foundation.gcc.versions."13.2.0";
gcc = packages.foundation.gcc.versions."13.2.0-stage1";
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
host = {
host = {
linux-headers = packages.foundation.linux-headers;
};
};
};
@ -83,15 +75,8 @@ in
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple} \
--with-headers=${config.deps.build.host.linux-headers.package}/include \
--with-binutils=${
if isFullyBootstrapped then
foundation.stage2-binutils
else if isCross then
config.deps.build.host.binutils.package
else
config.deps.build.only.binutils.package
}${lib.strings.when (isCross) "/${config.platform.target.triple}"}/bin
--with-headers=${config.deps.host.host.linux-headers.package}/include \
--with-binutils=${config.deps.build.host.binutils.package}/${config.platform.target.triple}/bin
'';
build = ''
@ -102,7 +87,7 @@ in
install = ''
# Install
make -j $NIX_BUILD_CORES install
ln -sv $(ls -d ${config.deps.build.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
ln -sv $(ls -d ${config.deps.host.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
'';
};
};

View file

@ -4,6 +4,7 @@
stable = config.packages.foundation.linux-headers.versions."6.5.6-bootstrap";
versions = {
"6.5.6" = ./versions/6.5.6.nix;
"6.5.6-bootstrap" = ./versions/6.5.6-bootstrap.nix;
};
};

View file

@ -0,0 +1,61 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
config = {
meta = {
description = "Header files and scripts for the Linux kernel.";
license = lib.licenses.lgpl2Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
{ build = "i686-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
# { build = "x86_64-linux"; host = "x86_64-linux"; target = "x86_64-linux"; }
];
builder = builders.basic;
src = builtins.fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major config.version}.x/linux-${config.version}.tar.xz";
sha256 = "eONtQhRUcFHCTfIUD0zglCjWxRWtmnGziyjoCUqV0vY=";
};
env = {
PATH = lib.paths.bin [
foundation.stage2-gcc
foundation.stage1-musl
foundation.stage2-binutils
foundation.stage2-gnumake
foundation.stage2-gnupatch
foundation.stage2-gnused
foundation.stage2-gnugrep
foundation.stage2-gawk
foundation.stage2-diffutils
foundation.stage2-findutils
foundation.stage2-gnutar
foundation.stage1-xz
];
};
phases = {
unpack = ''
tar xf ${config.src}
cd linux-${config.version}
'';
build = ''
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.target.linux.arch} headers
'';
install = ''
find usr/include -name '.*' -exec rm {} +
mkdir -p $out
cp -rv usr/include $out/
'';
};
};
}