Compare commits

..

4 commits

100 changed files with 2406 additions and 2542 deletions

View file

@ -27,4 +27,4 @@ may collaborate.
| Name | Phase | Description |
| ------------------------------ | --------- | ------------------------------------------------------------------------------------ |
| [Aux Tidepool](./tidepool) | Iteration | An initial package set built on top of Aux Foundation using Aux Lib's module system. |
| [Aux Tidepool](./tidepool) | Idea | An initial package set built on top of Aux Foundation using Aux Lib's module system. |

View file

@ -1,13 +1,10 @@
# Aux Tidepool
Aux Tidepool is an initial package set built on top of [Aux Foundation][foundation]. Packages
are created and managed using [Aux Lib][lib]'s module system to allow for highly dynamic and
Aux Tidepool is an initial package set built on top of [Aux Foundation](../foundation). Packages
are created and managed using [Aux Lib](../lib)'s module system to allow for highly dynamic and
extensible configuration.
[foundation]: https://git.auxolotl.org/auxolotl/foundation
[lib]: https://git.auxolotl.org/auxolotl/lib
## Installation
## Usage
Packages can be imported both with and without Nix Flakes. To import them using Nix Flakes,
add this repository as an input.
@ -29,174 +26,3 @@ let
in
# ...
```
## Usage
To build a package, you can run the following command inside of the `tidepool` directory:
```console
nix-build -A packages.foundation.bash.latest.packages.x86_64-linux.x86_64-linux.package
```
If you have `nix-command` experimental feature enabled, you can v3 CLI instead:
```console
nix build -f . packages.foundation.bash.latest.packages.x86_64-linux.x86_64-linux.package
```
Using flakes, the difference is only in calling:
```console
nix build .#packages.foundation.bash.latest.packages.x86_64-linux.x86_64-linux.package
```
This interface is verbose, but stable. We are still working out the details for
a friendlier interface!
The full command syntax looks like this:
```console
nix-build -A packages.${package-set}.${package}.${version}.packages.${build}.${host}.package
```
Tidepool packages can have multiple versions available. Tidepool also provides aliases
for convenience, currently "stable" and "latest". Aliases go directly after `${package}`:
```console
nix-build -A packages.${package-set}.${package}.${alias}.packages.${build}.${host}.package
```
The actual available versions live one level deeper, under `versions` namespace:
```console
nix-build -A packages.${package-set}.${package}.versions.${version}.packages.${build}.${host}.package
```
Here are a few practical examples for Tidepool. We can use a specific Bash version:
```console
nix-build -A packages.foundation.bash.versions."5.2.15-stage1".packages.x86_64-linux.x86_64-linux.package
```
Get Bash cross-compiled from `i686-linux` to `x86_64-linux`:
```console
nix build .#packages.foundation.bash.latest.packages.i686-linux.x86_64-linux.package
```
Or a native `aarch64-linux` Bash:
```console
nix build .#packages.foundation.bash.latest.packages.aarch64-linux.aarch64-linux.package
```
Running this command will:
- Bootstrap `i686-linux` `gcc` using Foundation
- Incrementally bootstrap `x86_64-linux` `gcc`
- Incrementally bootstrap `aarch64-linux` `gcc` from `x86_64-linux` `gcc`
- Build the native `aarch64-linux` `gcc`
- Build the native `aarch64-linux` `bash`
It's very early in Tidepool's development, and this syntax and UX is expected to change! For now,
the only syntax available is this developer-facing style. You can expect improvements to be made!
## Development
Tidepool is built with Aux's portable submodules. They function similarly to submodules used by NixOS.
Using the submodules, Tidepool provides a nice and easy-to-work-with API.
Tidepool can be used with flakes or without them. The solution we recommend
for non-flake usage is [npins](https://github.com/andir/npins).
Tidepool exports an attribute set, which can be viewed using `nix repl`.
We can visualize it!
```console
tidepool
├───builders
├───lib
├───mirrors
├───packages
│ ├───aux
│ │ ├───a
│ │ ├───b
│ │ └───c
│ ├───foundation
│ │ ├───bash
│ │ ├─── ...
│ │ └───zlib
│ ├───context
│ │ └─── ...
│ └───...
├───extend
├───internal
├───new
└───preferences
```
There are 4 outputs that share the name with folders under `src/`:
- `builders` - this is a set of Tidepool builders
- `lib` - this is the Tidepool library. It defines some nice-to-haves
for packaging
- `mirrors` - this is set of mirrors. Many projects, like GNU, provide
many mirrors - you can change a mirror to the one your prefer
- `packages` - this is a set for all of the Tidepool packages
You may learn more about those attributes in their corresponding folders.
Additionally, there are several other attributes, which don't have
corresponding folders:
- `extend` - this is a function to extend Tidepool's package set by providing
additional package modules. Here's how to use it:
```nix
let
tidepool = import ./tidepool;
in
tidepool.extend {
modules = [
# Put additional modules you want to include here.
];
}
```
- `internal` - this is the internal attribute set. Currently, it only brings Tidepool's
dependencies into scope: more concretely, it exposes the `foundation` namespace from
the (perhaps confusingly-named) [Foundation](https://git.auxolotl.org/auxolotl/foundation)
repository, which does the bootstrap chain from a 357-byte file. It is not the same
as Tidepool's `foundation` namespace, which makes those early-bootstrap packages integrate
with Tidepool (e.g., enabling cross-compilation)
- `new` - this is a function that allows to create a new empty package set.
It allows you to create a package set from scratch. Using this function,
you will get access to Tidepool library functions and the interface for defining
your own builders (but you don't get builder implementations). Here's how to use it:
```nix
let
tidepool = import ./tidepool;
module = { config }: {
config = {
# Create a new package set from scratch, no packages exist unless you define them.
};
};
in
tidepool.new module;
```
- `preferences` - this is an attribute set that lists your preferences for the package sets.
It has the following shape:
```nix
{
packages = {
allow = {
broken = false;
incompatible = false;
};
version = "latest";
};
}
```

View file

@ -28,8 +28,7 @@ let
};
};
new =
module:
new = module:
let
set = lib.modules.run {
modules = [
@ -38,17 +37,14 @@ let
./src/mirrors
recursiveLibModule
]
++ lib.lists.from.any module;
] ++ lib.lists.from.any module;
};
in
set.config
// {
inherit new;
inherit (set) extend;
};
set.config // {
inherit new;
inherit (set) extend;
};
in
new [
./src/packages
./src/builders/foundation/basic.nix
]
new [
./src/packages
]

View file

@ -8,9 +8,9 @@
},
"branch": "main",
"submodules": false,
"revision": "187b21870e60c650fb7f08c00b99e6f648c53198",
"revision": "ec6ba877756d3b898c75bdf8f75faff671fb3dbb",
"url": null,
"hash": "sha256-UZpbkervrxpUHgIEDHExevG7Aza36vjLMZFagzTJqLA="
"hash": "sha256-wCnUEFuFu1YKo2iE/kZeEpg3G8sCWeijuHXHTctKpJQ="
},
"lib": {
"type": "Git",
@ -20,9 +20,9 @@
},
"branch": "main",
"submodules": false,
"revision": "2af4e9f1d5dfe835c0eba15be1035bfa4065aca7",
"revision": "c55943c5e8197cbc2d0e506693fd5e7e3ea0a0c3",
"url": null,
"hash": "sha256-fwycuhXJGDHniLlxA8Xx4IELUObrP0EW3EnsDwNdyoQ="
"hash": "sha256-XBhIQ0XR1QabTgyo2c5wMk6xk/Bd3bCUlnTzRPcVfcw="
}
},
"version": 6

View file

@ -8,7 +8,7 @@ let
pretty = lib.generators.pretty { };
in
{
config.builders.foundation.basic = {
config.builders.basic = {
build =
package:
let
@ -25,8 +25,12 @@ in
phasesWithHooks =
let
all = lib.lists.flatten [
hooks.build
hooks.host
hooks.build.build
hooks.build.host
hooks.build.target
hooks.host.host
hooks.host.target
hooks.target.target
];
in
builtins.foldl' (
@ -47,59 +51,57 @@ in
sorted = lib.dag.sort.topological phases;
script = lib.strings.concatMapSep "\n" (entry: ''
# Phase: ${entry.name}
# ====================================================
if [[ -v NIX_LOG_FD ]]; then
# Sends a JSON command to the Nix build daemon, which sets the phase of the build allowing
# nix-output-monitor to display the phase properly.
# https://github.com/NixOS/nix/blob/1a9ba0d6fe7b6c05e8bbe1c59ead420759b631cc/src/libutil/logging.cc#L441
echo '@nix { "action": "setPhase", "phase": "${entry.name}" }' >&"$NIX_LOG_FD"
fi
${entry.value}
'') sorted.result;
script = lib.strings.concatMapSep "\n" (entry: entry.value) sorted.result;
executable =
if system == "i686-linux" then
"${foundation.stage2-bash}/bin/bash"
else if system == "x86_64-linux" then
"${
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system).package
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system system)
.package
}/bin/bash"
else
"${
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system).package
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system system)
.package
}/bin/bash";
built = builtins.derivation (
package.vars
package.env
// {
inherit (package) name env;
inherit (package) name;
inherit script system;
__structuredAttrs = true;
outputs = builtins.attrNames (lib.packages.getOutputs package);
passAsFile = [ "script" ];
SHELL = executable;
PATH =
let
bins = lib.paths.bin (
(lib.packages.dependencies.get dependencies.build)
++ (lib.packages.dependencies.get dependencies.host)
(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.host)
++ (lib.packages.dependencies.get dependencies.host.target)
++ (lib.packages.dependencies.get dependencies.target.target)
++ lib.lists.when (system == "i686-linux") [
foundation.stage2-bash
foundation.stage2-coreutils
]
++ lib.lists.when (system == "x86_64-linux") [
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system).package
(lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "i686-linux" system).package
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system system)
.package
(lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "i686-linux" system system)
.package
]
++ lib.lists.when (system != "i686-linux" && system != "x86_64-linux") [
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system).package
(lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "x86_64-linux" system)
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system system)
.package
(lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "x86_64-linux" system
system
).package
]
);
in
@ -112,28 +114,8 @@ in
args = [
"-e"
(builtins.toFile "bash-builder.sh" ''
set -eEuo pipefail
if [[ -e $NIX_ATTRS_SH_FILE ]]; then
source "$NIX_ATTRS_SH_FILE";
else
echo "Failed to find structuredAttrs"
exit 1
fi
export CONFIG_SHELL=$SHELL
# With structuredAttrs each output var must be exported manually
for outputName in "''${!outputs[@]}"; do
# Need to set $out=/nix/store...
export "$outputName=''${outputs[$outputName]}"
done
# Also need to export vars
for envVar in "''${!env[@]}"; do
export "$envVar=''${env[$envVar]}"
done
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
# means that we're supposed to try and auto-detect the number of
# available CPU cores at run-time.
@ -144,7 +126,7 @@ in
fi
export NIX_BUILD_CORES
eval "$script"
bash -eux $scriptPath
'')
];
}
@ -177,7 +159,7 @@ in
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` and `host`.
such as `build.build` and `build.host`.
'';
};
}

