Compare commits

...
Sign in to create a new pull request.

39 commits

Author SHA1 Message Date
1c26dd089b
packages/readme: clarify roles of packages.foundation and packages.core 2026-01-04 17:05:23 -05:00
b226ca0968 builders.foundation.basic: Add strings and numbers as valid types for vars (#54)
I forgor 💀

Reviewed-on: auxolotl/labs#54
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Ross Smyth <snix@treefroog.com>
Co-committed-by: Ross Smyth <snix@treefroog.com>
2025-11-18 07:56:06 +00:00
a89f53e923 config.builders.foundation.basic: Format structedAttrs change 2025-11-06 19:14:20 -05:00
cb215e54a6 config.builders.foundation.basic: Add structuredAttrs exports from vars 2025-11-06 19:12:55 -05:00
93eeee8024 config.builders.foundation.basic: Add vars to the derivation type 2025-11-06 19:10:01 -05:00
2523a43663 builders.basic: Validate environment variable names 2025-11-06 23:54:33 +00:00
521674fc9f Revert "labs/basic: Validate environment variables"
This reverts commit cabbf2372a.
2025-11-06 23:54:33 +00:00
d23a1c8387 Fix UK spelling of 'lib.licences', lib uses US spelling (probably reasonable) 2025-11-06 22:53:35 +00:00
cabbf2372a labs/basic: Validate environment variables 2025-10-28 00:08:51 -04:00
551bbc60de gnutar: Make bootstrap bash reproducible by default 2025-10-28 02:25:31 +00:00
fde83f51b4 gnutar: Make reproducible by default 2025-10-28 02:25:31 +00:00
2d844f8302 foundation/basic: Also use structuredAttrs 2025-10-28 02:23:24 +00:00
0b7e7d1e52 foundation/basic: Set the phase for nom
https://github.com/maralorn/nix-output-monitor
1a9ba0d6fe/src/libutil/logging.cc (L441)

Co-authored-by: dawn <dawnofmidnight@duck.com>
2025-10-25 17:13:10 -04:00
57a4021ce9 fix: temporarily patch gcc bootstrap compilation failures (#41)
This option was causing some compilation faliures. I want to address the root cause being foundation libstdc++ being broken, but for now let's avoid broken builds.

Reviewed-on: auxolotl/labs#41
Co-authored-by: Victor Fuentes <vlinkz@snowflakeos.org>
Co-committed-by: Victor Fuentes <vlinkz@snowflakeos.org>
2025-10-17 04:04:25 +00:00
e2f6de0b11 refactor: eval performant target (#40)
Using `.extend` function causes nix to not cache the evaluation of a package (`a.extend {} != a.extend {}` ). In effect this meant that every time we used
```
	          gcc-cross = packages.foundation.gcc.versions."13.2.0-stage2".extend {
            settings.target = config.platform.host;
          };
          binutils-cross = packages.foundation.binutils.versions."2.41-stage1".extend {
            settings.target = config.platform.host;
          };
```
we were performing full re-evaluations of binutils and gcc. To make this worse, since binutils and gcc depend on other binutils and gcc (sometimes with this `.extend`), the amount of evaluations would start to blow up.
Before this patch evaluating `packages.foundation.gcc.latest.packages.x86_64-linux.x86_64-linux.package` would evaluate `binutils` stage1 139 times, after this patch (and before target patch) it's 4.

Reviewed-on: auxolotl/labs#40
Co-authored-by: Victor Fuentes <vlinkz@snowflakeos.org>
Co-committed-by: Victor Fuentes <vlinkz@snowflakeos.org>
2025-10-15 03:23:25 +00:00
76cd63f5fe docs: update build instructions and foundation (#38)
Reviewed-on: auxolotl/labs#38
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: KFears <kfearsoff@gmail.com>
Co-committed-by: KFears <kfearsoff@gmail.com>
2025-10-15 03:21:49 +00:00
cb654dbfd0 tidepool/readme: update links to foundation and lib (#37)
A friend was looking at tidepool, and was confused when these were deadlinks.

Reviewed-on: auxolotl/labs#37
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: dawnofmidnight <dawnofmidnight@duck.com>
Co-committed-by: dawnofmidnight <dawnofmidnight@duck.com>
2025-10-15 03:20:52 +00:00
a5b66548d3 gcc: add glibc to rpath (#36)
This way, the binaries glibc builds will actually get linked to our libc.so at runtime, instead of the system one.

Reviewed-on: auxolotl/labs#36
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Piper McCorkle <contact@piperswe.me>
Co-committed-by: Piper McCorkle <contact@piperswe.me>
2025-10-07 06:17:07 +00:00
be0d6bc0e1 refactor: remove target (#31)
WIP. Posting just to make sure people know this is something I'd like to do.

Context: https://matrix.to/#/!PvnunzXUk4Vm1CmKS4:auxolotl.org/$bOm6iaBpWbo-KRJgo7FUZdeFIv9StzRHxklbx7OQ23g?via=auxolotl.org&via=matrix.org&via=catgirl.cloud

Reasons:

1. Why should GCC inflict complication upon all of tidepool just because of its own architectural deficiencies?
2. Most other compilers are multi-target so it doesn't matter
2. Target is useless for 99.9% of packages and only leads to user confusion, especially since many compilers also call what would be host here "target".
3. Canadian-cross is not very well supported. GCC barely supports it, and is broken in many cases. Nixpkgs does not support it (regardless of what its API may imply) and no one has ever complained.

Plan:

1. Remove most target related things. No reason to have it.
2. Add configuration parameter on GCC that selects its target

What does this mean:

This basically moves target to be a GCC-specific artifact rather than an official parameter every package must endure the cognitive load of. This is because it is.  Nixpkgs plans on dumping target in the future as well because of this. Or at least making it an alias.

If you want to create a compiler with a different target, then override GCC to do so. No need to pervade all of tidepool just for GCC.

Co-authored-by: Victor Fuentes <vlinkz@snowflakeos.org>
Reviewed-on: auxolotl/labs#31
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Ross Smyth <snix@treefroog.com>
Co-committed-by: Ross Smyth <snix@treefroog.com>
2025-10-07 03:46:52 +00:00
8174d3a494 fix lib.systems.validate.compatible (#35)
Use builtins and aux `lib.fp.id` instead of nixpkgs functions for `lib.systems.validate.compatible`.

Reviewed-on: auxolotl/labs#35
Reviewed-by: Ruby Iris Juric <ruby+auxolotl@srxl.me>
Co-authored-by: Victor Fuentes <vlinkz@snowflakeos.org>
Co-committed-by: Victor Fuentes <vlinkz@snowflakeos.org>
2025-10-06 15:10:56 +00:00
7f61482c7f refactor: use ftpmirror.gnu.org for gnu packages (#26)
https://ftp.gnu.org is very, *very* slow. From the [GNU downloads page](https://www.gnu.org/prep/ftp.en.html):

> [...]please try to use one of the many mirrors of our site listed below: the mirrors will give you faster response. [...] You can use the generic URLs https://ftpmirror.gnu.org and http://ftpmirror.gnu.org to automatically choose a nearby and up-to-date mirror.

Indeed, in my experience the mirrors are much faster. I don't see a reason we shouldn't default to them personally, so I've changed the default here.

Also see: auxolotl/foundation#8

Reviewed-on: auxolotl/labs#26
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Ruby Iris Juric <ruby@srxl.me>
Co-committed-by: Ruby Iris Juric <ruby@srxl.me>
2025-10-04 21:53:41 +00:00
02a45110c9 docs: add basic docs on Tidepool and its package sets (#18)
This is very far from perfect, but it lays some groundwork to Tidepool
documentation. This follows my (very limited) understanding, and so is
very much incomplete and WIP. I would like some help with the concepts I
haven't quite understood <3

Reviewed-on: auxolotl/labs#18
Reviewed-by: Jake Hamilton <jake.hamilton@hey.com>
Co-authored-by: KFears <kfearsoff@gmail.com>
Co-committed-by: KFears <kfearsoff@gmail.com>
2025-10-04 20:15:48 +00:00
b67847e7eb fix: Correctly resolve packages from preferences.packages.version (#33)
Before this, a value that does not correspond to an attribute under a
package alias' `versions` would make it default to the latest as defined
by `lib.packages.getLatest`, which isn't a silver bullt: it choose
"bash5.2.15-bootstrap" for instance instead of stage1-passthrough (and I
don;t think we have an easy fix for that).

Given values like `"1.2.3"` makes little sense in
`config.preferences.packages.version` (because it's a package-set-wide
preference), this means it was hardly ever useful.

before:

```console
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "latest";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-bootstrap"
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "stable";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-bootstrap"
```

after:

```console
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "latest";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-stage1-passthrough"
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "stable";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-bootstrap"
```

Co-authored-by: austreelis <git@swhaele.net>
Reviewed-on: auxolotl/labs#33
Reviewed-by: Ruby Iris Juric <ruby+auxolotl@srxl.me>
Co-authored-by: Austreelis <austreelis@noreply.git.auxolotl.org>
Co-committed-by: Austreelis <austreelis@noreply.git.auxolotl.org>
2025-10-04 00:40:05 +00:00
45ac7bc494 npins/source.json version bumps (#29)
Untested, but should fix #28?

Reviewed-on: auxolotl/labs#29
Reviewed-by: Ruby Iris Juric <ruby+auxolotl@srxl.me>
Co-authored-by: Steve Dee <steved424@gmail.com>
Co-committed-by: Steve Dee <steved424@gmail.com>
2025-10-03 14:40:57 +00:00
8ffc63ae42 fix: package license causing hydra eval fails (#30)
Difference in license attrset schema between lib and tidepool caused eval fails, as in [here](https://hydra.aux-cache.dev/jobset/aux/tidepool#tabs-errors).

This PR changes tidepool's scheme to align it with lib:
```console
❯ nix eval -f tidepool packages.foundation.bash.latest.meta.license --json | jq
{
  "free": true,
  "fullName": "GNU General Public License v3.0 or later",
  "name": "gpl3Plus",
  "redistributable": true,
  "spdxId": "GPL-3.0-or-later",
  "url": "https://spdx.org/licenses/GPL-3.0-or-later.html"
}
```

I kinda liked the previous schema of tidepool, but it's a lower impact fix than bumping lib's major, and I think we want to think more about licenses in lib (e.g. it would probably make sense to move tidepool's license type there to avoid dupplicating the code for the default behavior).

Co-authored-by: austreelis <git@swhaele.net>
Reviewed-on: auxolotl/labs#30
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Austreelis <austreelis@noreply.git.auxolotl.org>
Co-committed-by: Austreelis <austreelis@noreply.git.auxolotl.org>
2025-10-03 05:15:39 +00:00
9477da5166 refactor: fix cross compiling packages (#23)
A lot of misc fixes to foundation packages to better support cross compiling
- Reduce number of gcc stages
- Fix cross compile hooks for gcc, no overrides necessary in stage3 anymore
- Add hooks to zlib
- Fix compiliation for `i686-linux.i686-linux.i686-linux`
Depends on auxolotl/labs#20

Reviewed-on: auxolotl/labs#23
Co-authored-by: Victor Fuentes <vlinkz@snowflakeos.org>
Co-committed-by: Victor Fuentes <vlinkz@snowflakeos.org>
2025-10-03 03:59:40 +00:00
0ae450a116 feat: add lib.fetchurl function (#27)
See comment in `tidepool/src/lib/fetchurl.nix` for details on rationale.

I've made this a function in `lib` instead of defining this as a builder, since we don't have a great mechanism at the moment for specifying the source of a package as another package. We'll need to tackle this eventually, but given that this is a bit of a special case in that it's only intended to be used to fetch sources during bootstrap, I think it's fine to just have this be a function that returns a derivation, instead of being a full builder. Open to other opinions, though.

Reviewed-on: auxolotl/labs#27
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Ruby Iris Juric <ruby@srxl.me>
Co-committed-by: Ruby Iris Juric <ruby@srxl.me>
2025-10-01 05:20:06 +00:00
956d1447d1 fix: example aux packages eval (#25)
- add namespace for `aux.a`, `aux.b`, `aux.c`'s builder config
- break an infinite recursion of `aux.a`'s install phase depending on its own derivation's `outPath`

Co-authored-by: austreelis <git@swhaele.net>
Reviewed-on: auxolotl/labs#25
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Austreelis <austreelis@noreply.git.auxolotl.org>
Co-committed-by: Austreelis <austreelis@noreply.git.auxolotl.org>
2025-10-01 01:25:51 +00:00
ab85ed8550
refactor: default host and target platforms based on build 2025-09-19 21:03:13 -07:00
1f7ae040bc
feat: add package settings 2025-09-14 09:39:57 -07:00
9fb80e319d
chore: format 2025-09-14 09:36:55 -07:00
dbd936d32f
refactor: remove unused code 2025-09-14 09:35:05 -07:00
6854e9ccac
refactor: namespace builders 2025-09-14 09:27:13 -07:00
f4f1f0aea7
feat: build contexts for build, host, and target 2025-09-14 01:36:33 -07:00
9ae15ed2ff
Squashed commit of the following:
commit aa7b2cd4ca74bec7ad004e97c21e38a84e91e0c3
Author: Jake Hamilton <jake.hamilton@hey.com>
Date:   Wed Sep 10 08:42:05 2025 -0700

    refactor: use platform specs
2025-09-11 06:17:07 -07:00
9cc8f06638
refactor: do not include basic builder in new package sets 2025-09-11 06:16:26 -07:00
a7df517df8
chore: upgrade tidepool to iteration phase 2025-09-10 08:53:32 -07:00
2f31813c88 feat: add support for platform specs (#15)
This PR adds a new way of declaring supported platforms for packages. Previously individual build, host, and target values needed to be set for a given platform combination. Now, a platform spec can be written to generate many platform combinations.

This allows for easy mapping of all possible systems with `@all`, linux systems with `@linux` or any other available alias of `lib.systems.doubles.<alias>` by using `@<alias>`. In addition, you can use `@build` and `@host` to lock either the host or target respectively to match the prior platform.

Reviewed-on: auxolotl/labs#15
2025-09-10 12:32:11 +00:00
4e4b9366a4 feat: dynamic cross compiler (#14)
This pr adds initial support for creating a cross-compile tool chain for arbitrary architectures. For now only `aarch64`  and `riscv64` are implemented, but simlpy adding another architecture to the list of supported platforms in each package should mostly work with minimal patches.
In order to build native gcc for aarch64, you can run
```
nix-build --expr '((import ./tidepool).packages.foundation.gcc.versions."13.2.0-stage4".package.extend { platform = { build = "aarch64-linux"; host = "aarch64-linux"; target = "aarch64-linux"; }; }).package'
```
or
```
nix-build tidepool -A packages.foundation.gcc.latest.packages.aarch64-linux.aarch64-linux.aarch64-linux
```
Running this command:
- Uses [foundation](https://git.auxolotl.org/auxolotl/foundation) to bootstrap i686 gcc
- Incrementally bootstraps x86_64 gcc from i686
- Runs through the same incremental process, but this time using x86_64 gcc we previously built to bootstrap aarch64
- Build the final native aarch64 gcc

Co-authored-by: Jake Hamilton <jake.hamilton@hey.com>
Reviewed-on: auxolotl/labs#14
Reviewed-by: Jake Hamilton <jake.hamilton@hey.com>
Co-authored-by: Victor Fuentes <vlinkz@snowflakeos.org>
Co-committed-by: Victor Fuentes <vlinkz@snowflakeos.org>
2025-09-08 20:08:35 +00:00
102 changed files with 3484 additions and 1885 deletions

View file

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

View file

@ -1,10 +1,13 @@
# 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.
## Usage
[foundation]: https://git.auxolotl.org/auxolotl/foundation
[lib]: https://git.auxolotl.org/auxolotl/lib
## Installation
Packages can be imported both with and without Nix Flakes. To import them using Nix Flakes,
add this repository as an input.
@ -26,3 +29,174 @@ 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,7 +28,8 @@ let
};
};
new = module:
new =
module:
let
set = lib.modules.run {
modules = [
@ -37,14 +38,17 @@ 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
]
new [
./src/packages
./src/builders/foundation/basic.nix
]

View file

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

View file

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

View file

@ -8,7 +8,7 @@ let
pretty = lib.generators.pretty { };
in
{
config.builders.basic = {
config.builders.foundation.basic = {
build =
package:
let
@ -25,12 +25,8 @@ in
phasesWithHooks =
let
all = lib.lists.flatten [
hooks.build.build
hooks.build.host
hooks.build.target
hooks.host.host
hooks.host.target
hooks.target.target
hooks.build
hooks.host
];
in
builtins.foldl' (
@ -51,40 +47,58 @@ in
sorted = lib.dag.sort.topological phases;
script = lib.strings.concatMapSep "\n" (entry: entry.value) sorted.result;
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;
executable = if system == "i686-linux" then
"${foundation.stage2-bash}/bin/bash"
else
"${(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "i686-linux" system system).package}/bin/bash";
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
}/bin/bash"
else
"${
(lib.packages.build packages.foundation.bash.versions."5.2.15-stage1" "x86_64-linux" system).package
}/bin/bash";
built = builtins.derivation (
package.env
package.vars
// {
inherit (package) name;
inherit (package) name env;
inherit script system;
passAsFile = [ "script" ];
__structuredAttrs = true;
outputs = builtins.attrNames (lib.packages.getOutputs package);
SHELL = executable;
PATH =
let
bins = lib.paths.bin (
(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.packages.dependencies.get dependencies.build)
++ (lib.packages.dependencies.get dependencies.host)
++ 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 system)
.package
(lib.packages.build packages.foundation.coreutils.versions."9.4-stage1" "i686-linux" system system)
(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.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)
.package
]
);
@ -98,8 +112,28 @@ 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.
@ -110,7 +144,7 @@ in
fi
export NIX_BUILD_CORES
bash -eux $scriptPath
eval "$script"
'')
];
}
@ -143,7 +177,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.build` and `build.host`.
such as `build` and `host`.
'';
};
}

View file

@ -0,0 +1,9 @@
{
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

@ -0,0 +1,29 @@
{ 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

@ -1,27 +0,0 @@
{ 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,9 +1,10 @@
{
includes = [
./fetchurl.nix
./options.nix
./packages.nix
./platforms.nix
./systems.nix
./types.nix
./fp.nix
];
}

View file

@ -0,0 +1,73 @@
{
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 ];
};
};
}

View file

@ -1,14 +0,0 @@
{ 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,8 +15,7 @@ in
builtins.map (dependency: dependency.package) available;
build =
build: host: target:
builtins.mapAttrs (name: dep: dep.packages.${build}.${host}.${target});
build: host: builtins.mapAttrs (name: dep: (lib.packages.resolve dep).packages.${build}.${host});
collect =
package:
@ -28,53 +27,28 @@ in
dependencies:
let
getDeps =
name: dependency:
name: dep:
let
dependency = lib.packages.resolve dep;
deps = {
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;
};
build = getPropagatedDependencies dependency.deps.build ++ process dependency.deps.build;
host = getPropagatedDependencies dependency.deps.host ++ process dependency.deps.host;
};
in
lib.lists.flatten [
deps.build.build
deps.build.host
deps.build.target
deps.host.host
deps.host.target
deps.target.target
deps.build
deps.host
];
propagated = lib.attrs.mapToList getDeps dependencies;
in
lib.lists.flatten propagated;
withoutNulls = deps: builtins.filter (dep: dep != null) deps;
in
{
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;
};
build = withoutNulls (builtins.attrValues package.deps.build ++ process package.deps.build);
host = withoutNulls (builtins.attrValues package.deps.host ++ process package.deps.host);
};
};
@ -83,16 +57,19 @@ in
package: collected: ctx:
let
process =
path:
path: deps:
let
dependencies = lib.attrs.selectOrThrow path collected;
dependencies = lib.lists.flatten deps;
contexts = builtins.map (dependency: dependency.context or { }) dependencies;
result = lib.modules.run {
args = {
global = global.config;
};
prefix = package.__module__.args.dynamic.meta.prefix ++ [ "<context ${builtins.concatStringsSep path}>" ];
prefix = package.__module__.args.dynamic.meta.prefix ++ [
"<context ${path}>"
];
modules = (builtins.map (context: { config = context; }) contexts) ++ [
{
freeform = lib.types.any;
@ -101,22 +78,11 @@ in
target = lib.options.create {
description = "The dependency target that is being generated.";
type = lib.types.enum [
"build.build"
"build.host"
"build.target"
"host.host"
"host.target"
"target.target"
"build"
"host"
];
writable = false;
default.value = builtins.concatStringsSep "." path;
};
deps = lib.options.create {
description = "The collected dependencies.";
writable = false;
default.value = collected;
type = lib.types.dependencies;
default.value = path;
};
};
@ -126,38 +92,39 @@ in
};
in
result.config;
build = process "build" [
collected.build
];
host = process "host" [
collected.host
];
in
{
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"
];
};
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;
}
);
};
};
@ -176,36 +143,12 @@ in
hooks;
in
{
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"
];
};
build = process [
"build"
];
host = process [
"host"
];
};
};
@ -217,16 +160,39 @@ 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:
if alias ? versions then
alias.versions.${config.preferences.packages.version}
or (alias.versions.${lib.packages.getLatest 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})
else
alias;
build =
alias: build: host: target:
alias: build: host:
let
package = lib.packages.resolve alias;
@ -240,36 +206,34 @@ 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 targetSystem.double;
support = lib.packages.supports package buildSystem.double hostSystem.double;
result =
if !support.compatible then
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` does not support the platform build=${buildSystem.double}, host=${hostSystem.double}, target=${targetSystem.double}."
builtins.throw "📦 [Aux Tidepool] Package `${identifier}` does not support the platform build=${buildSystem.double}, host=${hostSystem.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}, target=${targetSystem.double}." result;
builtins.addErrorContext "📦 [Aux Tidepool] while building package `${identifier}` for platform build=${buildSystem.double}, host=${hostSystem.double}" result;
supports =
alias: build: host: target:
alias: build: host:
let
package = lib.packages.resolve alias;
matches = builtins.filter (
platform: platform.build == build && platform.host == host && platform.target == target
platform: platform.build == build && platform.host == host
) package.platforms;
in
{

View file

@ -0,0 +1,74 @@
{ 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,7 +25,8 @@ let
lib.attrs.match patterns;
getDoubles =
predicate: builtins.map lib.systems.into.double (builtins.filter predicate lib.systems.doubles.all);
predicate:
builtins.map lib.systems.into.double (builtins.filter predicate lib.systems.doubles.resolved);
in
{
config = {
@ -1048,7 +1049,7 @@ in
compatible =
a: b:
lib.any lib.id [
builtins.any lib.fp.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)
@ -2788,11 +2789,7 @@ 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,30 +2,101 @@
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;
};
short = lib.options.create {
description = "The short name of the license.";
type = lib.types.string;
};
name = lib.options.create {
description = "The short name of the license.";
type = lib.types.string;
};
spdx = lib.options.create {
fullName = lib.options.create {
description = "The full name of the license.";
type = lib.types.string;
};
spdxId = lib.options.create {
description = "The SPDX identifier for the license.";
type = lib.types.nullish lib.types.string;
default.value = null;
@ -33,7 +104,11 @@ in
url = lib.options.create {
description = "The URL for the license.";
type = lib.types.nullish lib.types.string;
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";
};
};
free = lib.options.create {
@ -60,41 +135,14 @@ 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 =
@ -172,84 +220,91 @@ 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 = [ ];
};
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;
result = lib.modules.run {
prefix = meta.prefix;
args = {
global = global.config;
};
modules = [
submodule
{ config.__modules__ = modules; }
]
++ modules;
};
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;
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 = [ ];
};
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;
};
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;
}
];
settings = lib.options.create {
description = "The settings for the builder.";
type = lib.types.submodule ({ config }: {});
default.value = { };
modules = config.__modules__ ++ normalized;
result = lib.modules.run {
prefix = meta.prefix;
args = {
global = global.config;
};
modules = [
submodule
{ config.__modules__ = modules; }
]
++ modules;
};
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;
};
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
@ -310,8 +365,7 @@ in
platforms = {
build = 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);
host = lib.types.attrs.of lib.types.platforms.host;
alias = lib.types.submodule {
options = {
stable = lib.options.create {
@ -324,6 +378,7 @@ 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;
@ -331,6 +386,25 @@ 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 =
@ -393,6 +467,8 @@ 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;
@ -480,49 +556,18 @@ in
};
deps =
build: host: target:
build: host:
lib.types.submodule {
options = {
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 = { };
};
build = lib.options.create {
description = "Dependencies which are executed in the build 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 = { };
};
host = lib.options.create {
description = "Dependencies which are executed in the host environment.";
type = lib.types.dependencies;
default.value = { };
};
};
};
@ -535,7 +580,6 @@ in
let
build = config.platform.build;
host = config.platform.host;
target = config.platform.target;
in
{
options = {
@ -548,10 +592,10 @@ in
__toString = lib.options.create {
description = "The derivation of the package as a string.";
type = lib.types.string;
type = lib.types.function lib.types.string;
internal = true;
writable = false;
default.value = builtins.toString config.package;
default.value = value: builtins.toString value.package;
};
extend = lib.options.create {
@ -696,30 +740,9 @@ in
platforms = lib.options.create {
description = "The platforms that the package supports.";
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;
};
};
}
)
);
type = lib.types.either lib.types.platforms.spec (lib.types.list.of lib.types.platforms.spec);
default.value = [ ];
apply = spec: lib.platforms.from.spec spec;
};
platform =
@ -738,12 +761,6 @@ 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 {
@ -778,76 +795,6 @@ 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 =
@ -859,13 +806,54 @@ 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 = "The environment for the package.";
type = lib.types.attrs.of lib.types.string;
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))
))
]
);
default.value = { };
};
@ -880,26 +868,28 @@ 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.attrs.generate lib.systems.doubles.all (target: lib.packages.build config build host target)
)
build: lib.attrs.generate lib.systems.doubles.all (host: lib.packages.build config build host)
);
};
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 {
@ -916,21 +906,11 @@ in
deps = lib.options.create {
description = "The dependencies for the package.";
type = deps build host target;
type = deps build host;
default.value = { };
apply = value: {
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;
};
build = lib.packages.dependencies.build build build value.build;
host = lib.packages.dependencies.build build host value.host;
};
};
};

View file

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

View file

@ -0,0 +1,99 @@
# 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,31 +13,40 @@ 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.basic;
builder = builders.foundation.basic;
deps.host.host = {
deps.host = {
inherit (packages.aux) b;
};
phases = {
install = ''
echo "a with b: ${config.deps.host.host.b.platform.host.double}" > $out
'';
};
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
'';
};
};
};
};

View file

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

View file

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

View file

@ -0,0 +1,61 @@
# 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

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

View file

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

View file

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

View file

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

View file

@ -5,15 +5,20 @@ let
lib
packages
builders
mirrors
;
inherit (global.internal.packages) foundation;
package = packages.foundation.gnupatch.versions."2.7-stage1".extend {
package = packages.foundation.bash.versions."5.2.15-stage1".extend {
platform = {
build = lib.modules.overrides.force "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -26,15 +31,12 @@ in
main = "/bin/bash";
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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
{
@ -27,44 +25,62 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/bash/bash-${version}.tar.gz";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
hash = "sha256-E3IJZbX0/DoNS2HdN+dWXHQdqaW+JO3CrgAYL8GzWIw=";
};
deps = {
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";
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";
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";
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 = {
@ -74,15 +90,26 @@ in
cd bash-${version}
'';
configure = ''
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build.triple} \
--host=${platform.host.triple} \
--enable-static-link \
bash_cv_func_strtoimax=y \
'';
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
'';
build = ''
# Build
@ -97,6 +124,5 @@ in
ln -s $out/bin/bash $out/bin/sh
'';
};
};
}

View file

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

View file

@ -5,19 +5,47 @@ 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 "i686-linux";
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
);
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.)";
@ -27,13 +55,12 @@ in
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
build = "@linux";
host = "@linux";
}
];
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,57 +7,71 @@ 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 =
lib.lists.when (!isCross) [
"LDFLAGS=--static"
]
++ [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
"--host=${platform.host.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"
];
"--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}"
];
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.)";
@ -68,59 +82,64 @@ 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";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/binutils/binutils-${version}.tar.xz";
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
deps = {
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";
gnupatch = packages.foundation.gnupatch.versions."2.7-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";
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";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
};
host = {
gcc =
if isBootstrapped then
packages.foundation.gcc.versions."13.2.0-bootstrap"
else
packages.foundation.gcc.versions."13.2.0-stage2";
binutils =
if isBootstrapped then
packages.foundation.binutils.versions."2.41-bootstrap"
else
packages.foundation.binutils.versions."2.41-stage1";
};
};
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";
gnupatch = packages.foundation.gnupatch.versions."2.7-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";
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
{
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";
gnupatch = packages.foundation.gnupatch.versions."2.7-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";
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};
});
};
phases = {

View file

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

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,18 +30,17 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};
};
hooks = package.hooks;
};
}

