Skip to content

luxus/hive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Since the core code of hivebus uses and draws inspiration from the @blaggacao’s hive , please read and understand the blog of primamateria-hive before starting.

‼️ If you want to learn the core code of hivebus, please read omnibus-hive

What are the differences from Hive?

  1. hive based on the std file structures.
  2. hivebus use inputs.omnibus.pops.hive.setHosts to export the target configuration.
  3. Hivebus is more flexible; you can use different functions to load the corresponding configuration modules, like building blocks. Unlike a predefined framework, it does not restrict you.

pops.hive

The core functionality of pops.hive involves exporting a set of hosts with specific attribute sets to different target configuration systems. It also uses the beeModule to transmit the necessary inputs required by the target systems.

let
  inherit (inputs) nixpkgs;
  hosts = {
    host1 = rec {
      colmena = {
        nixpkgs = { };
      };
      system = "x86_64-linux";
      nixosConfiguration = {
        bee.pkgs = import nixpkgs { system = system; };
        bee.system = system;
        imports = [ omnibus.flake.inputs.disko.nixosModules.default ];
      };
      asd = nixosConfiguration;
      colmenaConfiguration = {
        deployment = {
          allowLocalDeployment = true;
          targetHost = "127.0.0.1";
        };
        inherit (nixosConfiguration) bee imports;
      };
    };
    host2 = rec {
      colmena = {
        nixpkgs = { };
      };
      system = "aarch64-linux";
      darwinConfiguration = {
        bee.darwin = omnibus.flake.inputs.darwin;
        bee.system = system;
        bee.pkgs = import nixpkgs { system = system; };
      };

      homeConfiguration = {
        bee.system = system;
        bee.pkgs = import nixpkgs { system = system; };
        bee.home = omnibus.flake.inputs.home-manager;
      };
    };
  };
  hivePop =
    ((omnibus.pops.hive.setHosts hosts).addInputs {
      inherit (omnibus.flake.inputs) colmena nixpkgs;
    }).setNixosConfigurationsRenamer
      "asd";
  inherit (hivePop.exports) darwinConfigurations colmenaHive;
in
{
  inherit hivePop darwinConfigurations colmenaHive;
}

pops.hive.set{targetSystemRenamer}

the pops.hive.set{targetSystemRenamer} uses a POP style to modify the renamer of the target configuration. This renamer specifies which attribute set will be used to collect and load configurations into the target export system.

For example, in host1, we renamed nixosConfiguration to asd{...} as the specified configuration to be loaded for the target configuration ‘nixosConfiguration’.”

{
  hosts.host1 = rec {
    nixosConfiguration = {
      bee.pkgs = import nixpkgs { system = system; };
      bee.system = system;
      imports = [ omnibus.flake.inputs.disko.nixosModules.default ];
    };
    asd = nixosConfiguration;
  };
  hiveExporter = (omnibus.pops.hive.setHosts.hosts).setNixosConfigurationsRenamer "asd";
}

Of course, you can specify multiple hiveExporters to collect and export target configurations under different attribute sets.

hiveDarwinExporter = (omnibus.pops.hive.setHosts.hosts).setDarwinConfigurationsRenamer "myDarwin"

hiveHomeExporter = (omnibus.pops.hive.setHosts.hosts).setHomeConfigurationsRenamer "myHome"

Simplify configuration interface

Compared to the traditional {nixos, darwin,...}Configurations loading method, pops.hive only requires a set of hosts’ attribute sets to load the corresponding attribute set into the respective configuration interface. Additionally, it utilizes a clean eval-config mode.

{
  hosts.{simple,...}.nixosConfiguration = { bee = {...}; imports = [];};
  hiveExporter = (pops.hive.setHosts hosts).exports.nixosConfigurations;
  # =>
  simple = hiveExporter.simple;

  nixosConfigurations.simple = inputs.nixos-unstable.lib.nixosSystem {
    system = "x86_64-linux";
    modules = [ ];
  };
  homeConfigurations.simple = inputs.home-manager.lib.homeManagerConfiguration {
    pkgs = inputs.nixos-unstable.legacyPackages.x86_64-linux;
    modules = [ ];
  };
}

Available exporter of target system

  • nixosConfigurations
  • darwinConfigurations
  • homeConfigurations

    AttrSet -> home-manager.lib.homeManagerConfiguration -> homeManagerConfiguration

    {
      homeConfiguration = {
            bee.system = system;
            bee.pkgs = import nixpkgs { system = system; };
            bee.home = omnibus.flake.inputs.home-manager;
          };
    }
        
  • colmenaHive
    • https://github.com/zhaofengli/colmena
      {
        colmenaConfiguration = {
          deployment = {
            allowLocalDeployment = true;
            targetHost = "127.0.0.1";
          };
          bee = {
            pkgs = import nixpkgs { system = system; };
            colmena = inputs.colmena;
          };
          imports = [ ];
        };
      }
              

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages