add native x86_64 gcc #12

Open
vlinkz wants to merge 1 commit from vlinkz/labs:vlinkz/cross2native into main
26 changed files with 2413 additions and 538 deletions

View file

@ -12,28 +12,57 @@ in
inherit lib; inherit lib;
modules = import ./modules.nix; modules = import ./modules.nix;
packages = { packages =
aux-a = config.packages.aux.a; (builtins.listToAttrs (
aux-b = config.packages.aux.b; builtins.concatMap
(name: [
{
name = "foundation-${name}";
value = config.packages.foundation.${name};
}
{
name = "cross-foundation-${name}-x86_64-linux";
value = config.packages.cross.x86_64-linux.foundation.${name};
}
{
name = "cross-tool-foundation-${name}-x86_64-linux";
value = config.packages.cross-tools.x86_64-linux.foundation.${name};
}
])
[
"binutils"
"bzip2"
"diffutils"
"findutils"
"gawk"
"gcc"
"glibc"
"gnugrep"
"gnumake"
"gnupatch"
"gnused"
"gnutar"
"gzip"
"linux-headers"
"xz"
]
))
// {
aux-a = config.packages.aux.a;
aux-b = config.packages.aux.b;
foundation-gcc = config.packages.foundation.gcc; cross-tool-foundation-binutils-aarch64-linux =
foundation-glibc = config.packages.foundation.glibc; config.packages.cross-tools.aarch64-linux.foundation.binutils;
foundation-binutils = config.packages.foundation.binutils;
foundation-linux-headers = config.packages.foundation.linux-headers;
cross-foundation-glibc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.glibc; cross-tool-foundation-gcc-newlib-aarch64-linux =
cross-foundation-binutils-x86_64-linux = config.packages.cross.x86_64-linux.foundation.binutils; config.packages.cross-tools.aarch64-linux.foundation.gcc-newlib;
cross-tool-foundation-gcc-newlib-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.gcc-newlib; cross-tool-foundation-binutils-riscv64-linux =
cross-tool-foundation-gcc-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.gcc-cross; config.packages.cross-tools.riscv64-linux.foundation.binutils;
cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc-bootstrap;
example-a = config.packages.foundation.gcc.versions.latest.extend { cross-tool-foundation-gcc-newlib-riscv64-linux =
platform = { config.packages.cross-tools.riscv64-linux.foundation.gcc-newlib;
target = lib.modules.override 0 "x86_64-linux";
};
}; };
};
}; };
}; };
} }

View file

@ -211,15 +211,13 @@ in
path: path:
let let
dependencies = lib.attrs.selectOrThrow path collected; dependencies = lib.attrs.selectOrThrow path collected;
hooks = builtins.map hooks = builtins.map (
( dependency:
dependency: let
let getHooks = dependency.hooks or (lib.fp.const { });
getHooks = dependency.hooks or (lib.fp.const { }); in
in getHooks ctx
getHooks ctx ) dependencies;
)
dependencies;
in in
hooks; hooks;
in in

View file

@ -263,7 +263,8 @@ in
type = lib.types.function lib.types.raw; type = lib.types.function lib.types.raw;
internal = true; internal = true;
writable = false; writable = false;
default.value = module: default.value =
module:
let let
normalized = normalized =
if builtins.isList module then if builtins.isList module then
@ -271,17 +272,19 @@ in
else if builtins.isFunction module || module ? config then else if builtins.isFunction module || module ? config then
[ module ] [ module ]
else else
[{ [
config = module; {
}]; config = module;
}
];
modules = config.__modules__ ++ normalized; modules = config.__modules__ ++ normalized;
result = lib.modules.run { result = lib.modules.run {
modules = [ modules = [
submodule submodule
{ config.__modules__ = modules; } { config.__modules__ = modules; }
] ++ modules; ] ++ modules;
}; };
in in
result.config; result.config;

View file

