2019-12-14 05:30:43 +01:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
2020-07-30 23:29:58 +02:00
|
|
|
inherit (builtins) attrNames isAttrs readDir listToAttrs;
|
2019-12-14 05:30:43 +01:00
|
|
|
|
2020-12-25 20:53:57 +01:00
|
|
|
inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix
|
|
|
|
recursiveUpdate genAttrs;
|
2019-12-14 05:30:43 +01:00
|
|
|
|
|
|
|
# mapFilterAttrs ::
|
|
|
|
# (name -> value -> bool )
|
|
|
|
# (name -> value -> { name = any; value = any; })
|
|
|
|
# attrs
|
2020-01-04 06:06:31 +01:00
|
|
|
mapFilterAttrs = seive: f: attrs: filterAttrs seive (mapAttrs' f attrs);
|
2019-12-14 05:30:43 +01:00
|
|
|
|
2020-07-30 23:29:58 +02:00
|
|
|
# Generate an attribute set by mapping a function over a list of values.
|
|
|
|
genAttrs' = values: f: listToAttrs (map f values);
|
|
|
|
|
2020-12-25 20:53:57 +01:00
|
|
|
pkgImport = { pkgs, system, overlays }:
|
|
|
|
import pkgs {
|
|
|
|
inherit system overlays;
|
|
|
|
config = { allowUnfree = true; };
|
|
|
|
};
|
|
|
|
|
|
|
|
# Convert a list to 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:
|
|
|
|
genAttrs' paths (path: {
|
|
|
|
name = removeSuffix ".nix" (baseNameOf path);
|
|
|
|
value = import path;
|
|
|
|
});
|
|
|
|
|
2020-07-31 06:17:28 +02:00
|
|
|
in
|
|
|
|
{
|
2020-12-25 20:53:57 +01:00
|
|
|
inherit mapFilterAttrs genAttrs' pkgImport pathsToImportedAttrs;
|
|
|
|
|
|
|
|
genPkgset = { master, nixos, overlays, system }:
|
|
|
|
{
|
|
|
|
osPkgs = pkgImport {
|
|
|
|
inherit system overlays;
|
|
|
|
pkgs = nixos;
|
|
|
|
};
|
|
|
|
|
|
|
|
unstablePkgs = pkgImport {
|
|
|
|
inherit system overlays;
|
|
|
|
pkgs = master;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
overlayPaths =
|
|
|
|
let
|
|
|
|
overlayDir = ../overlays;
|
|
|
|
fullPath = name: overlayDir + "/${name}";
|
|
|
|
in
|
|
|
|
map fullPath (attrNames (readDir overlayDir));
|
2020-07-30 23:29:58 +02:00
|
|
|
|
2020-01-04 06:06:31 +01:00
|
|
|
recImport = { dir, _import ? base: import "${dir}/${base}.nix" }:
|
2020-07-31 06:17:28 +02:00
|
|
|
mapFilterAttrs
|
|
|
|
(_: v: v != null)
|
|
|
|
(n: v:
|
|
|
|
if n != "default.nix" && hasSuffix ".nix" n && v == "regular"
|
|
|
|
then
|
|
|
|
let name = removeSuffix ".nix" n; in nameValuePair (name) (_import name)
|
|
|
|
else
|
|
|
|
nameValuePair ("") (null))
|
|
|
|
(readDir dir);
|
2020-07-30 23:29:58 +02:00
|
|
|
|
2020-12-25 20:53:57 +01:00
|
|
|
modules =
|
|
|
|
let
|
|
|
|
# binary cache
|
|
|
|
cachix = import ../cachix.nix;
|
|
|
|
cachixAttrs = { inherit cachix; };
|
|
|
|
|
|
|
|
# modules
|
|
|
|
moduleList = import ../modules/list.nix;
|
|
|
|
modulesAttrs = pathsToImportedAttrs moduleList;
|
|
|
|
|
|
|
|
# profiles
|
|
|
|
profilesList = import ../profiles/list.nix;
|
|
|
|
profilesAttrs = { profiles = pathsToImportedAttrs profilesList; };
|
|
|
|
in
|
|
|
|
recursiveUpdate
|
|
|
|
(recursiveUpdate cachixAttrs modulesAttrs)
|
|
|
|
profilesAttrs;
|
|
|
|
|
2021-01-03 08:05:39 +01:00
|
|
|
genPackages = { self, pkgs }:
|
2020-12-25 20:53:57 +01:00
|
|
|
let
|
2021-01-03 08:05:39 +01:00
|
|
|
inherit (self) overlay overlays;
|
2020-12-25 20:53:57 +01:00
|
|
|
packages = overlay pkgs pkgs;
|
|
|
|
overlayPkgs =
|
|
|
|
genAttrs
|
2020-12-30 17:50:23 +01:00
|
|
|
(attrNames overlays)
|
|
|
|
(name: (overlays."${name}" pkgs pkgs)."${name}");
|
2020-12-25 20:53:57 +01:00
|
|
|
in
|
|
|
|
recursiveUpdate packages overlayPkgs;
|
2020-07-30 23:29:58 +02:00
|
|
|
|
2019-12-14 05:30:43 +01:00
|
|
|
}
|