Giter VIP home page Giter VIP logo

hive's Introduction

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 = [ ];
        };
      }
              

hive's People

Contributors

luxus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.