View file

@ -4,13 +4,14 @@ let
in
{
includes = [
./foundation
./basic.nix
./passthrough.nix
];
options = {
builders = lib.options.create {
description = "A set of builders that can be used to build packages.";
type = lib.types.attrs.of (lib.types.attrs.of lib.types.builder);
type = lib.types.attrs.of lib.types.builder;
default.value = { };
};
};

View file

@ -1,9 +0,0 @@
{
includes = [
# We explicitly don't include `basic` here to let users create package sets which do not
# include anything from `packages.foundation`.
# ./basic.nix
./passthrough.nix
];
}

View file

@ -1,29 +0,0 @@
{ config }:
let
cfg = config.builders.passthrough;
inherit (config) lib;
inherit (config.internal.packages) foundation;
in
{
config.builders.foundation.passthrough =
{ config }:
{
options = {
settings.derivation = lib.options.create {
description = "The derivation to use for the package.";
type = lib.types.derivation;
};
};
config = {
build =
package:
package.builder.settings.derivation
// {
inherit package;
inherit (package) meta extend extras;
};
};
};
}

View file

@ -0,0 +1,27 @@
{ config }:
let
cfg = config.builders.passthrough;
inherit (config) lib;
inherit (config.internal.packages) foundation;
in
{
config.builders.passthrough = { config }: {
options = {
settings.derivation = lib.options.create {
description = "The derivation to use for the package.";
type = lib.types.derivation;
};
};
config = {
build =
package:
package.builder.settings.derivation
// {
inherit package;
inherit (package) meta extend extras;
};
};
};
}

View file

@ -1,10 +1,9 @@
{
includes = [
./fetchurl.nix
./options.nix
./packages.nix
./platforms.nix
./systems.nix
./types.nix
./fp.nix
];
}

View file

@ -1,73 +0,0 @@
{
config = {
# This function is a vendored version of <nix/fetchurl.nix>. It uses the (largely undocumented) builtin:fetchurl
# builder for derivations to give us a way to download files (eg. source tarballs) in the early bootstrap phase,
# before we have access to tools like curl. It functions almost identically to the builtins.fetchurl function,
# except it downloads files during the derivation's build, instead of during Nix evaluation, preventing evaluation
# from being blocked by downloads.
#
# Most packages should avoid using this function, and instead prefer using builders to download sources, such as
# (TODO: create these).
#
# Original source: https://git.lix.systems/lix-project/lix/src/commit/6599be1a9f76f0fba2a6905ea85235aeb7b7eae9/lix/libexpr/fetchurl.nix
lib.fetchurl =
{
# URL of file to download
url,
# SRI hash of downloaded file
hash ? "",
# Legacy, base32-encoded hash specifications
md5 ? "",
sha1 ? "",
sha256 ? "",
sha512 ? "",
outputHash ?
if hash != "" then
hash
else if sha512 != "" then
sha512
else if sha1 != "" then
sha1
else if md5 != "" then
md5
else
sha256,
outputHashAlgo ?
if hash != "" then
""
else if sha512 != "" then
"sha512"
else if sha1 != "" then
"sha1"
else if md5 != "" then
"md5"
else
"sha256",
name ? baseNameOf url,
# Make the downloaded file executable (ie. chmod 755)
executable ? false,
# If the downloaded file is an archive, extract it before adding to the store
# NOTE: Only appears to unpack .xz archives?
unpack ? false,
}:
builtins.derivation {
inherit
name
url
executable
unpack
;
builder = "builtin:fetchurl";
system = "builtin";
preferLocalBuild = true;
inherit outputHashAlgo outputHash;
outputHashMode = if unpack || executable then "recursive" else "flat";
urls = [ url ];
};
};
}

14
tidepool/src/lib/fp.nix Normal file
View file

@ -0,0 +1,14 @@
{ lib, config }:
{
config = {
lib.fp = {
foldl =
f: default: items:
let
process =
index: if index < 0 then default else f (process (index - 1)) (builtins.elemAt items index);
in
process (builtins.length items - 1);
};
};
}

View file