View file

@ -7,14 +7,12 @@ 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
{
@ -26,45 +24,62 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/bison/bison-${version}.tar.xz";
sha256 = "m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I=";
hash = "sha256-m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I=";
};
deps = {
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";
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};
};
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 @@
{ config, global }:
{ global }:
let
inherit (global) lib packages builders;
inherit (global) lib builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,15 +12,9 @@ in
license = lib.licenses.gpl2Only;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-busybox;
};

View file

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

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.bsdOriginal;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -5,16 +5,13 @@ 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 (
@ -30,33 +27,50 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
hash = "sha256-q1oDF27hBtPw+pDjgdpHjdrkBZGBU8yiSOaCzQxKImk=";
};
deps = {
build = {
build = {
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";
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 = {
@ -66,17 +80,27 @@ in
cd bzip2-${version}
'';
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
'';
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
'';
install = ''
# Install

View file

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

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,20 +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;
};
prefix = lib.strings.when (
platform.build.triple != platform.host.triple
) "${platform.host.triple}-";
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build.triple}"
@ -37,39 +31,62 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/coreutils/coreutils-${version}.tar.gz";
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
};
deps = {
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";
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";
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";
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,3 +1,7 @@
{ config }:
let
inherit (config) lib;
in
{
includes = [
./bash
@ -25,4 +29,14 @@
./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 @@
{ config, global }:
{ global }:
let
inherit (global) lib packages builders;
inherit (global) lib builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,15 +12,9 @@ in
license = lib.licenses.gpl3Only;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-diffutils;
};

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Only;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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
{
@ -26,40 +24,64 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/diffutils/diffutils-${version}.tar.xz";
sha256 = "kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
hash = "sha256-kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
};
deps = {
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";
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};
};
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 @@
{ config, global }:
{ global }:
let
inherit (global) lib packages builders;
inherit (global) lib builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,15 +12,9 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-findutils;
};

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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
{
@ -26,40 +24,64 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/findutils/findutils-${version}.tar.xz";
sha256 = "or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
};
deps = {
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";
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};
};
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 @@
{ config, global }:
{ global }:
let
inherit (global) lib packages builders;
inherit (global) lib builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,15 +12,9 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gawk;
};

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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
{
@ -26,40 +24,64 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/gawk/gawk-${version}.tar.gz";
sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
hash = "sha256-lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
};
deps = {
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";
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};
};
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
};
};
};
phases = {

View file

@ -8,15 +8,16 @@
{
config.packages.foundation.gcc = {
stable = config.packages.foundation.gcc.versions."13.2.0-bootstrap";
latest = config.packages.foundation.gcc.versions."13.2.0-stage4";
latest = config.packages.foundation.gcc.versions."13.2.0-passthrough";
versions = {
"13.2.0-stage4" = ./versions/13.2.0-stage4.nix;
"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-stage3-passthrough" = ./versions/13.2.0-stage3-passthrough.nix;
"13.2.0-stage3" = ./versions/13.2.0-stage3.nix;
"13.2.0-stage2" = ./versions/13.2.0-stage2.nix;
"13.2.0-stage1" = ./versions/13.2.0-stage1.nix;
"13.2.0-bootstrap" = ./versions/13.2.0-bootstrap.nix;
"13.2.0-stage4" = ./versions/13.2.0-stage4.nix;
};
};
}

View file

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

View file

@ -0,0 +1,75 @@
{ config, global }:
let
inherit (global)
lib
packages
builders
;
package =
if
config.platform.build == config.platform.host && config.platform.host != config.settings.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
then
packages.foundation.gcc.versions."13.2.0-stage3".extend {
platform = lib.modules.overrides.force config.platform;
}
else
packages.foundation.gcc.versions."13.2.0-stage4".extend {
platform = lib.modules.overrides.force config.platform;
};
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.";
homepage = "https://gcc.gnu.org";
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "@linux";
}
{
build = "i686-linux";
host = "@linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
hooks = package.hooks;
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};
};
};
}

