machines: Add boilerplate for enabling modules and services

This commit is contained in:
Tom Hubrecht 2023-07-23 21:46:53 +02:00
parent 8cecf0eae8
commit 98f2077568
4 changed files with 71 additions and 22 deletions

View file

@ -25,6 +25,11 @@ rec {
*/
singleAttr = name: value: { ${name} = value; };
/* Enables a list of modules. */
enableAttrs' = enable: mapFuse (m: { ${m}.${enable} = true; });
enableModules = enableAttrs' "enable";
mapSingleFuse = f: mapFuse (x: singleAttr x (f x));
setDefault = default: mapFuse (name: { ${name} = default; });

View file

@ -1,6 +1,25 @@
{ ... }:
{ dgn-lib, ... }:
{
dgn-dns.enable = true;
let
inherit (dgn-lib)
enableModules
mkImports
recursiveFuse;
}
# List of modules to enable
enabledModules = [
"dgn-dns"
];
# List of services to enable
enabledServices = [
];
in
recursiveFuse [
(enableModules enabledModules)
{
imports = mkImports ./. enabledServices;
}
]

View file

@ -1,8 +1,24 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`).
{ dgn-lib, ... }:
{ config, pkgs, ... }:
let
inherit (dgn-lib)
enableModules
mkImports
recursiveFuse;
{
}
# List of modules to enable
enabledModules = [
];
# List of services to enable
enabledServices = [
];
in
recursiveFuse [
(enableModules enabledModules)
{
imports = mkImports ./. enabledServices;
}
]

View file

@ -1,17 +1,26 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ dgn-lib, ... }:
{ name, ... }:
let
inherit (dgn-lib)
enableModules
mkImports
recursiveFuse;
{
imports =
[
./plausible.nix
# ./wordpress
];
# List of modules to enable
enabledModules = [
];
networking.hostName = name;
# List of services to enable
enabledServices = [
"plausible"
# "wordpress"
];
in
recursiveFuse [
(enableModules enabledModules)
}
{
imports = mkImports ./. enabledServices;
}
]