@ -15,7 +15,8 @@ in
builtins.map (dependency: dependency.package) available;
build =
build: host: builtins.mapAttrs (name: dep: (lib.packages.resolve dep).packages.${build}.${host});
build: host: target:
builtins.mapAttrs (name: dep: dep.packages.${build}.${host}.${target});
collect =
package:
@ -27,28 +28,53 @@ in
dependencies:
let
getDeps =
name: dep:
name: dependency:
let
dependency = lib.packages.resolve dep;
deps = {
build = getPropagatedDependencies dependency.deps.build ++ process dependency.deps.build;
host = getPropagatedDependencies dependency.deps.host ++ process dependency.deps.host;
build = {
build =
getPropagatedDependencies dependency.deps.build.build ++ process dependency.deps.build.build;
host = getPropagatedDependencies dependency.deps.build.host ++ process dependency.deps.build.host;
target =
getPropagatedDependencies dependency.deps.build.target ++ process dependency.deps.build.target;
};
host = {
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
target =
getPropagatedDependencies dependency.deps.host.target ++ process dependency.deps.host.target;
};
target = {
target =
getPropagatedDependencies dependency.deps.target.target ++ process dependency.deps.target.target;
};
};
in
lib.lists.flatten [
deps.build
deps.host
deps.build.build
deps.build.host
deps.build.target
deps.host.host
deps.host.target
deps.target.target
];
propagated = lib.attrs.mapToList getDeps dependencies;
in
lib.lists.flatten propagated;
withoutNulls = deps: builtins.filter (dep: dep != null) deps;
in
{
build = withoutNulls (builtins.attrValues package.deps.build ++ process package.deps.build);
host = withoutNulls (builtins.attrValues package.deps.host ++ process package.deps.host);
build = {
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 = {
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 = {
target = builtins.attrValues package.deps.target.target ++ process package.deps.target.target;
};
};
};
@ -57,19 +83,16 @@ in
package: collected: ctx:
let
process =
path: deps:
path:
let
dependencies = lib.lists.flatten deps;
dependencies = lib.attrs.selectOrThrow path collected;
contexts = builtins.map (dependency: dependency.context or { }) dependencies;
result = lib.modules.run {
args = {
global = global.config;
};
prefix = package.__module__.args.dynamic.meta.prefix ++ [
"<context ${path}>"
];
prefix = package.__module__.args.dynamic.meta.prefix ++ [ "<context ${builtins.concatStringsSep path}>" ];
modules = (builtins.map (context: { config = context; }) contexts) ++ [
{
freeform = lib.types.any;
@ -78,11 +101,22 @@ in
target = lib.options.create {
description = "The dependency target that is being generated.";
type = lib.types.enum [
"build"
"host"
"build.build"
"build.host"
"build.target"
"host.host"
"host.target"
"target.target"
];
writable = false;
default.value = path;
default.value = builtins.concatStringsSep "." path;
};
deps = lib.options.create {
description = "The collected dependencies.";
writable = false;
default.value = collected;
type = lib.types.dependencies;
};
};
@ -92,39 +126,38 @@ in
};
in
result.config;
build = process "build" [
collected.build
];
host = process "host" [
collected.host
];
in
build
// host
// {
inherit
build
host
package
;
deps = collected;
__toString =
value:
let
all = builtins.mapAttrs (host: deps: builtins.map (dep: dep.package) deps) collected;
in
builtins.toJSON (
builtins.removeAttrs value [
"deps"
"__toString"
]
// {
deps = all;
}
);
{
build = {
build = process [
"build"
"build"
];
host = process [
"build"
"host"
];
target = process [
"build"
"target"
];
};
host = {
host = process [
"host"
"host"
];
target = process [
"host"
"target"
];
};
target = {
target = process [
"target"
"target"
];
};
};
};
@ -143,12 +176,36 @@ in
hooks;
in
{
build = process [
"build"
];
host = process [
"host"
];
build = {
build = process [
"build"
"build"
];
host = process [
"build"
"host"
];
target = process [
"build"
"target"
];
};
host = {
host = process [
"host"
"host"
];
target = process [
"host"
"target"
];
};
target = {
target = process [
"target"
"target"
];
};
};
};
@ -160,39 +217,16 @@ in
in
builtins.head sorted;
getOutputs =
alias:
let
package = lib.packages.resolve alias;
outputs =
if builtins.isList package.outputs then
lib.attrs.generate package.outputs (output: package.package.${output})
else
package.outputs;
in
outputs;
WELL_KNOWN_ALIASES = [
# NOTE: When adding a version alias here, update lib.types.alias and lib.types.platforms' alias sub-option
"stable"
"latest"
];
resolve =
alias:
let
prefered = config.preferences.packages.version;
isWellKnown = builtins.elem prefered lib.packages.WELL_KNOWN_ALIASES;
in
if isWellKnown && alias ? ${prefered} then
alias.${prefered}
else if alias ? versions then
alias.versions.${prefered} or (alias.versions.${lib.packages.getLatest alias})
if alias ? versions then
alias.versions.${config.preferences.packages.version}
or (alias.versions.${lib.packages.getLatest alias})
else
alias;
build =
alias: build: host:
alias: build: host: target:
let
package = lib.packages.resolve alias;
@ -206,34 +240,36 @@ in
buildSystem = lib.systems.withBuildInfo build;
hostSystem = lib.systems.withBuildInfo host;
targetSystem = lib.systems.withBuildInfo target;
platform = {
build = lib.modules.override 75 build;
host = lib.modules.override 75 host;
target = lib.modules.override 75 target;
};
built = package.extendTemporarily {
inherit platform;
};
support = lib.packages.supports package buildSystem.double hostSystem.double;
support = lib.packages.supports package buildSystem.double hostSystem.double targetSystem.double;
result =
if !support.compatible then
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` does not support the platform build=${buildSystem.double}, host=${hostSystem.double}"
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
built;
in
builtins.addErrorContext "📦 [Aux Tidepool] while building package `${identifier}` for platform build=${buildSystem.double}, host=${hostSystem.double}" result;
builtins.addErrorContext "📦 [Aux Tidepool] while building package `${identifier}` for platform build=${buildSystem.double}, host=${hostSystem.double}, target=${targetSystem.double}." result;
supports =
alias: build: host:
alias: build: host: target:
let
package = lib.packages.resolve alias;
matches = builtins.filter (
platform: platform.build == build && platform.host == host
platform: platform.build == build && platform.host == host && platform.target == target
) package.platforms;
in
{

View file

@ -1,74 +0,0 @@
{ config }:
let
inherit (config) lib;
in
{
config.lib.platforms = {
from = {
# Converts a platform spec into a list of platforms.
#
# Example specs:
#
# {
# build = "x86_64-linux";
# host = "x86_64-linux";
# }
#
# {
# build = "*";
# host = "*";
# }
#
# {
# build = "*";
# host = ["x86_64-linux", "aarch64-linux"];
# }
#
# [
# {
# build = "*";
# host = ["x86_64-linux", "aarch64-linux"];
# }
# {
# build = "i686-linux";
# host = "@build";
# }
# ]
#
spec =
input:
let
specs = lib.lists.from.any input;
platforms = lib.lists.flatten (
builtins.map (
spec:
let
build = lib.platforms.expand spec spec.build;
host = lib.platforms.expand spec spec.host;
in
builtins.concatMap (
build:
builtins.map (host: {
build = build;
host = if host == "@build" then build else host;
}) host
) build
) specs
);
in
platforms;
};
expand =
spec: value:
if builtins.isList value then
builtins.concatMap (system: lib.platforms.expand spec system) value
else if value == "@build" || value == "@host" then
[ value ]
else if lib.strings.hasPrefix "@" value then
lib.systems.doubles.${lib.strings.removePrefix "@" value}
else
[ value ];
};
}

View file

@ -25,8 +25,7 @@ let
lib.attrs.match patterns;
getDoubles =
predicate:
builtins.map lib.systems.into.double (builtins.filter predicate lib.systems.doubles.resolved);
predicate: builtins.map lib.systems.into.double (builtins.filter predicate lib.systems.doubles.all);
in
{
config = {
@ -1049,7 +1048,7 @@ in
compatible =
a: b:
builtins.any lib.fp.id [
lib.any lib.id [
# x86
(b == lib.systems.types.cpus.i386 && lib.systems.validate.compatible a lib.systems.types.cpus.i486)
(b == lib.systems.types.cpus.i486 && lib.systems.validate.compatible a lib.systems.types.cpus.i586)
@ -2789,7 +2788,11 @@ in
// (builtins.removeAttrs settings [ "system" ]);
assertions = builtins.foldl' (
result: { assertion, message }: if assertion resolved then result else builtins.throw message
result:
{ assertion, message }:
if assertion resolved then
result
else builtins.throw message
) true (resolved.system.abi.assertions or [ ]);
in
assert resolved.useAndroidPrebuilt -> resolved.isAndroid;

View file

@ -2,101 +2,30 @@
let
inherit (config) lib;
# Essentially black-listed environment variable names
#
# This is just a list of attributes based into builtins.derivation in
# tidepool/src/builders/foundation/basic.nix
#
# Please keep it in sync
reservedVars = [
"name"
"script"
"system"
"script"
"env"
"__structuredAttrs"
"SHELL"
"builder"
"args"
];
# str -> bool
notReservedVar = name: !(builtins.elem name reservedVars);
pretty = lib.generators.pretty { };
in
{
config = {
lib.types = {
# When passed-down to Bash, paths and derivations are just strings.
bashString =
(lib.types.one [
lib.types.string
lib.types.path
lib.types.derivation
])
// {
name = "BashString";
description = "A Bash-compatible string";
};
# Lists in Bash cannot be nested, just hold numbers and strings.
bashList =
(lib.types.list.of (
lib.types.one [
lib.types.number
lib.types.bashString
]
))
// {
name = "BashList";
description = "A bash-compatible list";
};
# Hashmaps/attrset/associated lists in Bash cannot be nested or hold lists. They just map
# strings to numbers or strings to strings.
bashMap =
(lib.types.attrs.of (
lib.types.one [
lib.types.number
lib.types.bashString
]
))
// {
name = "BashMap";
description = "A bash-compatible attrset/associated list";
};
# Any arbitrary Bash variable
bashVar =
(lib.types.one [
lib.types.number
lib.types.bashString
lib.types.bashList
lib.types.bashMap
])
// {
name = "BashVar";
description = "A bash-compatible variable";
};
license =
let
type = lib.types.submodule (
{ config }:
{
options = {
name = {
full = lib.options.create {
description = "The full name of the license.";
type = lib.types.string;
};
name = lib.options.create {
description = "The short name of the license.";
type = lib.types.string;
short = lib.options.create {
description = "The short name of the license.";
type = lib.types.string;
};
};
fullName = lib.options.create {
description = "The full name of the license.";
type = lib.types.string;
};
spdxId = lib.options.create {
spdx = lib.options.create {
description = "The SPDX identifier for the license.";
type = lib.types.nullish lib.types.string;
default.value = null;
@ -104,11 +33,7 @@ in
url = lib.options.create {
description = "The URL for the license.";
type = lib.types.string;
default = {
text = "spdx.org entry, if `spdxId` is set, `null` otherwise";
value = if config.spdxId == null then null else "https://spdx.org/licenses/${config.spdxId}.html";
};
type = lib.types.nullish lib.types.string;
};
free = lib.options.create {
@ -135,14 +60,41 @@ in
options = global.config.packages.context.options;
};
settings = lib.types.submodule {
options = global.config.packages.settings.options;
};
platform =
lib.types.coerce lib.types.string lib.systems.withBuildInfo
lib.systems.types.platformWithBuildInfo;
# builder = lib.types.submodules.portable {
# name = "Builder";
# module = (
# { config, name ? "builder" }:
# {
# freeform = lib.types.any;
#
# options = {
# name = lib.options.create {
# description = "The name of the builder.";
# type = lib.types.string;
# default = lib.attrs.when (name != "builder") {
# value = name;
# };
# writable = false;
# };
#
# build = lib.options.create {
# description = "The build function which takes a package definition and creates a derivation.";
# type = lib.types.function lib.types.artifact;
# };
#
# settings = lib.options.create {
# description = "The settings for the builder.";
# type = lib.types.submodule ({ config }: {});
# default.value = { };
# };
# };
# }
# );
# };
builder =
let
normalize =
@ -220,91 +172,84 @@ in
result.config;
};
submodule =
{
config,
meta,
name ? "builder",
}:
{
options = {
__modules__ = lib.options.create {
description = "User specified modules for the builder definition.";
type = lib.types.list.of (initial // { merge = lib.options.merge.one; });
internal = true;
default.value = [ ];
};
submodule = { config, meta, name ? "builder" }: {
options = {
__modules__ = lib.options.create {
description = "User specified modules for the builder definition.";
type = lib.types.list.of (initial // { merge = lib.options.merge.one; });
internal = true;
default.value = [ ];
};
extend = lib.options.create {
description = "Extend the package definition.";
type = lib.types.function lib.types.raw;
default.value =
module:
let
normalized =
if builtins.isList module then
module
else if builtins.isFunction module || module ? config then
[ module ]
else
[
{
config = module;
}
];
extend = lib.options.create {
description = "Extend the package definition.";
type = lib.types.function lib.types.raw;
default.value =
module:
let
normalized =
if builtins.isList module then
module
else if builtins.isFunction module || module ? config then
[ module ]
else
[
{
config = module;
}
];
modules = config.__modules__ ++ normalized;
modules = config.__modules__ ++ normalized;
result = lib.modules.run {
prefix = meta.prefix;
result = lib.modules.run {
prefix = meta.prefix;
args = {
global = global.config;
};
modules = [
submodule
{ config.__modules__ = modules; }
]
++ modules;
args = {
global = global.config;
};
in
result.config;
};
name = lib.options.create {
description = "The name of the builder.";
type = lib.types.string;
default = lib.attrs.when (name != "builder") {
value = name;
};
writable = false;
};
modules = [
submodule
{ config.__modules__ = modules; }
]
++ modules;
};
in
result.config;
};
build = lib.options.create {
description = "The build function which takes a package definition and creates a derivation.";
type = lib.types.function lib.types.artifact;
name = lib.options.create {
description = "The name of the builder.";
type = lib.types.string;
default = lib.attrs.when (name != "builder") {
value = name;
};
writable = false;
};
settings = lib.options.create {
description = "The settings for the builder.";
type = lib.types.submodule ({ config }: { });
default.value = { };
};
build = lib.options.create {
description = "The build function which takes a package definition and creates a derivation.";
type = lib.types.function lib.types.artifact;
};
settings = lib.options.create {
description = "The settings for the builder.";
type = lib.types.submodule ({ config }: {});
default.value = { };
};
};
};
type = (lib.types.coerceWithLocation initial transform final) // {
name = "Builder";
description = "a builder";
};
in
type
// {
children = type.children // {
inherit submodule;
type // {
children = type.children // {
inherit submodule;
};
};
};
aliases =
let
@ -365,7 +310,8 @@ in
platforms = {
build = lib.types.attrs.of lib.types.platforms.host;
host = lib.types.attrs.of lib.types.platforms.host;
host = lib.types.attrs.of lib.types.platforms.target;
target = lib.types.attrs.of (lib.types.attrs.of lib.types.platforms.alias);
alias = lib.types.submodule {
options = {
stable = lib.options.create {
@ -378,7 +324,6 @@ in
type = lib.types.artifact;
default.value = null;
};
# NOTE: When adding a version alias here, update lib.packages.WELL_KNOWN_ALIASES
versions = lib.options.create {
description = "Available versions of the artifact.";
type = lib.types.attrs.of lib.types.artifact;
@ -386,25 +331,6 @@ in
};
};
};
spec = lib.types.submodule (
{ config }:
{
options = {
build = lib.options.create {
description = "The build platform for the package.";
type = lib.types.string;
default.value = "@all";
};
host = lib.options.create {
description = "The host platform for the package.";
type = lib.types.string;
default.value = "@build";
};
};
}
);
};
artifact =
@ -467,8 +393,6 @@ in
if config.versions == { } then null else config.versions.${lib.packages.getLatest config};
};
# NOTE: When adding a version alias here, update lib.packages.WELL_KNOWN_ALIASES
versions = lib.options.create {
description = "Available versions of the package.";
type = lib.types.attrs.of lib.types.package;
@ -556,18 +480,49 @@ in
};
deps =
build: host:
build: host: target:
lib.types.submodule {
options = {
build = lib.options.create {
description = "Dependencies which are executed in the build environment.";
type = lib.types.dependencies;
default.value = { };
build = {
build = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the build environment.";
type = lib.types.dependencies;
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;
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;
default.value = { };
};
};
host = lib.options.create {
description = "Dependencies which are executed in the host environment.";
type = lib.types.dependencies;
default.value = { };
host = {
host = lib.options.create {
description = "Dependencies which are executed in the host environment.";
type = lib.types.dependencies;
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;
default.value = { };
};
};
target = {
target = lib.options.create {
description = "Dependencies which are executed in the target environment.";
type = lib.types.dependencies;
default.value = { };
};
};
};
};
@ -580,6 +535,7 @@ in
let
build = config.platform.build;
host = config.platform.host;
target = config.platform.target;
in
{
options = {
@ -592,10 +548,10 @@ in
__toString = lib.options.create {
description = "The derivation of the package as a string.";
type = lib.types.function lib.types.string;
type = lib.types.string;
internal = true;
writable = false;
default.value = value: builtins.toString value.package;
default.value = builtins.toString config.package;
};
extend = lib.options.create {
@ -740,9 +696,30 @@ in
platforms = lib.options.create {
description = "The platforms that the package supports.";
type = lib.types.either lib.types.platforms.spec (lib.types.list.of lib.types.platforms.spec);
type = lib.types.list.of (
lib.types.submodule (
{ config }:
{
options = {
build = lib.options.create {
description = "The build platform for the package.";
type = lib.types.string;
};
host = lib.options.create {
description = "The host platform for the package.";
type = lib.types.string;
};
target = lib.options.create {
description = "The target platform for the package.";
type = lib.types.string;
};
};
}
)
);
default.value = [ ];
apply = spec: lib.platforms.from.spec spec;
};
platform =
@ -761,6 +738,12 @@ in
type = lib.types.string;
default.value = initial.host or "x86_64-linux";
};
target = lib.options.create {
description = "The target platform for the package.";
type = lib.types.string;
default.value = initial.target or "x86_64-linux";
};
};
name = lib.options.create {
@ -795,6 +778,76 @@ in
type = lib.types.builder;
};
# builder = lib.options.create {
# description = "The builder for the package.";
# type =
# 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.options.getIdentifier [
# "builders"
# value.name
# ]
# }` for `${
# lib.options.getIdentifier [
# "packages"
# config.namespace
# config.id
# "versions"
# config.version
# ]
# }` is used but not defined."
# else
# value ? name && value ? build
# );
#
# transform =
# value:
# if value ? settings.__type__ then
# value
# // {
# settings = { };
# }
# else
# value;
#
# final = lib.types.withCheck lib.types.raw (
# 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 `${
# lib.options.getIdentifier [
# "packages"
# config.namespace
# config.id
# "versions"
# config.version
# "builder"
# "settings"
# name
# ]
# }` is not of type ${option.type.description}."
# ) builder.settings;
# checked = builtins.foldl' (acc: result: builtins.seq result acc) true results;
# in
# if value ? settings.__type__ then false else checked
# );
#
# coerced = lib.types.coerce initial transform final;
# in
# coerced;
# };
src = lib.options.create {
description = "The source for the package.";
type =
@ -806,54 +859,13 @@ in
]
);
in
lib.types.either type (lib.types.attrs.of type);
lib.types.either type (lib.types.attrs.of type);
default.value = null;
};
outputs = lib.options.create {
description = "The outputs for the package.";
type =
let
initial = lib.types.attrs.of lib.types.derivation;
transform = builtins.attrNames;
final = lib.types.list.of lib.types.string;
in
lib.types.coerce initial transform final;
default.value = [ "out" ];
apply = outputs: lib.attrs.generate outputs (output: config.package.${output});
};
env = lib.options.create {
description = "Environment variables in the derivation";
type = lib.types.withCheck (lib.types.attrs.of lib.types.bashString) (
# TODO: Better errors, these suck right now.
lib.fp.pipe [
builtins.attrNames
(builtins.all notReservedVar)
]
);
default.value = { };
};
# TOTHINK: Currently this only validates for Bash variables.
# In the future we could/should allow users to have JSON exports
# as well, which have relaxes requirements compared to Bash.
#
# Either relaxing this var, or adding another var.
vars = lib.options.create {
description = "Bash variables set in the derivation";
type = lib.types.withCheck (lib.types.attrs.of lib.types.bashVar) (
lib.fp.pipe [
# TODO: Better errors, these suck right now.
builtins.attrNames
# Cannot be a reservd name, and cannot be an environment variable
(builtins.all (
name: (notReservedVar name) && !(builtins.elem name (builtins.attrNames config.env))
))
]
);
description = "The environment for the package.";
type = lib.types.attrs.of lib.types.string;
default.value = { };
};
@ -868,28 +880,26 @@ in
type = lib.types.raw;
writable = false;
default.value = lib.attrs.generate lib.systems.doubles.all (
build: lib.attrs.generate lib.systems.doubles.all (host: lib.packages.build config build host)
build:
lib.attrs.generate lib.systems.doubles.all (
host:
lib.attrs.generate lib.systems.doubles.all (target: lib.packages.build config build host target)
)
);
};
phases = lib.options.create {
description = "The phases for the package.";
type = lib.types.either (lib.types.dag.of lib.types.string) (
lib.types.function (lib.types.dag.of lib.types.string)
lib.types.function lib.types.dag.of lib.types.string
);
default.value = { };
};
context = lib.options.create {
description = "The context information that the package provides.";
default.value = { };
type = lib.types.context;
default.value = { };
};
settings = lib.options.create {
description = "The settings for the package.";
type = lib.types.settings;
default.value = { };
};
hooks = lib.options.create {
@ -906,11 +916,21 @@ in
deps = lib.options.create {
description = "The dependencies for the package.";
type = deps build host;
type = deps build host target;
default.value = { };
apply = value: {
build = lib.packages.dependencies.build build build value.build;
host = lib.packages.dependencies.build build host value.host;
build = {
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 = {
host = lib.packages.dependencies.build build host host value.host.host;
target = lib.packages.dependencies.build build host target value.host.target;
};
target = {
target = lib.packages.dependencies.build build target target value.target.target;
};
};
};
};

View file

@ -4,7 +4,7 @@
gnu = lib.options.create {
description = "The GNU mirror to use";
type = lib.types.string;
default.value = "https://ftpmirror.gnu.org/gnu";
default.value = "https://ftp.gnu.org/gnu";
};
};
}

