flake: turn variables into a scope
Step II to move the code out of flake.nix. Done in a second intermediate commit to make it easier to review. Change-Id: I13fb386f2e9b87b1d28c366e9b7f0d2dbe03315c
This commit is contained in:
@@ -77,206 +77,225 @@
|
|||||||
(Run `touch .nocontribmsg` to hide this message.)
|
(Run `touch .nocontribmsg` to hide this message.)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
versionJson = builtins.fromJSON (builtins.readFile ./version.json);
|
scope = lib.fix (self: {
|
||||||
officialRelease = versionJson.official_release;
|
# Set to true to build the release notes for the next release.
|
||||||
|
buildUnreleasedNotes = true;
|
||||||
|
|
||||||
# Set to true to build the release notes for the next release.
|
versionJson = builtins.fromJSON (builtins.readFile ./version.json);
|
||||||
buildUnreleasedNotes = true;
|
officialRelease = self.versionJson.official_release;
|
||||||
|
|
||||||
versionSuffix =
|
versionSuffix =
|
||||||
if officialRelease then
|
if self.officialRelease then
|
||||||
""
|
""
|
||||||
else
|
else
|
||||||
"pre${
|
"pre${
|
||||||
builtins.substring 0 8 (lixSrc.lastModifiedDate or lixSrc.lastModified or "19700101")
|
builtins.substring 0 8 (lixSrc.lastModifiedDate or lixSrc.lastModified or "19700101")
|
||||||
}-dev_${lixSrc.shortRev or "dirty"}";
|
}-dev_${lixSrc.shortRev or "dirty"}";
|
||||||
|
|
||||||
linux32BitSystems = [ "i686-linux" ];
|
linux32BitSystems = [ "i686-linux" ];
|
||||||
linux64BitSystems = [
|
linux64BitSystems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
];
|
];
|
||||||
linuxSystems = linux32BitSystems ++ linux64BitSystems;
|
linuxSystems = self.linux32BitSystems ++ self.linux64BitSystems;
|
||||||
darwinSystems = [
|
darwinSystems = [
|
||||||
"x86_64-darwin"
|
"x86_64-darwin"
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
nonDarwinSystems = linuxSystems;
|
nonDarwinSystems = self.linuxSystems;
|
||||||
systems = linuxSystems ++ darwinSystems;
|
systems = self.linuxSystems ++ self.darwinSystems;
|
||||||
|
|
||||||
# If you add something here, please update the list in doc/manual/src/contributing/hacking.md.
|
# If you add something here, please update the list in doc/manual/src/contributing/hacking.md.
|
||||||
# Thanks~
|
# Thanks~
|
||||||
crossSystems = [
|
crossSystems = [
|
||||||
"armv6l-linux"
|
"armv6l-linux"
|
||||||
"armv7l-linux"
|
"armv7l-linux"
|
||||||
"riscv64-linux"
|
"riscv64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
"x86_64-freebsd"
|
"x86_64-freebsd"
|
||||||
# FIXME: broken dev shell due to python
|
# FIXME: broken dev shell due to python
|
||||||
# "x86_64-netbsd"
|
# "x86_64-netbsd"
|
||||||
];
|
];
|
||||||
|
|
||||||
stdenvs = [
|
stdenvs = [
|
||||||
# see assertion in package.nix why these two are disabled
|
# see assertion in package.nix why these two are disabled
|
||||||
# "stdenv"
|
# "stdenv"
|
||||||
# "gccStdenv"
|
# "gccStdenv"
|
||||||
"clangStdenv"
|
"clangStdenv"
|
||||||
"libcxxStdenv"
|
"libcxxStdenv"
|
||||||
"ccacheStdenv"
|
"ccacheStdenv"
|
||||||
];
|
];
|
||||||
|
|
||||||
forAllSystems = lib.genAttrs systems;
|
forAllSystems = lib.genAttrs self.systems;
|
||||||
# Same as forAllSystems, but removes nulls, in case something is broken
|
# Same as forAllSystems, but removes nulls, in case something is broken
|
||||||
# on that system.
|
# on that system.
|
||||||
forAvailableSystems =
|
forAvailableSystems =
|
||||||
f: lib.filterAttrs (name: value: value != null && value != { }) (forAllSystems f);
|
f: lib.filterAttrs (name: value: value != null && value != { }) (self.forAllSystems f);
|
||||||
|
|
||||||
forAllCrossSystems = lib.genAttrs crossSystems;
|
forAllCrossSystems = lib.genAttrs self.crossSystems;
|
||||||
|
|
||||||
forAllStdenvs =
|
forAllStdenvs =
|
||||||
f:
|
f:
|
||||||
lib.listToAttrs (
|
lib.listToAttrs (
|
||||||
map (stdenvName: {
|
map (stdenvName: {
|
||||||
name = "${stdenvName}Packages";
|
name = "${stdenvName}Packages";
|
||||||
value = f stdenvName;
|
value = f stdenvName;
|
||||||
}) stdenvs
|
}) self.stdenvs
|
||||||
)
|
)
|
||||||
// {
|
// {
|
||||||
# TODO delete this and reënable gcc stdenvs once gcc compiles kj coros correctly
|
# TODO delete this and reënable gcc stdenvs once gcc compiles kj coros correctly
|
||||||
stdenvPackages = f "clangStdenv";
|
stdenvPackages = f "clangStdenv";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Memoize nixpkgs for different platforms for efficiency.
|
# Memoize nixpkgs for different platforms for efficiency.
|
||||||
nixpkgsFor = forAllSystems (
|
nixpkgsFor = self.forAllSystems (
|
||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
make-pkgs =
|
make-pkgs =
|
||||||
crossSystem: stdenv:
|
crossSystem: stdenv:
|
||||||
import nixpkgs {
|
import nixpkgs {
|
||||||
localSystem = {
|
localSystem = {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
};
|
||||||
|
crossSystem = if crossSystem == null then null else { system = crossSystem; };
|
||||||
|
overlays = [ (self.overlayFor (p: p.${stdenv})) ];
|
||||||
};
|
};
|
||||||
crossSystem = if crossSystem == null then null else { system = crossSystem; };
|
stdenvs = self.forAllStdenvs (make-pkgs null);
|
||||||
overlays = [ (overlayFor (p: p.${stdenv})) ];
|
native = stdenvs.stdenvPackages;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit stdenvs native;
|
||||||
|
static = native.pkgsStatic;
|
||||||
|
cross = self.forAllCrossSystems (crossSystem: make-pkgs crossSystem "clangStdenv");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
overlayFor =
|
||||||
|
getStdenv: final: prev:
|
||||||
|
let
|
||||||
|
currentStdenv = getStdenv final;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
nixStable = prev.nix;
|
||||||
|
|
||||||
|
nixVersions = prev.nixVersions // {
|
||||||
|
# Nix 2.18 has been removed from Nixpkgs ≥ 25.05, so we need to reintroduce it ourselves for our tests.
|
||||||
|
nix_2_18 =
|
||||||
|
(import nix_2_18).packages.${currentStdenv.hostPlatform.system}.default.overrideAttrs
|
||||||
|
(_: {
|
||||||
|
pname = "nix";
|
||||||
|
});
|
||||||
};
|
};
|
||||||
stdenvs = forAllStdenvs (make-pkgs null);
|
|
||||||
native = stdenvs.stdenvPackages;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit stdenvs native;
|
|
||||||
static = native.pkgsStatic;
|
|
||||||
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "clangStdenv");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
overlayFor =
|
check-headers = final.buildPackages.callPackage ./maintainers/check-headers.nix { };
|
||||||
getStdenv: final: prev:
|
check-syscalls = final.buildPackages.callPackage ./maintainers/check-syscalls.nix { };
|
||||||
let
|
|
||||||
currentStdenv = getStdenv final;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
nixStable = prev.nix;
|
|
||||||
|
|
||||||
nixVersions = prev.nixVersions // {
|
default-busybox-sandbox-shell = final.busybox.override {
|
||||||
# Nix 2.18 has been removed from Nixpkgs ≥ 25.05, so we need to reintroduce it ourselves for our tests.
|
useMusl = true;
|
||||||
nix_2_18 =
|
enableStatic = true;
|
||||||
(import nix_2_18).packages.${currentStdenv.hostPlatform.system}.default.overrideAttrs
|
enableMinimal = true;
|
||||||
(_: {
|
extraConfig = ''
|
||||||
pname = "nix";
|
CONFIG_FEATURE_FANCY_ECHO y
|
||||||
});
|
CONFIG_FEATURE_SH_MATH y
|
||||||
|
CONFIG_FEATURE_SH_MATH_64 y
|
||||||
|
|
||||||
|
CONFIG_ASH y
|
||||||
|
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
|
||||||
|
|
||||||
|
CONFIG_ASH_ALIAS y
|
||||||
|
CONFIG_ASH_BASH_COMPAT y
|
||||||
|
CONFIG_ASH_CMDCMD y
|
||||||
|
CONFIG_ASH_ECHO y
|
||||||
|
CONFIG_ASH_GETOPTS y
|
||||||
|
CONFIG_ASH_INTERNAL_GLOB y
|
||||||
|
CONFIG_ASH_JOB_CONTROL y
|
||||||
|
CONFIG_ASH_PRINTF y
|
||||||
|
CONFIG_ASH_TEST y
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nix = final.callPackage ./package.nix {
|
||||||
|
inherit (self) versionSuffix officialRelease;
|
||||||
|
stdenv = currentStdenv;
|
||||||
|
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
|
||||||
|
# See below
|
||||||
|
lowdown = final.lowdown_3_0;
|
||||||
|
lowdown-unsandboxed = final.lowdown_3_0.override { enableDarwinSandbox = false; };
|
||||||
|
};
|
||||||
|
|
||||||
|
lix-clang-tidy = final.callPackage ./subprojects/lix-clang-tidy { };
|
||||||
|
|
||||||
|
nix-eval-jobs = final.callPackage ./subprojects/nix-eval-jobs {
|
||||||
|
stdenv = currentStdenv;
|
||||||
|
srcDir = ./subprojects/nix-eval-jobs;
|
||||||
|
};
|
||||||
|
|
||||||
|
# HACK: We need nix-prefetch-git for fetchCargoVendor for Rust stuff,
|
||||||
|
# so it can't use Lix, or we infrec:
|
||||||
|
# lix -> Rust stuff -> fetchCargoVendor -> nix-prefetch-git -> nix (lix)
|
||||||
|
# This will eventually become a problem upstream, but until then,
|
||||||
|
# apply some duct tape and pray.
|
||||||
|
nix-prefetch-git =
|
||||||
|
if (lib.functionArgs prev.nix-prefetch-git.override) ? "nix" then
|
||||||
|
prev.nix-prefetch-git.override { nix = prev.nix; }
|
||||||
|
else
|
||||||
|
prev.nix-prefetch-git;
|
||||||
|
|
||||||
|
# Export the patched version of boehmgc that Lix uses into the overlay
|
||||||
|
# for consumers of this flake.
|
||||||
|
boehmgc-nix = final.nix.passthru.boehmgc-nix;
|
||||||
|
# And same thing for our build-release-notes package.
|
||||||
|
build-release-notes = final.nix.passthru.build-release-notes;
|
||||||
|
|
||||||
|
# As soon as Nixpkgs updates to >= 3.0.0, change to lowdown_2_0!
|
||||||
|
# We don't change the default version in order to not change the hash
|
||||||
|
# of Nix/Lix from upstream Nixpkgs.
|
||||||
|
lowdown_3_0 =
|
||||||
|
if (lib.versions.major prev.lowdown.version == "3") then
|
||||||
|
prev.lowdown
|
||||||
|
else
|
||||||
|
prev.lowdown.overrideAttrs (
|
||||||
|
finalAttrs: _prevAttrs: {
|
||||||
|
version = "3.0.0";
|
||||||
|
|
||||||
|
src = final.fetchurl {
|
||||||
|
url = "https://kristaps.bsd.lv/lowdown/snapshots/lowdown-${finalAttrs.version}.tar.gz";
|
||||||
|
sha512 = "94e97234d598382c3c3dc27f9bfdb3a3a2fcf7dbb6a8df3c85ee09f27f792449034a41d49d9cfd3d8450d2de01b8562c20c3d120e65c81af4d7d6c9454119e93";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
capnproto = prev.capnproto.overrideAttrs (old: {
|
||||||
|
patches =
|
||||||
|
old.patches or [ ]
|
||||||
|
++ [
|
||||||
|
# backport of https://github.com/capnproto/capnproto/pull/1810
|
||||||
|
./misc/capnproto-promise-nodiscard.patch
|
||||||
|
]
|
||||||
|
++ lib.optionals (lib.versionOlder old.version "1.2.0") [
|
||||||
|
# backport of https://github.com/capnproto/capnproto/pull/2296
|
||||||
|
./misc/capnproto-monotonic-clocks-are-a-lie.patch
|
||||||
|
];
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
check-headers = final.buildPackages.callPackage ./maintainers/check-headers.nix { };
|
inherit (scope)
|
||||||
check-syscalls = final.buildPackages.callPackage ./maintainers/check-syscalls.nix { };
|
buildUnreleasedNotes
|
||||||
|
crossSystems
|
||||||
default-busybox-sandbox-shell = final.busybox.override {
|
darwinSystems
|
||||||
useMusl = true;
|
forAllStdenvs
|
||||||
enableStatic = true;
|
forAllSystems
|
||||||
enableMinimal = true;
|
forAvailableSystems
|
||||||
extraConfig = ''
|
linux64BitSystems
|
||||||
CONFIG_FEATURE_FANCY_ECHO y
|
nixpkgsFor
|
||||||
CONFIG_FEATURE_SH_MATH y
|
nonDarwinSystems
|
||||||
CONFIG_FEATURE_SH_MATH_64 y
|
officialRelease
|
||||||
|
overlayFor
|
||||||
CONFIG_ASH y
|
stdenvs
|
||||||
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
|
systems
|
||||||
|
versionSuffix
|
||||||
CONFIG_ASH_ALIAS y
|
;
|
||||||
CONFIG_ASH_BASH_COMPAT y
|
|
||||||
CONFIG_ASH_CMDCMD y
|
|
||||||
CONFIG_ASH_ECHO y
|
|
||||||
CONFIG_ASH_GETOPTS y
|
|
||||||
CONFIG_ASH_INTERNAL_GLOB y
|
|
||||||
CONFIG_ASH_JOB_CONTROL y
|
|
||||||
CONFIG_ASH_PRINTF y
|
|
||||||
CONFIG_ASH_TEST y
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
nix = final.callPackage ./package.nix {
|
|
||||||
inherit versionSuffix officialRelease;
|
|
||||||
stdenv = currentStdenv;
|
|
||||||
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
|
|
||||||
# See below
|
|
||||||
lowdown = final.lowdown_3_0;
|
|
||||||
lowdown-unsandboxed = final.lowdown_3_0.override { enableDarwinSandbox = false; };
|
|
||||||
};
|
|
||||||
|
|
||||||
lix-clang-tidy = final.callPackage ./subprojects/lix-clang-tidy { };
|
|
||||||
|
|
||||||
nix-eval-jobs = final.callPackage ./subprojects/nix-eval-jobs {
|
|
||||||
stdenv = currentStdenv;
|
|
||||||
srcDir = ./subprojects/nix-eval-jobs;
|
|
||||||
};
|
|
||||||
|
|
||||||
# HACK: We need nix-prefetch-git for fetchCargoVendor for Rust stuff,
|
|
||||||
# so it can't use Lix, or we infrec:
|
|
||||||
# lix -> Rust stuff -> fetchCargoVendor -> nix-prefetch-git -> nix (lix)
|
|
||||||
# This will eventually become a problem upstream, but until then,
|
|
||||||
# apply some duct tape and pray.
|
|
||||||
nix-prefetch-git =
|
|
||||||
if (lib.functionArgs prev.nix-prefetch-git.override) ? "nix" then
|
|
||||||
prev.nix-prefetch-git.override { nix = prev.nix; }
|
|
||||||
else
|
|
||||||
prev.nix-prefetch-git;
|
|
||||||
|
|
||||||
# Export the patched version of boehmgc that Lix uses into the overlay
|
|
||||||
# for consumers of this flake.
|
|
||||||
boehmgc-nix = final.nix.passthru.boehmgc-nix;
|
|
||||||
# And same thing for our build-release-notes package.
|
|
||||||
build-release-notes = final.nix.passthru.build-release-notes;
|
|
||||||
|
|
||||||
# As soon as Nixpkgs updates to >= 3.0.0, change to lowdown_2_0!
|
|
||||||
# We don't change the default version in order to not change the hash
|
|
||||||
# of Nix/Lix from upstream Nixpkgs.
|
|
||||||
lowdown_3_0 =
|
|
||||||
if (lib.versions.major prev.lowdown.version == "3") then
|
|
||||||
prev.lowdown
|
|
||||||
else
|
|
||||||
prev.lowdown.overrideAttrs (
|
|
||||||
finalAttrs: _prevAttrs: {
|
|
||||||
version = "3.0.0";
|
|
||||||
|
|
||||||
src = final.fetchurl {
|
|
||||||
url = "https://kristaps.bsd.lv/lowdown/snapshots/lowdown-${finalAttrs.version}.tar.gz";
|
|
||||||
sha512 = "94e97234d598382c3c3dc27f9bfdb3a3a2fcf7dbb6a8df3c85ee09f27f792449034a41d49d9cfd3d8450d2de01b8562c20c3d120e65c81af4d7d6c9454119e93";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
capnproto = prev.capnproto.overrideAttrs (old: {
|
|
||||||
patches =
|
|
||||||
old.patches or [ ]
|
|
||||||
++ [
|
|
||||||
# backport of https://github.com/capnproto/capnproto/pull/1810
|
|
||||||
./misc/capnproto-promise-nodiscard.patch
|
|
||||||
]
|
|
||||||
++ lib.optionals (lib.versionOlder old.version "1.2.0") [
|
|
||||||
# backport of https://github.com/capnproto/capnproto/pull/2296
|
|
||||||
./misc/capnproto-monotonic-clocks-are-a-lie.patch
|
|
||||||
];
|
|
||||||
});
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# for repl debugging
|
# for repl debugging
|
||||||
|
|||||||
Reference in New Issue
Block a user