perf: Home-manager to module
feat: Optionise config
This commit is contained in:
4
modules/host/adb.nix
Normal file
4
modules/host/adb.nix
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
programs.adb.enable = true;
|
||||
users.users.sweetbread.extraGroups = ["adbusers"]; # FIXME: check users
|
||||
}
|
14
modules/host/bluetooth.nix
Normal file
14
modules/host/bluetooth.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ config, lib, ... }: {
|
||||
hardware.bluetooth =
|
||||
lib.mkIf config.hardware.bluetooth.enable {
|
||||
powerOnBoot = true;
|
||||
settings = {
|
||||
General = {
|
||||
Enable = "Source,Sink,Media,Socket";
|
||||
Experimental = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.blueman.enable = true;
|
||||
}
|
37
modules/host/bootloader.nix
Normal file
37
modules/host/bootloader.nix
Normal file
@ -0,0 +1,37 @@
|
||||
{ pkgs, ... }: {
|
||||
boot = {
|
||||
loader = {
|
||||
timeout = 3;
|
||||
efi = {
|
||||
efiSysMountPoint = "/boot";
|
||||
canTouchEfiVariables = true;
|
||||
};
|
||||
|
||||
grub = {
|
||||
enable = true;
|
||||
efiSupport = true;
|
||||
device = "nodev";
|
||||
useOSProber = true;
|
||||
};
|
||||
};
|
||||
consoleLogLevel = 0;
|
||||
kernelParams = [
|
||||
# "quiet"
|
||||
"splash"
|
||||
"boot.shell_on_fail"
|
||||
"loglevel=3"
|
||||
# "rd.systemd.show_status=false"
|
||||
# "rd.udev.log_level=3"
|
||||
"udev.log_priority=0"
|
||||
];
|
||||
plymouth = {
|
||||
enable = true;
|
||||
theme = "black_hud";
|
||||
themePackages = with pkgs; [
|
||||
(adi1090x-plymouth-themes.override {
|
||||
selected_themes = [ "black_hud" ];
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
23
modules/host/console.nix
Normal file
23
modules/host/console.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{ pkgs, ... }: {
|
||||
console = {
|
||||
font = "${pkgs.kbd}/share/consolefonts/LatArCyrHeb-19.psfu.gz";
|
||||
colors = [
|
||||
"16161E"
|
||||
"1A1B26"
|
||||
"2F3549"
|
||||
"444B6A"
|
||||
"787C99"
|
||||
"787C99"
|
||||
"CBCCD1"
|
||||
"D5D6DB"
|
||||
"F7768E"
|
||||
"FF9E64"
|
||||
"E0AF68"
|
||||
"41A6B5"
|
||||
"7DCFFF"
|
||||
"7AA2F7"
|
||||
"BB9AF7"
|
||||
"D18616"
|
||||
];
|
||||
};
|
||||
}
|
8
modules/host/env.nix
Normal file
8
modules/host/env.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
environment.variables = {
|
||||
EDITOR = "hx";
|
||||
RANGER_LOAD_DEFAULT_RC = "FALSE";
|
||||
QT_QPA_PLATFORMTHEME = "qt5ct";
|
||||
GSETTINGS_BACKEND = "keyfile";
|
||||
};
|
||||
}
|
20
modules/host/gamemode.nix
Normal file
20
modules/host/gamemode.nix
Normal file
@ -0,0 +1,20 @@
|
||||
{ config, pkgs, pkgs-stable, lib, ... }:
|
||||
|
||||
lib.mkIf config.programs.gamemode.enable {
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
gamescopeSession.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs-stable; [
|
||||
mangohud
|
||||
protonup
|
||||
pkgs.bottles
|
||||
heroic
|
||||
];
|
||||
|
||||
environment.sessionVariables = {
|
||||
STEAM_EXTRA_COMPAT_TOOLS_PATHS =
|
||||
"\${HOME}/.steam/root/compatibilitytools.d";
|
||||
};
|
||||
}
|
6
modules/host/gpg.nix
Normal file
6
modules/host/gpg.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{ pkgs, ...}: {
|
||||
programs.gnupg.agent = {
|
||||
enable = true;
|
||||
enableSSHSupport = true;
|
||||
};
|
||||
}
|
19
modules/host/laptop.nix
Normal file
19
modules/host/laptop.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
lib.mkIf config.host.laptop {
|
||||
services.tlp = {
|
||||
enable = true;
|
||||
settings = {
|
||||
CPU_SCALING_GOVERNOR_ON_AC = "performance";
|
||||
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
|
||||
|
||||
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
|
||||
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
|
||||
|
||||
CPU_MIN_PERF_ON_AC = 0;
|
||||
CPU_MAX_PERF_ON_AC = 100;
|
||||
CPU_MIN_PERF_ON_BAT = 0;
|
||||
CPU_MAX_PERF_ON_BAT = 75;
|
||||
};
|
||||
};
|
||||
}
|
9
modules/host/printing.nix
Normal file
9
modules/host/printing.nix
Normal file
@ -0,0 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
lib.mkIf config.services.printing.enable {
|
||||
services.avahi = {
|
||||
enable = true;
|
||||
nssmdns4 = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
}
|
70
modules/host/shutdown-on-lan.nix
Normal file
70
modules/host/shutdown-on-lan.nix
Normal file
@ -0,0 +1,70 @@
|
||||
{ pkgs, lib, ... }:
|
||||
let
|
||||
sol = pkgs.writers.writePython3 "shutdown-on-lan.py" {
|
||||
libraries = [ pkgs.python312Packages.psutil ];
|
||||
flakeIgnore = [ "E501" "E302" "E305" ];
|
||||
} /*py*/ ''
|
||||
# https://habr.com/ru/articles/816765/
|
||||
|
||||
import socket
|
||||
import os
|
||||
import logging
|
||||
import psutil
|
||||
from time import sleep
|
||||
|
||||
WOL_PORT = 9
|
||||
|
||||
logging.basicConfig(format='%(levelname)s: %(asctime)s %(message)s', level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def get_ip_mac_address() -> tuple:
|
||||
ip_addr = mac_addr = None
|
||||
|
||||
while not ip_addr or not mac_addr or ip_addr == '127.0.0.1':
|
||||
net = psutil.net_if_addrs()
|
||||
for item in net[list(net.keys())[-1]]:
|
||||
addr = item.address
|
||||
# В IPv4-адресах разделители - точки
|
||||
if '.' in addr:
|
||||
ip_addr = addr
|
||||
# В MAC-адресах разделители либо тире, либо одинарное двоеточие.
|
||||
# Двойное двоеточие - это разделители для адресов IPv6
|
||||
elif ('-' in addr or ':' in addr) and '::' not in addr:
|
||||
# Приводим MAC-адрес к одному формату. Формат может меняться в зависимости от ОС
|
||||
mac_addr = addr.replace(':', '-').upper()
|
||||
if not ip_addr or not mac_addr or ip_addr == '127.0.0.1':
|
||||
logger.debug('Не удалось получить IP или MAC-адрес сетевого интерфейса')
|
||||
sleep(10)
|
||||
return ip_addr, mac_addr
|
||||
|
||||
def assemble_wol_packet(mac_address: str) -> str:
|
||||
return f'{"FF-" * 6}{(mac_address + "-") * 16}'
|
||||
|
||||
def check_is_wol_packet(raw_bytes: bytes, assembled_wol_packet: str) -> int:
|
||||
return '-'.join(f'{byte:02x}' for byte in raw_bytes).upper() + '-' == assembled_wol_packet
|
||||
|
||||
def run_udp_port_listener(port: int):
|
||||
ip_addr, mac_addr = get_ip_mac_address()
|
||||
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server_socket.bind((ip_addr, port))
|
||||
logger.info(f'Listening on {ip_addr}:{port}')
|
||||
assembled_wol_packet = assemble_wol_packet(mac_addr)
|
||||
while True:
|
||||
data, _ = server_socket.recvfrom(1024)
|
||||
if check_is_wol_packet(data, assembled_wol_packet):
|
||||
if os.name == 'posix':
|
||||
os.system('shutdown -h now')
|
||||
elif os.name == 'nt':
|
||||
os.system('shutdown -s -t 0 -f')
|
||||
run_udp_port_listener(WOL_PORT)
|
||||
'';
|
||||
in {
|
||||
systemd.services.shutdown-on-lan = {
|
||||
enable = true;
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "default.target" ];
|
||||
serviceConfig.ExecStart = sol;
|
||||
};
|
||||
|
||||
networking.firewall.allowedUDPPorts = [ 9 ];
|
||||
}
|
17
modules/host/sound.nix
Normal file
17
modules/host/sound.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
security.rtkit.enable = true;
|
||||
|
||||
services = {
|
||||
pulseaudio.enable = false;
|
||||
pipewire = {
|
||||
enable = true;
|
||||
|
||||
alsa = {
|
||||
enable = true;
|
||||
support32Bit = true;
|
||||
};
|
||||
|
||||
pulse.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
5
modules/host/virtmanager.nix
Normal file
5
modules/host/virtmanager.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ pkgs, ... }: {
|
||||
virtualisation.libvirtd.enable = true;
|
||||
programs.virt-manager.enable = true;
|
||||
}
|
||||
|
28
modules/host/vpn.nix
Normal file
28
modules/host/vpn.nix
Normal file
@ -0,0 +1,28 @@
|
||||
{pkgs, config, ...}: {
|
||||
systemd.services.v2raya = {
|
||||
enable = true;
|
||||
description = "v2rayA gui client";
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
ExecStart = "${pkgs.v2raya}/bin/v2rayA";
|
||||
};
|
||||
path = with pkgs; [ iptables bash iproute2 ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = {
|
||||
V2RAYA_LOG_FILE = "/var/log/v2raya/v2raya.log";
|
||||
V2RAY_LOCATION_ASSET = "/etc/v2raya";
|
||||
XRAY_LOCATION_ASSET = "/etc/v2raya";
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc = {
|
||||
"v2raya/ru_geoip.dat".source = pkgs.fetchurl {
|
||||
name = "geoip.dat";
|
||||
url = "https://github.com/runetfreedom/russia-blocked-geoip/releases/download/202501260919/geoip.dat";
|
||||
hash = "sha256-OZoWEyfp1AwIN1eQHaB5V3FP51gsUKKDbFBHtqs4UDM=";
|
||||
};
|
||||
|
||||
"v2raya/bolt.db".source = config.sops.secrets.vpn_bolt.path;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user