Created
February 4, 2019 10:58
-
-
Save johanot/91976e4e916e7965a28c2b496776d628 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, pkgs, lib, ... }: with lib; with lib.types; { | |
| options = { | |
| dbc.host = lib.mkOption { | |
| type = attrs; | |
| description = '' | |
| Holds host information as derived from JSON files in /hosts, | |
| about the current host system being built. | |
| ''; | |
| }; | |
| dbc.knownHosts = lib.mkOption { | |
| type = listOf attrs; | |
| description = '' | |
| Holds a collective list of all dbc hosts and their host keys | |
| in the format compliant to: | |
| <link linkend="opt-programs.ssh.knownHosts">programs.ssh.knownHosts</link>. | |
| ''; | |
| }; | |
| }; | |
| config.dbc.host = mkDefault | |
| (let | |
| byHostName = (import ../../hosts { inherit pkgs; }).allHostsbyName; | |
| netHostName = config.networking.hostName; | |
| in | |
| if netHostName != "" && hasAttr netHostName byHostName | |
| then byHostName.${netHostName} | |
| else {}); | |
| # This above else-block should throw (instead of the warning below) | |
| # - we'll probably change this once ALL hosts have a JSON file | |
| config.warnings = optional (config.dbc.host == {} && !config.deployment.buildOnly) | |
| (concatStringsSep "\n" | |
| [ | |
| "DBC Hostinfo is an empty set." | |
| (if config.networking.hostName == "" | |
| then "Looks like: `config.networking.hostName` is not set for ${config.deployment.targetHost}?" | |
| else "Looks like: `${config.networking.hostName}` doesn't have a json file?") | |
| "" | |
| ]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment