{ config, pkgs, lib, ... }: { options = { netbird = { enable = lib.mkEnableOption { description = "Enable Netbird"; default = false; }; opts = { setup_key = lib.mkOption { type = lib.types.str; description = '' Setup key obtained from the Management Service Dashboard (used to register peer) ''; default = ""; }; management_url = lib.mkOption { type = lib.types.str; description = '' Management Service URL [http|https]://[host]:[port] ''; default = "https://api.wiretrustee.com:443"; }; admin_url = lib.mkOption { type = lib.types.str; description = '' Admin Panel URL [http|https]://[host]:[port] ''; default = "https://app.netbird.io"; }; }; }; }; # TODO: This code should live somewhere else and be available to everything. # mkIfElse = p: yes: no: lib.mkMerge [ # (lib.mkIf p yes) # (lib.mkif (!p) no) # ]; config = lib.mkIf (config.netbird.enable) (lib.mkMerge [ { services.netbird.tunnels = { wt0.environment = (lib.mkMerge [ { NB_MANAGEMENT_URL = config.netbird.opts.management_url; NB_ADMIN_URL = config.netbird.opts.admin_url; } (lib.mkIf (config.netbird.opts.setup_key != "") { NB_SETUP_KEY = config.netbird.opts.setup_key; }) ]); }; } (lib.mkIf (config.gui.enable) { home-manager.users.${config.user} = { home.packages = [ pkgs.netbird-ui ]; }; }) ]); }