From 8370c89fbe34234d728d08ac28e4fc2b2bb4b23a Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 19 Jan 2024 14:07:31 +0100 Subject: [PATCH] ioc/outputs: generate an overlay containing the top package this generates an nixpkgs overlay[1], with the current top as a package inside `epnix.support` [1]: https://nixos.org/manual/nixpkgs/stable/#chap-overlays this means that the top can be exported as a support module, and dependants top can import that support module by importing the overlay, and adding the package in the `epnix.support.modules` option --- ioc/modules/outputs.nix | 42 +++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/ioc/modules/outputs.nix b/ioc/modules/outputs.nix index 34865ca6..41f56887 100644 --- a/ioc/modules/outputs.nix +++ b/ioc/modules/outputs.nix @@ -3,6 +3,7 @@ lib, pkgs, epnix, + epnixFunEval, ... }: with lib; let @@ -19,25 +20,42 @@ with lib; let toUpper ]; in { - options.epnix.buildConfig = { - attrs = mkOption { - description = "Extra attributes to pass to the derivation"; - type = types.attrs; - default = {}; - }; + options.epnix = { + buildConfig = { + attrs = mkOption { + description = "Extra attributes to pass to the derivation"; + type = types.attrs; + default = {}; + }; + + src = mkOption { + description = '' + The source code for the top. - src = mkOption { - description = '' - The source code for the top. + Defaults to the directory containing the `flake.nix` file. + ''; + type = types.path; + }; + }; - Defaults to the directory containing the `flake.nix` file. - ''; - type = types.path; + generatedOverlay = mkOption { + description = "A generated overlay which has your package inside `pkgs.epnix.support`."; + type = with types; functionTo (functionTo attrs); }; }; config.epnix.buildConfig.src = mkDefault config.epnix.inputs.self; + config.epnix.generatedOverlay = final: prev: let + newEval = final.callPackage epnixFunEval final; + in { + epnix = prev.epnix.extend (_final: prev: { + support = prev.support.extend (_final: _prev: { + "${config.epnix.meta.name}" = newEval.config.epnix.outputs.build; + }); + }); + }; + config.epnix.outputs.build = pkgs.mkEpicsPackage ({ pname = "epnix-${config.epnix.meta.name}"; inherit (config.epnix.meta) version;