View file

@ -1,99 +0,0 @@
# Packages
In this folder, the Tidepool package sets are stored.
## Foundation
The package set under `foundation` is a minimal set to start building everything
else. It provides a comprehensive set of packages that are
used to build all other basic Linux utilities, and are often transitive dependencies
of higher-level packages.
The goal of `foundation` is to build `gcc` and `glibc`,
as well as some supplementary packages, so that other packages can be built with
them. It also sets up a basic Linux environment: `coreutils`, `diffutils`, `bash`,
and other utilities you'd expect to find on a Linux distro.
To achieve this, we need a lot of other packages built, too! Some
examples include `python`, `xz` and `gzip`.
Lastly, `foundation` also includes `patchelf`, a simple C utility.
It is not used in `foundation`, but it is very useful for building
more high-level packages: in particular, it allows us to patch
binaries to point to our dependencies. This "unbreaks" proprietary
binaries by making them point to Tidepool-provided dependencies.
Neat!
The `foundation` package set builds upon and uses packages from [Foundation],
our early bootstrap chain. Since Aux Foundation only provides for
single-platform native builds, it augments the packages from Foundation with
Tidepool's cross-compilation capabilities, and adds additional flags
to compilers to better support our use case.
The packages in `foundation` are not intended for end user usage. They do not
integrate with the full scope of Tidepool's machinery, and provide no more than
necessary to bootstrap a cross-platform package set.
[Foundation]: https://git.auxolotl.org/auxolotl/foundation
## Core
`core`, and potentially other future namespaces, contains packages that
maximally integrate with the rest of Tidepool and are intended for end users.
This will include the "final" versions of the packages in the `foundation`
namespace as well as a wide variety of other tools. See
[`core/README.md`](core/README.md) for some further context.
## Aux
`aux`, at this time, is a trivial package set that demonstrates
the power of a fully-bootstrapped `foundation`. It consists of 3
trivial packages: `a`, `b` and `c`. The chain of dependencies
is like this (the arrow points to the **dependency**):
```
a -> b -> c
```
Package `a` merely depends on `b`.
Package `b` announces a build option `custom`. It sets up `context`
and sets up a hook after `unpack` phase. It also propagates dependency `c`.
It's worth discussing this in more depth, because it demonstrates a couple of
more advanced features.
`context` is information that the package provides when it is used as dependency,
which builders and hooks may use. For example, to use a C dependency, you
would need to tell the compiler where to look for relevant headers by appending
a flag. The C dependency can have `context` defined which includes the necessary
compiler flag, and the package that uses this dependency will append this flag
automatically.
[Nixpkgs](https://github.com/nixos/nixpkgs) uses a different approach to do this.
In Nixpkgs, packages include the `nix-support` subdirectory which contains the
same information as what `context` usually contains. Nixpkgs does this in
the builder code at build-time; Tidepool provides this information at eval time,
which provides the means to type-check the `context`.
Package `b` provides a `context` to include the necessary directory: `include` under
the Nix store path for package `b`. This Nix store path is provided as an environment
variable from a hook.
While Tidepool's architecture is subject to change, `context` already
has planned changes for it. When those changes happen - the information
about `context` will be moved to a historical design doc. But until then,
`context` is still relevant!
`hooks` provide extension points for packages. With `hooks`, you can inject arbitrary build
instructions between, before or after the default build stages. Package `b` does exactly
that: it uses a hook to add entry after `unpack` phase and before others, which exports
an environment variable that contains the Nix store path, that is then used for `context`.
Propagation ensures that the propagated dependency is also installed, when the package
is installed. Package `b` propagates dependency `c` - this means, when package `b` is
included as a dependency, package `c` is also included automatically. This is especially
useful when working with interpreted languages, such as Python - for them, all dependencies
need to be in a single scope, and propagation makes sure of that.
Package `c` doesn't have dependencies, but it is otherwise identical
to package `b`.

View file

@ -13,40 +13,31 @@ in
{
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.foundation.basic;
builder = builders.basic;
deps.host = {
deps.host.host = {
inherit (packages.aux) b;
};
phases =
ctx':
let
# break recursion on the derivation outPath itself
ctx = builtins.removeAttrs ctx' [ "package" ];
in
{
install = ''
echo "a with b: ${config.deps.host.b.platform.host}" > $out
echo >> $out
echo a=$out >> $out
echo b=$AUX_B >> $out
echo c=$AUX_C >> $out
echo >> $out
echo '${ctx}' >> $out
'';
};
phases = {
install = ''
echo "a with b: ${config.deps.host.host.b.platform.host.double}" > $out
'';
};
};
};
};

