Skip to content

Commit

Permalink
refactor(pops.hive): migrate divnix/hive to omnibus/hive
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Apr 24, 2024
1 parent 8588555 commit 60cb5ce
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 159 deletions.
4 changes: 2 additions & 2 deletions src/hive/collectors/colmenaConfigurations.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let
};
});
in
renamer: self:
renamer: self: system:
colmenaTopLevelCliSchema (
super.walk transformers.colmenaConfiguration [ ] renamer self
super.walk transformers.colmenaConfiguration [ ] renamer self system
)
30 changes: 19 additions & 11 deletions src/hive/collectors/walk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
# SPDX-License-Identifier: Unlicense

{ lib, root }:
transformer: extraPipe: renamer: hosts: system:

let
l = lib // builtins;
inherit (l) pipe;
inherit (root.hive) checks transformers;
walk' = lib.mapAttrs (
hostName: hostConfig:
pipe hostConfig (
l.optionals (hostConfig.meta ? ${renamer} || hostConfig ? ${renamer}) (
[
(hostConfig: hostConfig.meta.${renamer} or hostConfig.${renamer})
checks.bee
transformer
]
++ extraPipe
)
++ l.optionals (!hostConfig.meta ? ${renamer} && !hostConfig ? ${renamer}) [
(_: { })
]
)
) hosts;
in
transformer: extraPipe: renamer: hosts:
lib.mapAttrs (
hostName: hostConfig:
pipe (hostConfig.meta.${renamer} or hostConfig.${renamer}) (
[
checks.bee
transformer
]
++ extraPipe
)
) hosts
l.filterAttrs (_: c: c != { }) walk'
22 changes: 16 additions & 6 deletions src/pops/hive.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ in
nixosProfiles = { };
nixosModules = { };
};
system = "";
nixosConfigurationRenamer = "nixosConfiguration";
exports = {
hosts = { };
Expand All @@ -50,18 +51,27 @@ in
};
setHosts =
setHosts: extendPop final (_: superP: { hosts = superP.hosts // setHosts; });
addMapLoadToPops = load: { };

darwinConfiguraitons = root.hive.collectors.darwinConfigurations "darwinConfiguration" final.hosts;
setSystem = system: extendPop final (_: _: { inherit system; });

colmenaHive = root.hive.collectors.colmenaConfigurations "colmetaConfiguration" final.hosts;
addMapLoadToPops = load: { };

nixosConfigurations = root.hive.collectors.nixosConfigurations final.nixosConfigurationRenamer final.hosts;
setNixosConfigurationRenamer =
setNixosConfigurationsRenamer =
renamer: extendPop final (_: _: { nixosConfigurationRenamer = renamer; });

pops = { };
exports = {
darwinConfiguraitons =
root.hive.collectors.darwinConfigurations "darwinConfiguration" final.hosts
final.system;

colmenaHive =
root.hive.collectors.colmenaConfigurations "colmenaConfiguration" final.hosts
final.system;

nixosConfigurations =
root.hive.collectors.nixosConfigurations final.nixosConfigurationRenamer
final.hosts
final.system;
# hosts = lib.omnibus.mkHosts {
# # hostsDir = projectRoot + "/units/nixos/hosts";
# hostsDir = ./.;
Expand Down
48 changes: 1 addition & 47 deletions templates/nixos/units/nixos/hosts/beidou/layouts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,4 @@
# SPDX-FileCopyrightText: 2024 The omnibus Authors
#
# SPDX-License-Identifier: MIT

let
outputs = inputs.self;
in
# self' = inputs.self.hosts.nixos;
{
system = "x86_64-linux";

data = outputs.local.${self.system}.data;

hive = {
bee.system = self.system;
# use the mkHome function to create a home-manager profile
# bee.home = inputs.home-manager;
bee.pkgs = import inputs.nixpkgs { inherit (self) system; };
imports = lib.flatten self.nixosSuites;
};

nixosSuites = lib.flatten [
outputs.hosts.nixos.nixosProfiles.bootstrap

outputs.nixosProfiles.presets.boot
# outputs.nixosModules.default.programs.git

# # # --custom profiles
# outputs.pops.nixosProfiles.exports.customProfiles.presets.nix
# outputs.pops.nixosProfiles.exports.customProfiles.presets.boot
# outputs.pops.nixosModules.exports.customModules.boot

# outputs.srvos.default.common.nix
(outputs.omnibus.self.mkHome inputs.home.nixosModule {
admin = {
uid = 1000;
description = "default manager";
isNormalUser = true;
extraGroups = [ "wheel" ];
};
} "zsh" self.homeSuites)
];

homeSuites = [
outputs.homeProfiles.presets.emacs
# outputs.homeProfiles.presets.bat
# # # The parent directory of "presets" is categorized as a list type of "suites"
# (outputs.homeProfiles.shell { }).default
];
}
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@
#
# SPDX-License-Identifier: MIT

let
inherit (inputs) nixpkgs;
in
nixpkgs.lib.nixosSystem rec {
system = super.layouts.system;
pkgs = import nixpkgs { inherit system; };
modules = lib.flatten [ super.layouts.nixosSuites ];
}
{ }
73 changes: 35 additions & 38 deletions templates/nixos/units/nixos/hosts/darwin/layouts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,44 @@
#
# SPDX-License-Identifier: MIT

{
inputs,
self,
lib,
}:
let
outputs = inputs.self;
in
{
system = "aarch64-aarch";
{ self, lib }:
# let
# outputs = inputs.self;
# in
# {
# system = "aarch64-aarch";

data = outputs.local.${self.system}.data;
# data = outputs.local.${self.system}.data;

hive = {
bee.system = self.system;
bee.home = inputs.home-manager;
bee.darwin = inputs.darwin;
bee.pkgs = import inputs.nixpkgs { inherit (self) system; };
imports = lib.flatten self.darwinSuites;
};
# hive = {
# bee.system = self.system;
# bee.home = inputs.home-manager;
# bee.darwin = inputs.darwin;
# bee.pkgs = import inputs.nixpkgs { inherit (self) system; };
# imports = lib.flatten self.darwinSuites;
# };

darwinSuites = lib.flatten [
# outputs.darwinModules.exports.default.homebrew
# # # --custom profiles
# outputs.pops.nixosProfiles.exports.customProfiles.presets.nix
# outputs.pops.nixosProfiles.exports.customProfiles.presets.boot
# outputs.pops.nixosModules.exports.customModules.boot
# darwinSuites = lib.flatten [
# # outputs.darwinModules.exports.default.homebrew
# # # # --custom profiles
# # outputs.pops.nixosProfiles.exports.customProfiles.presets.nix
# # outputs.pops.nixosProfiles.exports.customProfiles.presets.boot
# # outputs.pops.nixosModules.exports.customModules.boot

# outputs.srvos.default.common.nix
(outputs.omnibus.mkHome inputs.home.darwinModule {
admin = {
uid = 1000;
description = "default manager";
};
} "zsh" self.homeSuites)
];
# # outputs.srvos.default.common.nix
# (outputs.omnibus.mkHome inputs.home.darwinModule {
# admin = {
# uid = 1000;
# description = "default manager";
# };
# } "zsh" self.homeSuites)
# ];

homeSuites = [
# outputs.homeProfiles.presets.emacs
# outputs.homeProfiles.presets.bat
# # # The parent directory of "presets" is categorized as a list type of "suites"
# (outputs.homeProfiles.shell { }).default
];
# homeSuites = [
# # outputs.homeProfiles.presets.emacs
# # outputs.homeProfiles.presets.bat
# # # # The parent directory of "presets" is categorized as a list type of "suites"
# # (outputs.homeProfiles.shell { }).default
# ];
{
}
47 changes: 1 addition & 46 deletions templates/nixos/units/nixos/hosts/nixos/layouts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,4 @@
#
# SPDX-License-Identifier: MIT

let
outputs = inputs.self;
in
# self' = inputs.self.hosts.nixos;
{
system = "x86_64-linux";

data = outputs.local.${self.system}.data;

hive = {
bee.system = self.system;
# use the mkHome function to create a home-manager profile
# bee.home = inputs.home-manager;
bee.pkgs = import inputs.nixpkgs { inherit (self) system; };
imports = lib.flatten self.nixosSuites;
};

nixosSuites = lib.flatten [
outputs.hosts.nixos.nixosProfiles.bootstrap

outputs.nixosProfiles.presets.boot
# outputs.nixosModules.default.programs.git

# # # --custom profiles
# outputs.pops.nixosProfiles.exports.customProfiles.presets.nix
# outputs.pops.nixosProfiles.exports.customProfiles.presets.boot
# outputs.pops.nixosModules.exports.customModules.boot

# outputs.srvos.default.common.nix
(outputs.omnibus.self.mkHome inputs.home.nixosModule {
admin = {
uid = 1000;
description = "default manager";
isNormalUser = true;
extraGroups = [ "wheel" ];
};
} "zsh" self.homeSuites)
];

homeSuites = [
outputs.homeProfiles.presets.emacs
# outputs.homeProfiles.presets.bat
# # # The parent directory of "presets" is categorized as a list type of "suites"
# (outputs.homeProfiles.shell { }).default
];
}
{ }
24 changes: 24 additions & 0 deletions tests/hive/example.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
debug,
lib,
root,
omnibus,
inputs,
}:
let
hosts = omnibus.load {
src = ../../templates/nixos/units/nixos/hosts;
inputs = {
nixpkgs = omnibus.flake.inputs.nixpkgs;
inputs = omnibus.flake.inputs;
};
};
hive = omnibus.pops.hive.setHosts hosts;
in
{
darwin = hive.darwinConfiguraitons.darwin.config.system;
inherit hive;
hiveExpr = (
(hive.setSystem "x86_64-linux").setNixosConfigurationsRenamer "asd"
);
}
3 changes: 2 additions & 1 deletion tests/hive/expr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ let
hive = omnibus.pops.hive.setHosts hosts;
in
{
# darwin = hive.darwinConfiguraitons.darwin.config.system;
darwin = hive.exports.darwinConfiguraitons.darwin.config.system;
inherit hive;
}

0 comments on commit 60cb5ce

Please sign in to comment.