nix machine / user configurations

feat(dusk@devel.mobi): add netbird userspace module [skip ci]

ptr.pet 53b4a94f f2f4317d

verified
Changed files
+104 -7
secrets
users
dusk@devel.mobi
modules
netbird
+1
secrets/develMobi.key.pub
···
···
+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILUIHFy8lBU8Iy5253Lglw0v67k9ozxjLWprjTjwTsrm dusk@devel.mobi
secrets/develMobiNetbirdClientKey.age

This is a binary file and will not be displayed.

+5
secrets/secrets.nix
···
let
yusdacra = builtins.readFile ./yusdacra.key.pub;
wolumonde = builtins.readFile ./wolumonde.key.pub;
in
{
"bernbotToken.age".publicKeys = [
···
"netbirdClientKey.age".publicKeys = [
yusdacra
wolumonde
];
}
···
let
yusdacra = builtins.readFile ./yusdacra.key.pub;
wolumonde = builtins.readFile ./wolumonde.key.pub;
+
develMobi = builtins.readFile ./develMobi.key.pub;
in
{
"bernbotToken.age".publicKeys = [
···
"netbirdClientKey.age".publicKeys = [
yusdacra
wolumonde
+
];
+
"develMobiNetbirdClientKey.age".publicKeys = [
+
yusdacra
+
develMobi
];
}
+26 -7
users/dusk@devel.mobi/default.nix
···
{
pkgs,
lib,
tlib,
···
"fzf"
"direnv"
"nushell"
]
# dev stuff
[
···
];
in
l.flatten [
../../modules/persist/null.nix
(tlib.prefixStrings "${inputs.self}/users/modules/" modulesToEnable)
];
home = {
homeDirectory = "/home/dusk";
username = "dusk";
stateVersion = "25.11";
-
# file.".ssh/authorized_keys".text = ''
-
# ${signKeyText}
-
# '';
};
programs = {
git = {
userName = name;
userEmail = email;
···
user.signingkey = signKeyText;
};
};
-
};
-
-
services.podman = {
-
enable = true;
};
}
···
{
+
config,
pkgs,
lib,
tlib,
···
"fzf"
"direnv"
"nushell"
+
"netbird"
]
# dev stuff
[
···
];
in
l.flatten [
+
inputs.agenix.homeManagerModules.default
../../modules/persist/null.nix
(tlib.prefixStrings "${inputs.self}/users/modules/" modulesToEnable)
];
+
age.identityPaths = ["${config.home.homeDirectory}/.ssh/id_ed25519"];
home = {
homeDirectory = "/home/dusk";
username = "dusk";
stateVersion = "25.11";
+
# shell
+
shell.enableShellIntegration = true;
+
shellAliases = {
+
ctl = "systemctl --user";
+
jtl = "journalctl --user";
+
jtlu = "journalctl --user --unit";
+
};
+
};
+
+
age.secrets.netbirdClientKey = {
+
file = ../../secrets/develMobiNetbirdClientKey.age;
+
mode = "600";
+
};
+
services.netbird = {
+
enable = true;
+
managementUrl = "https://bird.gaze.systems";
+
setupKeyFile = config.age.secrets.netbirdClientKey.path;
};
programs = {
+
bash = {
+
enable = true;
+
enableCompletion = true;
+
};
+
tealdeer.enable = true;
git = {
userName = name;
userEmail = email;
···
user.signingkey = signKeyText;
};
};
};
}
+72
users/modules/netbird/default.nix
···
···
+
{lib, config, pkgs, ...}: let
+
l = lib;
+
t = l.types;
+
cfg = config.services.netbird;
+
wrapped = pkgs.writers.writeBashBin "netbird" ''
+
${pkgs.netbird}/bin/netbird \
+
--daemon-addr "unix://netbird.sock" \
+
--config "${config.xdg.configHome}/netbird/config.json" $@
+
'';
+
proxychainsCfg = pkgs.writers.writeText "proxychains.conf" ''
+
proxy_dns
+
quiet_mode
+
[ProxyList]
+
socks5 127.0.0.1 1080
+
'';
+
wrappedProxychains = pkgs.writers.writeBashBin "netbird-proxychains" ''
+
${pkgs.proxychains-ng}/bin/proxychains4 \
+
-f "${proxychainsCfg}" \
+
$@
+
'';
+
in {
+
options = {
+
services.netbird = {
+
enable = l.mkEnableOption "netbird client";
+
managementUrl = l.mkOption {
+
type = t.str;
+
default = "https://api.netbird.cloud";
+
description = "NetBird management URL";
+
};
+
setupKeyFile = l.mkOption {
+
type = t.str;
+
description = "Path to the setup key file";
+
};
+
proxyScript = l.mkOption {
+
type = t.package;
+
description = "path to a script that uses proxychains to proxy traffic";
+
readOnly = true;
+
};
+
};
+
};
+
config = l.mkIf cfg.enable {
+
home.packages = [ wrapped wrappedProxychains ];
+
services.netbird.proxyScript = wrappedProxychains;
+
systemd.user.services.netbird = {
+
Unit = {
+
Description = "NetBird Client";
+
After = [ "network.target" ];
+
};
+
+
Service = {
+
ExecStart = "${pkgs.netbird}/bin/netbird up -F";
+
Restart = "on-failure";
+
RestartSec = "5s";
+
Environment = l.mapAttrsToList (k: v: "${k}=${toString v}") {
+
PATH = "${pkgs.coreutils}/bin:$PATH";
+
NB_WG_KERNEL_DISABLE = "true";
+
NB_USE_NETSTACK_MODE = "true";
+
NB_ENABLE_NETSTACK_LOCAL_FORWARDING = "true";
+
NB_NETSTACK_SKIP_PROXY = "false";
+
NB_SOCKS5_LISTENER_PORT = 1080;
+
NB_DISABLE_DNS = "false";
+
NB_SETUP_KEY_FILE = l.replaceString "\${XDG_RUNTIME_DIR}" "%t" cfg.setupKeyFile;
+
NB_MANAGEMENT_URL = cfg.managementUrl;
+
NB_CONFIG = "${config.xdg.configHome}/netbird/config.json";
+
NB_DAEMON_ADDR = "unix://%t/netbird.sock";
+
};
+
};
+
+
Install.WantedBy = [ "network.target" ];
+
};
+
};
+
}