View file

@ -17,25 +17,30 @@ in
{
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.foundation.basic;
builder = builders.basic;
deps = {
build = {
c = packages.aux.c.extend {
propagate = true;
host = {
c = packages.aux.c.extend {
propagate = true;
};
};
};
};

View file

@ -17,24 +17,28 @@ in
{
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.foundation.basic;
builder = builders.basic;
context = {
"foundation:cflags" = [ "-I $AUX_C/include" ];

View file

@ -1,61 +0,0 @@
# Core Packages
The goal of Core packages is to build commonly required software in addition to a Nix
implementation (Lix).
## Lix
In order to build Lix, we first need to package its dependencies:
- `aws-sdk-cpp`
- `boehmgc`
- `boehmgc-nix`
- `boost`
- `brotli`
- `build-release-notes`
- `busybox-sandbox-shell`
- `bzip2`
- `capnproto`
- `cmake`
- `curl`
- `doxygen`
- `editline`
- `editline-lix`
- `git`
- `gtest`
- `gcc`
- `glibc`
- `binutils`
- `python` (with `python-frontmatter`, `pycapnp`)
- `jq`
- `libarchive`
- `libcpuid`
- `libseccomp`
- `libsystemtap`
- `lowdown`
- `lowdown-unsandboxed`
- `lsof`
- `mdbook`
- `mdbook-linkcheck`
- `mercurial`
- `meson`
- `ncurses`
- `ninja`
- `nlohmann_json`
- `openssl`
- `passt-lix`
- `pegtl`
- `pkg-config`
- `python3`
- `rapidcheck`
- `removeReferencesTo`
- `rustc`
- `rustPlatform`
- `sqlite`
- `systemtap-lix`
- `toml11`
- `toml11-lix`
- `util-linuxMinimal`
- `utillinuxMinimal`
- `xz`
- `yq`

View file

@ -1,5 +0,0 @@
{
includes = [
./lix
];
}

View file

@ -1,3 +0,0 @@
{
config.packages.lix.lix = { };
}

View file

@ -5,7 +5,6 @@ in
{
includes = [
./aux
./core
./foundation
];
@ -24,12 +23,6 @@ in
default.value = { };
type = lib.types.attrs.of lib.types.option;
};
settings.options = lib.options.create {
description = "The available settings for packages.";
default.value = { };
type = lib.types.attrs.of lib.types.option;
};
};
};
};
@ -37,7 +30,10 @@ in
preferences.packages = {
version = lib.options.create {
description = "The preferred package version when using aliases.";
type = lib.types.enum lib.packages.WELL_KNOWN_ALIASES;
type = lib.types.enum [
"latest"
"stable"
];
default.value = "latest";
};

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -13,9 +13,15 @@ in
main = "/bin/bash";
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-bash;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.bash.versions."5.2.15-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -31,12 +28,25 @@ in
main = "/bin/bash";
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -25,29 +27,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/bash/bash-${version}.tar.gz";
hash = "sha256-E3IJZbX0/DoNS2HdN+dWXHQdqaW+JO3CrgAYL8GzWIw=";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -59,8 +65,6 @@ in
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -73,14 +77,18 @@ in
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
host = {
host = {
coreutils = packages.foundation.coreutils.versions."9.4-stage1";
};
};
};
phases = {
@ -90,26 +98,15 @@ in
cd bash-${version}
'';
configure =
let
flags = builtins.concatStringsSep " " (
[
"--prefix=$out"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--enable-static-link"
]
++ lib.lists.when (config.platform.host == "i686-linux") [
"--without-bash-malloc"
]
);
in
''
# Configure
bash ./configure \
${flags} \
bash_cv_func_strtoimax=y
'';
configure = ''
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build.triple} \
--host=${platform.host.triple} \
--enable-static-link \
bash_cv_func_strtoimax=y \
'';
build = ''
# Build
@ -124,5 +121,6 @@ in
ln -s $out/bin/bash $out/bin/sh
'';
};
};
}

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-binutils;
};

View file