View file

@ -8,14 +8,13 @@ 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;
target = lib.systems.withBuildInfo config.settings.target;
};
prefix = lib.strings.when (
@ -27,13 +26,12 @@ 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.target.binutils.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.target.binutils.package}/bin/${prefix}ld"
"--with-as=${config.deps.build.binutils-cross.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.binutils-cross.package}/bin/${prefix}ld"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
@ -75,6 +73,20 @@ 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 = {
@ -87,12 +99,13 @@ in
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -100,64 +113,85 @@ in
isl.version = "0.24";
src = {
gcc = builtins.fetchurl {
gcc = lib.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
gmp = lib.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = builtins.fetchurl {
mpfr = lib.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = builtins.fetchurl {
mpc = lib.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = builtins.fetchurl {
isl = lib.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
hash = "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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
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";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
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";
}
)
// {
binutils-cross =
packages.foundation.binutils.versions."2.41-stage1".target.${config.settings.target};
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
};
hooks = ctx: {
"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++'
# 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")
}'
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'
'';
@ -184,10 +218,6 @@ 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,30 +8,34 @@ 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.platform.target;
target = lib.systems.withBuildInfo config.settings.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"
"-Wl,${config.deps.target.target.glibc.package}/lib/ld-linux${
lib.strings.when (platform.target.isx86 && platform.target.is64bit) "-x86-64"
}.so.2"
"-B${config.deps.target.target.glibc.package}/lib"
"-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"
];
configureFlags = [
@ -39,17 +43,16 @@ let
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
"--with-as=${config.deps.build.target.binutils.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.target.binutils.package}/bin/${prefix}ld"
"--with-as=${config.deps.build.binutils-cross.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.binutils-cross.package}/bin/${prefix}ld"
"--enable-languages=c,c++"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--with-headers=${config.deps.target.target.glibc.package}/include"
"--with-headers=${config.deps.host.glibc.package}/include"
"--with-build-sysroot=/"
# "--with-sysroot=${config.deps.target.target.glibc.package}"
"--with-native-system-header-dir=${config.deps.target.target.glibc.package}/include"
"--with-build-time-tools=${config.deps.build.target.binutils.package}/bin"
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
"--with-build-time-tools=${config.deps.build.binutils-cross.package}/bin"
];
in
{
@ -73,6 +76,20 @@ 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 = {
@ -85,12 +102,13 @@ in
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -98,77 +116,97 @@ in
isl.version = "0.24";
src = {
gcc = builtins.fetchurl {
gcc = lib.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
gmp = lib.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = builtins.fetchurl {
mpfr = lib.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = builtins.fetchurl {
mpc = lib.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = builtins.fetchurl {
isl = lib.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
hash = "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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
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";
gcc = packages.foundation.gcc.versions."13.2.0-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
}
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";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
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";
}
)
// {
binutils-cross =
packages.foundation.binutils.versions."2.41-stage1".target.${config.settings.target};
};
target = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
};
};
target = {
target = {
glibc = packages.foundation.glibc.versions."2.38-stage1";
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1".extend {
platform.host = lib.modules.overrides.force config.settings.target;
};
};
};
env = {
CC = "gcc -Wl,-dynamic-linker";
CXX = "g++ -Wl,-dynamic-linker";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.target.target.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.target.target.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.target.target.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.target.triple}/libgcc -L${config.deps.host.glibc.package}/lib";
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
};
hooks = ctx: {
"aux:gcc: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}'
# 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")
}'
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'
'';
@ -196,16 +234,14 @@ in
configure = ''
# Configure
mkdir build
cd build
echo PATH=$PATH
# TODO(vlinkz) Hack to fix missing crti.o and crtn.o. Figure out how to properly find their paths.
mkdir gcc
ln -sv ${config.deps.target.target.glibc.package}/lib/{crti.o,crtn.o} gcc
mkdir -p x86_64-unknown-linux-gnu/libstdc++-v3/src
ln -sv ${config.deps.target.target.glibc.package}/lib/{crti.o,crtn.o} x86_64-unknown-linux-gnu/libstdc++-v3/src
ln -sv ${config.deps.host.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
bash ../configure ${builtins.concatStringsSep " " configureFlags}
'';
@ -221,6 +257,10 @@ 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,15 +6,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -26,15 +31,9 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms.build = "@linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -1,4 +1,4 @@
# gcc-bootstrap
# gcc-crossed
{ config, global }:
let
@ -8,46 +8,38 @@ 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"
"-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (platform.target.isx86 && platform.target.is64bit) "-x86-64"
}.so.2"
"-B${config.deps.host.host.glibc.package}/lib"
"-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}/lib"
"-B${config.package.outPath}/lib"
];
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
# Pretend we're native even though we're not
"--build=${platform.target.triple}"
"--build=${platform.build.triple}"
"--host=${platform.host.triple}"
"--target=${platform.target.triple}"
"--with-as=${config.deps.build.target.binutils.package}/bin/${prefix}as"
"--with-ld=${config.deps.build.target.binutils.package}/bin/${prefix}ld"
"--target=${platform.host.triple}"
"--enable-languages=c,c++"
"--disable-lto"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-native-system-header-dir=${config.deps.host.host.glibc.package}/include"
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
"--with-gxx-include-dir=${builtins.placeholder "out"}/include/c++/${config.version}/"
"--with-build-sysroot=/"
];
@ -73,6 +65,11 @@ in
type = lib.types.string;
description = "Version of isl.";
};
target.triple = lib.options.create {
type = lib.types.string;
description = "Target of GCC";
};
};
config = {
@ -86,11 +83,14 @@ in
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -98,79 +98,104 @@ in
isl.version = "0.24";
src = {
gcc = builtins.fetchurl {
gcc = lib.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
gmp = lib.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = builtins.fetchurl {
mpfr = lib.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = builtins.fetchurl {
mpc = lib.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = builtins.fetchurl {
isl = lib.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
build = {
build = {
bzip2 = packages.foundation.bzip2.versions."1.0.8-bootstrap";
diffutils = packages.foundation.diffutils.versions."3.10-bootstrap";
findutils = packages.foundation.findutils.versions."4.9.0-bootstrap";
gawk = packages.foundation.gawk.versions."5.2.2-bootstrap";
gnugrep = packages.foundation.gnugrep.versions."3.11-bootstrap";
gnumake = packages.foundation.gnumake.versions."4.4.1-bootstrap";
gnupatch = packages.foundation.gnupatch.versions."2.7-bootstrap";
gnused = packages.foundation.gnused.versions."4.9-bootstrap";
gnutar = packages.foundation.gnutar.versions."1.35-bootstrap";
gzip = packages.foundation.gzip.versions."1.13-bootstrap";
xz = packages.foundation.xz.versions."5.4.3-bootstrap";
binutils = packages.foundation.binutils.versions."2.41-stage1";
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";
binutils = packages.foundation.binutils.versions."2.41-bootstrap";
gcc = packages.foundation.gcc.versions."13.2.0-stage4";
glibc = packages.foundation.glibc.versions."2.38-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";
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 = {
host = {
glibc = packages.foundation.glibc.versions."2.38-stage1";
};
glibc = packages.foundation.glibc.versions."2.38-stage1";
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.package}/lib/ld-linux-x86-64.so.2";
LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET = "-L$(pwd)/${platform.target.triple}/libgcc -L${config.deps.host.host.glibc.package}/lib";
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";
CFLAGS = CFLAGS_FOR_TARGET;
LDFLAGS = LDFLAGS_FOR_TARGET;
LIBRARY_PATH = "${config.deps.host.glibc.package}/lib";
};
hooks = ctx: {
"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
"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")
}'
alias gcc='$CC'
alias g++='$CXX'
'';
@ -218,9 +243,5 @@ in
make -j $NIX_BUILD_CORES install
'';
};
context = {
a = true;
};
};
}

View file

@ -8,14 +8,12 @@ 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 = [
@ -23,25 +21,25 @@ let
];
gccFlags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (platform.target.isx86 && platform.target.is64bit) "-x86-64"
}.so.2"
"-B${config.deps.host.host.glibc.package}/lib"
"-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}/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.host.glibc.package}/include"
"--with-native-system-header-dir=${config.deps.host.glibc.package}/include"
];
in
{
@ -74,15 +72,9 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms.build = "@linux";
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
@ -90,78 +82,97 @@ in
isl.version = "0.24";
src = {
gcc = builtins.fetchurl {
gcc = lib.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
gmp = lib.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
hash = "sha256-o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
mpfr = builtins.fetchurl {
mpfr = lib.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
hash = "sha256-J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
mpc = builtins.fetchurl {
mpc = lib.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
hash = "sha256-q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
isl = builtins.fetchurl {
isl = lib.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
hash = "sha256-/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
deps = {
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";
};
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";
};
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";
};
};
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";
};
};
env = {
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${"${config.deps.host.host.glibc.package}/lib/ld-linux${lib.strings.when (platform.target.isx86 && platform.target.is64bit) "-x86-64"}.so.2"}";
LIBRARY_PATH = "${config.deps.host.host.glibc.package}/lib";
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.glibc.dynamicLinker}";
LIBRARY_PATH = "${config.deps.host.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
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")
}'
alias gcc='$CC'
alias g++='$CXX'
'';

View file

@ -1,10 +1,28 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
inherit (global)
lib
packages
builders
mirrors
;
version = lib.strings.removeSuffix "-bootstrap" config.version;
platform = {
build = lib.systems.withBuildInfo config.platform.build;
host = lib.systems.withBuildInfo config.platform.host;
};
in
{
options = {
dynamicLinker = lib.options.create {
type = lib.types.string;
description = "The dynamic linker/loader to be used.";
};
};
config = {
meta = {
description = "The GNU C Library.";
@ -12,18 +30,68 @@ in
license = lib.licenses.lgpl2Plus;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
settings = {
derivation = foundation.stage2-glibc;
builder = builders.foundation.basic;
src = lib.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${version}.tar.xz";
hash = "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";
};
};
dynamicLinker = "${config.package.outPath}/lib/ld-linux.so.2";
phases = {
unpack = ''
tar xf ${config.src}
cd glibc-${version}
'';
configure = ''
mkdir build
cd build
bash ../configure \
--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
'';
build = ''
# Build
make -j $NIX_BUILD_CORES
'';
install = ''
# Install
make -j $NIX_BUILD_CORES install
ln -sv $(ls -d ${config.deps.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
'';
};
};
}

View file

@ -5,19 +5,32 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
{
options = {
dynamicLinker = lib.options.create {
type = lib.types.string;
default = "ld-linux-x86-64.so.2";
description = "The dynamic linker/loader to be used.";
};
};
config = {
meta = {
description = "The GNU C Library.";
@ -25,15 +38,14 @@ in
license = lib.licenses.lgpl2Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
dynamicLinker = package.dynamicLinker;
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,17 +7,23 @@ 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
{
options = {
dynamicLinker = lib.options.create {
type = lib.types.string;
default = "ld-linux-x86-64.so.2";
description = "The dynamic linker/loader to be used.";
};
};
config = {
meta = {
description = "The GNU C Library.";
@ -26,62 +32,120 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${version}.tar.xz";
sha256 = "+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
hash = "sha256-+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
};
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";
python = packages.foundation.python.versions."3.12.0-bootstrap";
bison = packages.foundation.bison.versions."3.8.2-bootstrap";
linux-headers = packages.foundation.linux-headers.versions."6.5.6-bootstrap";
};
host = {
gcc = packages.foundation.gcc.versions."13.2.0-stage1";
binutils = packages.foundation.binutils.versions."2.41-stage1";
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";
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
{
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";
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 = {
linux-headers = packages.foundation.linux-headers.versions."6.5.6-stage1";
};
};
dynamicLinker =
"${config.package.outPath}/lib/"
+ (
if platform.host.double == "x86_64-linux" then
"ld-linux-x86-64.so.2"
else if platform.host.double == "aarch64-linux" then
"ld-linux-aarch64.so.1"
else if platform.host.double == "riscv64-linux" then
"ld-linux-riscv64-lp64d.so.1"
else
"ld-linux.so.2"
);
phases = {
unpack = ''
tar xf ${config.src}
cd glibc-${version}
'';
configure = ''
mkdir build
cd build
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
bash ../configure \
--prefix=$out \
--build=${platform.build.triple} \
--host=${platform.host.triple} \
--with-headers=${config.deps.build.build.linux-headers.package}/include \
--with-binutils=${config.deps.build.host.binutils.package}/${platform.target.triple}/bin
'';
bash ../configure ${flags}
'';
build = ''
# Build
@ -91,7 +155,25 @@ in
install = ''
# Install
make -j $NIX_BUILD_CORES install
ln -sv $(ls -d ${config.deps.build.build.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
${
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/
'';
};
};

View file

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

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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
{
@ -26,40 +24,64 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/grep/grep-${version}.tar.xz";
sha256 = "HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
hash = "sha256-HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
};
deps = {
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";
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};
};
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 @@
{ config, global }:
{ global }:
let
inherit (global) lib packages builders;
inherit (global) lib builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,15 +12,9 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-gnum4;
};

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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
{
@ -26,40 +24,64 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/m4/m4-${version}.tar.xz";
sha256 = "Y67eXG0zttmxNRHNC+LKwEby5w/QoHqpVzoEqCeDr5Y=";
hash = "sha256-Y67eXG0zttmxNRHNC+LKwEby5w/QoHqpVzoEqCeDr5Y=";
};
deps = {
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";
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};
};
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 @@
{ config, global }:
{ global }:
let
inherit (global) lib packages builders;
inherit (global) lib builders;
inherit (global.internal.packages) foundation;
in
{
@ -12,15 +12,9 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "i686-linux";
host = "i686-linux";
target = "i686-linux";
}
];
platforms.build = "i686-linux";
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gnumake;
};

View file

@ -5,15 +5,20 @@ 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 "i686-linux";
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
);
host = lib.modules.overrides.force config.platform.host;
target = lib.modules.overrides.force config.platform.target;
};
};
in
@ -25,15 +30,12 @@ in
license = lib.licenses.gpl3Plus;
};
platforms = [
{
build = "x86_64-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
];
platforms = {
build = "@linux";
host = "@linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -7,14 +7,12 @@ 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 = [
@ -31,40 +29,65 @@ in
};
platforms = [
{
build = "i686-linux";
}
{
build = "i686-linux";
host = "x86_64-linux";
target = "x86_64-linux";
}
{
build = "x86_64-linux";
host = "@linux";
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
src = lib.fetchurl {
url = "${mirrors.gnu}/make/make-${version}.tar.gz";
sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
hash = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
};
deps = {
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";
};
build =
(
if (config.platform.build == "i686-linux") then
host = {
binutils = packages.foundation.binutils.versions."2.41-stage1";
gcc = packages.foundation.gcc.versions."13.2.0-stage2";
{
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";