alloy is a tool for managing interdependent services between different configurations inside a flake.
See more on https://backyard-hg.net/alloy.html!
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}"
];
}To install alloy you can use flake-parts or do it yourself.
- When using parts, add
alloy.flakeModuleto your imports, put your configuration inflake.alloy.configand moveflake.nixosConfigurationstoflake.alloy.nixosConfigurations. See module defenition for details. - When doing it yourself, wrap your
nixosConfigurationsin a call toalloy.lib.apply, providing configuration:
nixosConfigurations = alloy.lib.apply {
config = [ ./alloy_config.nix ];
extraSpecialArgs = { ... };
nixosConfigurations = {
host = { ... };
# your configs
}
};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.
See /example for a complete flake, defining multiple interdependent configurations via alloy.
- make this a flake-parts module
- use nix's module system for config
- handle multi-instance services
- remote extend
- middleware
- documentation, errors