@ -5,47 +5,21 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.binutils.versions."2.41-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
inherit (config) settings;
};
in
{
options = {
settings = {
target = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
};
allTargets = lib.options.create {
description = "Include all targets (dramatically increases size of binaries).";
type = lib.types.bool;
default.value = false;
};
};
target = lib.options.create {
type = lib.types.raw;
default.value = lib.attrs.generate lib.systems.doubles.all (
target:
(config.extend { settings.target = target; })
.packages.${config.platform.build}.${config.platform.host}
);
};
};
config = {
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
@ -55,12 +29,23 @@ in
platforms = [
{
build = "@linux";
host = "@linux";
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,71 +7,57 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
isBuildBootstrapped = platform.build.double == "i686-linux";
isHostBootstrapped = platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross =
platform.build.double != platform.host.double && platform.host.double == platform.target.double;
version = lib.strings.removeSuffix "-stage1" config.version;
patches = [
../patches/2.41-deterministic.patch
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
configureFlags =
lib.lists.when (!isCross) [
"LDFLAGS=--static"
]
++ [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
"--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
"--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"
# 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=:"
# 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"
"--enable-64-bit-bfd"
]
++ lib.lists.when (config.settings.allTargets) [
"--enable-target=all"
]
++ lib.lists.when (config.settings.target != null) [
"--target=${(lib.systems.withBuildInfo config.settings.target).triple}"
];
"--disable-multilib"
];
in
{
options = {
settings = {
target = lib.options.create {
type = lib.types.nullish lib.types.string;
default.value = null;
};
allTargets = lib.options.create {
description = "Include all targets (dramatically increases size of binaries).";
type = lib.types.bool;
default.value = false;
};
};
target = lib.options.create {
type = lib.types.raw;
default.value = lib.attrs.generate lib.systems.doubles.all (
target:
(config.extend { settings.target = target; })
.packages.${config.platform.build}.${config.platform.host}
);
};
};
config = {
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
@ -82,27 +68,56 @@ 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";
}
{
build = "x86_64-linux";
host = "@linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "riscv64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/binutils/binutils-${version}.tar.xz";
hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -116,7 +131,6 @@ in
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
@ -132,14 +146,27 @@ in
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
bzip2 = packages.foundation.bzip2.versions."1.0.8-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// (lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
});
};
host = {
gcc =
if isBootstrapped then
packages.foundation.gcc.versions."13.2.0-bootstrap"
else if isCross then
packages.foundation.gcc.versions."13.2.0-stage2"
else
packages.foundation.gcc.versions."13.2.0-stage4";
binutils =
if isBootstrapped then
packages.foundation.binutils.versions."2.41-bootstrap"
else if isCross then
packages.foundation.binutils.versions."2.41-stage1"
else
packages.foundation.binutils.versions."2.41-stage1-passthrough";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage1-bison;
};

View file

@ -5,20 +5,15 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.bison.versions."3.8.2-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
);
build = lib.modules.overrides.force "i686-linux";
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,17 +25,18 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};
};
hooks = package.hooks;
};
}

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -24,62 +26,45 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
target = "x86_64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/bison/bison-${version}.tar.xz";
hash = "sha256-m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I=";
sha256 = "m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I=";
};
deps = {
build =
(
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gnum4 = packages.foundation.gnum4.versions."1.4.19-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
gnumake = packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
gnused = packages.foundation.gnused.versions."4.9-stage1-passthrough";
gnugrep = packages.foundation.gnugrep.versions."3.11-stage1-passthrough";
gawk = packages.foundation.gawk.versions."5.2.2-stage1-passthrough";
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
gnutar = packages.foundation.gnutar.versions."1.35-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gnum4 = packages.foundation.gnum4.versions."1.4.19-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
build = {
build = {
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gnum4 = packages.foundation.gnum4.versions."1.4.19-bootstrap";
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
host = {
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl2Only;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-busybox;
};

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.bsdOriginal;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-bzip2;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.bzip2.versions."1.0.8-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.bsdOriginal;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -5,13 +5,16 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
prefix = lib.strings.when (
@ -27,50 +30,51 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
hash = "sha256-q1oDF27hBtPw+pDjgdpHjdrkBZGBU8yiSOaCzQxKImk=";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
gnumake = packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
gnutar = packages.foundation.gnutar.versions."1.35-stage1-passthrough";
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {
@ -80,27 +84,17 @@ in
cd bzip2-${version}
'';
build =
let
flags = builtins.concatStringsSep " " (
[
"CC=\"$CC\""
]
++ lib.lists.when (config.platform.build != config.platform.host) [
"AR=\"${config.deps.build.binutils-cross.package}/bin/${prefix}ar\""
"RANLIB=\"${config.deps.build.binutils-cross.package}/bin/${prefix}ranlib\""
"STRIP=\"${config.deps.build.binutils-cross.package}/bin/${prefix}strip\""
"NM=\"${config.deps.build.binutils-cross.package}/bin/${prefix}nm\""
]
);
in
''
# Build
make \
-j $NIX_BUILD_CORES \
${flags} \
bzip2 bzip2recover
'';
build = ''
# Build
make \
-j $NIX_BUILD_CORES \
CC="$CC" \
AR="${config.deps.build.host.binutils.package}/bin/${prefix}ar" \
RANLIB="${config.deps.build.host.binutils.package}/bin/${prefix}ranlib" \
STRIP="${config.deps.build.host.binutils.package}/bin/${prefix}strip" \
NM="${config.deps.build.host.binutils.package}/bin/${prefix}nm" \
bzip2 bzip2recover
'';
install = ''
# Install

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-coreutils;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.coreutils.versions."9.4-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,20 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
prefix = lib.strings.when (
platform.build.triple != platform.host.triple
) "${platform.host.triple}-";
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
@ -31,29 +37,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/coreutils/coreutils-${version}.tar.gz";
hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -65,8 +75,6 @@ in
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -79,14 +87,13 @@ in
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -1,7 +1,3 @@
{ config }:
let
inherit (config) lib;
in
{
includes = [
./bash
@ -29,14 +25,4 @@ in
./xz
./zlib
];
config = {
packages.context.options = {
"foundation:cflags" = lib.options.create {
description = "C compiler flags used by the foundation compiler toolchain.";
type = lib.types.list.of lib.types.string;
default.value = [ ];
};
};
};
}

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Only;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-diffutils;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.diffutils.versions."3.10-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Only;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -24,29 +26,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/diffutils/diffutils-${version}.tar.xz";
hash = "sha256-kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
sha256 = "kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -59,8 +65,6 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -74,14 +78,13 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-findutils;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.findutils.versions."4.9.0-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -24,29 +26,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/findutils/findutils-${version}.tar.xz";
hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
sha256 = "or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -59,8 +65,6 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -74,14 +78,13 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-gawk;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gawk.versions."5.2.2-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -24,29 +26,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/gawk/gawk-${version}.tar.gz";
hash = "sha256-lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -59,8 +65,6 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -74,14 +78,13 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -8,16 +8,17 @@
{
config.packages.foundation.gcc = {
stable = config.packages.foundation.gcc.versions."13.2.0-bootstrap";
latest = config.packages.foundation.gcc.versions."13.2.0-passthrough";
latest = config.packages.foundation.gcc.versions."13.2.0-stage5";
versions = {
"13.2.0-bootstrap" = ./versions/13.2.0-bootstrap.nix;
"13.2.0-passthrough" = ./versions/13.2.0-passthrough.nix;
"13.2.0-stage1" = ./versions/13.2.0-stage1.nix;
"13.2.0-stage2" = ./versions/13.2.0-stage2.nix;
"13.2.0-stage5" = ./versions/13.2.0-stage5.nix;
"13.2.0-stage4" = ./versions/13.2.0-stage4.nix;
"13.2.0-stage3-passthrough" = ./versions/13.2.0-stage3-passthrough.nix;
"13.2.0-stage3" = ./versions/13.2.0-stage3.nix;
"13.2.0-stage4" = ./versions/13.2.0-stage4.nix;
"13.2.0-stage2" = ./versions/13.2.0-stage2.nix;
"13.2.0-stage1" = ./versions/13.2.0-stage1.nix;
"13.2.0-stage0" = ./versions/13.2.0-stage0.nix;
"13.2.0-bootstrap" = ./versions/13.2.0-bootstrap.nix;
};
};
}

View file

@ -1,16 +1,13 @@
{ global }:
{ config, global }:
let
inherit (global)
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
gccFlags = [
"-Wl,-dynamic-linker=${foundation.stage1-musl}/lib/libc.so"
"-B${foundation.stage1-musl}/lib"
];
in
{
config = {
@ -20,9 +17,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-gcc;
};
@ -30,18 +33,12 @@ in
hooks = ctx: {
"aux:gcc:env" = lib.dag.entry.before [ "unpack" ] ''
export CC='${foundation.stage2-gcc}/bin/gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CXX='${foundation.stage2-gcc}/bin/g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CC_FOR_BUILD='${foundation.stage2-gcc}/bin/gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.build."foundation:cflags")
}'
export CXX_FOR_BUILD='${foundation.stage2-gcc}/bin/g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.build."foundation:cflags")
}'
export CC='gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -B${foundation.stage1-musl}/lib'
export CXX='g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -B${foundation.stage1-musl}/lib'
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

@ -0,0 +1,208 @@
# gcc-bootstrap-glibc
{ config, global }:
let
inherit (global)
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage0" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.target.target.glibc.dynamicLinker}"
"-B${config.deps.target.target.glibc.package}/lib"
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${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.target.target.glibc.package}/include"
];
in
{
options = {
gmp.version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
mpfr.version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
mpc.version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
isl.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 = "i686-linux";
target = "i686-linux";
}
];
builder = builders.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
mpc.version = "1.3.1";
isl.version = "0.24";
src = {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = 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-bootstrap";
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
};
};
target = {
target = {
glibc = packages.foundation.glibc.versions."2.38-bootstrap";
};
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.target.target.glibc.dynamicLinker} -B${config.deps.target.target.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.target.target.glibc.package}/lib";
LIBRARY_PATH = "${config.deps.target.target.glibc.package}/lib";
};
hooks = 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.gcc}
tar xf ${config.src.gmp}
tar xf ${config.src.mpfr}
tar xf ${config.src.mpc}
tar xf ${config.src.isl}
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 (platform.host.is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install
'';
};
};
}

View file

