forked from pub-solar/os
5a3bae7be5
220: Drop flattenTreeSystem and use custom function for filtering packages r=nrdxp a=Pacman99 I don't think we should flatten the system because if a user doesn't make a package a derivation in pkgs/default.nix we should trust that there is a reason for doing so. So instead this drops the flattenTreeSystem reference(and switches to flake-utils master branch) and replaces its usage with a custom function `filterPackages`. This function filter all packages that match three conditions; - is a derivation - not broken - system is supported In that order as to not cause errors when trying to reference non-derivation meta attributes. And then also just dump *all* packages into legacy packages, so everything else is still accessible. I was considering removing the packages that are already in the packages output in legacyPackages, but I don't think its necessary since nix looks to the packages output first. Co-authored-by: Pacman99 <pachum99@gmail.com>
41 lines
1.3 KiB
Nix
41 lines
1.3 KiB
Nix
{ lib, ... }:
|
|
rec {
|
|
# mapFilterAttrs ::
|
|
# (name -> value -> bool )
|
|
# (name -> value -> { name = any; value = any; })
|
|
# attrs
|
|
mapFilterAttrs = seive: f: attrs:
|
|
lib.filterAttrs
|
|
seive
|
|
(lib.mapAttrs' f attrs);
|
|
|
|
# Generate an attribute set by mapping a function over a list of values.
|
|
genAttrs' = values: f: lib.listToAttrs (map f values);
|
|
|
|
# Convert a list of file paths to attribute set
|
|
# that has the filenames stripped of nix extension as keys
|
|
# and imported content of the file as value.
|
|
#
|
|
pathsToImportedAttrs = paths:
|
|
let
|
|
paths' = lib.filter (lib.hasSuffix ".nix") paths;
|
|
in
|
|
genAttrs' paths' (path: {
|
|
name = lib.removeSuffix ".nix"
|
|
# Safe as long this is just used as a name
|
|
(builtins.unsafeDiscardStringContext (baseNameOf path));
|
|
value = import path;
|
|
});
|
|
|
|
concatAttrs = lib.fold (attr: sum: lib.recursiveUpdate sum attr) { };
|
|
|
|
# Filter out packages that support given system and follow flake check requirements
|
|
filterPackages = system: packages:
|
|
let
|
|
# Everything that nix flake check requires for the packages output
|
|
filter = (n: v: with v; let platforms = meta.hydraPlatforms or meta.platforms or [ ]; in
|
|
lib.isDerivation v && !meta.broken && builtins.elem system platforms);
|
|
in
|
|
lib.filterAttrs filter packages;
|
|
}
|