From f24f0876a9103c7adb8120ce9709fb90c73f2a7c Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Tue, 11 Jun 2024 04:39:26 -0700 Subject: [PATCH] feat: customizable gnu mirror, remove inputs for monorepo, potluck base --- foundation/flake.lock | 18 +- foundation/flake.nix | 11 +- foundation/src/default.nix | 1 + foundation/src/mirrors/default.nix | 9 + foundation/src/stages/stage1/bash/boot.nix | 2 +- foundation/src/stages/stage1/bash/default.nix | 2 +- .../src/stages/stage1/binutils/default.nix | 2 +- .../src/stages/stage1/bison/default.nix | 2 +- .../src/stages/stage1/coreutils/boot.nix | 2 +- .../src/stages/stage1/coreutils/default.nix | 2 +- .../src/stages/stage1/diffutils/default.nix | 2 +- .../src/stages/stage1/findutils/default.nix | 2 +- foundation/src/stages/stage1/gawk/boot.nix | 2 +- foundation/src/stages/stage1/gawk/default.nix | 2 +- foundation/src/stages/stage1/gcc/default.nix | 8 +- foundation/src/stages/stage1/gcc/v4.6.cxx.nix | 10 +- foundation/src/stages/stage1/gcc/v4.6.nix | 10 +- foundation/src/stages/stage1/gcc/v8.nix | 8 +- .../src/stages/stage1/gnugrep/default.nix | 2 +- .../src/stages/stage1/gnum4/default.nix | 2 +- foundation/src/stages/stage1/gnumake/boot.nix | 2 +- .../src/stages/stage1/gnumake/default.nix | 2 +- .../src/stages/stage1/gnupatch/default.nix | 2 +- foundation/src/stages/stage1/gnused/boot.nix | 2 +- .../src/stages/stage1/gnused/default.nix | 2 +- foundation/src/stages/stage1/gnutar/boot.nix | 2 +- .../src/stages/stage1/gnutar/default.nix | 2 +- foundation/src/stages/stage1/gnutar/musl.nix | 2 +- foundation/src/stages/stage1/gzip/default.nix | 2 +- foundation/src/stages/stage1/mes/default.nix | 2 +- foundation/src/stages/stage2/bash/default.nix | 2 +- .../src/stages/stage2/binutils/default.nix | 2 +- .../src/stages/stage2/coreutils/default.nix | 2 +- .../src/stages/stage2/diffutils/default.nix | 2 +- .../src/stages/stage2/findutils/default.nix | 2 +- foundation/src/stages/stage2/gawk/default.nix | 2 +- foundation/src/stages/stage2/gcc/default.nix | 8 +- .../src/stages/stage2/glibc/default.nix | 2 +- .../src/stages/stage2/gnugrep/default.nix | 2 +- .../src/stages/stage2/gnumake/default.nix | 2 +- .../src/stages/stage2/gnupatch/default.nix | 2 +- .../src/stages/stage2/gnused/default.nix | 2 +- .../src/stages/stage2/gnutar/default.nix | 2 +- foundation/src/stages/stage2/gzip/default.nix | 2 +- lib/src/modules/default.nix | 26 +- lib/src/types/default.nix | 24 +- potluck/default.nix | 11 +- potluck/flake.lock | 41 +++ potluck/flake.nix | 21 +- potluck/src/export.nix | 13 + potluck/src/exports/default.nix | 1 + potluck/src/exports/modules.nix | 34 +++ potluck/src/exports/packages.nix | 4 + potluck/src/lib/default.nix | 22 ++ potluck/src/lib/options.nix | 12 + potluck/src/lib/types.nix | 267 ++++++++++++++++++ potluck/src/modules.nix | 5 +- potluck/src/packages/default.nix | 33 +++ 58 files changed, 561 insertions(+), 106 deletions(-) create mode 100644 foundation/src/mirrors/default.nix create mode 100644 potluck/flake.lock create mode 100644 potluck/src/export.nix create mode 100644 potluck/src/exports/modules.nix create mode 100644 potluck/src/lib/default.nix create mode 100644 potluck/src/lib/options.nix create mode 100644 potluck/src/lib/types.nix create mode 100644 potluck/src/packages/default.nix diff --git a/foundation/flake.lock b/foundation/flake.lock index 9bd4432..5999137 100644 --- a/foundation/flake.lock +++ b/foundation/flake.lock @@ -1,22 +1,6 @@ { "nodes": { - "lib": { - "locked": { - "lastModified": 1, - "narHash": "sha256-vaPypHCYtWP6e0APNsV3ttoW9D2PlL2WpMytd6LdOmk=", - "path": "../lib", - "type": "path" - }, - "original": { - "path": "../lib", - "type": "path" - } - }, - "root": { - "inputs": { - "lib": "lib" - } - } + "root": {} }, "root": "root", "version": 7 diff --git a/foundation/flake.nix b/foundation/flake.nix index 9fef9dc..d6e3e0c 100644 --- a/foundation/flake.nix +++ b/foundation/flake.nix @@ -2,13 +2,16 @@ description = "A set of foundational packages required for bootstrapping a larger package set."; inputs = { - lib = { - url = "path:../lib"; - }; + # TODO: When this project is moved to its own repository we will want to add + # inputs for the relevant dependencies. + # lib = { + # url = "path:../lib"; + # }; }; outputs = inputs: let - inherit (inputs.lib) lib; + # inherit (inputs.lib) lib; + lib = import ./../lib; modules = import ./src; diff --git a/foundation/src/default.nix b/foundation/src/default.nix index a00b9a8..9e5f4ed 100644 --- a/foundation/src/default.nix +++ b/foundation/src/default.nix @@ -4,6 +4,7 @@ let builderFileText = ./builders/file/text; builderKaem = ./builders/kaem; builderRaw = ./builders/raw; + mirrors = ./mirrors; exports = ./exports; platform = ./platform; stage0 = ./stages/stage0; diff --git a/foundation/src/mirrors/default.nix b/foundation/src/mirrors/default.nix new file mode 100644 index 0000000..1788c3b --- /dev/null +++ b/foundation/src/mirrors/default.nix @@ -0,0 +1,9 @@ +{lib}: { + options.aux.mirrors = { + gnu = lib.options.create { + type = lib.types.string; + default.value = "https://ftp.gnu.org/gnu"; + description = "The GNU mirror to use"; + }; + }; +} diff --git a/foundation/src/stages/stage1/bash/boot.nix b/foundation/src/stages/stage1/bash/boot.nix index 97d6bcf..1403422 100644 --- a/foundation/src/stages/stage1/bash/boot.nix +++ b/foundation/src/stages/stage1/bash/boot.nix @@ -57,7 +57,7 @@ in { version = "2.05b"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/bash/bash-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/bash/bash-${cfg.version}.tar.gz"; sha256 = "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs"; }; diff --git a/foundation/src/stages/stage1/bash/default.nix b/foundation/src/stages/stage1/bash/default.nix index 28c924f..38952c0 100644 --- a/foundation/src/stages/stage1/bash/default.nix +++ b/foundation/src/stages/stage1/bash/default.nix @@ -68,7 +68,7 @@ in { version = "5.2.15"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/bash/bash-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/bash/bash-${cfg.version}.tar.gz"; sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; }; diff --git a/foundation/src/stages/stage1/binutils/default.nix b/foundation/src/stages/stage1/binutils/default.nix index 3a762ec..9e93240 100644 --- a/foundation/src/stages/stage1/binutils/default.nix +++ b/foundation/src/stages/stage1/binutils/default.nix @@ -58,7 +58,7 @@ in { version = "2.41"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/binutils/binutils-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/binutils/binutils-${cfg.version}.tar.xz"; sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; }; diff --git a/foundation/src/stages/stage1/bison/default.nix b/foundation/src/stages/stage1/bison/default.nix index 2428414..0adedf3 100644 --- a/foundation/src/stages/stage1/bison/default.nix +++ b/foundation/src/stages/stage1/bison/default.nix @@ -58,7 +58,7 @@ in { version = "3.8.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/bison/bison-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/bison/bison-${cfg.version}.tar.xz"; sha256 = "m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I="; }; diff --git a/foundation/src/stages/stage1/coreutils/boot.nix b/foundation/src/stages/stage1/coreutils/boot.nix index ce92ba0..d49209b 100644 --- a/foundation/src/stages/stage1/coreutils/boot.nix +++ b/foundation/src/stages/stage1/coreutils/boot.nix @@ -30,7 +30,7 @@ in { version = "5.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/coreutils/coreutils-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/coreutils/coreutils-${cfg.version}.tar.gz"; sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"; }; diff --git a/foundation/src/stages/stage1/coreutils/default.nix b/foundation/src/stages/stage1/coreutils/default.nix index ab108e3..a995064 100644 --- a/foundation/src/stages/stage1/coreutils/default.nix +++ b/foundation/src/stages/stage1/coreutils/default.nix @@ -62,7 +62,7 @@ in { version = "9.4"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/coreutils/coreutils-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/coreutils/coreutils-${cfg.version}.tar.gz"; sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk="; }; diff --git a/foundation/src/stages/stage1/diffutils/default.nix b/foundation/src/stages/stage1/diffutils/default.nix index d5b3233..67d6ee7 100644 --- a/foundation/src/stages/stage1/diffutils/default.nix +++ b/foundation/src/stages/stage1/diffutils/default.nix @@ -58,7 +58,7 @@ in { version = "3.8"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/diffutils/diffutils-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/diffutils/diffutils-${cfg.version}.tar.xz"; sha256 = "pr3X0bMSZtEcT03mwbdI1GB6sCMa9RiPwlM9CuJDj+w="; }; diff --git a/foundation/src/stages/stage1/findutils/default.nix b/foundation/src/stages/stage1/findutils/default.nix index e639eee..dc62440 100644 --- a/foundation/src/stages/stage1/findutils/default.nix +++ b/foundation/src/stages/stage1/findutils/default.nix @@ -58,7 +58,7 @@ in { version = "4.9.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/findutils/findutils-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/findutils/findutils-${cfg.version}.tar.xz"; sha256 = "or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4="; }; diff --git a/foundation/src/stages/stage1/gawk/boot.nix b/foundation/src/stages/stage1/gawk/boot.nix index fd5dc4e..165ab89 100644 --- a/foundation/src/stages/stage1/gawk/boot.nix +++ b/foundation/src/stages/stage1/gawk/boot.nix @@ -31,7 +31,7 @@ in { version = "3.0.6"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gawk/gawk-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gawk/gawk-${cfg.version}.tar.gz"; sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb"; }; diff --git a/foundation/src/stages/stage1/gawk/default.nix b/foundation/src/stages/stage1/gawk/default.nix index 99190d8..df8b03f 100644 --- a/foundation/src/stages/stage1/gawk/default.nix +++ b/foundation/src/stages/stage1/gawk/default.nix @@ -68,7 +68,7 @@ in { version = "5.2.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gawk/gawk-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gawk/gawk-${cfg.version}.tar.gz"; sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA="; }; diff --git a/foundation/src/stages/stage1/gcc/default.nix b/foundation/src/stages/stage1/gcc/default.nix index 01d8791..94eac78 100644 --- a/foundation/src/stages/stage1/gcc/default.nix +++ b/foundation/src/stages/stage1/gcc/default.nix @@ -118,14 +118,14 @@ in { version = "13.2.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz"; sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o="; }; gmp = { version = "6.3.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.xz"; sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg="; }; }; @@ -133,7 +133,7 @@ in { mpfr = { version = "4.2.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.xz"; sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I="; }; }; @@ -141,7 +141,7 @@ in { mpc = { version = "1.3.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz"; sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg="; }; }; diff --git a/foundation/src/stages/stage1/gcc/v4.6.cxx.nix b/foundation/src/stages/stage1/gcc/v4.6.cxx.nix index c09886f..bc4835b 100644 --- a/foundation/src/stages/stage1/gcc/v4.6.cxx.nix +++ b/foundation/src/stages/stage1/gcc/v4.6.cxx.nix @@ -74,13 +74,13 @@ in { version = "4.6.4"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-core-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-core-${cfg.version}.tar.gz"; sha256 = "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75"; }; cc = { src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-g++-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-g++-${cfg.version}.tar.gz"; sha256 = "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9"; }; }; @@ -89,7 +89,7 @@ in { version = "4.3.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.gz"; sha256 = "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"; }; }; @@ -98,7 +98,7 @@ in { version = "2.4.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.gz"; sha256 = "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"; }; }; @@ -107,7 +107,7 @@ in { version = "1.0.3"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz"; sha256 = "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"; }; }; diff --git a/foundation/src/stages/stage1/gcc/v4.6.nix b/foundation/src/stages/stage1/gcc/v4.6.nix index c1f0840..c47df89 100644 --- a/foundation/src/stages/stage1/gcc/v4.6.nix +++ b/foundation/src/stages/stage1/gcc/v4.6.nix @@ -74,13 +74,13 @@ in { version = "4.6.4"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-core-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-core-${cfg.version}.tar.gz"; sha256 = "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75"; }; cc = { src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-g++-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-g++-${cfg.version}.tar.gz"; sha256 = "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9"; }; }; @@ -89,7 +89,7 @@ in { version = "4.3.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.gz"; sha256 = "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"; }; }; @@ -98,7 +98,7 @@ in { version = "2.4.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.gz"; sha256 = "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"; }; }; @@ -107,7 +107,7 @@ in { version = "1.0.3"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz"; sha256 = "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"; }; }; diff --git a/foundation/src/stages/stage1/gcc/v8.nix b/foundation/src/stages/stage1/gcc/v8.nix index 0e9c263..6188475 100644 --- a/foundation/src/stages/stage1/gcc/v8.nix +++ b/foundation/src/stages/stage1/gcc/v8.nix @@ -85,7 +85,7 @@ in { version = "8.5.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz"; sha256 = "0wiEGlEbuDCmEAOXsAQtskzhH2Qtq26m7kSELlMl7VA="; }; @@ -93,7 +93,7 @@ in { # last version to compile with gcc 4.6 version = "6.2.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.xz"; sha256 = "/UgpkSzd0S+EGBw0Ucx1K+IkZD6H+sSXtp7d2txJtPI="; }; }; @@ -101,7 +101,7 @@ in { mpfr = { version = "4.2.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.xz"; sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I="; }; }; @@ -109,7 +109,7 @@ in { mpc = { version = "1.3.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz"; sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg="; }; }; diff --git a/foundation/src/stages/stage1/gnugrep/default.nix b/foundation/src/stages/stage1/gnugrep/default.nix index 36416d4..502bdb1 100644 --- a/foundation/src/stages/stage1/gnugrep/default.nix +++ b/foundation/src/stages/stage1/gnugrep/default.nix @@ -63,7 +63,7 @@ in { version = "2.4"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/grep/grep-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/grep/grep-${cfg.version}.tar.gz"; sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853"; }; diff --git a/foundation/src/stages/stage1/gnum4/default.nix b/foundation/src/stages/stage1/gnum4/default.nix index 55c973d..1e7e9c3 100644 --- a/foundation/src/stages/stage1/gnum4/default.nix +++ b/foundation/src/stages/stage1/gnum4/default.nix @@ -58,7 +58,7 @@ in { version = "1.4.19"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/m4/m4-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/m4/m4-${cfg.version}.tar.xz"; sha256 = "Y67eXG0zttmxNRHNC+LKwEby5w/QoHqpVzoEqCeDr5Y="; }; diff --git a/foundation/src/stages/stage1/gnumake/boot.nix b/foundation/src/stages/stage1/gnumake/boot.nix index 59dc2c1..8cc0a1f 100644 --- a/foundation/src/stages/stage1/gnumake/boot.nix +++ b/foundation/src/stages/stage1/gnumake/boot.nix @@ -30,7 +30,7 @@ in { version = "4.4.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/make/make-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/make/make-${cfg.version}.tar.gz"; sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx"; }; diff --git a/foundation/src/stages/stage1/gnumake/default.nix b/foundation/src/stages/stage1/gnumake/default.nix index 7af82c7..09c3da0 100644 --- a/foundation/src/stages/stage1/gnumake/default.nix +++ b/foundation/src/stages/stage1/gnumake/default.nix @@ -62,7 +62,7 @@ in { version = "4.4.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/make/make-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/make/make-${cfg.version}.tar.gz"; sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; }; diff --git a/foundation/src/stages/stage1/gnupatch/default.nix b/foundation/src/stages/stage1/gnupatch/default.nix index 7e80937..fcd53b7 100644 --- a/foundation/src/stages/stage1/gnupatch/default.nix +++ b/foundation/src/stages/stage1/gnupatch/default.nix @@ -57,7 +57,7 @@ in { version = "2.5.9"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/patch/patch-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/patch/patch-${cfg.version}.tar.gz"; sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"; }; diff --git a/foundation/src/stages/stage1/gnused/boot.nix b/foundation/src/stages/stage1/gnused/boot.nix index f40fc35..0f28085 100644 --- a/foundation/src/stages/stage1/gnused/boot.nix +++ b/foundation/src/stages/stage1/gnused/boot.nix @@ -30,7 +30,7 @@ in { version = "4.0.9"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/sed/sed-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/sed/sed-${cfg.version}.tar.gz"; sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3"; }; diff --git a/foundation/src/stages/stage1/gnused/default.nix b/foundation/src/stages/stage1/gnused/default.nix index a2e1850..74d804a 100644 --- a/foundation/src/stages/stage1/gnused/default.nix +++ b/foundation/src/stages/stage1/gnused/default.nix @@ -68,7 +68,7 @@ in { version = "4.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/sed/sed-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/sed/sed-${cfg.version}.tar.gz"; sha256 = "20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM="; }; diff --git a/foundation/src/stages/stage1/gnutar/boot.nix b/foundation/src/stages/stage1/gnutar/boot.nix index c72ac7f..178e2dc 100644 --- a/foundation/src/stages/stage1/gnutar/boot.nix +++ b/foundation/src/stages/stage1/gnutar/boot.nix @@ -31,7 +31,7 @@ in { version = "1.12"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz"; sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6"; }; diff --git a/foundation/src/stages/stage1/gnutar/default.nix b/foundation/src/stages/stage1/gnutar/default.nix index 55129bd..1c69b74 100644 --- a/foundation/src/stages/stage1/gnutar/default.nix +++ b/foundation/src/stages/stage1/gnutar/default.nix @@ -69,7 +69,7 @@ in { version = "1.35"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz"; sha256 = "FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4="; }; diff --git a/foundation/src/stages/stage1/gnutar/musl.nix b/foundation/src/stages/stage1/gnutar/musl.nix index af5389a..ea02d70 100644 --- a/foundation/src/stages/stage1/gnutar/musl.nix +++ b/foundation/src/stages/stage1/gnutar/musl.nix @@ -31,7 +31,7 @@ in { version = "1.12"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz"; sha256 = "xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo="; }; diff --git a/foundation/src/stages/stage1/gzip/default.nix b/foundation/src/stages/stage1/gzip/default.nix index 87cc2a7..88bd6ce 100644 --- a/foundation/src/stages/stage1/gzip/default.nix +++ b/foundation/src/stages/stage1/gzip/default.nix @@ -57,7 +57,7 @@ in { version = "1.2.4"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gzip/gzip-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gzip/gzip-${cfg.version}.tar.gz"; sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w"; }; diff --git a/foundation/src/stages/stage1/mes/default.nix b/foundation/src/stages/stage1/mes/default.nix index 38a8f87..b3d9c98 100644 --- a/foundation/src/stages/stage1/mes/default.nix +++ b/foundation/src/stages/stage1/mes/default.nix @@ -30,7 +30,7 @@ in { version = "0.25"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mes/mes-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mes/mes-${cfg.version}.tar.gz"; sha256 = "MlJQs1Z+2SA7pwFhyDWvAQeec+vtl7S1u3fKUAuCiUA="; }; }; diff --git a/foundation/src/stages/stage2/bash/default.nix b/foundation/src/stages/stage2/bash/default.nix index 1000f5a..11e6e7f 100644 --- a/foundation/src/stages/stage2/bash/default.nix +++ b/foundation/src/stages/stage2/bash/default.nix @@ -64,7 +64,7 @@ in { version = "5.2.15"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/bash/bash-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/bash/bash-${cfg.version}.tar.gz"; sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; }; diff --git a/foundation/src/stages/stage2/binutils/default.nix b/foundation/src/stages/stage2/binutils/default.nix index 95248c0..27a4fcb 100644 --- a/foundation/src/stages/stage2/binutils/default.nix +++ b/foundation/src/stages/stage2/binutils/default.nix @@ -58,7 +58,7 @@ in { version = "2.41"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/binutils/binutils-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/binutils/binutils-${cfg.version}.tar.xz"; sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; }; diff --git a/foundation/src/stages/stage2/coreutils/default.nix b/foundation/src/stages/stage2/coreutils/default.nix index 7b541dd..4d9ec19 100644 --- a/foundation/src/stages/stage2/coreutils/default.nix +++ b/foundation/src/stages/stage2/coreutils/default.nix @@ -58,7 +58,7 @@ in { version = "9.4"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/coreutils/coreutils-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/coreutils/coreutils-${cfg.version}.tar.gz"; sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk="; }; diff --git a/foundation/src/stages/stage2/diffutils/default.nix b/foundation/src/stages/stage2/diffutils/default.nix index 9044ef6..90c8747 100644 --- a/foundation/src/stages/stage2/diffutils/default.nix +++ b/foundation/src/stages/stage2/diffutils/default.nix @@ -58,7 +58,7 @@ in { version = "3.10"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/diffutils/diffutils-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/diffutils/diffutils-${cfg.version}.tar.xz"; sha256 = "kOXpPMck5OvhLt6A3xY0Bjx6hVaSaFkZv+YLVWyb0J4="; }; diff --git a/foundation/src/stages/stage2/findutils/default.nix b/foundation/src/stages/stage2/findutils/default.nix index 9ed6023..201b530 100644 --- a/foundation/src/stages/stage2/findutils/default.nix +++ b/foundation/src/stages/stage2/findutils/default.nix @@ -58,7 +58,7 @@ in { version = "4.9.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/findutils/findutils-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/findutils/findutils-${cfg.version}.tar.xz"; sha256 = "or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4="; }; diff --git a/foundation/src/stages/stage2/gawk/default.nix b/foundation/src/stages/stage2/gawk/default.nix index 12ddffe..dd7f269 100644 --- a/foundation/src/stages/stage2/gawk/default.nix +++ b/foundation/src/stages/stage2/gawk/default.nix @@ -64,7 +64,7 @@ in { version = "5.2.2"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gawk/gawk-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/gawk/gawk-${cfg.version}.tar.gz"; sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA="; }; diff --git a/foundation/src/stages/stage2/gcc/default.nix b/foundation/src/stages/stage2/gcc/default.nix index c661b05..51da8ea 100644 --- a/foundation/src/stages/stage2/gcc/default.nix +++ b/foundation/src/stages/stage2/gcc/default.nix @@ -112,14 +112,14 @@ in { version = "13.2.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz"; sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o="; }; gmp = { version = "6.3.0"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gmp/gmp-${cfg.gmp.version}.tar.xz"; sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg="; }; }; @@ -127,7 +127,7 @@ in { mpfr = { version = "4.2.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/mpfr/mpfr-${cfg.mpfr.version}.tar.xz"; sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I="; }; }; @@ -135,7 +135,7 @@ in { mpc = { version = "1.3.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/mpc/mpc-${cfg.mpc.version}.tar.gz"; sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg="; }; }; diff --git a/foundation/src/stages/stage2/glibc/default.nix b/foundation/src/stages/stage2/glibc/default.nix index 3764344..2e76ebb 100644 --- a/foundation/src/stages/stage2/glibc/default.nix +++ b/foundation/src/stages/stage2/glibc/default.nix @@ -59,7 +59,7 @@ in { version = "2.38"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/libc/glibc-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/libc/glibc-${cfg.version}.tar.xz"; sha256 = "+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I="; }; diff --git a/foundation/src/stages/stage2/gnugrep/default.nix b/foundation/src/stages/stage2/gnugrep/default.nix index c0fd716..1ecd5ec 100644 --- a/foundation/src/stages/stage2/gnugrep/default.nix +++ b/foundation/src/stages/stage2/gnugrep/default.nix @@ -64,7 +64,7 @@ in { version = "3.11"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/grep/grep-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/grep/grep-${cfg.version}.tar.xz"; sha256 = "HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs="; }; diff --git a/foundation/src/stages/stage2/gnumake/default.nix b/foundation/src/stages/stage2/gnumake/default.nix index f0ce734..f43c46a 100644 --- a/foundation/src/stages/stage2/gnumake/default.nix +++ b/foundation/src/stages/stage2/gnumake/default.nix @@ -59,7 +59,7 @@ in { version = "4.4.1"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/make/make-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/make/make-${cfg.version}.tar.gz"; sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; }; diff --git a/foundation/src/stages/stage2/gnupatch/default.nix b/foundation/src/stages/stage2/gnupatch/default.nix index f763054..e5520f1 100644 --- a/foundation/src/stages/stage2/gnupatch/default.nix +++ b/foundation/src/stages/stage2/gnupatch/default.nix @@ -58,7 +58,7 @@ in { version = "2.7"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/patch/patch-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/patch/patch-${cfg.version}.tar.xz"; sha256 = "XCyR/kFUKWISbwvhUKpPo0lIXPLtwMfqfbwky4FxEa4="; }; diff --git a/foundation/src/stages/stage2/gnused/default.nix b/foundation/src/stages/stage2/gnused/default.nix index f6fa2ff..3b1c564 100644 --- a/foundation/src/stages/stage2/gnused/default.nix +++ b/foundation/src/stages/stage2/gnused/default.nix @@ -64,7 +64,7 @@ in { version = "4.9"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/sed/sed-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/sed/sed-${cfg.version}.tar.xz"; sha256 = "biJrcy4c1zlGStaGK9Ghq6QteYKSLaelNRljHSSXUYE="; }; diff --git a/foundation/src/stages/stage2/gnutar/default.nix b/foundation/src/stages/stage2/gnutar/default.nix index d914545..9dd33f6 100644 --- a/foundation/src/stages/stage2/gnutar/default.nix +++ b/foundation/src/stages/stage2/gnutar/default.nix @@ -64,7 +64,7 @@ in { version = "1.35"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; + url = "${config.aux.mirrors.gnu}/tar/tar-${cfg.version}.tar.gz"; sha256 = "FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4="; }; diff --git a/foundation/src/stages/stage2/gzip/default.nix b/foundation/src/stages/stage2/gzip/default.nix index 349e094..a3babb9 100644 --- a/foundation/src/stages/stage2/gzip/default.nix +++ b/foundation/src/stages/stage2/gzip/default.nix @@ -58,7 +58,7 @@ in { version = "1.13"; src = builtins.fetchurl { - url = "https://ftpmirror.gnu.org/gzip/gzip-${cfg.version}.tar.xz"; + url = "${config.aux.mirrors.gnu}/gzip/gzip-${cfg.version}.tar.xz"; sha256 = "dFTraTXbF8ZlVXbC4bD6vv04tNCTbg+H9IzQYs6RoFc="; }; diff --git a/lib/src/modules/default.nix b/lib/src/modules/default.nix index 6870bd9..e1b7f3b 100644 --- a/lib/src/modules/default.nix +++ b/lib/src/modules/default.nix @@ -201,7 +201,14 @@ lib: { name: value: builtins.addErrorContext "while evaluating the module argument `${name}` in `${key}`" - (args.${name} or args.config.__module__.args.dynamic.${name}) + ( + # The base case here is the set of static arguments supplied in the + # call to `lib.modules.run`. + args.${name} + # Then, any other arguments must be created dynamically from within + # the modules being evaluated. + or args.config.__module__.args.dynamic.${name} + ) ) (lib.fp.args module); in @@ -577,7 +584,7 @@ lib: { }; freeform = lib.options.create { - type = lib.types.nullish lib.types.option; + type = lib.types.nullish lib.types.type; default.value = null; internal = true; description = "If set, all options that don't have a declared type will be merged using this type."; @@ -594,8 +601,6 @@ lib: { meta = { inherit extend type; }; - - lib = lib.modules.overrides.default lib; }; }; }; @@ -607,7 +612,18 @@ lib: { collect (args.path or "") (modules ++ [internal]) - ({inherit options config;} // args); + ( + { + inherit options config; + + # The library does not include `extend` out of the box to avoid infinite recursion + # in most cases. Instead, we supply an estensible version here for modules to consume. + # This is only something that affects internal use of `lib`, the properly exported + # `lib` is augmented with an `extend` method. + lib = lib.points.withExtend (lib.fp.const lib); + } + // args + ); in lib.modules.combine prefix (lib.lists.reverse collected); diff --git a/lib/src/types/default.nix b/lib/src/types/default.nix index e8c151d..191caf9 100644 --- a/lib/src/types/default.nix +++ b/lib/src/types/default.nix @@ -548,13 +548,13 @@ lib: { else merged; }; - packages = { - ## A type that allows a shell package. This is a package with an accompanying + derivations = { + ## A type that allows a shell derivation. This is a derivation with an accompanying ## `shellPath` attribute. ## ## @type Attrs shell = - lib.types.package + lib.types.derivation // { check = value: lib.packages.isDerivation && builtins.hasAttr "shellPath" value; }; @@ -762,10 +762,10 @@ lib: { modules = [ { - options.__module__.args.name = lib.options.create { + options.__module__.args.dynamic.name = lib.options.create { type = lib.types.string; }; - config.__module__.args.name = lib.modules.overrides.default ""; + config.__module__.args.dynamic.name = lib.modules.overrides.default ""; } ] ++ modules; @@ -785,7 +785,7 @@ lib: { merge = location: definitions: let result = base.extend { modules = - [{config.__module__.args.name = lib.lists.last location;}] + [{config.__module__.args.dynamic.name = lib.lists.last location;}] ++ getModules definitions; }; in @@ -882,7 +882,17 @@ lib: { }; }; - ## Create a type that allows an Option. + ## A type that allows a Type. + ## + ## @type Attrs + type = lib.types.create { + name = "Type"; + description = "type"; + check = lib.types.is "type"; + merge = lib.options.merge.one; + }; + + ## A type that allows an Option. ## ## @type Attrs option = lib.types.create { diff --git a/potluck/default.nix b/potluck/default.nix index 6843b25..c9dfa6b 100644 --- a/potluck/default.nix +++ b/potluck/default.nix @@ -6,21 +6,22 @@ result = lib.modules.run { modules = - modules + (builtins.attrValues modules) ++ [ + ./src/export.nix { __file__ = ./default.nix; - options.aux.packages.foundation = { - raw = lib.options.create { + options.packages.aux = { + foundation = lib.options.create { type = lib.types.attrs.of lib.types.package; internal = true; description = "The foundational packages used to construct the larger package set."; }; }; - config.aux.packages.foundation = { - raw = foundation; + config.packages.aux = { + foundation = foundation; }; } ]; diff --git a/potluck/flake.lock b/potluck/flake.lock new file mode 100644 index 0000000..eb4db76 --- /dev/null +++ b/potluck/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "foundation": { + "inputs": { + "lib": [ + "lib" + ] + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-CDfGWoJg+7i9z6quwh/WXuTkOhqKme73dUTvWCvJ8EA=", + "path": "../foundation", + "type": "path" + }, + "original": { + "path": "../foundation", + "type": "path" + } + }, + "lib": { + "locked": { + "lastModified": 1, + "narHash": "sha256-TtgysWL53BK3f3JrPFunjzJaXWaDG2RbuPMglCwATOY=", + "path": "../lib", + "type": "path" + }, + "original": { + "path": "../lib", + "type": "path" + } + }, + "root": { + "inputs": { + "foundation": "foundation", + "lib": "lib" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/potluck/flake.nix b/potluck/flake.nix index c35d334..f797c5f 100644 --- a/potluck/flake.nix +++ b/potluck/flake.nix @@ -1,19 +1,20 @@ { inputs = { - lib = { - url = "path:../lib"; - }; - - foundation = { - url = "path:../foundation"; - inputs.lib.follows = "lib"; - }; + # TODO: When this project is moved to its own repository we will want to add + # inputs for the relevant dependencies. + # lib = { + # url = "path:../lib"; + # }; + # foundation = { + # url = "path:../foundation"; + # inputs.lib.follows = "lib"; + # }; }; outputs = inputs: let exports = import ./default.nix { - lib = inputs.lib.lib; - foundation = inputs.foundation.packages.i686-linux; + # lib = inputs.lib.lib; + # foundation = inputs.foundation.packages.i686-linux; }; in exports; diff --git a/potluck/src/export.nix b/potluck/src/export.nix new file mode 100644 index 0000000..9686fc3 --- /dev/null +++ b/potluck/src/export.nix @@ -0,0 +1,13 @@ +# This file handles creating all of the exports for this project and is not +# exported itself. +{ + lib, + config, +}: let +in { + config = { + exports = { + modules = import ./modules.nix; + }; + }; +} diff --git a/potluck/src/exports/default.nix b/potluck/src/exports/default.nix index e4b93c8..600a161 100644 --- a/potluck/src/exports/default.nix +++ b/potluck/src/exports/default.nix @@ -1,5 +1,6 @@ { includes = [ ./packages.nix + ./modules.nix ]; } diff --git a/potluck/src/exports/modules.nix b/potluck/src/exports/modules.nix new file mode 100644 index 0000000..ed70ee1 --- /dev/null +++ b/potluck/src/exports/modules.nix @@ -0,0 +1,34 @@ +{ + lib, + config, +}: let + cfg = config.exports.modules; + + type = lib.types.one [ + lib.types.path + (lib.types.attrs.any) + (lib.types.function lib.types.attrs.any) + ]; +in { + options = { + exports = { + modules = lib.options.create { + type = lib.types.attrs.of type; + default.value = {}; + description = "An attribute set of modules to export."; + }; + }; + + exported = { + modules = lib.options.create { + type = lib.types.attrs.of type; + default.value = {}; + description = "An attribute set of modules to export."; + }; + }; + }; + + config = { + exported.modules = cfg.modules; + }; +} diff --git a/potluck/src/exports/packages.nix b/potluck/src/exports/packages.nix index 0081a2f..96f6ba1 100644 --- a/potluck/src/exports/packages.nix +++ b/potluck/src/exports/packages.nix @@ -12,4 +12,8 @@ in { default.value = {}; }; }; + + config = { + exported.packages = {}; + }; } diff --git a/potluck/src/lib/default.nix b/potluck/src/lib/default.nix new file mode 100644 index 0000000..1455ee8 --- /dev/null +++ b/potluck/src/lib/default.nix @@ -0,0 +1,22 @@ +{ + lib, + config, +}: let + cfg = config.lib; +in { + includes = [ + ./options.nix + ./types.nix + ]; + + freeform = lib.types.any; + + options = { + lib = lib.options.create { + type = lib.types.attrs.any; + default.value = {}; + description = "An attribute set of values to be added to `lib`."; + apply = value: lib.extend (final: prev: prev.attrs.mergeRecursive prev value); + }; + }; +} diff --git a/potluck/src/lib/options.nix b/potluck/src/lib/options.nix new file mode 100644 index 0000000..5441bd4 --- /dev/null +++ b/potluck/src/lib/options.nix @@ -0,0 +1,12 @@ +{ + lib, + config, +}: let +in { + lib.options = { + package = lib.options.create { + type = config.lib.types.package; + description = "A package definition."; + }; + }; +} diff --git a/potluck/src/lib/types.nix b/potluck/src/lib/types.nix new file mode 100644 index 0000000..0ca17c2 --- /dev/null +++ b/potluck/src/lib/types.nix @@ -0,0 +1,267 @@ +{ + lib, + config, +}: let + lib' = config.lib; +in { + lib.types = { + license = let + type = lib.types.submodule ({config}: { + options = { + name = { + full = lib.options.create { + type = lib.types.string; + description = "The full name of the license."; + }; + + short = lib.options.create { + type = lib.types.string; + description = "The short name of the license."; + }; + }; + + spdx = lib.options.create { + type = lib.types.nullish lib.types.string; + default.value = null; + description = "The SPDX identifier for the license."; + }; + + url = lib.options.create { + type = lib.types.nullish lib.types.string; + description = "The URL for the license."; + }; + + free = lib.options.create { + type = lib.types.bool; + default.value = true; + description = "Whether the license is free."; + }; + + redistributable = lib.options.create { + type = lib.types.bool; + default = { + text = "config.free"; + value = config.free; + }; + description = "Whether the license is allows redistribution."; + }; + }; + }); + in + lib.types.either type (lib.types.list.of type); + + meta = lib.types.submodule { + options = { + name = lib.options.create { + type = lib.types.string; + description = "The name of the package."; + }; + + description = lib.options.create { + type = lib.types.string; + description = "The description for the package."; + }; + + homepage = lib.options.create { + type = lib.types.nullish lib.types.string; + default.value = null; + description = "The homepage for the package."; + }; + + license = lib.options.create { + type = config.lib.types.license; + description = "The license for the package."; + }; + + free = lib.options.create { + type = lib.types.bool; + default.value = true; + description = "Whether the package is free."; + }; + + insecure = lib.options.create { + type = lib.types.bool; + default.value = false; + description = "Whether the package is insecure."; + }; + + broken = lib.options.create { + type = lib.types.bool; + default.value = false; + description = "Whether the package is broken."; + }; + + main = lib.options.create { + type = lib.types.nullish lib.types.string; + default.value = null; + description = "The main entry point for the package."; + }; + + platforms = lib.options.create { + type = lib.types.list.of lib.types.string; + default.value = []; + description = "The platforms the package supports."; + }; + }; + }; + + package = lib.types.submodule ({config}: { + freeform = lib.types.any; + + options = { + name = lib.options.create { + type = lib.types.string; + default = { + value = "${config.pname}-${config.version}"; + text = "\${config.pname}-\${config.version}"; + }; + description = "The name of the package."; + }; + + pname = lib.options.create { + type = lib.types.nullish lib.types.string; + default.value = null; + description = "The name of the package."; + }; + + version = lib.options.create { + type = lib.types.nullish lib.types.string; + default.value = null; + description = "The version of the package."; + }; + + meta = lib.options.create { + type = lib'.types.meta; + }; + + env = lib.options.create { + type = lib.types.attrs.of lib.types.string; + default.value = {}; + description = "Environment variables for the package's builder to use."; + }; + + phases = lib.options.create { + type = lib.types.attrs.of lib.types.string; + default.value = {}; + description = "Phases for the package's builder to use."; + }; + + platform = { + build = lib.options.create { + type = lib.types.string; + description = "The platform the package is built on."; + }; + + host = lib.options.create { + type = lib.types.string; + description = "The platform the package is run on."; + }; + + target = lib.options.create { + type = lib.types.string; + description = "The platform the package generates code for."; + }; + }; + + builder = lib.options.create { + type = lib'.types.builder; + description = "The builder for the package."; + }; + + package = lib.options.create { + type = lib.types.derivation; + default = { + value = config.builder.build config.builder config; + text = ""; + }; + description = "The package derivation."; + }; + + deps = { + build = { + only = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are only used in the build environment."; + }; + + build = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are created in the build environment and are run in the build environment."; + }; + + host = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are created in the build environment and are run in the host environment."; + }; + + target = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are created in the build environment and are run in the target environment."; + }; + }; + + host = { + only = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are only used in the host environment."; + }; + + host = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are run in the host environment."; + }; + + target = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are run in the host environment which produces code for the target environment."; + }; + }; + + target = { + only = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are only used in the target environment."; + }; + + target = lib.options.create { + type = lib'.types.dependencies; + default.value = {}; + description = "Dependencies which are run in the target environment."; + }; + }; + }; + + versions = lib.options.create { + type = lib.types.attrs.of lib'.types.package; + default.value = {}; + description = "Available versions of the package."; + }; + }; + }); + + dependencies = lib.types.attrs.of (lib.types.nullish lib'.types.package); + + packages = lib.types.attrs.of (lib.types.submodule { + freeform = lib.types.nullish lib'.types.package; + }); + + builder = lib.types.submodule { + freeform = lib.types.any; + + options = { + build = lib.options.create { + type = lib.types.function lib.types.derivation; + description = "The function that creates the package derivation."; + }; + }; + }; + }; +} diff --git a/potluck/src/modules.nix b/potluck/src/modules.nix index fe51488..3c39156 100644 --- a/potluck/src/modules.nix +++ b/potluck/src/modules.nix @@ -1 +1,4 @@ -[] +{ + exports = ./exports; + lib = ./lib; +} diff --git a/potluck/src/packages/default.nix b/potluck/src/packages/default.nix new file mode 100644 index 0000000..e6cac18 --- /dev/null +++ b/potluck/src/packages/default.nix @@ -0,0 +1,33 @@ +{ + lib, + config, +}: let + lib' = config.lib; + + configure = namespace: packages: + builtins.mapAttrs + (key: package: let + name = + if package.pname != null && package.version != null + then "${package.pname}-${package.version}" + else key; + in { + name = lib.modules.overrides.default name; + package = lib.modules.overrides.default (package.builder package); + }) + packages; + + configs = builtins.mapAttrs configure config.packages; +in { + includes = [ + ./aux/foundation.nix + ]; + + options = { + packages = lib.options.create { + type = lib'.types.packages; + }; + }; + + config = lib.modules.merge configs; +}