nixos/modules/common/applications/netbird.nix

64 lines
1.7 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
{
options = {
netbird = {
enable = lib.mkEnableOption {
description = "Enable Netbird";
default = false;
};
2024-07-25 10:15:25 -04:00
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";
};
};
};
};
2024-07-25 10:15:25 -04:00
# 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 [
2024-07-25 10:15:25 -04:00
{
services.netbird.tunnels = {
wt0.environment = (lib.mkMerge [
{
NB_MANAGEMENT_URL = config.netbird.opts.management_url;
NB_ADMIN_URL = config.netbird.opts.admin_url;
}
# isString e
(lib.mkIf (config.netbird.opts.setup_key != "") {
NB_SETUP_KEY = config.netbird.opts.setup_key;
})
]);
};
2024-07-25 10:15:25 -04:00
}
(lib.mIf (config.gui.enable) {
home-manager.users.${config.user} = {
home.packages = [
2024-07-25 10:15:25 -04:00
pkgs.netbird-ui
];
};
})
]);
}