move some nixos configuration to ./nixos/modules and ./nixos/configurations. try to find a good arch to conbine home-manager and nixos modules.

This commit is contained in:
Ulic-youthlic 2025-01-07 22:41:55 +08:00
parent 6be554822c
commit 64db779064
32 changed files with 534 additions and 635 deletions

View file

@ -3,7 +3,6 @@ include {
}
global {
# 绑定到 LAN 和/或 WAN 接口。将下述接口替换成你自己的接口名。
lan_interface: auto
wan_interface: auto
@ -11,21 +10,31 @@ global {
allow_insecure: false
auto_config_kernel_parameter: true
dial_mode: domain
tcp_check_url: 'http://cp.cloudflare.com'
udp_check_dns: 'dns.google.com:53'
check_interval: 600s
check_tolerance: 50ms
tproxy_port: 12345
}
# 更多的 DNS 样例见 https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md
dns {
ipversion_prefer: 4
upstream {
googledns: 'tcp+udp://8.8.8.8:53'
alidns: 'udp://114.114.114.114:53'
alidns: 'udp://dns.alidns.com:53'
}
routing {
request {
fallback: alidns
qname(geosite: category-ads) -> reject
qname(geosite: category-ads-all) -> reject
qname(geosite: cn) -> alidns
fallback: googledns
}
response {
upstream(googledns) -> accept
ip(geoip: private) && !qname(geosite: cn) -> googledns
upstream(googledns) && ip(geoip: private) -> alidns
fallback: accept
}
}
@ -50,19 +59,20 @@ group {
routing {
pname(hickory-dns) && dport(53) -> must_direct
pname(mihomo) -> must_direct
domain(geosite:cn) -> direct
# personal config routing
pname(systemd-resolved) -> must_direct
domain(full: time.windows.com) -> must_direct
domain(suffix: 'hit.edu.cn') -> must_direct
domain(regex: ".*wgetcloud.*v2ray.*") -> must_direct
domain(suffix: "hit.edu.cn") -> must_direct
domain(geosite: microsoft) -> proxy
# domain(geosite: onedrive) -> must_direct
domain(geosite: 'category-ai-chat-!cn') -> us
domain(geosite: "category-ai-chat-!cn") -> us
domain(geosite: google) -> us
domain(geosite: google-play) -> proxy
domain(geosite: apple) -> us
domain(keyword: spotify) -> us
domain(geosite: spotify) -> us
domain(geosite: tiktok) -> us
domain(geosite: cn) -> direct
dip(geoip:private) -> direct
dip(geoip:cn) -> direct
@ -75,8 +85,5 @@ routing {
# dip(175.27.0.0/16) -> block
# dip('2409:8C1E:75B0:80::/64') -> block
## 禁用 h3因为它通常消耗很多 CPU 和内存资源
# l4proto(udp) && dport(443) -> block
fallback: proxy
}

View file

@ -73,42 +73,38 @@
wantedBy = [ "multi-user.target" ];
};
"update-dae-subscription-weekly" = {
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStartPre = [ "${config.systemd.package}/bin/systemctl stop dae.service" ];
ExecStartPost = [
"${config.systemd.package}/bin/systemctl start dae.service"
];
ExecStart =
let
script = pkgs.writeTextFile {
name = "update-dae-subscription-weekly";
executable = true;
destination = "/bin/script";
text = ''
${pkgs.coreutils}/bin/echo "Force subscription update..."
${pkgs.coreutils}/bin/mkdir -p /etc/proxy.d
${update}
'';
};
in
[
"${pkgs.bash}/bin/bash ${script}/bin/script"
];
};
};
# "update-dae-subscription-weekly" = {
# after = [ "network-online.target" ];
# wants = [ "network-online.target" ];
# wantedBy = [ "multi-user.target" ];
# serviceConfig = {
# Type = "oneshot";
# ExecStart =
# let
# script = pkgs.writeTextFile {
# name = "update-dae-subscription-weekly";
# executable = true;
# destination = "/bin/script";
# text = ''
# ${pkgs.coreutils}/bin/echo "Force subscription update..."
# ${pkgs.coreutils}/bin/mkdir -p /etc/proxy.d
# ${update}
# '';
# };
# in
# [
# "${pkgs.bash}/bin/bash ${script}/bin/script"
# ];
# };
# };
};
systemd.timers."dae-update" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "weekly";
Unit = "dae-update.service";
Persistent = true;
};
};
# systemd.timers."dae-update" = {
# wantedBy = [ "timers.target" ];
# timerConfig = {
# OnCalendar = "weekly";
# Unit = "dae-update.service";
# Persistent = true;
# };
# };
}

View file

