mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-10-26 09:37:17 +03:00
d5d304d5b5
* Include dependencies of haskell.nix that were tracked in `nix/sources.json` as flake inputs (`flake.lock` replaces `nix/sources.json`). * Use `flake-compat` to continue to provide a compatible interface for non flake projects. Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru> Co-authored-by: Shea Levy <shea@shealevy.com>
46 lines
2.2 KiB
Nix
46 lines
2.2 KiB
Nix
{
|
|
# Generic nixpkgs, use *only* for lib functions that are stable across versions
|
|
pkgs ? (import ./. {}).pkgs,
|
|
lib ? pkgs.lib
|
|
}: rec {
|
|
inherit (import ./dimension.nix) dimension;
|
|
|
|
# A filter for removing packages that aren't supported on the current platform
|
|
# according to 'meta.platforms'.
|
|
platformFilterGeneric = pkgs: system:
|
|
# This needs to use the correct nixpkgs version so all the systems line up
|
|
let lib = pkgs.lib;
|
|
platform = lib.systems.elaborate { inherit system; };
|
|
# Can't just default to [] for platforms, since no meta.platforms
|
|
# means "all platforms" not "no platforms"
|
|
in drv : if drv ? meta && drv.meta ? platforms then
|
|
lib.any (lib.meta.platformMatch platform) drv.meta.platforms
|
|
else true;
|
|
|
|
# Hydra doesn't like these attributes hanging around in "jobsets": it thinks they're jobs!
|
|
stripAttrsForHydra = filterAttrsOnlyRecursive (n: _: n != "recurseForDerivations" && n != "dimension");
|
|
|
|
# Keep derivations and attrsets with 'recurseForDerivations'. This ensures that we match the
|
|
# derivations that Hercules will see, and prevents Hydra from trying to pick up all sorts of bad stuff
|
|
# (like attrsets that contain themselves!).
|
|
filterDerivations = filterAttrsOnlyRecursive (n: attrs: lib.isDerivation attrs || attrs.recurseForDerivations or false);
|
|
|
|
# A version of 'filterAttrsRecursive' that doesn't recurse into derivations. This prevents us from going into an infinite
|
|
# loop with the 'out' attribute on derivations.
|
|
# TODO: Surely this shouldn't be necessary. I think normal 'filterAttrsRecursive' will effectively cause infinite loops
|
|
# if you keep derivations and your predicate forces the value of the attribute, as this then triggers a loop on the
|
|
# 'out' attribute. Weird.
|
|
# To make this function faster, unwanted attributes are mapped to {} instead of being
|
|
# removed. This keeps the function lazy and avoids unwanted evaluation of sibling
|
|
# derivations.
|
|
filterAttrsOnlyRecursive = pred: set:
|
|
lib.mapAttrs (name: v:
|
|
if pred name v
|
|
then
|
|
if builtins.isAttrs v
|
|
&& !lib.isDerivation v
|
|
then filterAttrsOnlyRecursive pred v
|
|
else v
|
|
else {}) set;
|
|
}
|