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; }; 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)); mapSingleFuse = f: mapFuse (x: singleAttr x (f x));
setDefault = default: mapFuse (name: { ${name} = default; }); setDefault = default: mapFuse (name: { ${name} = default; });

View file

@ -1,6 +1,25 @@
{ ... }: { dgn-lib, ... }:
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)
{ {
dgn-dns.enable = true; imports = mkImports ./. enabledServices;
} }
]

View file

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