summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGrisha Shipunov2025-01-11 03:55:19 +0100
committerGrisha Shipunov2025-01-11 03:55:19 +0100
commit62e2519639faa250f43f9e80e69906a59d07a44e (patch)
tree08d662d7674904d566d2dd7ccf85affb9ddd7cd9 /modules
parent595d4935de99cc2ff10be9eaddac498c7c38489f (diff)
delete legacy stuff and reformat
Diffstat (limited to 'modules')
-rw-r--r--modules/basic-tools/default.nix76
-rw-r--r--modules/basic-tools/fzf.nix26
-rw-r--r--modules/basic-tools/multiplexers.nix3
-rw-r--r--modules/basic-tools/nix-ld.nix10
-rw-r--r--modules/basic-tools/nix.nix18
-rw-r--r--modules/binary-caches.nix3
-rw-r--r--modules/devtools.nix59
-rw-r--r--modules/dvb-dump-nfs-automount.nix38
-rw-r--r--modules/gnome.nix3
-rw-r--r--modules/mail/default.nix11
-rw-r--r--modules/sway.nix4
-rw-r--r--modules/tlp.nix2
-rw-r--r--modules/virtualization.nix7
-rw-r--r--modules/wg/default.nix3
-rw-r--r--modules/wg/mgmt.nix20
-rw-r--r--modules/wg/module.nix85
-rw-r--r--modules/wg/options.nix141
17 files changed, 304 insertions, 205 deletions
diff --git a/modules/basic-tools/default.nix b/modules/basic-tools/default.nix
index f7ef3c3..1d4f2a4 100644
--- a/modules/basic-tools/default.nix
+++ b/modules/basic-tools/default.nix
@@ -8,37 +8,48 @@
./nix-ld.nix
];
- environment.systemPackages = with pkgs; [
- bat
- fd
- file
- gnupg
- glow
- htop
- irssi
- killall
- neovim
- ripgrep
- tealdeer
- traceroute
- tcpdump
- tree
- (aspellWithDicts (ps: with ps; [ en en-science en-computers ru nl ]))
- exfatprogs
- nmap
- bind
- nnn
- lf
- man-pages
- unzip
- usbutils
- pciutils
- ouch
- cryptsetup
- sshfs
- whois
- mtr
- ] ++ (if config.networking.hostName == "toaster" then [ gitFull ] else [ git ]);
+ environment.systemPackages =
+ with pkgs;
+ [
+ bat
+ fd
+ file
+ gnupg
+ glow
+ htop
+ irssi
+ killall
+ neovim
+ ripgrep
+ tealdeer
+ traceroute
+ tcpdump
+ tree
+ (aspellWithDicts (
+ ps: with ps; [
+ en
+ en-science
+ en-computers
+ ru
+ nl
+ ]
+ ))
+ exfatprogs
+ nmap
+ bind
+ nnn
+ lf
+ man-pages
+ unzip
+ usbutils
+ pciutils
+ ouch
+ cryptsetup
+ sshfs
+ whois
+ mtr
+ ]
+ ++ (if config.networking.hostName == "toaster" then [ gitFull ] else [ git ]);
environment.variables =
let
@@ -53,7 +64,8 @@
{
PAGER = "less";
LESS = "-X -R -F";
- } // editorconf;
+ }
+ // editorconf;
environment.shellAliases = {
ls = "ls --color=auto";
diff --git a/modules/basic-tools/fzf.nix b/modules/basic-tools/fzf.nix
index 6fc84fe..8ad1b92 100644
--- a/modules/basic-tools/fzf.nix
+++ b/modules/basic-tools/fzf.nix
@@ -1,4 +1,10 @@
-{ lib, config, pkgs, ... }: {
+{
+ lib,
+ config,
+ pkgs,
+ ...
+}:
+{
environment = {
systemPackages = [ pkgs.fzf ];
@@ -8,11 +14,15 @@
};
};
# integrate fzf into shell, >23.05 only
- programs = with lib;
- if (toInt (elemAt (splitVersion config.system.nixos.release) 0) >= 23) then {
- fzf = {
- keybindings = true;
- fuzzyCompletion = true;
- };
- } else { };
+ programs =
+ with lib;
+ if (toInt (elemAt (splitVersion config.system.nixos.release) 0) >= 23) then
+ {
+ fzf = {
+ keybindings = true;
+ fuzzyCompletion = true;
+ };
+ }
+ else
+ { };
}
diff --git a/modules/basic-tools/multiplexers.nix b/modules/basic-tools/multiplexers.nix
index 55268ef..b744942 100644
--- a/modules/basic-tools/multiplexers.nix
+++ b/modules/basic-tools/multiplexers.nix
@@ -1,4 +1,5 @@
-{ pkgs, inputs, ... }: {
+{ pkgs, inputs, ... }:
+{
programs.tmux = {
enable = true;
keyMode = "vi";
diff --git a/modules/basic-tools/nix-ld.nix b/modules/basic-tools/nix-ld.nix
index 2462721..d9abd55 100644
--- a/modules/basic-tools/nix-ld.nix
+++ b/modules/basic-tools/nix-ld.nix
@@ -1,10 +1,10 @@
{ pkgs, lib, ... }:
{
- programs.nix-ld ={
- enable = true;
- libraries = [
- pkgs.stdenv.cc.cc
- ];
+ programs.nix-ld = {
+ enable = true;
+ libraries = [
+ pkgs.stdenv.cc.cc
+ ];
};
#environment.variables = {
# NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [
diff --git a/modules/basic-tools/nix.nix b/modules/basic-tools/nix.nix
index 9faa527..980ab76 100644
--- a/modules/basic-tools/nix.nix
+++ b/modules/basic-tools/nix.nix
@@ -1,9 +1,15 @@
-{ lib, pkgs, inputs, ... }: {
+{
+ lib,
+ pkgs,
+ inputs,
+ ...
+}:
+{
nix = {
extraOptions = ''
- experimental-features = nix-command flakes
- narinfo-cache-negative-ttl = 0
+ experimental-features = nix-command flakes
+ narinfo-cache-negative-ttl = 0
'';
};
@@ -12,8 +18,10 @@
# override default nix shell nixpkgs# behaviour to use current flake lock
nix.registry =
- let flakes = lib.filterAttrs (_name: value: value ? outputs) inputs.self.inputs;
- in builtins.mapAttrs (_name: v: { flake = v; }) flakes;
+ let
+ flakes = lib.filterAttrs (_name: value: value ? outputs) inputs.self.inputs;
+ in
+ builtins.mapAttrs (_name: v: { flake = v; }) flakes;
nix.nixPath = lib.mapAttrsToList (name: value: "${name}=${value.outPath}") inputs.self.inputs;
diff --git a/modules/binary-caches.nix b/modules/binary-caches.nix
index 8a2b5ac..f1fee1d 100644
--- a/modules/binary-caches.nix
+++ b/modules/binary-caches.nix
@@ -1,4 +1,5 @@
-{ ... }: {
+{ ... }:
+{
nix = {
extraOptions = ''
builders-use-substitutes = true
diff --git a/modules/devtools.nix b/modules/devtools.nix
index 16737df..c4f7c88 100644
--- a/modules/devtools.nix
+++ b/modules/devtools.nix
@@ -1,31 +1,36 @@
-{ pkgs, inputs, ... }: {
+{ pkgs, inputs, ... }:
+{
- environment.systemPackages = with pkgs;
- let
- kicad = pkgs.kicad.override {
- addons = with pkgs.kicadAddons; [ kikit kikit-library ];
- };
- in
- [
- # general
- cmake
- gcc
- gef
- gdb
- binutils
- binwalk
- clang
- clang-tools
- direnv
- sops
- nil
- nixpkgs-fmt
- nix-index
- kicad
- freecad-wayland
- imhex
- python313Full
- ];
+ environment.systemPackages =
+ with pkgs;
+ let
+ kicad = pkgs.kicad.override {
+ addons = with pkgs.kicadAddons; [
+ kikit
+ kikit-library
+ ];
+ };
+ in
+ [
+ # general
+ cmake
+ gcc
+ gef
+ gdb
+ binutils
+ binwalk
+ clang
+ clang-tools
+ direnv
+ sops
+ nil
+ nixpkgs-fmt
+ nix-index
+ kicad
+ freecad-wayland
+ imhex
+ python313Full
+ ];
# Wireshark
programs.wireshark = {
diff --git a/modules/dvb-dump-nfs-automount.nix b/modules/dvb-dump-nfs-automount.nix
index 2dce2ea..fbc6a8f 100644
--- a/modules/dvb-dump-nfs-automount.nix
+++ b/modules/dvb-dump-nfs-automount.nix
@@ -4,23 +4,25 @@
environment.systemPackages = with pkgs; [ nfs-utils ];
services.rpcbind.enable = true;
- systemd.mounts = [{
- type = "nfs";
- mountConfig = {
- Options = "noatime";
- };
- what = "10.13.37.5:/";
- where = "/mnt/dvb";
- }];
+ systemd.mounts = [
+ {
+ type = "nfs";
+ mountConfig = {
+ Options = "noatime";
+ };
+ what = "10.13.37.5:/";
+ where = "/mnt/dvb";
+ }
+ ];
- systemd.automounts = [{
- wantedBy = [ "multi-user.target" ];
- requires = [ "wg-quick-wg-dvb.service" ];
- automountConfig = {
- TimeoutIdleSec = "600";
- };
- where = "/mnt/dvb";
- }];
+ systemd.automounts = [
+ {
+ wantedBy = [ "multi-user.target" ];
+ requires = [ "wg-quick-wg-dvb.service" ];
+ automountConfig = {
+ TimeoutIdleSec = "600";
+ };
+ where = "/mnt/dvb";
+ }
+ ];
}
-
-
diff --git a/modules/gnome.nix b/modules/gnome.nix
index 999ebe2..d902933 100644
--- a/modules/gnome.nix
+++ b/modules/gnome.nix
@@ -1,4 +1,5 @@
-{ config, pkgs, ... }: {
+{ config, pkgs, ... }:
+{
imports = [
./desktop-software.nix
diff --git a/modules/mail/default.nix b/modules/mail/default.nix
index f0a9853..ba65f2c 100644
--- a/modules/mail/default.nix
+++ b/modules/mail/default.nix
@@ -82,13 +82,15 @@ in
'';
};
-
systemd.user = {
# Service and timer to sync imap to local maildir
services.mbsync = {
enable = true;
- after = [ "graphical.target" "network-online.target" ];
+ after = [
+ "graphical.target"
+ "network-online.target"
+ ];
script = ''
${pkgs.isync}/bin/mbsync -q -a --config=${mbsyncConf}
'';
@@ -110,7 +112,10 @@ in
# service and timer to flush the msmtp queue
services.flush-msmtpq = {
enable = true;
- after = [ "graphical.target" "network-online.target" ];
+ after = [
+ "graphical.target"
+ "network-online.target"
+ ];
script = ''
${pkgs.msmtp}/bin/msmtp-queue -r
'';
diff --git a/modules/sway.nix b/modules/sway.nix
index 06b3606..f536bcb 100644
--- a/modules/sway.nix
+++ b/modules/sway.nix
@@ -120,7 +120,9 @@
wl-mirror
];
};
- environment.sessionVariables = { GTK_THEME = "Adwaita:dark"; };
+ environment.sessionVariables = {
+ GTK_THEME = "Adwaita:dark";
+ };
xdg.portal = {
enable = true;
wlr.enable = true;
diff --git a/modules/tlp.nix b/modules/tlp.nix
index 930ca6d..ad3d743 100644
--- a/modules/tlp.nix
+++ b/modules/tlp.nix
@@ -9,7 +9,7 @@
USB_BLACKLIST = "1d50:604b 1d50:6089 1d50:cc15 1fc9:000c";
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
- WIFI_PWR_ON_BAT= "off";
+ WIFI_PWR_ON_BAT = "off";
};
};
}
diff --git a/modules/virtualization.nix b/modules/virtualization.nix
index d04bed6..b61cc4f 100644
--- a/modules/virtualization.nix
+++ b/modules/virtualization.nix
@@ -1,4 +1,9 @@
-{ config, pkgs, inputs, ... }:
+{
+ config,
+ pkgs,
+ inputs,
+ ...
+}:
{
environment.systemPackages = with pkgs; [
virt-manager
diff --git a/modules/wg/default.nix b/modules/wg/default.nix
index cab721b..82c1179 100644
--- a/modules/wg/default.nix
+++ b/modules/wg/default.nix
@@ -1,4 +1,5 @@
-{ ... }: {
+{ ... }:
+{
imports = [
# module
./module.nix
diff --git a/modules/wg/mgmt.nix b/modules/wg/mgmt.nix
index 33f483e..64a55fd 100644
--- a/modules/wg/mgmt.nix
+++ b/modules/wg/mgmt.nix
@@ -4,11 +4,17 @@
oxalab.wg = [
{
networkName = "0xa-mgmt";
- CIDRs = [ "10.89.87.0/24" "fd31:185d:722e::/48" ];
+ CIDRs = [
+ "10.89.87.0/24"
+ "fd31:185d:722e::/48"
+ ];
hosts = {
"cloud" = {
- address = [ "10.89.87.1/24" "fd31:185d:722e::1/48" ];
+ address = [
+ "10.89.87.1/24"
+ "fd31:185d:722e::1/48"
+ ];
publicKey = "zKSaw+SXzWgi/T7ByXHqPk1XNXXapoQYB8UPMTRmhm0=";
privateKeyFile = config.sops.secrets."wg/0xa-mgmt".path;
endpoint = {
@@ -20,12 +26,18 @@
};
"toaster" = {
- address = [ "10.89.87.100/24" "fd31:185d:722e::100/48" ];
+ address = [
+ "10.89.87.100/24"
+ "fd31:185d:722e::100/48"
+ ];
publicKey = "H+WeYIBdX7ZHwkgm4BGnF0HF0JULkxyNMcvCviHhmks=";
privateKeyFile = config.sops.secrets."wg/0xa-mgmt".path;
};
"minime" = {
- address = [ "10.89.87.10/24" "fd31:185d:722e::10/48" ];
+ address = [
+ "10.89.87.10/24"
+ "fd31:185d:722e::10/48"
+ ];
publicKey = "zN2Dr/ZGMh1Ftparszp22Qnbz2ISJU12iDVatebOHUE=";
privateKeyFile = config.sops.secrets."wg/0xa-mgmt".path;
};
diff --git a/modules/wg/module.nix b/modules/wg/module.nix
index 84575c7..c27f325 100644
--- a/modules/wg/module.nix
+++ b/modules/wg/module.nix
@@ -1,8 +1,11 @@
-{ lib
-, config
-, self
-, registry
-, ... }: {
+{
+ lib,
+ config,
+ self,
+ registry,
+ ...
+}:
+{
config =
let
@@ -17,10 +20,20 @@
name = "30-wg-${net.networkName}";
value = {
matchConfig.Name = "wg-${net.networkName}";
- networkConfig = {
- Address = net.hosts.${currenthost}.address;
- IPv6AcceptRA = false; # for now static IPv6
- } // (if net.hosts.${currenthost}.endpoint.enable then {IPv4Forwarding=true; IPv6Forwarding=true; } else {});
+ networkConfig =
+ {
+ Address = net.hosts.${currenthost}.address;
+ IPv6AcceptRA = false; # for now static IPv6
+ }
+ // (
+ if net.hosts.${currenthost}.endpoint.enable then
+ {
+ IPv4Forwarding = true;
+ IPv6Forwarding = true;
+ }
+ else
+ { }
+ );
};
}) networks;
@@ -45,8 +58,7 @@
wireguardPeers =
let
endpoint = lib.attrsets.filterAttrs (_k: v: v.endpoint.enable) net.hosts;
- wg-peers-attrs = lib.attrsets.mapAttrs (_k: v:
- {
+ wg-peers-attrs = lib.attrsets.mapAttrs (_k: v: {
PersistentKeepalive = 29;
PublicKey = v.publicKey;
Endpoint = "${v.endpoint.endpoint}:${toString v.endpoint.port}";
@@ -55,19 +67,24 @@
wg-peers = lib.attrsets.attrValues wg-peers-attrs;
in
wg-peers;
- };
- }) net-client;
- netdev-client = builtins.listToAttrs netdev-client-list;
+ };
+ }) net-client;
+ netdev-client = builtins.listToAttrs netdev-client-list;
- maskip = (net: hostattrs:
- if hostattrs.endpoint.enable then hostattrs.address else map (baseaddr:
- if lib.strings.hasInfix "." baseaddr then "${baseaddr}/32" else "${baseaddr}/128"
- ) (map (addr: builtins.elemAt (lib.strings.splitString "/" addr) 0) hostattrs.address));
+ maskip = (
+ net: hostattrs:
+ if hostattrs.endpoint.enable then
+ hostattrs.address
+ else
+ map (baseaddr: if lib.strings.hasInfix "." baseaddr then "${baseaddr}/32" else "${baseaddr}/128") (
+ map (addr: builtins.elemAt (lib.strings.splitString "/" addr) 0) hostattrs.address
+ )
+ );
# endpoint
# TODO: this requires bit more logic for allowedIPs if we have more then
# 2 endpoints e.g. for routing client -> endpoint1 -> endpoint2 ->
# client2
- netdev-endpoint-list = map (net: {
+ netdev-endpoint-list = map (net: {
name = "30-wg-${net.networkName}";
value = {
netdevConfig = {
@@ -79,19 +96,27 @@
wireguardPeers =
let
peers = lib.attrsets.filterAttrs (k: _v: k != currenthost) net.hosts;
- wg-peers-attrs = lib.attrsets.mapAttrs (_k: v:
- {
- PersistentKeepalive = 29;
- PublicKey = v.publicKey;
- # only route to /32 or /128, i.e. single client
- AllowedIPs = maskip net v;
- } // (if !isNull v.endpoint.endpoint then { Endpoint = "${v.endpoint.endpoint}:${toString v.endpoint.port}"; } else {})) peers;
+ wg-peers-attrs = lib.attrsets.mapAttrs (
+ _k: v:
+ {
+ PersistentKeepalive = 29;
+ PublicKey = v.publicKey;
+ # only route to /32 or /128, i.e. single client
+ AllowedIPs = maskip net v;
+ }
+ // (
+ if !isNull v.endpoint.endpoint then
+ { Endpoint = "${v.endpoint.endpoint}:${toString v.endpoint.port}"; }
+ else
+ { }
+ )
+ ) peers;
wg-peers = lib.attrsets.attrValues wg-peers-attrs;
in
wg-peers;
- };
- }) net-endpoint;
- netdev-endpoint = builtins.listToAttrs netdev-endpoint-list;
+ };
+ }) net-endpoint;
+ netdev-endpoint = builtins.listToAttrs netdev-endpoint-list;
in
{
@@ -102,4 +127,4 @@
systemd.network.networks = systemd-networks;
systemd.network.netdevs = netdev-client // netdev-endpoint;
};
- }
+}
diff --git a/modules/wg/options.nix b/modules/wg/options.nix
index 4f090d0..56fd964 100644
--- a/modules/wg/options.nix
+++ b/modules/wg/options.nix
@@ -1,79 +1,88 @@
-{ lib
-, ...}:
{
- options.oxalab.wg = with lib;
- lib.mkOption {
- default = [];
- type = types.listOf (types.submodule {
- options = {
- # general network stuff
- networkName = mkOption {
- type = types.nullOr types.str;
- default = null;
- };
- CIDRs = mkOption {
- type = types.nullOr (types.listOf types.str);
- default = null;
- };
-
- hosts = mkOption {
- default = {};
- type = types.attrsOf (types.submodule {
- options = {
-
- enable = mkOption {
- type = types.bool;
- default = true;
- };
- address = mkOption {
- type = types.listOf types.str;
- default = null;
- };
- publicKey = mkOption {
- type = types.str;
- default = null;
- };
- privateKeyFile = mkOption {
- type = types.path;
- default = null;
- };
-
- endpoint.enable = mkOption {
- type = types.bool;
- default = false;
- };
- endpoint.endpoint = mkOption {
- type = types.nullOr types.str;
- default = null;
- };
- endpoint.port = mkOption {
- type = types.nullOr types.int;
- default = null;
- };
- endpoint.publicIface = mkOption {
- type = types.nullOr types.str;
- default = null;
- };
+ lib,
+ ...
+}:
+{
+ options.oxalab.wg =
+ with lib;
+ lib.mkOption {
+ default = [ ];
+ type = types.listOf (
+ types.submodule {
+ options = {
+ # general network stuff
+ networkName = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ };
+ CIDRs = mkOption {
+ type = types.nullOr (types.listOf types.str);
+ default = null;
+ };
- endpoint.extraPeers = mkOption {
- default = [];
- type = types.listOf (types.submodule {
+ hosts = mkOption {
+ default = { };
+ type = types.attrsOf (
+ types.submodule {
options = {
+
+ enable = mkOption {
+ type = types.bool;
+ default = true;
+ };
address = mkOption {
type = types.listOf types.str;
- default = [];
+ default = null;
};
publicKey = mkOption {
+ type = types.str;
+ default = null;
+ };
+ privateKeyFile = mkOption {
+ type = types.path;
+ default = null;
+ };
+
+ endpoint.enable = mkOption {
+ type = types.bool;
+ default = false;
+ };
+ endpoint.endpoint = mkOption {
type = types.nullOr types.str;
default = null;
};
+ endpoint.port = mkOption {
+ type = types.nullOr types.int;
+ default = null;
+ };
+ endpoint.publicIface = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ };
+
+ endpoint.extraPeers = mkOption {
+ default = [ ];
+ type = types.listOf (
+ types.submodule {
+ options = {
+ address = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ };
+ publicKey = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ };
+ };
+ }
+ );
+ };
};
- });
- };
+ }
+ );
};
- });
- };
- };
- });
- };
+ };
+ }
+ );
+ };
}