@ -8,13 +8,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.settings.target;
target = lib.systems.withBuildInfo config.platform.target;
};
prefix = lib.strings.when (
@ -26,12 +27,13 @@ let
];
configureFlags = [
"LDFLAGS=--static"
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
"--with-as=${config.deps.build.binutils-cross.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.binutils-cross.package}/bin/${prefix}ld"
"--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"
@ -73,20 +75,6 @@ in
type = lib.types.string;
description = "Version of isl.";
};
settings.target = lib.options.create {
type = lib.types.string;
default.value = "x86_64-linux";
description = "Target of the compiler";
};
target = lib.options.create {
type = lib.types.raw;
default.value = lib.attrs.generate lib.systems.doubles.all (
target:
(config.extend { settings.target = target; })
.packages.${config.platform.build}.${config.platform.host}
);
};
};
config = {
@ -99,13 +87,22 @@ in
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -113,35 +110,35 @@ in
isl.version = "0.24";
src = {
gcc = lib.fetchurl {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = lib.fetchurl {
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = lib.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = lib.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = lib.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
@ -173,25 +170,21 @@ in
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// {
binutils-cross =
packages.foundation.binutils.versions."2.41-stage1".target.${config.settings.target};
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
};
hooks = ctx: {
# Explicitly don't set CC_FOR_BUILD
"aux:gcc-cross:env" = lib.dag.entry.between [ "aux:gcc:env" ] [ "configure" ] ''
export CC='${config.package}/bin/${prefix}gcc ${
builtins.concatStringsSep " " (ctx.host."foundation:cflags")
}'
export CXX='${config.package}/bin/${prefix}g++ ${
builtins.concatStringsSep " " (ctx.host."foundation:cflags")
}'
"aux:gcc:env" = lib.dag.entry.before [ "unpack" "configure" "build" "install" ] ''
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
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
@ -218,6 +211,10 @@ in
'';
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
mkdir build
cd build

View file

@ -8,34 +8,28 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage2" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.settings.target;
target = lib.systems.withBuildInfo config.platform.target;
};
prefix = lib.strings.when (
platform.build.triple != platform.target.triple
) "${platform.target.triple}-";
libPrefix = lib.strings.when (
platform.build.triple != platform.target.triple
) "/${platform.target.triple}";
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
"-Wl,-dynamic-linker=${config.deps.host.glibc.dynamicLinker}"
"-Wl,-rpath,${config.deps.host.glibc.package}/lib"
"-L${config.deps.host.glibc.package}/lib"
"-B${config.deps.host.glibc.package}/lib"
"-L${config.package.outPath}${libPrefix}/lib"
"-B${config.package.outPath}${libPrefix}/lib"
"-Wl,-dynamic-linker"
"-Wl,${config.deps.target.target.glibc.dynamicLinker}"
"-B${config.deps.target.target.glibc.package}/lib"
];
configureFlags = [
@ -43,16 +37,16 @@ let
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
"--with-as=${config.deps.build.binutils-cross.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.binutils-cross.package}/bin/${prefix}ld"
"--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-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--with-headers=${config.deps.host.glibc.package}/include"
"--with-headers=${config.deps.target.target.glibc.package}/include"
"--with-build-sysroot=/"
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
"--with-build-time-tools=${config.deps.build.binutils-cross.package}/bin"
"--with-native-system-header-dir=${config.deps.target.target.glibc.package}/include"
"--with-build-time-tools=${config.deps.build.target.binutils.package}/bin"
];
in
{
@ -76,20 +70,6 @@ in
type = lib.types.string;
description = "Version of isl.";
};
settings.target = lib.options.create {
type = lib.types.string;
default.value = "x86_64-linux";
description = "Target of the compiler";
};
target = lib.options.create {
type = lib.types.raw;
default.value = lib.attrs.generate lib.systems.doubles.all (
target:
(config.extend { settings.target = target; })
.packages.${config.platform.build}.${config.platform.host}
);
};
};
config = {
@ -102,13 +82,22 @@ in
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -116,35 +105,35 @@ in
isl.version = "0.24";
src = {
gcc = lib.fetchurl {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = lib.fetchurl {
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = lib.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = lib.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = lib.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
@ -176,37 +165,34 @@ in
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// {
binutils-cross =
packages.foundation.binutils.versions."2.41-stage1".target.${config.settings.target};
};
};
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1".extend {
platform.host = lib.modules.overrides.force config.settings.target;
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
target = {
target = {
glibc = packages.foundation.glibc.versions."2.38-stage1";
};
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker} -B${config.deps.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.host.glibc.package}/lib";
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.target.target.glibc.dynamicLinker} -B${config.deps.target.target.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.target.target.glibc.package}/lib";
LIBRARY_PATH = "${config.deps.target.target.glibc.package}/lib";
};
hooks = ctx: {
# Explicitly don't set CC_FOR_BUILD
"aux:gcc-cross:env" = lib.dag.entry.between [ "aux:gcc:env" ] [ "configure" ] ''
export CC='${config.package}/bin/${prefix}gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CXX='${config.package}/bin/${prefix}g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
"aux:gcc-cross:env" = lib.dag.entry.before [ "unpack" "configure" "build" "install" ] ''
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
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
@ -239,9 +225,9 @@ in
# 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.host.glibc.package}/lib/{crti.o,crtn.o} gcc
ln -sv ${config.deps.target.target.glibc.package}/lib/{crti.o,crtn.o} gcc
mkdir -p ${platform.target.triple}/libstdc++-v3/src
ln -sv ${config.deps.host.glibc.package}/lib/{crti.o,crtn.o} ${platform.target.triple}/libstdc++-v3/src
ln -sv ${config.deps.target.target.glibc.package}/lib/{crti.o,crtn.o} ${platform.target.triple}/libstdc++-v3/src
bash ../configure ${builtins.concatStringsSep " " configureFlags}
'';
@ -257,10 +243,6 @@ in
mkdir -p $out/lib
ln -s lib $out/lib64
''}
${lib.strings.when (platform.target.is64bit) ''
mkdir -p $out/${platform.target.triple}/lib
ln -s lib $out/${platform.target.triple}/lib64
''}
make -j $NIX_BUILD_CORES install
'';
};

View file

@ -6,20 +6,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gcc.versions."13.2.0-stage3".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.target == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -31,9 +28,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "@linux";
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -8,38 +8,44 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage3" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
prefix = lib.strings.when (
platform.build.triple != platform.target.triple
) "${platform.target.triple}-";
patches = [
../patches/libstdc++-target.patch
];
gccFlags = [
"-Wl,-dynamic-linker=${config.deps.host.glibc.dynamicLinker}"
"-Wl,-rpath,${config.deps.host.glibc.package}/lib"
"-L${config.deps.host.glibc.package}/lib"
"-B${config.deps.host.glibc.package}/lib"
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.dynamicLinker}"
"-B${config.deps.host.host.glibc.package}/lib"
]
++ lib.lists.when (config.platform.target == "riscv64-linux") [
"-L${config.package.outPath}/lib"
"-B${config.package.outPath}/lib"
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.host.triple}"
"--target=${platform.target.triple}"
"--enable-languages=c,c++"
"--disable-lto"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
"--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=/"
];
@ -65,11 +71,6 @@ in
type = lib.types.string;
description = "Version of isl.";
};
target.triple = lib.options.create {
type = lib.types.string;
description = "Target of GCC";
};
};
config = {
@ -83,14 +84,21 @@ in
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -98,35 +106,35 @@ in
isl.version = "0.24";
src = {
gcc = lib.fetchurl {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = lib.fetchurl {
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = lib.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = lib.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = lib.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
@ -140,8 +148,8 @@ in
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";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage0";
glibc = packages.foundation.glibc.versions."2.38-bootstrap";
}
else
@ -160,48 +168,61 @@ in
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
glibc = packages.foundation.glibc.versions."2.38-stage1-passthrough";
}
)
// {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1";
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1";
};
};
};
env = rec {
CFLAGS_FOR_BUILD = "-Wl,-dynamic-linker -Wl,${config.deps.build.glibc.dynamicLinker} -B${config.deps.build.glibc.package}/lib";
LDFLAGS_FOR_BUILD = "-L${config.deps.build.gcc.package}/lib -L${config.deps.build.glibc.package}/lib -Wl,-rpath,${config.deps.build.gcc.package}/lib -Wl,-rpath,${config.deps.build.glibc.package}/lib";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker} -B${config.deps.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.host.triple}/libgcc -L${config.deps.host.glibc.package}/lib";
CC_FOR_BUILD = "${config.deps.build.build.gcc.package}/bin/gcc -Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.dynamicLinker} -B${config.deps.build.build.glibc.package}/lib";
CXX_FOR_BUILD = "${config.deps.build.build.gcc.package}/bin/g++ -Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.dynamicLinker} -B${config.deps.build.build.glibc.package}/lib";
CFLAGS_FOR_BUILD = "-Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.dynamicLinker} -B${config.deps.build.build.glibc.package}/lib";
LDFLAGS_FOR_BUILD = "-L${config.deps.build.build.gcc.package}/lib -L${config.deps.build.build.glibc.package}/lib -Wl,-rpath,${config.deps.build.build.gcc.package}/lib -Wl,-rpath,${config.deps.build.build.glibc.package}/lib";
CC_FOR_TARGET = "${prefix}gcc -Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.dynamicLinker} -B${config.deps.host.host.glibc.package}/lib";
CXX_FOR_TARGET = "${prefix}g++ -Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.dynamicLinker} -B${config.deps.host.host.glibc.package}/lib";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.dynamicLinker} -B${config.deps.host.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.host.host.glibc.package}/lib";
CC = CC_FOR_TARGET;
CXX = CXX_FOR_TARGET;
CFLAGS = CFLAGS_FOR_TARGET;
LDFLAGS = LDFLAGS_FOR_TARGET;
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
LD_LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
};
hooks = ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CXX='${config.package}/bin/g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CC_FOR_BUILD='${config.package}/bin/gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.build."foundation:cflags")
}'
export CXX_FOR_BUILD='${config.package}/bin/g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.build."foundation:cflags")
}'
"aux:gcc:env" = lib.dag.entry.before [ "unpack" "configure" "build" "install" ] ''
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 = {
"aux:gcc:env" = '''';
"aux:gcc-cross:env" = '''';
unpack = ''
# Unpack
tar xf ${config.src.gcc}

View file

@ -8,12 +8,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage4" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
patches = [
@ -21,25 +23,26 @@ let
];
gccFlags = [
"-Wl,-dynamic-linker=${config.deps.host.glibc.dynamicLinker}"
"-Wl,-rpath,${config.deps.host.glibc.package}/lib"
"-L${config.deps.host.glibc.package}/lib"
"-B${config.deps.host.glibc.package}/lib"
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.dynamicLinker}"
"-B${config.deps.host.host.glibc.package}/lib"
]
++ lib.lists.when (config.platform.target == "riscv64-linux") [
"-L${config.package.outPath}/lib"
"-B${config.package.outPath}/lib"
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${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.glibc.package}/include"
"--with-native-system-header-dir=${config.deps.host.host.glibc.package}/include"
];
in
{
@ -72,9 +75,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "@linux";
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -82,97 +101,78 @@ in
isl.version = "0.24";
src = {
gcc = lib.fetchurl {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = lib.fetchurl {
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = lib.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = lib.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = lib.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build =
if (config.platform.build == "i686-linux") then
{
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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
bzip2 = packages.foundation.bzip2.versions."1.0.8-stage1-passthrough";
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
gawk = packages.foundation.gawk.versions."5.2.2-stage1-passthrough";
gnugrep = packages.foundation.gnugrep.versions."3.11-stage1-passthrough";
gnumake = packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
gnupatch = packages.foundation.gnupatch.versions."2.7-stage1-passthrough";
gnused = packages.foundation.gnused.versions."4.9-stage1-passthrough";
gnutar = packages.foundation.gnutar.versions."1.35-stage1-passthrough";
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage3-passthrough";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
};
build = {
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-stage1-passthrough";
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
gawk = packages.foundation.gawk.versions."5.2.2-stage1-passthrough";
gnugrep = packages.foundation.gnugrep.versions."3.11-stage1-passthrough";
gnumake = packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
gnupatch = packages.foundation.gnupatch.versions."2.7-stage1-passthrough";
gnused = packages.foundation.gnused.versions."4.9-stage1-passthrough";
gnutar = packages.foundation.gnutar.versions."1.35-stage1-passthrough";
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
};
host =
if (config.platform.build == "i686-linux") then
{
glibc = packages.foundation.glibc.versions."2.38-bootstrap";
}
else
{
glibc = packages.foundation.glibc.versions."2.38-stage1-passthrough";
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage3-passthrough";
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
};
};
host = {
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1-passthrough";
};
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker}";
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.dynamicLinker}";
LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
};
hooks = ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CXX='${config.package}/bin/g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.host."foundation:cflags")
}'
export CC_FOR_BUILD='${config.package}/bin/gcc ${
builtins.concatStringsSep " " (gccFlags ++ ctx.build."foundation:cflags")
}'
export CXX_FOR_BUILD='${config.package}/bin/g++ ${
builtins.concatStringsSep " " (gccFlags ++ ctx.build."foundation:cflags")
}'
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'
'';

