Skip to content

Commit

Permalink
ioc/outputs: generate an overlay containing the top package
Browse files Browse the repository at this point in the history
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
  • Loading branch information
minijackson committed Jan 19, 2024
1 parent 4c31602 commit 8370c89
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions ioc/modules/outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
lib,
pkgs,
epnix,
epnixFunEval,
...
}:
with lib; let
Expand All @@ -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;
Expand Down

0 comments on commit 8370c89

Please sign in to comment.