refactor: allow src to be an attribute set of sources

This commit is contained in:
Jake Hamilton 2025-08-31 01:48:01 -07:00
parent 1ae64357af
commit 5d8dc6e478
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
5 changed files with 134 additions and 286 deletions

View file

@ -850,12 +850,16 @@ in
src = lib.options.create {
description = "The source for the package.";
type = lib.types.nullish (
lib.types.one [
lib.types.derivation
lib.types.path
]
);
type =
let
type = lib.types.nullish (
lib.types.one [
lib.types.derivation
lib.types.path
]
);
in
lib.types.either type (lib.types.attrs.of type);
default.value = null;
};

View file

@ -56,58 +56,24 @@ let
in
{
options = {
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
gmp.version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
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.";
};
isl.version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
@ -128,38 +94,33 @@ in
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
mpc.version = "1.3.1";
isl.version = "0.24";
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
src = {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
@ -205,11 +166,11 @@ in
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
tar xf ${config.src.gcc}
tar xf ${config.src.gmp}
tar xf ${config.src.mpfr}
tar xf ${config.src.mpc}
tar xf ${config.src.isl}
cd gcc-${version}
ln -s ../gmp-${config.gmp.version} gmp

View file

@ -54,58 +54,24 @@ let
in
{
options = {
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
gmp.version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
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.";
};
isl.version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
@ -126,38 +92,33 @@ in
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
mpc.version = "1.3.1";
isl.version = "0.24";
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
src = {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
@ -216,11 +177,11 @@ in
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
tar xf ${config.src.gcc}
tar xf ${config.src.gmp}
tar xf ${config.src.mpfr}
tar xf ${config.src.mpc}
tar xf ${config.src.isl}
cd gcc-${version}
ln -s ../gmp-${config.gmp.version} gmp

View file

@ -54,58 +54,24 @@ let
in
{
options = {
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
gmp.version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
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.";
};
isl.version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
@ -126,38 +92,33 @@ in
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
mpc.version = "1.3.1";
isl.version = "0.24";
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
src = {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
@ -218,11 +179,11 @@ in
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
tar xf ${config.src.gcc}
tar xf ${config.src.gmp}
tar xf ${config.src.mpfr}
tar xf ${config.src.mpc}
tar xf ${config.src.isl}
cd gcc-${version}
ln -s ../gmp-${config.gmp.version} gmp

View file

@ -46,58 +46,24 @@ let
in
{
options = {
cc = {
src = lib.options.create {
type = lib.types.derivation;
description = "The cc source for the package.";
};
gmp.version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
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.version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
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.";
};
isl.version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
@ -118,38 +84,33 @@ in
builder = builders.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp.version = "6.3.0";
mpfr.version = "4.2.1";
mpc.version = "1.3.1";
isl.version = "0.24";
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
src = {
gcc = builtins.fetchurl {
url = "${mirrors.gnu}/gcc/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = builtins.fetchurl {
url = "${mirrors.gnu}/gmp/gmp-${config.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
mpfr = builtins.fetchurl {
url = "${mirrors.gnu}/mpfr/mpfr-${config.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
mpc = builtins.fetchurl {
url = "${mirrors.gnu}/mpc/mpc-${config.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
isl = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${config.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
@ -209,11 +170,11 @@ in
phases = {
unpack = ''
# Unpack
tar xf ${config.src}
tar xf ${config.gmp.src}
tar xf ${config.mpfr.src}
tar xf ${config.mpc.src}
tar xf ${config.isl.src}
tar xf ${config.src.gcc}
tar xf ${config.src.gmp}
tar xf ${config.src.mpfr}
tar xf ${config.src.mpc}
tar xf ${config.src.isl}
cd gcc-${version}
ln -s ../gmp-${config.gmp.version} gmp