ALPHA: wire is a tool to deploy nixos systems
wire.althaea.zone/
1---
2comment: true
3title: Use hive.default
4description: Deduplicate options with default node configuration.
5---
6
7# `Use hive.default`
8
9{{ $frontmatter.description }}
10
11## Introduction
12
13At the top level of a hive wire reserves the `defaults` attribute. It's applied
14to every node.
15
16::: warning
17
18`defaults` must not rely on modules that a node imports, but a
19node may rely on modules that default imports.
20
21:::
22
23```nix:line-numbers [hive.nix]
24let
25 sources = import ./npins;
26 wire = import sources.wire;
27in wire.makeHive {
28 meta.nixpkgs = import sources.nixpkgs { };
29
30 defaults = {
31 # name of the node that defaults is being applied to
32 name,
33 # attribute set of all nodes
34 nodes,
35 ...
36 }: {
37 import = [
38 ./default-module.nix
39
40 # module that is imported for all nodes
41 some-flake.nixosModules.default
42 ];
43
44 # default configuration
45 # may or may not utilise `name` or `nodes`
46 };
47
48 node-a = {
49 # some config
50 };
51
52 node-b = {
53 # some more config
54 };
55}
56```