View file

@ -5,18 +5,19 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package =
if
config.platform.build == config.platform.host && config.platform.host != config.settings.target
config.platform.build == config.platform.host && config.platform.host != config.platform.target
then
packages.foundation.gcc.versions."13.2.0-stage2".extend {
platform = lib.modules.overrides.force config.platform;
settings.target = config.settings.target;
}
else if
config.platform.build != config.platform.host && config.platform.host == config.settings.target
config.platform.build != config.platform.host && config.platform.host == config.platform.target
then
packages.foundation.gcc.versions."13.2.0-stage3".extend {
platform = lib.modules.overrides.force config.platform;
@ -27,22 +28,6 @@ let
};
in
{
options = {
settings.target = lib.options.create {
type = lib.types.string;
default.value = config.platform.host;
description = "Target of the compiler";
};
target = lib.options.create {
type = lib.types.raw;
default.value = lib.attrs.generate lib.systems.doubles.all (
target:
(config.extend { settings.target = target; })
.packages.${config.platform.build}.${config.platform.host}
);
};
};
config = {
meta = {
description = "GNU Compiler Collection.";
@ -51,22 +36,41 @@ in
};
platforms = [
{
build = "@linux";
}
{
build = "i686-linux";
host = "@linux";
host = "i686-linux";
target = "i686-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "riscv64-linux";
}
];
hooks = package.hooks;
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-bootstrap" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -30,35 +32,43 @@ in
license = lib.licenses.lgpl2Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${version}.tar.xz";
hash = "sha256-+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
sha256 = "+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
};
deps = {
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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
};
host = {
linux-headers = packages.foundation.linux-headers.versions."6.5.6-stage1";
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 = {
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
linux-headers = packages.foundation.linux-headers.versions."6.5.6-stage1";
};
};
};
@ -78,8 +88,8 @@ in
--prefix=$out \
--build=${platform.build.triple} \
--host=${platform.host.triple} \
--with-headers=${config.deps.host.linux-headers.package}/include \
--with-binutils=${config.deps.build.binutils.package}/bin
--with-headers=${config.deps.build.host.linux-headers.package}/include \
--with-binutils=${config.deps.build.host.binutils.package}/${platform.target.triple}/bin
'';
build = ''
@ -90,7 +100,7 @@ in
install = ''
# Install
make -j $NIX_BUILD_CORES install
ln -sv $(ls -d ${config.deps.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
ln -sv $(ls -d ${config.deps.build.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
'';
};
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.glibc.versions."2.38-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -38,14 +35,27 @@ in
license = lib.licenses.lgpl2Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
dynamicLinker = package.dynamicLinker;
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -32,29 +34,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${version}.tar.xz";
hash = "sha256-+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
sha256 = "+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
@ -70,11 +76,6 @@ in
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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
// lib.attrs.when (config.platform.build != config.platform.host) {
glibc = packages.foundation.glibc.versions."2.38-bootstrap";
}
else
{
@ -91,30 +92,23 @@ in
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
python = packages.foundation.python.versions."3.12.0-stage1";
bison = packages.foundation.bison.versions."3.8.2-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
// lib.attrs.when (config.platform.build != config.platform.host) {
glibc = packages.foundation.glibc.versions."2.38-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage1".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage1";
binutils = packages.foundation.binutils.versions."2.41-stage1";
linux-headers = packages.foundation.linux-headers.versions."6.5.6-stage1";
};
host = {
linux-headers = packages.foundation.linux-headers.versions."6.5.6-stage1";
};
};
dynamicLinker =
"${config.package.outPath}/lib/"
+ (
if platform.host.double == "x86_64-linux" then
if platform.target.double == "x86_64-linux" then
"ld-linux-x86-64.so.2"
else if platform.host.double == "aarch64-linux" then
else if platform.target.double == "aarch64-linux" then
"ld-linux-aarch64.so.1"
else if platform.host.double == "riscv64-linux" then
else if platform.target.double == "riscv64-linux" then
"ld-linux-riscv64-lp64d.so.1"
else
"ld-linux.so.2"
@ -126,26 +120,17 @@ in
cd glibc-${version}
'';
configure =
let
flags = builtins.concatStringsSep " " (
[
"--prefix=$out"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--with-headers=${config.deps.host.linux-headers.package}/include"
]
++ lib.lists.when (config.platform.build != config.platform.host) [
"--with-binutils=${config.deps.build.binutils-cross.package}/${platform.host.triple}/bin"
]
);
in
''
mkdir build
cd build
configure = ''
mkdir build
cd build
bash ../configure ${flags}
'';
bash ../configure \
--prefix=$out \
--build=${platform.build.triple} \
--host=${platform.host.triple} \
--with-headers=${config.deps.build.host.linux-headers.package}/include \
--with-binutils=${config.deps.build.host.binutils.package}/${platform.target.triple}/bin
'';
build = ''
# Build
@ -155,25 +140,7 @@ in
install = ''
# Install
make -j $NIX_BUILD_CORES install
${
if
(
config.platform.build == config.platform.host
|| config.platform.build == "i686-linux" && config.platform.host == "x86_64-linux"
)
then
"make \"localedata/install-locales\" \"localedir=$out/lib/locale\""
else
''
mkdir -p $TMPDIR/${config.deps.build.glibc.package}/lib/locale
sed -i -e \
's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix=''${TMPDIR} --${platform.host.system.cpu.endian.name}-endian,' \
../localedata/Makefile
make SHELL='sh -x' "localedata/install-locales" "localedir=$out/lib/locale"
cp -r $TMPDIR/${config.deps.build.glibc.package}/lib/locale $out/lib
''
}
ln -sv $(ls -d ${config.deps.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
ln -sv $(ls -d ${config.deps.build.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
'';
};
};

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-gnugrep;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gnugrep.versions."3.11-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -24,29 +26,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/grep/grep-${version}.tar.xz";
hash = "sha256-HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
sha256 = "HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
@ -59,8 +65,6 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -74,14 +78,13 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage1-gnum4;
};

View file

@ -5,20 +5,15 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gnum4.versions."1.4.19-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
);
build = lib.modules.overrides.force "i686-linux";
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +25,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
in
{
@ -24,64 +26,40 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
target = "x86_64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/m4/m4-${version}.tar.xz";
hash = "sha256-Y67eXG0zttmxNRHNC+LKwEby5w/QoHqpVzoEqCeDr5Y=";
sha256 = "Y67eXG0zttmxNRHNC+LKwEby5w/QoHqpVzoEqCeDr5Y=";
};
deps = {
build =
(
if (config.platform.build == "i686-linux") then
{
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";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
gnumake = packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
gnupatch = packages.foundation.gnupatch.versions."2.7-stage1-passthrough";
gnused = packages.foundation.gnused.versions."4.9-stage1-passthrough";
gnutar = packages.foundation.gnutar.versions."1.35-stage1-passthrough";
gnugrep = packages.foundation.gnugrep.versions."3.11-stage1-passthrough";
gawk = packages.foundation.gawk.versions."5.2.2-stage1-passthrough";
gzip = packages.foundation.gzip.versions."1.13-stage1-passthrough";
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
build = {
build = {
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";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-gnumake;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gnumake.versions."4.4.1-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
};
patches = [
@ -29,29 +31,33 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "x86_64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.basic;
builder = builders.basic;
src = lib.fetchurl {
src = builtins.fetchurl {
url = "${mirrors.gnu}/make/make-${version}.tar.gz";
hash = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
};
deps = {
build =
(
build = {
build =
if (config.platform.build == "i686-linux") then
{
@ -65,8 +71,6 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
else
{
@ -80,14 +84,13 @@ in
diffutils = packages.foundation.diffutils.versions."3.10-stage1-passthrough";
findutils = packages.foundation.findutils.versions."4.9.0-stage1-passthrough";
xz = packages.foundation.xz.versions."5.4.3-stage1-passthrough";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
binutils = packages.foundation.binutils.versions."2.41-stage1-passthrough";
}
)
// lib.attrs.when (config.platform.build != config.platform.host) {
gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".target.${config.platform.host};
binutils-cross = packages.foundation.binutils.versions."2.41-stage1".target.${config.platform.host};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -1,7 +1,7 @@
{ global }:
{ config, global }:
let
inherit (global) lib builders;
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,9 +12,15 @@ in
license = lib.licenses.gpl3Plus;
};
platforms.build = "i686-linux";
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-gnupatch;
};

View file

@ -5,20 +5,17 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gnupatch.versions."2.7-stage1".extend {
platform = {
build = lib.modules.overrides.force (
if (config.platform.build == config.platform.host) then
if (config.platform.build == "x86_64-linux" || config.platform.build == "i686-linux") then
"i686-linux"
else
"x86_64-linux"
else
config.platform.build
if config.platform.build == "x86_64-linux" then "i686-linux" else "x86_64-linux"
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -30,12 +27,25 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = {
build = "@linux";
host = "@linux";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "aarch64-linux";
host = "aarch64-linux";
target = "aarch64-linux";
}
{
build = "riscv64-linux";
host = "riscv64-linux";
target = "riscv64-linux";
}
];
builder = builders.foundation.passthrough.extend {
builder = builders.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,12 +7,14 @@ let
builders
mirrors
;
inherit (global.internal.packages) foundation;
version = lib.strings.removeSuffix "-stage1" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;