@ -4,7 +4,10 @@ let
doubles = lib.systems.doubles.all; doubles = lib.systems.doubles.all;
packages = builtins.removeAttrs config.packages [ "cross" "cross-tools" ]; packages = builtins.removeAttrs config.packages [
"cross"
"cross-tools"
];
in in
{ {
includes = [ includes = [
@ -64,64 +67,60 @@ in
config = { config = {
packages.cross-tools = lib.attrs.generate doubles ( packages.cross-tools = lib.attrs.generate doubles (
system: system:
builtins.mapAttrs builtins.mapAttrs (
( namespace:
namespace: builtins.mapAttrs (
builtins.mapAttrs ( name: alias:
name: alias: let
let setTarget =
setTarget = package:
package: package
package // {
// { __modules__ = package.__modules__ ++ [
__modules__ = package.__modules__ ++ [ {
{ config.platform = {
config.platform = { target = lib.modules.override 5 system;
target = lib.modules.override 5 system; };
}; }
} ];
]; };
};
updated = alias // { updated = alias // {
versions = builtins.mapAttrs (version: package: setTarget package) alias.versions; versions = builtins.mapAttrs (version: package: setTarget package) alias.versions;
}; };
in in
updated updated
)
) )
packages ) packages
); );
packages.cross = lib.attrs.generate doubles ( packages.cross = lib.attrs.generate doubles (
system: system:
builtins.mapAttrs builtins.mapAttrs (
( namespace:
namespace: builtins.mapAttrs (
builtins.mapAttrs ( name: alias:
name: alias: let
let setPlatform =
setPlatform = package:
package: package
package // {
// { __modules__ = package.__modules__ ++ [
__modules__ = package.__modules__ ++ [ {
{ config.platform = {
config.platform = { host = lib.modules.override 5 system;
host = lib.modules.override 5 system; target = lib.modules.override 5 system;
target = lib.modules.override 5 system; };
}; }
} ];
]; };
};
updated = alias // { updated = alias // {
versions = builtins.mapAttrs (version: package: setPlatform package) alias.versions; versions = builtins.mapAttrs (version: package: setPlatform package) alias.versions;
}; };
in in
updated updated
)
) )
packages ) packages
); );
}; };
} }

View file

@ -1,8 +1,8 @@
{ lib {
, lib' lib,
, config lib',
, options config,
, options,
}: }:
let let
inherit (config) inherit (config)
@ -46,7 +46,17 @@ in
]; ];
}; };
pname = "binutils"; platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "binutils-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
version = "2.41"; version = "2.41";
builder = builders.basic; builder = builders.basic;
@ -54,26 +64,30 @@ in
deps = { deps = {
build = { build = {
only = { only = {
gcc = lib.modules.when (!isBootstrapped) ( gcc = lib.modules.when (!isBootstrapped && !isCross) (packages.foundation.gcc.versions.latest);
if isCross then binutils = lib.modules.when (!isBootstrapped && !isCross) (
packages.foundation.gcc-cross.versions.latest.extend packages.foundation.binutils.versions.latest
{
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) ( gnumake = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnumake.versions.latest;
packages.foundation.glibc.versions.latest.extend { gnupatch = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnupatch.versions.latest;
gnused = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnused.versions.latest;
gnugrep = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnugrep.versions.latest;
gawk = lib.modules.when (!isBuildBootstrapped) packages.foundation.gawk.versions.latest;
diffutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.diffutils.versions.latest;
findutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.findutils.versions.latest;
gnutar = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnutar.versions.latest;
xz = lib.modules.when (!isBuildBootstrapped) packages.foundation.xz.versions.latest;
};
host = {
gcc = lib.modules.when isCross (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 { platform = lib.modules.override 0 {
inherit (config.platform) host target build; inherit (config.platform) build target;
host = config.platform.build;
}; };
} }
); );
binutils = lib.modules.when (isCross) ( binutils = lib.modules.when isCross (
packages.foundation.binutils.versions.latest.extend { packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 { platform = lib.modules.override 0 {
inherit (config.platform) target build; inherit (config.platform) target build;
@ -87,10 +101,11 @@ in
env = { env = {
PATH = lib.paths.bin ( PATH = lib.paths.bin (
lib.lists.when (isBootstrapped) [ foundation.stage2-gcc ] lib.lists.when (isBootstrapped) [
++ [
foundation.stage2-gcc foundation.stage2-gcc
foundation.stage2-binutils foundation.stage2-binutils
]
++ (lib.lists.when (isBuildBootstrapped) [
foundation.stage2-gnumake foundation.stage2-gnumake
foundation.stage2-gnupatch foundation.stage2-gnupatch
foundation.stage2-gnused foundation.stage2-gnused
@ -100,11 +115,9 @@ in
foundation.stage2-findutils foundation.stage2-findutils
foundation.stage2-gnutar foundation.stage2-gnutar
foundation.stage1-xz 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 = phases =
let let
@ -139,7 +152,6 @@ in
"--with-lib-path=:" "--with-lib-path=:"
"--disable-multilib" "--disable-multilib"
]; ];
in in
{ {

View file

@ -0,0 +1,119 @@
{ config, options }:
let
inherit (config)
lib
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.bzip2 = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "bzip2";
version = "1.0.8";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
foundation.stage2-gnumake
foundation.stage2-gnutar
foundation.stage2-gzip
]
);
};
phases = {
unpack = ''
tar xf ${config.src}
cd bzip2-${config.version}
'';
build = ''
${lib.strings.when (isCross) ''
export PATH="$PATH:${config.deps.build.host.binutils.package}/${config.platform.target.triple}/bin"
''}
make -j $NIX_BUILD_CORES \
CC="$CC" \
bzip2 bzip2recover
'';
install = ''
make -j $NIX_BUILD_CORES install PREFIX=$out
'';
};
src = builtins.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${config.version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
};
};
};
};
};
}

View file

@ -5,12 +5,25 @@
options, options,
}: }:
{ {
# includes = lib.attrs.mapToList (key: value: ./${key}) (
# lib.attrs.filter (key: value: value == "directory") (builtins.readDir ./.)
# );
includes = [ includes = [
./gcc
./binutils ./binutils
./linux-headers ./bzip2
./diffutils
./findutils
./gawk
./gcc
./glibc ./glibc
# ./xz ./gnugrep
./gnumake
./gnupatch
./gnused
./gnutar
./gzip
./linux-headers
./xz
]; ];
config = { config = {

View file

@ -0,0 +1,125 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.diffutils = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "diffutils";
version = "3.10";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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 diffutils-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/diffutils/diffutils-${config.version}.tar.xz";
sha256 = "kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4=";
};
};
};
};
};
}

View file

@ -0,0 +1,126 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.findutils = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "findutils";
version = "4.9.0";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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 findutils-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
rm $out/bin/updatedb
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/findutils/findutils-${config.version}.tar.xz";
sha256 = "or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
};
};
};
};
};
}

View file

@ -0,0 +1,126 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gawk = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gawk";
version = "5.2.2";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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.stage2-gzip
]
);
};
phases = {
unpack = ''
tar xf ${config.src}
cd gawk-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
rm $out/bin/gawkbug
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/gawk/gawk-${config.version}.tar.gz";
sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA=";
};
};
};
};
};
}

