2024-07-30 21:40:27 +00:00
|
|
|
{ lix, versionSuffix ? "" }:
|
2024-03-07 19:27:15 +00:00
|
|
|
final: prev:
|
|
|
|
let
|
2024-07-30 21:38:08 +00:00
|
|
|
lixPackageFromSource = final.callPackage (lix + "/package.nix") ({
|
2024-08-13 00:57:09 +00:00
|
|
|
inherit versionSuffix;
|
2024-06-19 06:29:08 +00:00
|
|
|
});
|
2024-04-22 21:59:54 +00:00
|
|
|
|
2024-09-30 20:35:21 +00:00
|
|
|
# These packages should receive CppNix since they may link to it or otherwise
|
|
|
|
# cause problems (or even just silly mass-rebuilds) if we give them Lix
|
2024-09-18 03:47:29 +00:00
|
|
|
overridelist_upstream = [
|
2024-05-08 14:50:45 +00:00
|
|
|
"attic-client"
|
2024-05-16 18:47:30 +00:00
|
|
|
"devenv"
|
2024-05-08 14:50:45 +00:00
|
|
|
"nix-du"
|
2024-05-08 14:24:21 +00:00
|
|
|
"nix-init"
|
|
|
|
"nix-prefetch-git"
|
|
|
|
"nixos-option"
|
|
|
|
"nurl"
|
|
|
|
"prefetch-yarn-deps" # force these onto upstream so we are not regularly rebuilding electron
|
|
|
|
];
|
|
|
|
|
2024-07-30 21:38:08 +00:00
|
|
|
inherit (prev) lib;
|
|
|
|
|
|
|
|
csi = builtins.fromJSON ''"\u001b"'';
|
|
|
|
orange = "${csi}[35;1m";
|
|
|
|
normal = "${csi}[0m";
|
2024-06-06 04:15:44 +00:00
|
|
|
warning = ''
|
2024-07-30 21:38:08 +00:00
|
|
|
${orange}warning${normal}: You have the lix overlay included into a nixpkgs import twice,
|
2024-06-06 04:15:44 +00:00
|
|
|
perhaps due to the NixOS module being included twice, or because of using
|
|
|
|
pkgs.nixos and also including it in imports, or perhaps some unknown
|
|
|
|
machinations of a complicated flake library.
|
|
|
|
This is completely harmless since we have no-op'd the second one if you are
|
|
|
|
seeing this message, but it would be a small style improvement to fix
|
|
|
|
it :)
|
|
|
|
P.S. If you had some hack to fix nixos-option build failures in your
|
|
|
|
configuration, that was caused by including an older version of the lix
|
|
|
|
overlay twice, which is now mitigated if you see this message, so you can
|
|
|
|
delete that.
|
|
|
|
P.P.S. This Lix has super catgirl powers.
|
|
|
|
'';
|
2024-07-30 21:38:08 +00:00
|
|
|
wrongMajorWarning = ''
|
|
|
|
${orange}warning${normal}: This Lix NixOS module is being built against a Lix with a
|
|
|
|
major version (got ${lixPackageToUse.version}) other than the one the
|
|
|
|
module was designed for (expecting ${supportedLixMajor}). Some downstream
|
|
|
|
packages like nix-eval-jobs may be broken by this. Consider using a
|
|
|
|
matching version of the Lix NixOS module to the version of Lix you are
|
|
|
|
using.
|
|
|
|
'';
|
2024-04-16 03:06:52 +00:00
|
|
|
|
2024-06-06 04:15:44 +00:00
|
|
|
maybeWarnDuplicate = x: if final.lix-overlay-present > 1 then builtins.trace warning x else x;
|
2024-04-16 03:06:52 +00:00
|
|
|
|
2024-07-30 21:38:08 +00:00
|
|
|
versionJson = builtins.fromJSON (builtins.readFile ./version.json);
|
2024-08-13 00:57:09 +00:00
|
|
|
supportedLixMajor = lib.versions.majorMinor versionJson.version;
|
2024-07-30 21:38:08 +00:00
|
|
|
lixPackageToUse = if lix != null then lixPackageFromSource else prev.lix;
|
|
|
|
# Especially if using Lix from nixpkgs, it is plausible that the overlay
|
|
|
|
# could be used against the wrong Lix major version and cause confusing build
|
|
|
|
# errors. This is a simple safeguard to put in at least something that might be seen.
|
|
|
|
maybeWarnWrongMajor = x: if !(lib.hasPrefix supportedLixMajor lixPackageToUse.version) then builtins.trace wrongMajorWarning x else x;
|
|
|
|
|
2024-09-30 20:35:21 +00:00
|
|
|
# It is not enough to *just* throw whatever the default nix version is at
|
|
|
|
# anything in the "don't give lix" list, we have to *also* ensure that we
|
|
|
|
# give whatever upstream version as specified in the callPackage invocation.
|
|
|
|
#
|
|
|
|
# Unfortunately I don't think there is any actual way to directly query that,
|
|
|
|
# so we instead do something extremely evil and guess which version it
|
|
|
|
# probably was. This code is not generalizable to arbitrary derivations, so
|
|
|
|
# it will hopefully not make us cry, at least.
|
|
|
|
useCppNixOverlay =
|
2024-09-18 03:47:29 +00:00
|
|
|
lib.genAttrs overridelist_upstream (
|
2024-09-30 20:35:21 +00:00
|
|
|
name:
|
|
|
|
if (lib.functionArgs prev.${name}.override ? "nix") then
|
|
|
|
let
|
|
|
|
# Get the two common inputs of a derivation/package.
|
|
|
|
inputs = prev.${name}.buildInputs ++ prev.${name}.nativeBuildInputs;
|
|
|
|
nixDependency = lib.findFirst
|
|
|
|
(drv: (drv.pname or "") == "nix")
|
2024-10-01 00:51:33 +00:00
|
|
|
final.nixVersions.stable_upstream # default to stable nix if nix is not an input
|
2024-09-30 20:35:21 +00:00
|
|
|
inputs;
|
|
|
|
nixMajor = lib.versions.major (nixDependency.version or "");
|
|
|
|
nixMinor = lib.versions.minor (nixDependency.version or "");
|
|
|
|
nixAttr = "nix_${nixMajor}_${nixMinor}";
|
|
|
|
finalNix = final.nixVersions.${nixAttr};
|
|
|
|
in
|
|
|
|
prev.${name}.override {
|
|
|
|
nix = finalNix;
|
|
|
|
}
|
|
|
|
else prev.${name}
|
|
|
|
);
|
|
|
|
|
|
|
|
overlay = useCppNixOverlay // {
|
2024-06-06 04:15:44 +00:00
|
|
|
lix-overlay-present = 1;
|
|
|
|
# used for things that one wouldn't necessarily want to update, but we
|
|
|
|
# nevertheless shove it in the overlay and fixed-point it in case one *does*
|
|
|
|
# want to do that.
|
|
|
|
lix-sources = import ./pins.nix;
|
2024-05-27 19:03:12 +00:00
|
|
|
|
2024-07-30 21:38:08 +00:00
|
|
|
lix = maybeWarnWrongMajor (maybeWarnDuplicate lixPackageToUse);
|
2024-07-21 18:15:55 +00:00
|
|
|
|
2024-09-18 03:47:29 +00:00
|
|
|
nixVersions = prev.nixVersions // {
|
|
|
|
stable = final.lix;
|
|
|
|
stable_upstream = prev.nixVersions.stable;
|
2024-06-06 04:15:44 +00:00
|
|
|
};
|
2024-04-16 03:06:52 +00:00
|
|
|
|
2024-06-06 04:15:44 +00:00
|
|
|
nix-eval-jobs = (prev.nix-eval-jobs.override {
|
|
|
|
# lix
|
2024-09-18 03:47:29 +00:00
|
|
|
nix = final.lix;
|
2024-06-06 04:15:44 +00:00
|
|
|
}).overrideAttrs (old:
|
|
|
|
let src = final.lix-sources.nix-eval-jobs;
|
|
|
|
in {
|
2024-07-30 21:07:09 +00:00
|
|
|
version = "2.91.0-lix-${builtins.substring 0 7 src.rev}";
|
2024-06-06 04:15:44 +00:00
|
|
|
|
|
|
|
# FIXME: should this be patches instead?
|
|
|
|
inherit src;
|
2024-04-22 21:59:54 +00:00
|
|
|
|
2024-06-06 04:15:44 +00:00
|
|
|
mesonBuildType = "debugoptimized";
|
|
|
|
|
|
|
|
ninjaFlags = old.ninjaFlags or [ ] ++ [ "-v" ];
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
nix-doc = prev.callPackage ./nix-doc/package.nix { withPlugin = false; };
|
|
|
|
};
|
|
|
|
in
|
2024-08-13 00:57:09 +00:00
|
|
|
# Make the overlay idempotent, since flakes passing nixos modules around by
|
2024-06-06 04:15:44 +00:00
|
|
|
# value and many other things make it way too easy to include the overlay
|
|
|
|
# twice
|
2024-08-13 00:57:09 +00:00
|
|
|
if (prev ? lix-overlay-present) then { lix-overlay-present = 2; } else overlay
|