Skip to content

melting Nix modules together across configurations

License

Notifications You must be signed in to change notification settings

head-gardener/alloy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alloy

alloy is a tool for managing interdependent services between different configurations inside a flake.

Overview

It works by allowing defined modules to access each other's configuration options from args.

{ alloy, ... }:
let
  inherit (alloy) nix-serve;
in
{
  nix.settings.substituters = [
    "http://${nix-serve.host}:${toString nix-serve.config.services.nix-serve.port}"
  ];
}

Installation

To install alloy you can use flake-parts or do it yourself.

  • When using parts, add alloy.flakeModule to your imports, put your configuration in flake.alloy.config and move flake.nixosConfigurations to flake.alloy.nixosConfigurations. See module defenition for details.
  • When doing it yourself, wrap your nixosConfigurations in a call to alloy.lib.apply, providing configuration:
nixosConfigurations = alloy.lib.apply {
  config = [ ./alloy_config.nix ];
  extraSpecialArgs = { ... };
  nixosConfigurations = {
    host = { ... };
    # your configs
  }
};

Configuration

In general your configuration would look like this.

{
  modules = {
    module = ./module.nix; # anything that's considered a module
  };

  hosts = mods: with mods; {
    host = [ module ]; # what modules go where
  };
}

alloy configuration uses Nix modules, so you can use imports, config, etc. alloy modules have a special argument alloy-utils, which is alloy.lib.utils.

Example

See /example for a complete flake, defining multiple interdependent configurations via alloy.

TODO

  • make this a flake-parts module
  • use nix's module system for config
  • handle multi-instance services
  • middleware
  • remote extend
  • documentation, errors

About

melting Nix modules together across configurations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published