View file

@ -8,44 +8,79 @@ in
{ {
config.packages.foundation.gcc-bootstrap = { config.packages.foundation.gcc-bootstrap = {
versions = { versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend "latest" = config.packages.foundation.gcc-common.versions.latest.extend (
( { config }:
{ config }: {
{ config =
config = { let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
bootstrapArch =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
in
{
meta = { meta = {
platforms = lib.modules.override 0 [ platforms = lib.modules.override 0 [
"i686-linux" "i686-linux"
]; ];
}; };
platform = lib.modules.override 1 {
build = bootstrapArch;
};
pname =
lib.modules.override 0
"gcc-bootstrap-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
deps = { deps = {
build = { build = {
build = { only = {
binutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.binutils.versions.latest;
gnumake = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnumake.versions.latest;
gnused = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnused.versions.latest;
gnugrep = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnugrep.versions.latest;
gnupatch = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnupatch.versions.latest;
gawk = lib.modules.when (!isBuildBootstrapped) packages.foundation.gawk.versions.latest;
diffutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.diffutils.versions.latest;
findutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.findutils.versions.latest;
gnutar = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnutar.versions.latest;
gzip = lib.modules.when (!isBuildBootstrapped) packages.foundation.gzip.versions.latest;
bzip2 = lib.modules.when (!isBuildBootstrapped) packages.foundation.bzip2.versions.latest;
xz = lib.modules.when (!isBuildBootstrapped) packages.foundation.xz.versions.latest;
};
host = {
gcc = lib.modules.override 0 ( gcc = lib.modules.override 0 (
packages.foundation.gcc-cross.versions.latest.extend { packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 { platform = lib.modules.override 0 {
build = "i686-linux"; inherit (config.platform) target;
target = config.platform.target; build = bootstrapArch;
host = "i686-linux"; host = bootstrapArch;
}; };
} }
); );
binutils = lib.modules.override 0 ( binutils = lib.modules.override 0 (
packages.foundation.binutils.versions.latest.extend { packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 { platform = lib.modules.override 0 {
build = "i686-linux"; inherit (config.platform) target host;
target = config.platform.target; build = bootstrapArch;
host = config.platform.host;
}; };
} }
); );
};
};
host = {
host = {
glibc = lib.modules.override 0 ( glibc = lib.modules.override 0 (
packages.foundation.glibc.versions.latest.extend { packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 { platform = lib.modules.override 0 {
build = "i686-linux"; inherit (config.platform) target host;
target = config.platform.target; build = bootstrapArch;
host = config.platform.host;
}; };
} }
); );
@ -54,31 +89,58 @@ in
}; };
env = { env = {
LIBRARY_PATH = lib.modules.override 0 "${config.deps.build.build.glibc.package}/lib"; CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${config.deps.host.host.glibc.package}/lib/ld-linux-x86-64.so.2";
LIBRARY_PATH = lib.modules.override 0 "${config.deps.host.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET = LDFLAGS_FOR_TARGET =
lib.modules.override 0 lib.modules.override 0
"-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.build.build.glibc.package}/lib"; "-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.host.host.glibc.package}/lib";
}; };
hooks =
let
flags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (
(lib.systems.withBuildInfo config.platform.target).isx86
&& (lib.systems.withBuildInfo config.platform.target).is64bit
) "-x86-64"
}.so.2"
"-B${config.deps.host.host.glibc.package}/lib"
];
in
lib.modules.override 0 (ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/gcc ${builtins.concatStringsSep " " flags}'
export CXX='${config.package}/bin/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 = lib.modules.override 0 [ configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}" "--prefix=${builtins.placeholder "out"}"
# Pretend we're native even though we're not # Pretend we're native even though we're not
"--build=${config.platform.target.triple}" "--build=${config.platform.target.triple}"
"--host=${config.platform.host.triple}" "--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}" "--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/as" "--with-as=${config.deps.build.host.binutils.package}/bin/as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/ld" "--with-ld=${config.deps.build.host.binutils.package}/bin/ld"
"--enable-languages=c,c++" "--enable-languages=c,c++"
"--disable-bootstrap" "--disable-bootstrap"
"--disable-libsanitizer" "--disable-libsanitizer"
"--disable-multilib" "--disable-multilib"
"--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include" "--with-native-system-header-dir=${config.deps.host.host.glibc.package}/include"
"--with-gxx-include-dir=${placeholder "out"}/include/c++/${config.version}/" "--with-gxx-include-dir=${placeholder "out"}/include/c++/${config.version}/"
"--with-build-sysroot=/" "--with-build-sysroot=/"
]; ];
}; };
} }
); );
}; };
}; };
} }

