dream2nix/v1/nix/modules/flake-parts/packages.nix

34 lines
1.0 KiB
Nix
Raw Normal View History

2023-02-11 16:38:53 +03:00
{ self, lib, inputs, ... }: {
perSystem = { config, self', inputs', pkgs, system, ... }: let
2023-02-11 16:38:53 +03:00
2023-03-05 10:15:38 +03:00
# A module imported into every package setting up the eval cache
evalCacheSetup = {config,...}: {
eval-cache.cacheFileRel = "/nix/modules/drvs/${config.public.name}/cache-${system}.json";
eval-cache.repoRoot = self;
2023-02-15 07:39:05 +03:00
eval-cache.enable = true;
};
2023-03-05 10:15:38 +03:00
# evalautes the package behind a given module
2023-02-11 16:38:53 +03:00
makeDrv = module: let
evaled = lib.evalModules {
modules = [
inputs.drv-parts.modules.drv-parts.core
2023-02-27 20:00:25 +03:00
inputs.drv-parts.modules.drv-parts.docs
module
2023-03-05 10:15:38 +03:00
../drv-parts/eval-cache
evalCacheSetup
];
2023-02-11 16:38:53 +03:00
specialArgs.dependencySets = {
2023-03-12 17:45:11 +03:00
nixpkgs = inputs'.nixpkgsV1.legacyPackages;
2023-02-11 16:38:53 +03:00
};
specialArgs.drv-parts = inputs.drv-parts;
};
in
evaled // evaled.config.public;
2023-02-11 16:38:53 +03:00
in {
2023-03-05 10:15:38 +03:00
# map all modules in ../drvs to a package output in the flake.
2023-02-11 16:38:53 +03:00
packages = lib.mapAttrs (_: drvModule: makeDrv drvModule) self.modules.drvs;
};
}