feat: passthrough foundation

This commit is contained in:
Jake Hamilton 2025-08-25 01:37:11 -07:00
parent 1d8f94fabe
commit c393a33a1d
Signed by untrusted user: jakehamilton
GPG key ID: 9762169A1B35EA68
67 changed files with 1539 additions and 1459 deletions

View file

@ -1,3 +1,6 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
.direnv
result
tidepool/src/packages/foundation.old

View file

@ -20,13 +20,13 @@ let
apply = value: lib.extend (final: prev: lib.attrs.mergeRecursive lib value);
};
foundation = lib.options.create {
internal.packages.foundation = lib.options.create {
type = lib.types.attrs.of lib.types.derivation;
};
};
config = {
inherit foundation;
internal.packages.foundation = foundation;
};
}
];

View file

@ -1,10 +1,53 @@
/*
This file is provided under the MIT licence:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range =
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
# (Taken from Niv for compatibility)
mayOverride =
name: path:
let
envVarName = "NPINS_OVERRIDE_${saneName}";
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
ersatz = builtins.getEnv envVarName;
in
if ersatz == "" then
path
else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
if builtins.substring 0 1 ersatz == "/" then
/. + ersatz
else
/. + builtins.getEnv "PWD" + "/${ersatz}"
);
mkSource =
spec:
name: spec:
assert spec ? type;
let
path =
@ -16,16 +59,19 @@ let
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else if spec.type == "Tarball" then
mkTarballSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };
spec // { outPath = mayOverride name path; };
mkGitSource =
{
repository,
revision,
url ? null,
submodules,
hash,
branch ? null,
...
@ -33,31 +79,39 @@ let
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null then
(builtins.fetchTarball {
if url != null && !submodules then
builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
sha256 = hash;
}
else
assert repository.type == "Git";
let
url =
if repository.type == "Git" then
repository.url
else if repository.type == "GitHub" then
"https://github.com/${repository.owner}/${repository.repo}.git"
else if repository.type == "GitLab" then
"${repository.server}/${repository.repo_path}.git"
else
throw "Unrecognized repository type ${repository.type}";
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName repository.url revision;
name = urlToName url revision;
in
builtins.fetchGit {
url = repository.url;
rev = revision;
inherit name;
# hash = hash;
narHash = hash;
inherit name submodules url;
};
mkPyPiSource =
@ -73,8 +127,20 @@ let
inherit url;
sha256 = hash;
};
mkTarballSource =
{
url,
locked_url ? url,
hash,
...
}:
builtins.fetchTarball {
url = locked_url;
sha256 = hash;
};
in
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins
if version == 6 then
builtins.mapAttrs mkSource data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

View file

@ -7,9 +7,10 @@
"url": "git+ssh://forgejo@git.auxolotl.org/auxolotl/foundation.git"
},
"branch": "main",
"revision": "47707c015ddd2f3b2a75ec83c582819dbef83ef5",
"submodules": false,
"revision": "ec6ba877756d3b898c75bdf8f75faff671fb3dbb",
"url": null,
"hash": "0fvs7ymwnyrssng4mwiyig5w8dkjclxw222hcx0lrs8wpa0az3i5"
"hash": "sha256-wCnUEFuFu1YKo2iE/kZeEpg3G8sCWeijuHXHTctKpJQ="
},
"lib": {
"type": "Git",
@ -18,10 +19,11 @@
"url": "git+ssh://forgejo@git.auxolotl.org/auxolotl/lib.git"
},
"branch": "main",
"revision": "7552ab48bb394d59d2bf1f7a558d28ce59da524d",
"submodules": false,
"revision": "137908ce11cc8a2b65f25ad81a9d6fdfa80cdc13",
"url": null,
"hash": "0705fm00k9f95b6idf5qnfvqm4qf1a0cv966ghgd48kd1qy4il5c"
"hash": "sha256-xfEIYhQzCPzo9SWs7uSAw8SnkwAwCZusDCgyzNFCmZ8="
}
},
"version": 3
}
"version": 6
}

View file

@ -2,7 +2,8 @@
let
cfg = config.builders.basic;
inherit (config) lib foundation;
inherit (config) lib;
inherit (config.internal.packages) foundation;
in
{
config.builders = {
@ -107,18 +108,17 @@ in
}
);
result =
built
// {
inherit (package) meta extend;
extras = {
inherit package context;
phases = builtins.listToAttrs sorted.result;
} // package.extras;
result = built // {
inherit package;
inherit (package) meta extend;
extras = package.extras // {
inherit context;
phases = builtins.listToAttrs sorted.result;
};
};
in
# (builtins.trace "build: ${package.name} -> build=${package.platform.build.triple} host=${package.platform.host.triple} target=${package.platform.target.triple}")
result;
result;
};
};
}

View file

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

View file

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

View file

@ -34,25 +34,21 @@ in
build = {
only = getPropagatedDependencies dependency.deps.build.only ++ process dependency.deps.build.only;
build =
getPropagatedDependencies dependency.deps.build.build
++ process dependency.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;
getPropagatedDependencies dependency.deps.build.target ++ process dependency.deps.build.target;
};
host = {
only = getPropagatedDependencies dependency.deps.host.only ++ process dependency.deps.host.only;
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
target =
getPropagatedDependencies dependency.deps.host.target
++ process dependency.deps.host.target;
getPropagatedDependencies dependency.deps.host.target ++ process dependency.deps.host.target;
};
target = {
only = getPropagatedDependencies dependency.deps.target.only ++ process dependency.deps.target.only;
target =
getPropagatedDependencies dependency.deps.target.target
++ process dependency.deps.target.target;
getPropagatedDependencies dependency.deps.target.target ++ process dependency.deps.target.target;
};
};
in
@ -101,6 +97,10 @@ in
dependencies = lib.attrs.selectOrThrow path collected;
contexts = builtins.map (dependency: dependency.context or { }) dependencies;
result = lib.modules.run {
args = {
global = config;
};
prefix = [ "<package>" ];
modules = builtins.map (context: { config = context; }) contexts ++ [
{
@ -211,15 +211,13 @@ in
path:
let
dependencies = lib.attrs.selectOrThrow path collected;
hooks = builtins.map
(
dependency:
let
getHooks = dependency.hooks or (lib.fp.const { });
in
getHooks ctx
)
dependencies;
hooks = builtins.map (
dependency:
let
getHooks = dependency.hooks or (lib.fp.const { });
in
getHooks ctx
) dependencies;
in
hooks;
in
@ -290,17 +288,17 @@ in
let
package = lib.packages.resolve alias;
buildDependencies =
build': host': target':
builtins.mapAttrs (name: dep: lib.packages.build dep build' host' target');
platform = {
build = lib.modules.overrides.force build;
host = lib.modules.overrides.force host;
target = lib.modules.overrides.force target;
build = lib.modules.override 10 build;
host = lib.modules.override 10 host;
target = lib.modules.override 10 target;
};
withPlatform = lib.modules.run {
args = {
global = config;
};
modules = package.__modules__ ++ [
lib.types.package.children.submodule
(
@ -322,24 +320,30 @@ in
withDeps = withPlatform.config // {
deps = {
build = {
only = buildDependencies build build build withPlatform.config.deps.build.only;
build = buildDependencies build build target withPlatform.config.deps.build.build;
host = buildDependencies build host target withPlatform.config.deps.build.host;
target = buildDependencies build target target withPlatform.config.deps.build.target;
only = lib.packages.dependencies.build build build build withPlatform.config.deps.build.only;
build = lib.packages.dependencies.build build build host withPlatform.config.deps.build.build;
host = lib.packages.dependencies.build build host target withPlatform.config.deps.build.host;
target = lib.packages.dependencies.build build target target withPlatform.config.deps.build.target;
};
host = {
only = buildDependencies host host host withPlatform.config.deps.host.only;
host = buildDependencies host host target withPlatform.config.deps.host.host;
target = buildDependencies host target target withPlatform.config.deps.host.target;
only = lib.packages.dependencies.build host host host withPlatform.config.deps.host.only;
host = lib.packages.dependencies.build host host target withPlatform.config.deps.host.host;
target = lib.packages.dependencies.build host target target withPlatform.config.deps.host.target;
};
target = {
only = buildDependencies target target target withPlatform.config.deps.target.only;
target = buildDependencies target target target withPlatform.config.deps.target.target;
only = lib.packages.dependencies.build target target target withPlatform.config.deps.target.only;
target =
lib.packages.dependencies.build target target target
withPlatform.config.deps.target.target;
};
};
};
withPackage = lib.modules.run {
args = {
global = config;
};
modules = package.__modules__ ++ [
lib.types.package.children.submodule
(
@ -366,13 +370,11 @@ in
${name} = lib.modules.merge [
alias
{
versions = builtins.mapAttrs
(version: package: {
id = lib.modules.overrides.default name;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
})
alias.versions;
versions = builtins.mapAttrs (version: package: {
id = lib.modules.overrides.default name;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
}) alias.versions;
}
];
};

View file

@ -602,7 +602,8 @@ in
mipsel-linux-gnu = {
triple = "mipsel-unknown-linux-gnu";
} // lib'.systems.platforms.gcc_mips32r2_o32;
}
// lib'.systems.platforms.gcc_mips32r2_o32;
# This function takes a minimally-valid "platform" and returns an
# attrset containing zero or more additional attrs which should be
@ -2548,254 +2549,253 @@ in
let
settings = if builtins.isString args then { system = args; } else args;
resolved =
{
system = lib'.systems.from.string (if settings ? triple then settings.triple else settings.system);
resolved = {
system = lib'.systems.from.string (if settings ? triple then settings.triple else settings.system);
inherit
(
{
linux-kernel = settings.linux-kernel or { };
gcc = settings.gcc or { };
rustc = settings.rustc or { };
}
// lib'.systems.platforms.select resolved
)
linux-kernel
gcc
rustc
;
inherit
(
{
linux-kernel = settings.linux-kernel or { };
gcc = settings.gcc or { };
rustc = settings.rustc or { };
}
// lib'.systems.platforms.select resolved
)
linux-kernel
gcc
rustc
;
double = lib'.systems.into.double resolved.system;
triple = lib'.systems.into.triple resolved.system;
double = lib'.systems.into.double resolved.system;
triple = lib'.systems.into.triple resolved.system;
isExecutable =
platform:
(resolved.isAndroid == platform.isAndroid)
&& resolved.system.kernel == platform.system.kernel
&& lib'.systems.validate.compatible resolved.system.cpu platform.system.cpu;
isExecutable =
platform:
(resolved.isAndroid == platform.isAndroid)
&& resolved.system.kernel == platform.system.kernel
&& lib'.systems.validate.compatible resolved.system.cpu platform.system.cpu;
# The difference between `isStatic` and `hasSharedLibraries` is mainly the
# addition of the `staticMarker` (see make-derivation.nix). Some
# platforms, like embedded machines without a libc (e.g. arm-none-eabi)
# don't support dynamic linking, but don't get the `staticMarker`.
# `pkgsStatic` sets `isStatic=true`, so `pkgsStatic.hostPlatform` always
# has the `staticMarker`.
isStatic = resolved.isWasm || resolved.isRedox;
# The difference between `isStatic` and `hasSharedLibraries` is mainly the
# addition of the `staticMarker` (see make-derivation.nix). Some
# platforms, like embedded machines without a libc (e.g. arm-none-eabi)
# don't support dynamic linking, but don't get the `staticMarker`.
# `pkgsStatic` sets `isStatic=true`, so `pkgsStatic.hostPlatform` always
# has the `staticMarker`.
isStatic = resolved.isWasm || resolved.isRedox;
# It is important that hasSharedLibraries==false when the platform has no
# dynamic library loader. Various tools (including the gcc build system)
# have knowledge of which platforms are incapable of dynamic linking, and
# will still build on/for those platforms with --enable-shared, but simply
# omit any `.so` build products such as libgcc_s.so. When that happens,
# it causes hard-to-troubleshoot build failures.
hasSharedLibraries =
!resolved.isStatic
&& (
# Linux (allows multiple libcs)
resolved.isAndroid
|| resolved.isGnu
|| resolved.isMusl
# BSDs
|| resolved.isDarwin
|| resolved.isSunOS
|| resolved.isOpenBSD
|| resolved.isFreeBSD
|| resolved.isNetBSD
# Windows
|| resolved.isCygwin
|| resolved.isMinGW
);
# It is important that hasSharedLibraries==false when the platform has no
# dynamic library loader. Various tools (including the gcc build system)
# have knowledge of which platforms are incapable of dynamic linking, and
# will still build on/for those platforms with --enable-shared, but simply
# omit any `.so` build products such as libgcc_s.so. When that happens,
# it causes hard-to-troubleshoot build failures.
hasSharedLibraries =
!resolved.isStatic
&& (
# Linux (allows multiple libcs)
resolved.isAndroid
|| resolved.isGnu
|| resolved.isMusl
# BSDs
|| resolved.isDarwin
|| resolved.isSunOS
|| resolved.isOpenBSD
|| resolved.isFreeBSD
|| resolved.isNetBSD
# Windows
|| resolved.isCygwin
|| resolved.isMinGW
);
libc =
if resolved.isDarwin then
"libSystem"
else if resolved.isMinGW then
"msvcrt"
else if resolved.isWasi then
"wasilibc"
else if resolved.isRedox then
"relibc"
else if resolved.isMusl then
"musl"
else if resolved.isUClibc then
"uclibc"
else if resolved.isAndroid then
"bionic"
else if resolved.isLinux then
"glibc"
else if resolved.isFreeBSD then
"fblibc"
else if resolved.isNetBSD then
"nblibc"
else if resolved.isAvr then
"avrlibc"
else if resolved.isGhcjs then
null
else if resolved.isNone then
"newlib"
else
"native/impure";
libc =
if resolved.isDarwin then
"libSystem"
else if resolved.isMinGW then
"msvcrt"
else if resolved.isWasi then
"wasilibc"
else if resolved.isRedox then
"relibc"
else if resolved.isMusl then
"musl"
else if resolved.isUClibc then
"uclibc"
else if resolved.isAndroid then
"bionic"
else if resolved.isLinux then
"glibc"
else if resolved.isFreeBSD then
"fblibc"
else if resolved.isNetBSD then
"nblibc"
else if resolved.isAvr then
"avrlibc"
else if resolved.isGhcjs then
null
else if resolved.isNone then
"newlib"
else
"native/impure";
linker = if resolved.isDarwin then "cctools" else "bfd";
linker = if resolved.isDarwin then "cctools" else "bfd";
extensions =
(lib.attrs.when resolved.hasSharedLibraries {
shared =
if resolved.isDarwin then
".dylib"
else if resolved.isWindows then
".dll"
else
".so";
})
// {
static = if resolved.isWindows then ".lib" else ".a";
library = if resolved.isStatic then resolved.extensions.static else resolved.extensions.shared;
executable = if resolved.isWindows then ".exe" else "";
};
uname = {
system =
if resolved.system.kernel.name == "linux" then
"Linux"
else if resolved.system.kernel.name == "windows" then
"Windows"
else if resolved.system.kernel.name == "darwin" then
"Darwin"
else if resolved.system.kernel.name == "netbsd" then
"NetBSD"
else if resolved.system.kernel.name == "freebsd" then
"FreeBSD"
else if resolved.system.kernel.name == "openbsd" then
"OpenBSD"
else if resolved.system.kernel.name == "wasi" then
"Wasi"
else if resolved.system.kernel.name == "redox" then
"Redox"
else if resolved.system.kernel.name == "redox" then
"Genode"
extensions =
(lib.attrs.when resolved.hasSharedLibraries {
shared =
if resolved.isDarwin then
".dylib"
else if resolved.isWindows then
".dll"
else
null;
".so";
})
// {
static = if resolved.isWindows then ".lib" else ".a";
processor =
if resolved.isPower64 then
"ppc64${lib.strings.when resolved.isLittleEndian "le"}"
else if resolved.isPower then
"ppc${lib.strings.when resolved.isLittleEndian "le"}"
else if resolved.isMips64 then
"mips64"
else
resolved.system.cpu.name;
library = if resolved.isStatic then resolved.extensions.static else resolved.extensions.shared;
release = null;
executable = if resolved.isWindows then ".exe" else "";
};
useAndroidPrebuilt = false;
useiOSPrebuilt = false;
uname = {
system =
if resolved.system.kernel.name == "linux" then
"Linux"
else if resolved.system.kernel.name == "windows" then
"Windows"
else if resolved.system.kernel.name == "darwin" then
"Darwin"
else if resolved.system.kernel.name == "netbsd" then
"NetBSD"
else if resolved.system.kernel.name == "freebsd" then
"FreeBSD"
else if resolved.system.kernel.name == "openbsd" then
"OpenBSD"
else if resolved.system.kernel.name == "wasi" then
"Wasi"
else if resolved.system.kernel.name == "redox" then
"Redox"
else if resolved.system.kernel.name == "redox" then
"Genode"
else
null;
linux.arch =
if resolved.isAarch32 then
"arm"
else if resolved.isAarch64 then
"arm64"
else if resolved.isx86_32 then
"i386"
else if resolved.isx86_64 then
"x86_64"
# linux kernel does not distinguish microblaze/microblazeel
else if resolved.isMicroBlaze then
"microblaze"
else if resolved.isMips32 then
"mips"
else if resolved.isMips64 then
"mips" # linux kernel does not distinguish mips32/mips64
processor =
if resolved.isPower64 then
"ppc64${lib.strings.when resolved.isLittleEndian "le"}"
else if resolved.isPower then
"powerpc"
else if resolved.isRiscV then
"riscv"
else if resolved.isS390 then
"s390"
else if resolved.isLoongArch64 then
"loongarch"
"ppc${lib.strings.when resolved.isLittleEndian "le"}"
else if resolved.isMips64 then
"mips64"
else
resolved.system.cpu.name;
uboot.arch =
if resolved.isx86_32 then
"x86" # not i386
else if resolved.isMips64 then
"mips64" # uboot *does* distinguish between mips32/mips64
else
resolved.linux.arch; # other cases appear to agree with linuxArch
release = null;
};
qemu.arch =
if resolved.isAarch32 then
"arm"
else if resolved.isS390 && !resolved.isS390x then
null
else if resolved.isx86_64 then
"x86_64"
else if resolved.isx86 then
"i386"
else if resolved.isMips64n32 then
"mipsn32${lib.strings.when resolved.isLittleEndian "el"}"
else if resolved.isMips64 then
"mips64${lib.strings.when resolved.isLittleEndian "el"}"
else
resolved.uname.processor;
useAndroidPrebuilt = false;
useiOSPrebuilt = false;
efi.arch =
if resolved.isx86_32 then
"ia32"
else if resolved.isx86_64 then
"x64"
else if resolved.isAarch32 then
"arm"
else if resolved.isAarch64 then
"aa64"
linux.arch =
if resolved.isAarch32 then
"arm"
else if resolved.isAarch64 then
"arm64"
else if resolved.isx86_32 then
"i386"
else if resolved.isx86_64 then
"x86_64"
# linux kernel does not distinguish microblaze/microblazeel
else if resolved.isMicroBlaze then
"microblaze"
else if resolved.isMips32 then
"mips"
else if resolved.isMips64 then
"mips" # linux kernel does not distinguish mips32/mips64
else if resolved.isPower then
"powerpc"
else if resolved.isRiscV then
"riscv"
else if resolved.isS390 then
"s390"
else if resolved.isLoongArch64 then
"loongarch"
else
resolved.system.cpu.name;
uboot.arch =
if resolved.isx86_32 then
"x86" # not i386
else if resolved.isMips64 then
"mips64" # uboot *does* distinguish between mips32/mips64
else
resolved.linux.arch; # other cases appear to agree with linuxArch
qemu.arch =
if resolved.isAarch32 then
"arm"
else if resolved.isS390 && !resolved.isS390x then
null
else if resolved.isx86_64 then
"x86_64"
else if resolved.isx86 then
"i386"
else if resolved.isMips64n32 then
"mipsn32${lib.strings.when resolved.isLittleEndian "el"}"
else if resolved.isMips64 then
"mips64${lib.strings.when resolved.isLittleEndian "el"}"
else
resolved.uname.processor;
efi.arch =
if resolved.isx86_32 then
"ia32"
else if resolved.isx86_64 then
"x64"
else if resolved.isAarch32 then
"arm"
else if resolved.isAarch64 then
"aa64"
else
resolved.system.cpu.name;
darwin = {
arch =
if resolved.system.cpu.name == "armv7a" then
"armv7"
else if resolved.system.cpu.name == "aarch64" then
"arm64"
else
resolved.system.cpu.name;
darwin = {
arch =
if resolved.system.cpu.name == "armv7a" then
"armv7"
else if resolved.system.cpu.name == "aarch64" then
"arm64"
else
resolved.system.cpu.name;
platform =
if resolved.isMacOS then
"macos"
else if resolved.isiOS then
"ios"
else
null;
platform =
sdk = {
version = resolved.darwinSdkVersion or (if resolved.isAarch64 then "11.0" else "10.12");
min = resolved.darwin.sdk.version;
variable =
if resolved.isMacOS then
"macos"
"MACOSX_DEPLOYMENT_TARGET"
else if resolved.isiOS then
"ios"
"IPHONEOS_DEPLOYMENT_TARGET"
else
null;
sdk = {
version = resolved.darwinSdkVersion or (if resolved.isAarch64 then "11.0" else "10.12");
min = resolved.darwin.sdk.version;
variable =
if resolved.isMacOS then
"MACOSX_DEPLOYMENT_TARGET"
else if resolved.isiOS then
"IPHONEOS_DEPLOYMENT_TARGET"
else
null;
};
};
}
// builtins.mapAttrs (name: match: match resolved.system) lib'.systems.match
// builtins.mapAttrs (
name: validate: validate (resolved.gcc.arch or "default")
) lib'.systems.validate.architecture
// (builtins.removeAttrs settings [ "system" ]);
};
}
// builtins.mapAttrs (name: match: match resolved.system) lib'.systems.match
// builtins.mapAttrs (
name: validate: validate (resolved.gcc.arch or "default")
) lib'.systems.validate.architecture
// (builtins.removeAttrs settings [ "system" ]);
assertions = builtins.foldl' (
result: { assertion, message }: if assertion resolved then result else builtins.throw message

View file

@ -60,65 +60,77 @@ in
lib.types.coerce lib.types.string lib.systems.withBuildInfo
lib.systems.types.platformWithBuildInfo;
builder = lib.types.submodule {
freeform = lib.types.any;
builder = lib.types.submodule ({ config, name }: {
freeform = lib.types.raw;
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.attrs.of lib.types.option;
default.value = {};
};
};
};
aliasesx = lib.types.attrs.of (lib.types.submodule ({ config, name }: {
freeform = lib.types.attrs.of lib.types.alias;
config = builtins.mapAttrs (x: { }) config;
}));
});
aliases =
let
normalize =
value:
if builtins.isFunction value || builtins.isList value then
if builtins.isNull value then
{}
else if builtins.isPath value then
{ includes = [ value ]; }
else if builtins.isFunction value || builtins.isList value then
value
else if value ? __modules__ then
value.__modules__
else
{ config = value; };
initial = lib.types.raw;
initial = lib.types.create {
name = "PackageConfig";
description = "configuration for a package";
check = value:
builtins.isFunction value || builtins.isAttrs value || builtins.isList value || builtins.isNull value || builtins.isPath value;
};
transform =
value:
let
result =
builtins.mapAttrs
(namespace: aliases:
builtins.mapAttrs
(id: alias:
alias // {
versions = builtins.mapAttrs
(version: package:
{
__modules__ = (lib.lists.from.any (normalize package)) ++ [
{
config = {
id = lib.modules.overrides.default id;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
};
}
];
}
)
alias.versions;
result = builtins.mapAttrs (
namespace: aliases:
builtins.mapAttrs (
id: alias:
alias
// {
versions = builtins.mapAttrs (version: package: {
__modules__ = (lib.lists.from.any (normalize package)) ++ [
{
config = {
id = lib.modules.overrides.default id;
version = lib.modules.overrides.default version;
namespace = lib.modules.overrides.default namespace;
};
}
)
aliases
)
value;
];
}) alias.versions;
}
) aliases
) value;
in
result;
@ -134,7 +146,7 @@ in
options = {
stable = lib.options.create {
description = "The stable version of the artifact.";
type = lib.types.nullish lib.types.artifact;
type = lib.types.artifact;
default.value = null;
};
latest = lib.options.create {
@ -151,9 +163,27 @@ in
};
};
artifact = lib.types.nullish (lib.types.withCheck
lib.types.derivation
(value: value ? extend && builtins.isFunction value.extend));
artifact =
let
base = lib.types.derivation // {
name = "Artifact";
description = "package artifact";
};
in
lib.types.nullish (
lib.types.withCheck
base
(value:
value ? package
&& builtins.isAttrs value.package
&& value ? meta
&& builtins.isAttrs value.meta
&& value ? extend
&& builtins.isFunction value.extend
&& value ? extras
&& builtins.isAttrs value.extras
)
);
dependencies =
build: host: target:
@ -169,48 +199,53 @@ in
in
lib.types.attrs.of (lib.types.coerce initial transform lib.types.package);
alias = lib.types.submodule ({ config, name }: {
options = {
extend = lib.options.create {
description = "Extend the default version with additional attributes.";
type = lib.types.function lib.types.raw;
writable = false;
default.value =
let
default = config.${global.config.preferences.packages.version};
in
default.extend or (builtins.throw "Package \"${name}\" does not have a ${global.config.preferences.packages.version} release.");
};
alias = lib.types.submodule (
{ config, name }:
{
options = {
extend = lib.options.create {
description = "Extend the default version with additional attributes.";
type = lib.types.function lib.types.raw;
writable = false;
default.value =
let
default = config.${global.config.preferences.packages.version};
in
default.extend
or (builtins.throw "Package \"${name}\" does not have a ${global.config.preferences.packages.version} release.");
};
stable = lib.options.create {
description = "The stable version of the package.";
type = lib.types.nullish lib.types.package;
default.value = null;
};
stable = lib.options.create {
description = "The stable version of the package.";
type = lib.types.package;
default.value = null;
};
latest = lib.options.create {
description = "The latest version of the package.";
type = lib.types.package;
default.value =
if config.versions == { } then
null
else
config.versions.${lib.packages.getLatest config};
};
latest = lib.options.create {
description = "The latest version of the package.";
type = lib.types.package;
default.value =
if config.versions == { } then null else config.versions.${lib.packages.getLatest config};
};
versions = lib.options.create {
description = "Available versions of the package.";
type = lib.types.attrs.of lib.types.package;
default.value = { };
versions = lib.options.create {
description = "Available versions of the package.";
type = lib.types.attrs.of lib.types.package;
default.value = { };
};
};
};
});
}
);
package =
let
normalize =
value:
if builtins.isFunction value || builtins.isList value then
if builtins.isNull value then
{}
else if builtins.isPath value then
{ includes = [ value ]; }
else if builtins.isFunction value || builtins.isList value then
value
else if value ? __modules__ then
value.__modules__
@ -220,7 +255,8 @@ in
initial = lib.types.create {
name = "PackageConfig";
description = "configuration for a package";
check = value: builtins.isFunction value || builtins.isAttrs value || builtins.isList value;
check = value:
builtins.isFunction value || builtins.isAttrs value || builtins.isList value || builtins.isNull value || builtins.isPath value;
merge =
location: definitions:
let
@ -250,11 +286,12 @@ in
result.config;
final = lib.types.raw // {
merge = location: definitions:
merge =
location: definitions:
let
modules = builtins.concatMap
(definition: lib.lists.from.any (normalize definition.value))
definitions;
modules = builtins.concatMap (
definition: lib.lists.from.any (normalize definition.value)
) definitions;
result = lib.modules.run {
prefix = location;
@ -339,7 +376,11 @@ in
};
submodule =
{ config, meta, name }:
{
config,
meta,
name,
}:
let
build = config.platform.build;
host = config.platform.host;
@ -384,7 +425,8 @@ in
modules = [
submodule
{ config.__modules__ = modules; }
] ++ modules;
]
++ modules;
};
in
result.config;
@ -432,12 +474,6 @@ in
type = lib.types.nullish lib.types.string;
default.value = null;
};
platforms = lib.options.create {
description = "The platforms the package supports.";
type = lib.types.list.of lib.types.string;
default.value = [ ];
};
};
extras = lib.options.create {
@ -446,6 +482,34 @@ in
default.value = { };
};
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.platform;
};
host = lib.options.create {
description = "The host platform for the package.";
type = lib.types.platform;
};
target = lib.options.create {
description = "The target platform for the package.";
type = lib.types.platform;
};
};
}
)
);
default.value = [ ];
};
platform = {
build = lib.options.create {
description = "The build platform for the package.";
@ -495,7 +559,82 @@ in
builder = lib.options.create {
description = "The builder for the package.";
type = lib.types.builder;
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 = lib.types.nullish (lib.types.one [ lib.types.derivation lib.types.path ]);
default.value = null;
};
env = lib.options.create {

View file

@ -4,16 +4,14 @@ let
in
{
config.packages.aux.a = {
stable = packages.aux.a.versions."1.0.0";
versions = {
"1.0.0" =
{ config }:
{
config = {
meta = {
platforms = [ "i686-linux" "x86_64-linux" ];
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.basic;

View file

@ -3,7 +3,7 @@ let
inherit (config) lib builders packages;
in
{
config.packages = lib.packages.create "aux" "b" {
config.packages.aux.b = {
versions = {
"1.0.0" =
{ config }:
@ -13,10 +13,6 @@ in
};
config = {
meta = {
platforms = [ "i686-linux" "x86_64-linux" ];
};
custom = true;
builder = builders.basic;

View file

@ -13,10 +13,6 @@ in
};
config = {
meta = {
platforms = [ "i686-linux" ];
};
custom = true;
builder = builders.basic;

View file

@ -0,0 +1,7 @@
{
includes = [
./a.nix
./b.nix
./c.nix
];
}

View file

@ -4,9 +4,13 @@ let
doubles = lib.systems.doubles.all;
packages = lib.attrs.filter (name: value: !(builtins.elem name doubles) && name != "context" && name != "platforms") config.packages;
packages = lib.attrs.filter
(
name: value: !(builtins.elem name doubles) && name != "context" && name != "platforms"
)
config.packages;
platforms = lib.attrs.generate doubles (
allPlatformOptions = lib.attrs.generate doubles (
build:
lib.options.create {
description = "Packages which are built on the ${build} system.";
@ -14,82 +18,143 @@ let
type = lib.types.submodule {
freeform = lib.types.platforms.build;
options = lib.attrs.generate doubles
(
host:
lib.options.create {
description = "Packages which are run on the ${host} system.";
default.value = { };
type = lib.types.submodule {
freeform = lib.types.platforms.host;
options = lib.attrs.generate doubles (
host:
lib.options.create {
description = "Packages which are run on the ${host} system.";
default.value = { };
type = lib.types.submodule {
freeform = lib.types.platforms.host;
options = lib.attrs.generate doubles (
target:
lib.options.create {
description = "Packages which are cross-compiled for the ${target} system.";
type = lib.types.platforms.target;
default.value =
let
outputs = builtins.mapAttrs
(namespace: aliases:
builtins.mapAttrs
(id: alias:
options = lib.attrs.generate doubles (
target:
lib.options.create {
description = "Packages which are cross-compiled for the ${target} system.";
type = lib.types.platforms.target;
default.value =
let
builtPlatforms =
let
builtNamespaces = builtins.mapAttrs
(
namespace: aliases:
let
override = {
platform = {
inherit build host target;
};
};
produce = path:
let
entry = lib.attrs.select path null alias;
in
if entry == null || !(entry ? extend) then
null
else if (builtins.elem build entry.meta.platforms) && (builtins.elem host entry.meta.platforms) && (builtins.elem target entry.meta.platforms) then
(lib.packages.build entry build host target).package
else
null;
in
{
stable = produce [ "stable" ];
latest = produce [ "latest" ];
builtAliases = builtins.mapAttrs
(
id: alias:
let
produce =
path:
let
entry = lib.attrs.select path null alias;
matches = builtins.partition
(platform:
platform.build.double == build &&
platform.host.double == host &&
platform.target.double == target)
entry.platforms;
in
if entry == null || !(entry ? extend) then
null
else if builtins.length matches.right > 0 then
(lib.packages.build entry build host target).package
else
null;
in
{
stable = produce [ "stable" ];
latest = produce [ "latest" ];
versions = builtins.mapAttrs
(version: alias: produce [ "versions" version ])
alias.versions;
})
aliases
)
packages;
in
outputs;
}
);
};
}
);
versions = builtins.mapAttrs
(
version: alias:
produce [
"versions"
version
]
)
alias.versions;
}
)
aliases;
filteredAliases = lib.attrs.filter (name: value:
let
entries = builtins.filter
(entry: entry != null)
([value.latest value.stable] ++ (builtins.attrValues value.versions));
isValid = value != null && entries != [];
in
isValid
) builtAliases;
in
filteredAliases
)
packages;
filteredNamespaces = lib.attrs.filter
(name: value: value != {})
builtNamespaces;
in
filteredNamespaces;
in
builtPlatforms;
}
);
};
}
);
};
}
);
builtPlatforms =
builtins.mapAttrs (build: hosts:
builtins.mapAttrs (host: targets:
builtins.mapAttrs (target: namespaces:
builtins.mapAttrs (namespace: aliases:
lib.attrs.filter (id: alias:
let
entries = builtins.filter
(entry: entry != null)
([alias.latest alias.stable] ++ (builtins.attrValues alias.versions));
isValid = alias != null && entries != [];
in
isValid
) aliases
) namespaces
) targets
) hosts
) config.internal.packages.platforms;
in
{
includes = [
./aux
./foundation
./aux/a.nix
./aux/b.nix
./aux/c.nix
];
options = {
internal.packages.platforms = lib.options.create {
description = "The built versions of packages for each platform.";
internal = true;
default.value = {};
type = lib.types.submodule {
options = allPlatformOptions;
};
};
packages = lib.options.create {
description = "The package set.";
default.value = { };
type = lib.types.submodule {
freeform = lib.types.aliases;
options = platforms // {
inherit platforms;
options = {
platforms = lib.options.create {
description = "The built versions of packages which are available.";
default.value = builtPlatforms;
type = lib.types.attrs.of lib.types.platforms.build;
};
# NOTE: We may offer a way to set default context values. For this reason we have
# nested `options` under `context` rather than using a plain option directly under `packages`.

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.bash = {
stable = config.packages.foundation.bash.versions."5.2.15-bootstrap";
versions = {
"5.2.15-bootstrap" = ./versions/5.2.15-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,25 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
homepage = "https://www.gnu.org/software/bash";
license = lib.licenses.gpl3Plus;
main = "/bin/bash";
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-bash;
};
};
};
}

View file

@ -1,177 +1,10 @@
{
lib,
lib',
config,
options,
}:
let
inherit (config)
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{ config }:
{
config.packages.foundation.binutils = {
stable = config.packages.foundation.binutils.versions."2.41-bootstrap";
versions = {
"latest" =
{ config }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross =
config.platform.build.double != config.platform.host.double
&& config.platform.host.double == config.platform.target.double;
in
{
meta = {
platforms = [
"i686-linux"
"x86_64-linux"
];
};
pname = "binutils";
version = "2.41";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isBootstrapped) (
if isCross then
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.build;
};
}
else
packages.foundation.gcc.versions.latest
);
glibc = lib.modules.when (isCross) (
packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) host target build;
};
}
);
binutils = lib.modules.when (isCross) (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) target build;
host = config.platform.build;
};
}
);
};
};
};
env =
{
PATH = lib.paths.bin (
lib.lists.when (isBootstrapped) [ foundation.stage2-gcc ]
++ [
foundation.stage2-gcc
foundation.stage2-binutils
foundation.stage2-gnumake
foundation.stage2-gnupatch
foundation.stage2-gnused
foundation.stage2-gnugrep
foundation.stage2-gawk
foundation.stage2-diffutils
foundation.stage2-findutils
foundation.stage2-gnutar
foundation.stage1-xz
]
);
}
// (lib.attrs.when (isCross) {
LDFLAGS_FOR_TARGET = "-B${config.deps.build.only.glibc.package}/lib -L${config.deps.build.only.glibc.package}/lib -I${config.deps.build.only.glibc.package}/include";
});
phases =
let
patches = [
# Make binutils output deterministic by default.
./patches/deterministic.patch
];
configureFlags =
lib.lists.when (!isCross) [
"LDFLAGS=--static"
]
++ [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries.
"--with-lib-path=:"
"--disable-multilib"
];
in
{
unpack = ''
tar xf ${config.src}
cd binutils-${config.version}
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
'';
configure = ''
bash ./configure ${builtins.concatStringsSep " " configureFlags}
'';
build = ''
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install-strip
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/binutils/binutils-${config.version}.tar.xz";
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
};
};
"2.41-bootstrap" = ./versions/2.41-bootstrap.nix;
};
};
}

View file

@ -1,13 +0,0 @@
diff -ur orig/binutils-2.23.1/ld/ldlang.c binutils-2.23.1/ld/ldlang.c
--- orig/ld/ldlang.c
+++ new/ld/ldlang.c
@@ -3095,6 +3095,8 @@
ldfile_output_machine))
einfo (_("%P%F:%s: can not set architecture: %E\n"), name);
+ link_info.output_bfd->flags |= BFD_DETERMINISTIC_OUTPUT;
+
link_info.hash = bfd_link_hash_table_create (link_info.output_bfd);
if (link_info.hash == NULL)
einfo (_("%P%F: can not create hash table: %E\n"));

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
homepage = "https://www.gnu.org/software/binutils";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-binutils;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.bison = {
stable = config.packages.foundation.bison.versions."3.8.2-bootstrap";
versions = {
"3.8.2-bootstrap" = ./versions/3.8.2-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Yacc-compatible parser generator.";
homepage = "https://www.gnu.org/software/bison";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage1-bison;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.busybox = {
stable = config.packages.foundation.busybox.versions."1.36.1-bootstrap";
versions = {
"1.36.1-bootstrap" = ./versions/1.36.1-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Tiny versions of common UNIX utilities in a single small executable.";
homepage = "https://busybox.net";
license = lib.licenses.gpl2Only;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-busybox;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.bzip2 = {
stable = config.packages.foundation.bzip2.versions."1.0.8-bootstrap";
versions = {
"1.0.8-bootstrap" = ./versions/1.0.8-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "High-quality data compression program.";
homepage = "https://www.sourceware.org/bzip2";
license = lib.licenses.bsdOriginal;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-bzip2;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.coreutils = {
stable = config.packages.foundation.coreutils.versions."9.4-bootstrap";
versions = {
"9.4-bootstrap" = ./versions/9.4-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "The GNU Core Utilities";
homepage = "https://www.gnu.org/software/coreutils";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-coreutils;
};
};
};
}

View file

@ -1,14 +1,27 @@
{ lib
, config
, options
,
}:
{
includes = [
./gcc
./bash
./binutils
./linux-headers
./bison
./busybox
./bzip2
./coreutils
./diffutils
./findutils
./gawk
./gcc
./glibc
# ./xz
./gnugrep
./gnum4
./gnumake
./gnupatch
./gnused
./gnutar
./gzip
./linux-headers
./patchelf
./python
./xz
./zlib
];
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.diffutils = {
stable = config.packages.foundation.diffutils.versions."3.10-bootstrap";
versions = {
"3.10-bootstrap" = ./versions/3.10-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Commands for showing the differences between files (diff, cmp, etc.).";
homepage = "https://www.gnu.org/software/diffutils";
license = lib.licenses.gpl3Only;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-diffutils;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.findutils = {
stable = config.packages.foundation.findutils.versions."4.9.0-bootstrap";
versions = {
"4.9.0-bootstrap" = ./versions/4.9.0-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system.";
homepage = "https://www.gnu.org/software/findutils";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-findutils;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gawk = {
stable = config.packages.foundation.gawk.versions."5.2.2-bootstrap";
versions = {
"5.2.2-bootstrap" = ./versions/5.2.2-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU implementation of the Awk programming language.";
homepage = "https://www.gnu.org/software/gawk";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gawk;
};
};
};
}

View file

@ -1,98 +0,0 @@
{ config, options }:
let
inherit (config)
lib
foundation
packages
;
in
{
config.packages.foundation.gcc-cross = {
versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend (
{ config }:
{
config =
let
programPrefix = lib.strings.when (
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
in
{
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
deps = {
build = {
build = {
binutils = (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 config.platform;
}
);
glibc = (
packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.target;
};
}
);
linux-headers = (
packages.foundation.linux-headers.versions.latest.extend {
platform.target = lib.modules.override 0 config.platform.target;
}
);
};
};
};
env = {
# LIBRARY_PATH = lib.modules.override 0 "${foundation.stage1-musl}/lib";
CC = lib.modules.override 0 "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -idirafter ${foundation.stage1-musl}/include";
CXX = lib.modules.override 0 "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -idirafter ${foundation.stage1-musl}/include";
CFLAGS_FOR_TARGET = lib.modules.override 0 "-Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.build.glibc.package}/lib";
LDFLAGS_FOR_TARGET = lib.modules.override 0 "-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.build.build.glibc.package}/lib";
};
configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/${programPrefix}as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/${programPrefix}ld"
"--enable-languages=c,c++"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--with-headers=${config.deps.build.build.glibc.package}/include"
"--with-build-sysroot=/"
# "--with-sysroot=${config.deps.build.build.glibc.package}"
"--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include"
];
phases.configure = lib.modules.override 0 ''
# 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.build.build.glibc.package}/lib/{crti.o,crtn.o} gcc
mkdir -p x86_64-unknown-linux-gnu/libstdc++-v3/src
ln -sv ${config.deps.build.build.glibc.package}/lib/{crti.o,crtn.o} x86_64-unknown-linux-gnu/libstdc++-v3/src
bash ../configure ${builtins.concatStringsSep " " config.configureFlags}
'';
};
}
);
};
};
}

View file

@ -1,392 +1,10 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{ config }:
{
includes = [
./newlib.nix
./cross.nix
# ./bootstrap.nix
];
config.packages.foundation.gcc = {
stable = config.packages.foundation.gcc.versions."13.2.0-bootstrap";
versions = {
"13.2.0" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.derivation;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.derivation;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
configureFlags = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Flags to pass to the configure script.";
};
exports = lib.options.create {
type = lib.types.attrs.of lib.types.string;
description = "List of exports to add to the environment.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
crossTool =
(config.platform.target.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.build.triple);
cross =
(config.platform.target.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
programPrefix = lib.strings.when
(
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
libc = if isBootstrapped then foundation.stage1-musl else config.deps.build.build.glibc.package;
libcLd =
if isBootstrapped then
"${foundation.stage1-musl}/lib/libc.so"
else
"${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2";
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
in
{
meta = {
platforms = [
"i686-linux"
];
};
id = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
version = "13.2.0";
builder = builders.basic;
deps = {
build = {
build = lib.modules.when (!isBootstrapped) {
gcc = packages.foundation.gcc-cross.versions.latest;
glibc = packages.foundation.glibc.versions.latest;
linux-headers = packages.foundation.linux-headers.versions.latest;
binutils = packages.foundation.binutils.versions.latest;
};
};
};
env =
{
PATH = lib.modules.when (isBuildBootstrapped) (
lib.paths.bin (
[
foundation.stage2-gnumake
foundation.stage2-gnused
foundation.stage2-gnugrep
foundation.stage2-gnupatch
foundation.stage2-gawk
foundation.stage2-diffutils
foundation.stage2-findutils
foundation.stage2-gnutar
foundation.stage2-gzip
foundation.stage2-bzip2
foundation.stage1-xz
]
++ (lib.lists.when (isBootstrapped) [
foundation.stage2-gcc
foundation.stage2-binutils
])
)
);
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${libcLd}";
}
// lib.attrs.when (isBootstrapped) {
CC = "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
CXX = "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
}
// lib.attrs.when (!cross && !crossTool) {
LIBRARY_PATH = "${libc}/lib";
};
hooks =
let
flags =
if (isBootstrapped && !(cross || crossTool)) then
[
"-Wl,-dynamic-linker"
"-Wl,${foundation.stage1-musl}/lib/libc.so"
]
else
[
"-Wl,-dynamic-linker"
"-Wl,${config.deps.build.build.glibc.package}/lib/ld-linux${
lib.strings.when (target.isx86 && target.is64bit) "-x86-64"
}.so.2"
"-B${config.deps.build.build.glibc.package}/lib"
# "-idirafter ${config.deps.build.build.glibc.package}/include"
];
in
ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/${programPrefix}gcc ${builtins.concatStringsSep " " flags}'
export CXX='${config.package}/bin/${programPrefix}g++ ${builtins.concatStringsSep " " flags}'
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'
'';
};
configureFlags =
[
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-build-sysroot=/"
"--with-native-system-header-dir=${libc}/include"
]
++ lib.lists.when (isBootstrapped) [
"--disable-lto"
];
phases =
let
patches = [
# Make binutils output deterministic by default.
./patches/libstdc++-target.patch
];
in
{
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
cd gcc-${config.version}
ln -s ../gmp-${config.gmp.version} gmp
ln -s ../mpfr-${config.mpfr.version} mpfr
ln -s ../mpc-${config.mpc.version} mpc
ln -s ../isl-${config.isl.version} isl
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
${lib.strings.when (isBootstrapped && !(crossTool || cross)) ''
# force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
''}
'';
configure = ''
# Configure
mkdir build
cd build
bash ../configure ${builtins.concatStringsSep " " config.configureFlags}
'';
build = ''
# Build
make -j $NIX_BUILD_CORES
'';
install = ''
# Install
${lib.strings.when (host.is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${config.version}/gcc-${config.version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
};
};
# "bootstrap" = config.packages.foundation.gcc.versions.latest.extend (
# { config }:
# {
# config = {
# meta = {
# platforms = lib.modules.override 0 [
# "i686-linux"
# ];
# };
#
# deps = {
# build = {
# build = {
# gcc = lib.modules.override 0 (
# packages.foundation.gcc-cross.versions.latest.extend {
# platform = lib.modules.override 0 {
# build = "i686-linux";
# target = config.platform.target;
# host = "i686-linux";
# };
# }
# );
# binutils = lib.modules.override 0 (
# packages.foundation.binutils.versions.latest.extend {
# platform = lib.modules.override 0 {
# build = "i686-linux";
# target = config.platform.target;
# host = config.platform.host;
# };
# }
# );
# glibc = lib.modules.override 0 (
# packages.foundation.glibc.versions.latest.extend {
# platform = lib.modules.override 0 {
# build = "i686-linux";
# target = config.platform.target;
# host = config.platform.host;
# };
# }
# );
# };
# };
# };
#
# env = {
# LIBRARY_PATH = lib.modules.override 0 "${config.deps.build.build.glibc.package}/lib";
# LDFLAGS_FOR_TARGET = lib.modules.override 0 "-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.build.build.glibc.package}/lib";
# };
#
# configureFlags = lib.modules.override 0 [
# "--prefix=${builtins.placeholder "out"}"
# # Pretend we're native even though we're not
# "--build=${config.platform.target.triple}"
# "--host=${config.platform.host.triple}"
# "--target=${config.platform.target.triple}"
# "--with-as=${config.deps.build.build.binutils.package}/bin/as"
# "--with-ld=${config.deps.build.build.binutils.package}/bin/ld"
# "--enable-languages=c,c++"
# "--disable-bootstrap"
# "--disable-libsanitizer"
# "--disable-multilib"
# "--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include"
# "--with-gxx-include-dir=${placeholder "out"}/include/c++/${config.version}/"
# "--with-build-sysroot=/"
# ];
# };
# }
# );
"13.2.0-bootstrap" = ./versions/13.2.0-bootstrap.nix;
};
};
}

View file

@ -1,70 +0,0 @@
{ config, options }:
let
inherit (config)
lib
packages
;
in
{
config.packages.foundation.gcc-newlib = {
versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend (
{ config }:
{
config =
let
programPrefix = lib.strings.when (
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
in
{
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
deps = {
build = {
build = {
binutils = (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 config.platform;
}
);
};
};
};
configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/${programPrefix}as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/${programPrefix}ld"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--disable-plugin"
"--disable-libssp"
"--disable-libvtv"
"--disable-libstdcxx"
"--disable-libquadmath"
"--disable-threads"
"--disable-decimal-float"
"--disable-shared"
"--disable-libmudflap"
"--disable-libgomp"
"--disable-libatomic"
"--without-headers"
"--with-newlib"
];
};
}
);
};
};
}

View file

@ -1,33 +0,0 @@
# From https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/development/compilers/gcc/patches/libstdc%2B%2B-target.patch
Patch to make the target libraries 'configure' scripts find the proper CPP.
I noticed that building the mingw32 cross compiler.
Looking at the build script for mingw in archlinux, I think that only nixos
needs this patch. I don't know why.
diff --git a/Makefile.in b/Makefile.in
index 93f66b6..d691917 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
AR="$(AR_FOR_TARGET)"; export AR; \
AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
RAW_CXX_TARGET_EXPORTS = \
$(BASE_TARGET_EXPORTS) \
CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
NORMAL_TARGET_EXPORTS = \
$(BASE_TARGET_EXPORTS) \
- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
# Where to find GMP
HOST_GMPLIBS = @gmplibs@

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU Compiler Collection.";
homepage = "https://gcc.gnu.org";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gcc;
};
};
};
}

View file

@ -1,152 +1,10 @@
{
lib,
lib',
config,
options,
packages,
}:
let
inherit (config)
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
packages
foundation
;
in
{ config }:
{
config.packages.foundation.glibc = {
stable = config.packages.foundation.glibc.versions."2.38-bootstrap";
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
binutils =
if isCross then
"${
(packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.build;
};
}).package
}/${config.platform.target.triple}"
else
foundation.stage2-binutils;
in
{
meta = {
platforms = [
"i686-linux"
"x86_64-linux"
];
};
pname = "glibc";
version = "2.38";
src = builtins.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${config.version}.tar.xz";
sha256 = "+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
};
builder = builders.basic;
deps = {
build = {
host = {
linux-headers = (
packages.foundation.linux-headers.versions.latest.extend {
platform.target = lib.modules.override 0 config.platform.target;
}
);
};
};
};
env = {
PATH =
let
gcc =
if
isCross
# Otherwise we are going to need a cross-compiler.
then
(packages.foundation.gcc-newlib.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.build;
};
}).package
# If we're on the same system then we can use the existing GCC instance.
else
foundation.stage2-gcc;
in
lib.paths.bin [
gcc
binutils
foundation.stage2-gnumake
foundation.stage2-gnused
foundation.stage2-gnugrep
foundation.stage2-gawk
foundation.stage2-diffutils
foundation.stage2-findutils
foundation.stage2-gnutar
foundation.stage2-gzip
foundation.stage2-bzip2
foundation.stage1-python
foundation.stage1-bison
foundation.stage1-xz
];
};
phases =
{
unpack = ''
tar xf ${config.src}
cd glibc-${config.version}
'';
configure = ''
mkdir build
cd build
bash ../configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple} \
--with-headers=${config.deps.build.host.linux-headers.package}/include \
--with-binutils=${binutils}/bin
'';
build = ''
# Build
make -j $NIX_BUILD_CORES
'';
install = ''
# Install
make -j $NIX_BUILD_CORES install
ln -sv $(ls -d ${config.deps.build.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
'';
};
};
};
"2.38-bootstrap" = ./versions/2.38-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "The GNU C Library.";
homepage = "https://www.gnu.org/software/libc";
license = lib.licenses.lgpl2Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-glibc;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gnugrep = {
stable = config.packages.foundation.gnugrep.versions."3.11-bootstrap";
versions = {
"3.11-bootstrap" = ./versions/3.11-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU implementation of the Unix grep command.";
homepage = "https://www.gnu.org/software/grep";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gnugrep;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gnum4 = {
stable = config.packages.foundation.gnum4.versions."1.4.19-bootstrap";
versions = {
"1.4.19-bootstrap" = ./versions/1.4.19-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU M4, a macro processor.";
homepage = "https://www.gnu.org/software/m4";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage1-gnum4;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gnumake = {
stable = config.packages.foundation.gnumake.versions."4.4.1-bootstrap";
versions = {
"4.4.1-bootstrap" = ./versions/4.4.1-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "A tool to control the generation of non-source files from sources.";
homepage = "https://www.gnu.org/software/make";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gnumake;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gnupatch = {
stable = config.packages.foundation.gnupatch.versions."2.7-bootstrap";
versions = {
"2.7-bootstrap" = ./versions/2.7-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU Patch, a program to apply differences to files.";
homepage = "https://www.gnu.org/software/patch";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gnupatch;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gnused = {
stable = config.packages.foundation.gnused.versions."4.9-bootstrap";
versions = {
"4.9-bootstrap" = ./versions/4.9-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU sed, a batch stream editor.";
homepage = "https://www.gnu.org/software/sed";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gnused;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gnutar = {
stable = config.packages.foundation.gnutar.versions."1.35-bootstrap";
versions = {
"1.35-bootstrap" = ./versions/1.35-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU implementation of the `tar` archiver.";
homepage = "https://www.gnu.org/software/tar";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gnutar;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.gzip = {
stable = config.packages.foundation.gzip.versions."1.13-bootstrap";
versions = {
"1.13-bootstrap" = ./versions/1.13-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "GNU zip compression program.";
homepage = "https://www.gnu.org/software/gzip";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-gzip;
};
};
};
}

View file

@ -1,84 +1,10 @@
{
lib,
lib',
config,
options,
}:
let
inherit (config)
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
;
in
{ config }:
{
config.packages.foundation.linux-headers = {
stable = config.packages.foundation.linux-headers.versions."6.5.6-bootstrap";
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config = {
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
pname = "linux-headers";
version = "6.5.6";
builder = builders.basic;
env = {
PATH = lib.paths.bin [
foundation.stage2-gcc
foundation.stage1-musl
foundation.stage2-binutils
foundation.stage2-gnumake
foundation.stage2-gnupatch
foundation.stage2-gnused
foundation.stage2-gnugrep
foundation.stage2-gawk
foundation.stage2-diffutils
foundation.stage2-findutils
foundation.stage2-gnutar
foundation.stage1-xz
];
};
phases = {
unpack = ''
tar xf ${config.src}
cd linux-${config.version}
'';
build = ''
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.target.linux.arch} headers
'';
install = ''
find usr/include -name '.*' -exec rm {} +
mkdir -p $out
cp -rv usr/include $out/
'';
};
src = builtins.fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major config.version}.x/linux-${config.version}.tar.xz";
sha256 = "eONtQhRUcFHCTfIUD0zglCjWxRWtmnGziyjoCUqV0vY=";
};
};
};
"6.5.6-bootstrap" = ./versions/6.5.6-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,23 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Header files and scripts for the Linux kernel.";
license = lib.licenses.lgpl2Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage1-linux-headers;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.patchelf = {
stable = config.packages.foundation.patchelf.versions."0.18.0-bootstrap";
versions = {
"0.18.0-bootstrap" = ./versions/0.18.0-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "A small utility to modify the dynamic linker and RPATH of ELF executables.";
homepage = "https://github.com/NixOS/patchelf";
license = lib.licenses.gpl3Plus;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage2-patchelf;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.python = {
stable = config.packages.foundation.python.versions."3.12.0-bootstrap";
versions = {
"3.12.0-bootstrap" = ./versions/3.12.0-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "A high-level dynamically-typed programming language.";
homepage = "https://www.python.org";
license = lib.licenses.psfl;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage1-python;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.xz = {
stable = config.packages.foundation.xz.versions."5.4.3-bootstrap";
versions = {
"5.4.3-bootstrap" = ./versions/5.4.3-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,27 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "A general-purpose data compression software, successor of LZMA.";
homepage = "https://tukaani.org/xz";
license = [
lib.licences.gpl2Plus
lib.licenses.lgpl21Plus
];
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage1-xz;
};
};
};
}

View file

@ -0,0 +1,10 @@
{ config }:
{
config.packages.foundation.zlib = {
stable = config.packages.foundation.zlib.versions."1.3-bootstrap";
versions = {
"1.3-bootstrap" = ./versions/1.3-bootstrap.nix;
};
};
}

View file

@ -0,0 +1,24 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
in {
config = {
meta = {
description = "Lossless data-compression library.";
homepage = "https://zlib.net";
license = lib.licenses.zlib;
};
platforms = [
{ build = "i686-linux"; host = "i686-linux"; target = "i686-linux"; }
];
builder = builders.passthrough // {
settings = {
derivation = foundation.stage1-zlib;
};
};
};
}