@ -8,7 +8,6 @@
imports = [
./starship
./helix
./wezterm
./fish
./rime-ice.nix
./firefox.nix

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, firefox-addons, ... }:
{
programs.firefox = {
enable = true;
@ -9,8 +9,8 @@
profiles.default = {
name = "default";
isDefault = true;
extensions = with pkgs.nur.repos; [
rycee.firefox-addons.immersive-translate
extensions = with (pkgs.callPackage firefox-addons { }); [
immersive-translate
];
search = {
force = true;

View file

@ -1,18 +0,0 @@
{
pkgs,
wezterm,
...
}:
{
programs.wezterm = {
enable = true;
package = wezterm.packages."${pkgs.system}".default;
};
home.file.".config/wezterm" = {
source = ./lua;
recursive = true;
};
home.packages = with pkgs; [
nerd-fonts.fira-code
];
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 MiB

View file

@ -1,33 +0,0 @@
local wezterm = require("wezterm")
---@class Config
---@filed options table
local Config = {}
---Init Config
---@return Config
function Config:init()
local o = {}
self = setmetatable(o, { __index = Config })
self.options = {}
return o
end
---Append to `Config.options`
---@param new_options table new options to append
---@return Config
function Config:append(new_options)
for key, val in pairs(new_options) do
if self.options[key] ~= nil then
wezterm.log_warn("Duplicate config option detected: ", {
old = self.options[key],
new = new_options[key],
})
else
self.options[key] = val
end
end
return self
end
return Config

View file

@ -1,7 +0,0 @@
return {
---Check whether the current os is windows
---@return boolean whether the current os is windows
is_windows = function()
return require("wezterm").target_triple:find("windows") ~= nil
end,
}

View file

@ -1,22 +0,0 @@
return {
family = [[FiraCode Nerd Font]],
assume_emoji_presentation = false,
style = [[Normal]],
harfbuzz_features = {
"calt=1",
"clig=1",
"liga=1",
"cv01",
"cv02",
"cv06",
"zero",
"onum",
"cv17",
"ss05",
"ss03",
"cv16",
"cv31",
"cv29",
"cv30",
},
}

View file

@ -1,4 +0,0 @@
return {
family = [[Noto Color Emiji]],
assume_emoji_presentation = true,
}

View file

@ -1,4 +0,0 @@
return {
family = [[Noto Sans CJK SC]],
assume_emoji_presentation = false,
}

View file

@ -1,4 +0,0 @@
return {
family = [[Segoe UI Emoji]],
assume_emoji_presentation = true,
}

View file

@ -1,5 +0,0 @@
return {
family = [[VictorMono Nerd Font]],
assume_emoji_presentation = false,
style = "Italic",
}

View file

@ -1,17 +0,0 @@
local wezterm = require("wezterm")
local M = {
-- front_end = 'WebGpu',
webgpu_power_preference = "HighPerformance",
}
for _, gpu in ipairs(wezterm.gui.enumerate_gpus()) do
if gpu.backend == "Vulkan" and gpu.device_type == "DiscreteGpu" then
M.webgpu_preferred_adapter = gpu
break
elseif gpu.backend == "Vulkan" and M.webgpu_preferred_adapter == nil then
M.webgpu_preferred_adapter = gpu
end
end
return M

View file

@ -1,28 +0,0 @@
local wezterm = require("wezterm")
return {
automatically_reload_config = true,
cell_width = 1.0,
audible_bell = "Disabled",
tab_bar_at_bottom = true,
use_fancy_tab_bar = false,
hide_tab_bar_if_only_one_tab = true,
window_decorations = "RESIZE|TITLE",
underline_thickness = 3.0,
enable_scroll_bar = true,
color_scheme = "MaterialOcean",
window_background_image = wezterm.config_dir .. [[/background/background.png]],
window_background_image_hsb = {
brightness = 0.02,
hue = 1.0,
saturation = 1.0,
},
window_padding = {
left = "0.5cell",
right = 0,
top = "0cell",
bottom = "0cell",
},
window_background_opacity = 0.9,
text_background_opacity = 0.6,
}

View file

@ -1,5 +0,0 @@
if require("fn").is_windows() then
return require("options.os.windows")
else
return require("options.os.other_os")
end

View file

@ -1,30 +0,0 @@
local wezterm = require("wezterm")
local fonts = {
require("fonts.firacode_nerd_font"),
require("fonts.noto_sans_cjk_sc"),
require("fonts.noto_color_emoji"),
}
return {
term = "wezterm",
font_size = 14.0,
animation_fps = 1,
max_fps = 1,
font = wezterm.font_with_fallback(fonts),
font_rules = {
{
italic = true,
font = wezterm.font_with_fallback({
require("fonts.victor_mono_nerd_font"),
}),
},
{
italic = false,
font = wezterm.font_with_fallback({
require("fonts.firacode_nerd_font"),
require("fonts.noto_sans_cjk_sc"),
}),
},
},
}

View file

@ -1,31 +0,0 @@
local wezterm = require("wezterm")
local fonts = {
require("fonts.firacode_nerd_font"),
require("fonts.segoe_ui_emoji"),
}
return {
font_size = 16.0,
animation_fps = 144,
max_fps = 144,
default_prog = {
[[pwsh]],
},
font = wezterm.font_with_fallback(fonts),
font_rules = {
{
italic = true,
font = wezterm.font_with_fallback({
require("fonts.victor_mono_nerd_font"),
}),
},
{
italic = false,
font = wezterm.font_with_fallback({
require("fonts.firacode_nerd_font"),
require("fonts.noto_sans_cjk_sc"),
}),
},
},
}

View file

@ -1,6 +0,0 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
[sort_requires]
enabled = true

View file

@ -1,5 +0,0 @@
return require("config")
:init()
:append(require("options.base"))
:append(require("options.backend"))
:append(require("options.os")).options