Skip to content

Commit

Permalink
feat: add darwin's cider
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Apr 4, 2023
1 parent cef2a89 commit f412bca
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/bee-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
};
description = "divnix/hive requires you to set the home-manager input via 'config.bee.home = inputs.home-22-05;'";
};
darwin = l.mkOption {
type = l.mkOptionType {
name = "input";
description = "darwin input";
check = x: (l.isAttrs x) && (l.hasAttr "sourceInfo" x);
};
description = "divnix/hive requires you to set the darwin input via 'config.bee.darwin = inputs.darwin;'";
};
pkgs = l.mkOption {
type = l.mkOptionType {
name = "packages";
Expand Down Expand Up @@ -130,6 +138,39 @@
imports = [beeModule locatedConfig extraConfig] ++ nixosModules;
};

tranformToDarwinConfig = evaled: locatedConfig: let
darwinModules =
import (evaled.config.bee.darwin + "/modules/module-list.nix")
++ [
evaled.options.bee.darwin.darwinModules.flakeOverrides
];
extraConfig = {
# seemlessly integrate hm if desired
imports = l.optionals evaled.options.bee.home.isDefined [
evaled.config.bee.home.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
eval = extra:
evaled.config.bee.darwin.lib.darwinSystem {
inherit (evaled.config.bee) system pkgs;
modules = [beeModule locatedConfig extraConfig extra];
};
bee =
evaled.config.bee
// {
_evaled = eval {config._module.check = true;};
_unchecked = eval {config._module.check = false;};
};
in {
inherit bee;
# complete module set, can be lib.evalModuled as-is
imports = [beeModule locatedConfig extraConfig] ++ darwinModules;
};

tranformToHomeManagerConfig = evaled: locatedConfig: let
lib = import (evaled.config.bee.home + /modules/lib/stdlib-extended.nix) l;
hmModules = import (evaled.config.bee.home + /modules/modules.nix) {
Expand Down Expand Up @@ -163,6 +204,7 @@ in {
beeModule
checkBeeAnd
tranformToNixosConfig
tranformToDarwinConfig
tranformToHomeManagerConfig
;
}
22 changes: 22 additions & 0 deletions src/collect-darwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
inputs, # unused for now
nixpkgs,
cellBlock,
}: renamer: let
l = nixpkgs.lib // builtins;
inherit (import ./walk.nix {inherit nixpkgs cellBlock;}) walkPaisano;
inherit (import ./bee-module.nix {inherit nixpkgs;}) beeModule checkBeeAnd tranformToDarwinConfig;

walk = self:
walkPaisano self (system: cell: [
(l.mapAttrs (target: config: {
_file = "Cell: ${cell} - Block: ${cellBlock} - Target: ${target}";
imports = [config];
}))
(l.mapAttrs (_: checkBeeAnd tranformToDarwinConfig))
(l.filterAttrs (_: config: config.bee.system == system))
(l.mapAttrs (_: config: config.bee._evaled))
])
renamer;
in
walk
7 changes: 7 additions & 0 deletions src/collect.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,32 @@
/*
Modules declare an interface into a problem domain
*/
darwinModules = throw "not implemented yet";
nixosModules = throw "not implemented yet";
homeModules = throw "not implemented yet";
shellModules = throw "not implemented yet";
/*
Profiles define values on that interface
*/
hardwareProfiles = throw "not implemented yet";
darwinProfiles = throw "not implemented yet";
nixosProfiles = throw "not implemented yet";
homeProfiles = throw "not implemented yet";
shellProfiles = throw "not implemented yet";
/*
Suites aggregate profiles into groups
*/
darwinSuites = throw "not implemented yet";
nixosSuites = throw "not implemented yet";
homeSuites = throw "not implemented yet";
shellSuites = throw "not implemented yet";
/*
Configurations have an init-sequence and can be deployed
*/
darwinConfigurations = import ./collect-darwin.nix {
cellBlock = "darwinConfigurations";
inherit nixpkgs inputs;
};
nixosConfigurations = import ./collect-nixos.nix {
cellBlock = "nixosConfigurations";
inherit nixpkgs inputs;
Expand Down

0 comments on commit f412bca

Please sign in to comment.