-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: implement modules and profiles #16
base: main
Are you sure you want to change the base?
Conversation
I will provide more Info's tomorrow. It's 3 in the morning for me :) |
@blaggacao I have also addressed this comment #15 (comment) in the haumea PR (#15). The |
d07f12e
to
45e4f5d
Compare
c02dc60
to
59d1da6
Compare
fc960b5
to
8fcabbe
Compare
I will probably abandon this PR, I'm currently working on a loader more akin to hive.findLoad, and hive.load. This is currently implemented an used here. If there is interest to upstream this loader (changing the namespacing from hoppla to bee of course), I would be happy to create a new PR. |
Overview
This PR uses the haumea refactoring of PR #15 and implements the blockType, collector, and transformer (checks still missing) for nixosModules, nixosProfiles, darwinModules, darwinProfiles.
The example repo can be used to aid understanding these changes.
BlockTypes
Modules
The target blocktype to implement nixosModules and darwinModules is as follows:
When the
hive.collect
function is used, the collector uses thehive.collect.renamer
functions to determines the moduleName. The default renamer sets the modules to${cellName}-${targetName}
. Assuming the previous target was of the cellexample
with the namedefault
(the block name is always "nixosModules" or "darwinModules"), the following module would be the result of the collect operation:As you can see in the resulting module, the collector automagically adds a 'switch' to enable and disable the module.
Profiles
Profiles are similar to modules with the difference that the shouldn't have options. Therefore the target block type for nixosProfiles and darwinProfiles assume that the target returns a function that expects moduleInputs as input and returns an config attribute set. For example:
The resulting nixos module (with cell = "example" and target = "default") would be:
Again, the collector automagically added a switch. In contrast to modules, profiles can be enabled using the
bee.profiles
option, which expects a list of strings.Scope
This PR modifies the collector for
nixosConfigurations
in a way thatnixosModules
andnixosProfiles
of the same cell are automatically loaded. However these modules and profiles still have to be configured and enabled using thebee.modules
andbee.profiles
config options. The behaviour fordarwin
is equivilent.Modules and profiles of other cells of the same flake or other flakes can the loaded using the
bee.extraModules
andbee.extraProfiles
options.Example
A full example can be found in the example repository linked in the beginning. I have pinned the link to a commit, which should be fully working.
Tests
I have only tested this PR using the example repo. I am planning to extend this to a full VM setup, maybe including tests for darwin.
Further work
Suites
By implementing the
bee.profiles
as a list of lists, suites can then also be implemented as lists of strings.Naming collision avoidance
One should be able to use the
hive.collect
function on an input instead ofself
and by overriding thehive.collect.renamer
function, one should be able to change all module and profile names, including their references in profiles and suites.Checks for modules and profiles
In the implementation of the PR i refactored the
checkBeeAnd
function tochecks.bee
. And instead of calling the transformation function usingcheckBeeAnd
, thechecks.bee
function asserts that the bee modules has no alerts and is just another step in the pipe. With this setup one could also implement checks for modules and profiles, however I'm not yet sure how to implement this.Update 1
Pass
targetName
function to profilesChange to the profiles block type:
The
targetName
function is passed to the profile from thehive.collect
function and its definition istargetName = hive.collect.renamer cell
. Basically the targetName is a curried function with the cell paramter pre-applied. The resulting nixos module (with cell = "example" and target = "default") with the default renamer (renamer = cell: target: "${cell}-${target}"
) is:This allows profiles to reference modules in the same cell, without breaking when overriding the
renamer
attribute ofhive.collect
. The example repository demonstrates this.