View file

@ -0,0 +1,226 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
;
in
{
config.packages.foundation.gcc-common = {
versions = {
"latest" =
{ 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;
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
version = "13.2.0";
builder = builders.basic;
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
])
)
);
}
// 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";
};
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}
'';
configure = ''
# Configure
mkdir build
cd build
bash ../configure ${builtins.concatStringsSep " " config.configureFlags}
'';
build = ''
# Build
make -j $NIX_BUILD_CORES
'';
install = ''
# Install
${lib.strings.when ((lib.systems.withBuildInfo config.platform.host).is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''}
make -j $NIX_BUILD_CORES install
'';
};
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=";
};
};
};
};
};
};
}

View file

@ -9,96 +9,165 @@ in
{ {
config.packages.foundation.gcc-cross = { config.packages.foundation.gcc-cross = {
versions = { versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend "latest" = config.packages.foundation.gcc-common.versions.latest.extend (
( { config }:
{ config }: {
{ config =
config = let
let programPrefix = lib.strings.when (
programPrefix = lib.strings.when config.platform.build.triple != config.platform.target.triple
( ) "${config.platform.target.triple}-";
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
in
{
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
deps = { isBuildBootstrapped = config.platform.build.double == "i686-linux";
build = { isHostBootstrapped = config.platform.host.double == "i686-linux";
build = { isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
binutils = (
bootstrapArch =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
in
{
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
pname =
lib.modules.override 0
"gcc-cross-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
deps = {
build = {
only = {
binutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.binutils.versions.latest;
gnumake = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnumake.versions.latest;
gnused = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnused.versions.latest;
gnugrep = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnugrep.versions.latest;
gnupatch = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnupatch.versions.latest;
gawk = lib.modules.when (!isBuildBootstrapped) packages.foundation.gawk.versions.latest;
diffutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.diffutils.versions.latest;
findutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.findutils.versions.latest;
gnutar = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnutar.versions.latest;
gzip = lib.modules.when (!isBuildBootstrapped) packages.foundation.gzip.versions.latest;
bzip2 = lib.modules.when (!isBuildBootstrapped) packages.foundation.bzip2.versions.latest;
xz = lib.modules.when (!isBuildBootstrapped) packages.foundation.xz.versions.latest;
};
host = {
gcc = (
lib.modules.when (!isBootstrapped) (
lib.modules.override 0 (
packages.foundation.gcc.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build host;
target = bootstrapArch;
};
}
)
)
);
binutils = (
lib.modules.override 0 (
packages.foundation.binutils.versions.latest.extend { packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 config.platform; 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;
}
);
};
}; };
}; };
host = {
env = { host = {
# LIBRARY_PATH = lib.modules.override 0 "${foundation.stage1-musl}/lib"; glibc = (
CC = lib.modules.override 0 "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -idirafter ${foundation.stage1-musl}/include"; packages.foundation.glibc.versions.latest.extend {
CXX = lib.modules.override 0 "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -idirafter ${foundation.stage1-musl}/include"; platform = lib.modules.override 0 {
CFLAGS_FOR_TARGET = inherit (config.platform) build target;
lib.modules.override 0 host = config.platform.target;
"-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}
'';
}; };
}
); env = {
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.host.host.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.host.host.glibc.package}/lib";
LDFLAGS_FOR_TARGET =
lib.modules.override 0
"-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.host.host.glibc.package}/lib";
};
hooks =
let
flags = [
"-Wl,-dynamic-linker"
"-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
lib.strings.when (
(lib.systems.withBuildInfo config.platform.target).isx86
&& (lib.systems.withBuildInfo config.platform.target).is64bit
) "-x86-64"
}.so.2"
"-B${config.deps.host.host.glibc.package}/lib"
];
in
lib.modules.override 0 (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 = 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.host.binutils.package}/bin/${programPrefix}as"
"--with-ld=${config.deps.build.host.binutils.package}/bin/${programPrefix}ld"
"--enable-languages=c,c++"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--with-headers=${config.deps.host.host.glibc.package}/include"
"--with-build-sysroot=/"
"--with-native-system-header-dir=${config.deps.host.host.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.host.host.glibc.package}/lib/{crti.o,crtn.o} gcc
mkdir -p x86_64-unknown-linux-gnu/libstdc++-v3/src
ln -sv ${config.deps.host.host.glibc.package}/lib/{crti.o,crtn.o} x86_64-unknown-linux-gnu/libstdc++-v3/src
bash ../configure ${builtins.concatStringsSep " " config.configureFlags}
'';
};
}
);
}; };
}; };
} }

View file

@ -2,10 +2,7 @@
let let
inherit (config) inherit (config)
lib lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project. # These are the upstream foundational packages exported from the Aux Foundation project.
foundation foundation
packages packages
; ;
@ -15,186 +12,180 @@ in
./newlib.nix ./newlib.nix
./cross.nix ./cross.nix
./bootstrap.nix ./bootstrap.nix
./common.nix
]; ];
config.packages.foundation.gcc = { config.packages.foundation.gcc = {
versions = { versions = {
"latest" = "latest" = config.packages.foundation.gcc-common.versions.latest.extend (
{ config, meta }: { 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 = config =
let let
isBuildBootstrapped = config.platform.build.double == "i686-linux"; isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux"; isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped; isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
crossTool = bootstrapArch =
(config.platform.target.triple != config.platform.host.triple) if
&& (config.platform.host.triple == config.platform.build.triple); config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
cross = then
(config.platform.target.triple != config.platform.host.triple) "i686-linux"
&& (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 else
"${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2"; "x86_64-linux";
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target; target = lib.systems.withBuildInfo config.platform.target;
in in
{ {
meta = {
platforms = [
"i686-linux"
];
};
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
version = "13.2.0";
builder = builders.basic;
deps = { deps = {
build = { build = {
build = lib.modules.when (!isBootstrapped) { only = {
gcc = packages.foundation.gcc-cross.versions.latest; gcc = lib.modules.when (!isBootstrapped) (
glibc = packages.foundation.glibc.versions.latest; packages.foundation.gcc-bootstrap.versions.latest.extend {
linux-headers = packages.foundation.linux-headers.versions.latest; platform = lib.modules.override 0 ({
binutils = packages.foundation.binutils.versions.latest; inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
binutils = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gnumake = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gnumake.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gnused = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gnused.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gnugrep = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gnugrep.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gnupatch = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gnupatch.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gawk = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gawk.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
diffutils = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.diffutils.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
findutils = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.findutils.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gnutar = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gnutar.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
gzip = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.gzip.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
bzip2 = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.bzip2.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
xz = lib.modules.when (!isBuildBootstrapped) (
packages.foundation.xz.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
}
);
};
};
host = {
host = {
glibc = packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 ({
inherit (config.platform) target host;
build = bootstrapArch;
});
};
}; };
}; };
}; };
env = env = {
{ CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${
PATH = lib.modules.when (isBuildBootstrapped) ( if isBootstrapped then
lib.paths.bin ([ "${foundation.stage1-musl}/lib/libc.so"
foundation.stage2-gnumake else
foundation.stage2-gnused "${config.deps.host.host.glibc.package}/lib/ld-linux${
foundation.stage2-gnugrep lib.strings.when (target.isx86 && target.is64bit) "-x86-64"
foundation.stage2-gnupatch }.so.2"
foundation.stage2-gawk }";
foundation.stage2-diffutils LIBRARY_PATH = "${
foundation.stage2-findutils if isBootstrapped then foundation.stage1-musl else config.deps.host.host.glibc.package
foundation.stage2-gnutar }/lib";
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 = hooks =
let let
flags = flags = [
if (isBootstrapped && !(cross || crossTool)) then "-Wl,-dynamic-linker"
[ "-Wl,${config.deps.host.host.glibc.package}/lib/ld-linux${
"-Wl,-dynamic-linker" lib.strings.when (target.isx86 && target.is64bit) "-x86-64"
"-Wl,${foundation.stage1-musl}/lib/libc.so" }.so.2"
] "-B${config.deps.host.host.glibc.package}/lib"
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 in
ctx: { ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] '' "aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/${programPrefix}gcc ${builtins.concatStringsSep " " flags}' export CC='${config.package}/bin/gcc ${builtins.concatStringsSep " " flags}'
export CXX='${config.package}/bin/${programPrefix}g++ ${builtins.concatStringsSep " " flags}' export CXX='${config.package}/bin/g++ ${builtins.concatStringsSep " " flags}'
export CC_FOR_TARGET=$CC export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC export CC_FOR_BUILD=$CC
@ -215,7 +206,9 @@ in
"--disable-libsanitizer" "--disable-libsanitizer"
"--disable-multilib" "--disable-multilib"
"--with-build-sysroot=/" "--with-build-sysroot=/"
"--with-native-system-header-dir=${libc}/include" "--with-native-system-header-dir=${
if isBootstrapped then foundation.stage1-musl else config.deps.host.host.glibc.package
}/include"
] ]
++ lib.lists.when (isBootstrapped) [ ++ lib.lists.when (isBootstrapped) [
"--disable-lto" "--disable-lto"
@ -229,92 +222,13 @@ in
]; ];
in in
{ {
unpack = '' patch = lib.modules.override 0 ''
# 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.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=";
};
};
}; };
}; }
);
}; };
}; };
} }

View file

@ -8,42 +8,99 @@ in
{ {
config.packages.foundation.gcc-newlib = { config.packages.foundation.gcc-newlib = {
versions = { versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend ( "latest" = config.packages.foundation.gcc-common.versions.latest.extend (
{ config }: { config }:
{ {
config = config =
let let
programPrefix = lib.strings.when programPrefix = lib.strings.when (
( config.platform.build.triple != config.platform.target.triple
config.platform.build.triple != config.platform.target.triple ) "${config.platform.target.triple}-";
) "${config.platform.target.triple}-";
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
bootstrapArch =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
in in
{ {
meta = { meta = {
platforms = lib.modules.override 0 [ platforms = lib.modules.override 0 [
"i686-linux" "i686-linux"
"x86_64-linux"
]; ];
}; };
pname =
lib.modules.override 0
"gcc-newlib-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
deps = { deps = {
build = { build = {
build = { only = {
binutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.binutils.versions.latest;
gnumake = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnumake.versions.latest;
gnused = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnused.versions.latest;
gnugrep = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnugrep.versions.latest;
gnupatch = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnupatch.versions.latest;
gawk = lib.modules.when (!isBuildBootstrapped) packages.foundation.gawk.versions.latest;
diffutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.diffutils.versions.latest;
findutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.findutils.versions.latest;
gnutar = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnutar.versions.latest;
gzip = lib.modules.when (!isBuildBootstrapped) packages.foundation.gzip.versions.latest;
bzip2 = lib.modules.when (!isBuildBootstrapped) packages.foundation.bzip2.versions.latest;
xz = lib.modules.when (!isBuildBootstrapped) packages.foundation.xz.versions.latest;
};
host = {
gcc = (
lib.modules.when (!isBootstrapped) (
lib.modules.override 0 (
packages.foundation.gcc.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build host;
target = bootstrapArch;
};
}
)
)
);
binutils = ( binutils = (
packages.foundation.binutils.versions.latest.extend { lib.modules.override 0 (
platform = lib.modules.override 0 config.platform; packages.foundation.binutils.versions.latest.extend {
} platform = lib.modules.override 0 config.platform;
}
)
); );
}; };
}; };
}; };
hooks = lib.modules.override 0 (ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/${programPrefix}gcc'
export CXX='${config.package}/bin/${programPrefix}g++'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
});
configureFlags = lib.modules.override 0 [ configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}" "--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}" "--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}" "--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}" "--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/${programPrefix}as" "--with-as=${config.deps.build.host.binutils.package}/bin/${programPrefix}as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/${programPrefix}ld" "--with-ld=${config.deps.build.host.binutils.package}/bin/${programPrefix}ld"
"--enable-languages=c,c++" "--enable-languages=c,c++"
"--disable-bootstrap" "--disable-bootstrap"
"--disable-libsanitizer" "--disable-libsanitizer"

View file

@ -30,22 +30,12 @@ in
config = config =
let let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross = isCross =
(config.platform.build.triple != config.platform.host.triple) (config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.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 in
{ {
@ -56,7 +46,17 @@ in
]; ];
}; };
pname = "glibc"; platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "glibc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}";
version = "2.38"; version = "2.38";
src = builtins.fetchurl { src = builtins.fetchurl {
@ -68,9 +68,48 @@ in
deps = { deps = {
build = { build = {
only = {
gcc = lib.modules.when (!isBootstrapped && !isCross) (packages.foundation.gcc.versions.latest);
binutils = lib.modules.when (!isBootstrapped && !isCross) (
packages.foundation.binutils.versions.latest
);
gnumake = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnumake.versions.latest;
gnused = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnused.versions.latest;
gnugrep = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnugrep.versions.latest;
gnupatch = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnupatch.versions.latest;
gawk = lib.modules.when (!isBuildBootstrapped) packages.foundation.gawk.versions.latest;
diffutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.diffutils.versions.latest;
findutils = lib.modules.when (!isBuildBootstrapped) packages.foundation.findutils.versions.latest;
gnutar = lib.modules.when (!isBuildBootstrapped) packages.foundation.gnutar.versions.latest;
gzip = lib.modules.when (!isBuildBootstrapped) packages.foundation.gzip.versions.latest;
bzip2 = lib.modules.when (!isBuildBootstrapped) packages.foundation.bzip2.versions.latest;
xz = lib.modules.when (!isBuildBootstrapped) packages.foundation.xz.versions.latest;
};
host = {
gcc = lib.modules.when isCross (
packages.foundation.gcc-newlib.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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;
};
}
);
};
};
host = {
host = { host = {
linux-headers = ( linux-headers = (
packages.foundation.linux-headers.versions.latest.extend { packages.foundation.linux-headers.versions.latest.extend {
platform.build = lib.modules.override 0 config.platform.build;
platform.host = lib.modules.override 0 config.platform.host;
platform.target = lib.modules.override 0 config.platform.target; platform.target = lib.modules.override 0 config.platform.target;
} }
); );
@ -79,26 +118,12 @@ in
}; };
env = { env = {
PATH = PATH = lib.paths.bin (
let lib.lists.when (isBootstrapped) [
gcc = foundation.stage2-gcc
if foundation.stage2-binutils
isCross ]
# Otherwise we are going to need a cross-compiler. ++ (lib.lists.when (isBuildBootstrapped) [
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-gnumake
foundation.stage2-gnused foundation.stage2-gnused
foundation.stage2-gnugrep foundation.stage2-gnugrep
@ -111,40 +136,46 @@ in
foundation.stage1-python foundation.stage1-python
foundation.stage1-bison foundation.stage1-bison
foundation.stage1-xz foundation.stage1-xz
]; ])
);
}; };
phases = phases = {
unpack = ''
tar xf ${config.src}
cd glibc-${config.version}
'';
{ configure = ''
unpack = '' mkdir build
tar xf ${config.src} cd build
cd glibc-${config.version}
'';
configure = '' bash ../configure \
mkdir build --prefix=$out \
cd build --build=${config.platform.build.triple} \
--host=${config.platform.host.triple} \
--with-headers=${config.deps.host.host.linux-headers.package}/include \
--with-binutils=${
if isBootstrapped then
foundation.stage2-binutils
else if isCross then
config.deps.build.host.binutils.package
else
config.deps.build.only.binutils.package
}${lib.strings.when (isCross) "/${config.platform.target.triple}"}/bin
'';
bash ../configure \ build = ''
--prefix=$out \ # Build
--build=${config.platform.build.triple} \ make -j $NIX_BUILD_CORES
--host=${config.platform.host.triple} \ '';
--with-headers=${config.deps.build.host.linux-headers.package}/include \
--with-binutils=${binutils}/bin
'';
build = '' install = ''
# Build # Install
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES install
''; ln -sv $(ls -d ${config.deps.host.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
'';
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/
'';
};
}; };
}; };
}; };

View file

@ -0,0 +1,126 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gnugrep = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gnugrep";
version = "3.11";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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 grep-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
rm $out/bin/{egrep,fgrep}
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/grep/grep-${config.version}.tar.xz";
sha256 = "HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
};
};
};
};
};
}

