Created
October 30, 2018 17:34
-
-
Save yorickvP/99f9e16c673a17ec9135065ffba4675d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { config, lib, pkgs, ... }@mod: | |
| let | |
| inherit (lib) types mkOption; | |
| module = with types; { name, config, ... }: { options = { | |
| path = mkOption { default = ../profiles/cd + "/${config.src}.nix"; type = path;}; | |
| port = mkOption { type = int; }; | |
| };}; | |
| modules = with lib; (lib.mapAttrsToList (name: cfg: (let file = toString cfg.path; key = file; in | |
| unifyModuleSyntax file key (applyIfFunction key (import cfg.path cfg) mod))) config.cd); | |
| in | |
| { | |
| options.cd = lib.mkOption { | |
| type = types.attrsOf (types.submodule module); | |
| default = {}; | |
| }; | |
| config.services = lib.mkMerge (lib.concatMap (x: (builtins.map (y: y.services or {}) (lib.pushDownProperties x.config))) modules); | |
| config.systemd = lib.mkMerge (lib.concatMap (x: (builtins.map (y: y.systemd or {}) (lib.pushDownProperties x.config))) modules); | |
| config.cd.test = { port = 9001; }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment