difftreelog
feat apply networking.hostName from fleet attr name
in: trunk
2 files changed
lib/fleetLib.nixdiffbeforeafterboth1# Shared functions for fleet configuration, available as `fleet` module argument1# Shared functions for fleet configuration, available as `fleet` module argument2{ nixpkgs, hostNames }: with nixpkgs.lib; rec {2{3 nixpkgs,4 hostNames,5}:6with nixpkgs.lib; rec {3 hostsToAttrs = f: listToAttrs (7 hostsToAttrs = f:34 then "${this}-${other}"28 else "${other}-${this}";35 else "${other}-${this}";3637 # For places, where fleet knows better than nixpkgs defaults38 mkFleetDefault = mkOverride 999;29}39}3040modules/fleet/meta.nixdiffbeforeafterboth--- a/modules/fleet/meta.nix
+++ b/modules/fleet/meta.nix
@@ -5,9 +5,12 @@
nixpkgs,
...
}:
-with lib; let
+with lib;
+with fleetLib; let
hostModule = with types;
- {...} @ hostConfig: {
+ {...} @ hostConfig: let
+ hostName = hostConfig.config._module.args.name;
+ in {
options = {
modules = mkOption {
type = listOf (mkOptionType {
@@ -32,12 +35,19 @@
description = "Nixos configuration";
};
};
- config.nixosSystem = nixpkgs.lib.nixosSystem {
- inherit (hostConfig.config) system modules;
- specialArgs = {
- inherit fleetLib;
- fleet = fleetLib.hostsToAttrs (host: config.hosts.${host}.nixosSystem.config);
+ config = {
+ nixosSystem = nixpkgs.lib.nixosSystem {
+ inherit (hostConfig.config) system modules;
+ specialArgs = {
+ inherit fleetLib;
+ fleet = hostsToAttrs (host: config.hosts.${host}.nixosSystem.config);
+ };
};
+ modules = [
+ ({...}: {
+ networking.hostName = mkFleetDefault hostName;
+ })
+ ];
};
};
overlayType = mkOptionType {
@@ -69,7 +79,7 @@
};
};
config = {
- hosts = fleetLib.hostsToAttrs (host: {
+ hosts = hostsToAttrs (host: {
modules =
config.globalModules
++ [