View file

@ -0,0 +1,140 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gnumake = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gnumake";
version = "4.4.1";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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.stage2-gzip
]
);
};
phases =
let
patches = [
# Replaces /bin/sh with sh, see patch file for reasoning
./patches/0001-No-impure-bin-sh.patch
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
# included Makefiles, don't look in /usr/include and friends.
./patches/0002-remove-impure-dirs.patch
];
in
{
unpack = ''
tar xf ${config.src}
cd make-${config.version}
'';
patch = ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/make/make-${config.version}.tar.gz";
sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
};
};
};
};
};
}

View file

@ -0,0 +1,36 @@
From e00a5257a6ca5fedbf68b09eee7df3502971a057 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Sat, 24 Apr 2021 10:11:40 +0200
Subject: [PATCH 1/2] No impure bin sh
default_shell is used to populuate default shell used to execute jobs.
Unless SHELL is set to a different value this would be /bin/sh.
Our stdenv provides sh in form of bash anyway. Having this value not
hard-coded has some advantages:
- It would ensure that on all systems it uses sh from its PATH rather
than /bin/sh, which helps as different systems might have different
shells there (bash vs. dash)
- In the past I had issues with LD_PRELOAD with BEAR, where /bin/sh
used a different glibc than BEAR which came from my development shell.
---
src/job.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/job.c b/src/job.c
index ae1f18b..6b4ddb3 100644
--- a/src/job.c
+++ b/src/job.c
@@ -77,7 +77,7 @@ char * vms_strsignal (int status);
#else
-const char *default_shell = "/bin/sh";
+const char *default_shell = "sh";
int batch_mode_shell = 0;
#endif
--
2.31.1

View file

@ -0,0 +1,41 @@
From 795d63d3c8b5c0dbb7e544954f75507b371b7228 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Sat, 24 Apr 2021 10:20:16 +0200
Subject: [PATCH 2/2] remove impure dirs
---
src/read.c | 3 ---
src/remake.c | 2 --
2 files changed, 5 deletions(-)
diff --git a/src/read.c b/src/read.c
index fa197fb..defacfb 100644
--- a/src/read.c
+++ b/src/read.c
@@ -109,9 +109,6 @@ static const char *default_include_directories[] =
#endif
INCLUDEDIR,
#ifndef _AMIGA
- "/usr/gnu/include",
- "/usr/local/include",
- "/usr/include",
#endif
0
};
diff --git a/src/remake.c b/src/remake.c
index fb237c5..94bff7d 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -1601,8 +1601,6 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
static const char *dirs[] =
{
#ifndef _AMIGA
- "/lib",
- "/usr/lib",
#endif
#if defined(WINDOWS32) && !defined(LIBDIR)
/*
--
2.31.1

View file

@ -0,0 +1,125 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gnupatch = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gnupatch";
version = "2.7";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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 patch-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/patch/patch-${config.version}.tar.xz";
sha256 = "XCyR/kFUKWISbwvhUKpPo0lIXPLtwMfqfbwky4FxEa4=";
};
};
};
};
};
}

View file

@ -0,0 +1,125 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gnused = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gnused";
version = "4.9";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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 sed-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/sed/sed-${config.version}.tar.xz";
sha256 = "biJrcy4c1zlGStaGK9Ghq6QteYKSLaelNRljHSSXUYE=";
};
};
};
};
};
}

View file

@ -0,0 +1,125 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gnutar = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gnutar";
version = "1.35";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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.stage2-gzip
]
);
};
phases = {
unpack = ''
tar xf ${config.src}
cd tar-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/tar/tar-${config.version}.tar.gz";
sha256 = "FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4=";
};
};
};
};
};
}

View file

@ -0,0 +1,125 @@
{ config, options }:
let
inherit (config)
lib
mirrors
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.gzip = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "gzip";
version = "1.13";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
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 gzip-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "${mirrors.gnu}/gzip/gzip-${config.version}.tar.xz";
sha256 = "dFTraTXbF8ZlVXbC4bD6vv04tNCTbg+H9IzQYs6RoFc=";
};
};
};
};
};
}

View file

@ -1,12 +1,11 @@
{ lib {
, lib' lib,
, config lib',
, options config,
, options,
}: }:
let let
inherit (config) inherit (config)
mirrors
builders builders
# These are the upstream foundational packages exported from the Aux Foundation project. # These are the upstream foundational packages exported from the Aux Foundation project.
@ -28,7 +27,10 @@ in
config = { config = {
meta = { meta = {
platforms = [ "x86_64-linux" "i686-linux" ]; platforms = [
"x86_64-linux"
"i686-linux"
];
}; };
pname = "linux-headers"; pname = "linux-headers";

View file

@ -0,0 +1,121 @@
{ config, options }:
let
inherit (config)
lib
builders
# These are the upstream foundational packages exported from the Aux Foundation project.
foundation
packages
;
in
{
config.packages.foundation.xz = {
versions = {
"latest" =
{ config, meta }:
{
options = {
src = lib.options.create {
type = lib.types.derivation;
description = "Source for the package.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
in
{
meta = {
platforms = [
"x86_64-linux"
"i686-linux"
];
};
platform = lib.modules.override 1 {
build =
if
config.platform.target.double == "x86_64-linux" || config.platform.target.double == "i686-linux"
then
"i686-linux"
else
"x86_64-linux";
};
pname = "xz";
version = "5.4.3";
builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isCross) packages.foundation.gcc.versions.latest;
binutils = lib.modules.when (!isCross) packages.foundation.binutils.versions.latest;
};
host = {
gcc = lib.modules.when (isCross) (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.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 (isBuildBootstrapped) [
foundation.stage2-gnumake
foundation.stage2-gnused
foundation.stage2-gnugrep
foundation.stage2-gawk
foundation.stage2-gnutar
foundation.stage2-gzip
]
);
};
phases = {
unpack = ''
tar xf ${config.src}
cd xz-${config.version}
'';
build = ''
bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple}
make -j $NIX_BUILD_CORES
'';
install = ''
make -j $NIX_BUILD_CORES install
'';
};
src = builtins.fetchurl {
url = "https://tukaani.org/xz/xz-${config.version}.tar.gz";
sha256 = "HDguC8Lk4K9YOYqQPdYv/35RAXHS3keh6+BtFSjpt+k=";
};
};
};
};
};
}