From 3088f2aea813b83057ab90062cddda87906e1b97 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 26 Apr 2025 19:35:04 +0800 Subject: [PATCH] change file copy to soft link --- .gitignore | 1 + modules/home/hyprland/default.nix | 64 ++++++++---------------------- modules/nixos/core/default.nix | 6 +-- profiles/apollo/configuration.nix | 4 +- profiles/apollo/hm/ssh/default.nix | 5 +-- profiles/apollo/network.nix | 6 +++ 6 files changed, 29 insertions(+), 57 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2f5dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result \ No newline at end of file diff --git a/modules/home/hyprland/default.nix b/modules/home/hyprland/default.nix index bd7f285..fcc5262 100644 --- a/modules/home/hyprland/default.nix +++ b/modules/home/hyprland/default.nix @@ -1,5 +1,9 @@ { config, lib, pkgs, ... }: - +let + conf = [ "hypr" "waybar" "rofi" "kitty" "mako" "wlogout" ]; + confPath = "${config.home.homeDirectory}/.nix/modules/home/hyprland/conf"; + inherit (lib.my) mkOutOfStoreSymlinks; +in { imports = [ ./env.nix @@ -12,16 +16,7 @@ package = pkgs.hyprland; # Whether to enable XWayland xwayland.enable = true; - - # Optional - # Whether to enable hyprland-session.target on hyprland startup - # systemd.enable = true; - settings = lib.mkDefault { - decoration = { - shadow_offset = "0 5"; - "col.shadow" = "rgba(00000099)"; - }; - }; + systemd.enable = false; }; home.packages = with pkgs; [ @@ -52,42 +47,17 @@ swaylock.enable = true; }; - # hyprland configs, based on https://github.com/notwidow/hyprland - home.file.".config/hypr" = { - source = ./conf/hypr; - # copy the scripts directory recursively - recursive = true; - }; - - home.file.".config/rofi" = { - source = ./conf/rofi; - recursive = true; - }; - - home.file.".config/kitty" = { - source = ./conf/kitty; - recursive = true; - }; - - home.file.".config/mako" = { - source = ./conf/mako; - recursive = true; - }; - - # home.file.".config/swww" = { - # source = ./conf/swww; - # recursive = true; - # }; - - home.file.".config/waybar" = { - source = ./conf/waybar; - recursive = true; - }; - - home.file.".config/wlogout" = { - source = ./conf/wlogout; - recursive = true; - }; + # 使用map函数循环 conf 变量,动态的生成 home.file..config.${i} + xdg.configFile = builtins.listToAttrs + (builtins.map + (name: { + inherit name; + value = { + source = config.lib.file.mkOutOfStoreSymlink "${confPath}/${name}"; + }; + }) + conf + ); } diff --git a/modules/nixos/core/default.nix b/modules/nixos/core/default.nix index 48525c0..8f10c19 100644 --- a/modules/nixos/core/default.nix +++ b/modules/nixos/core/default.nix @@ -15,11 +15,7 @@ networking.firewall = lib.mkDefault { enable = true; allowedTCPPorts = [ 22 80 443 ]; # 根据需要调整 - allowedUDPPorts = [ 53 ]; # 根据需要调整 - # 如果需要,可以添加特定服务的规则 - allowedTCPPortRanges = [ - { from = 1714; to = 1764; } # KDE Connect - ]; + allowedUDPPorts = [ 9 53 ]; # 9: wol, 53: dns }; # Select internationalisation properties. diff --git a/profiles/apollo/configuration.nix b/profiles/apollo/configuration.nix index d2ee4c9..427427d 100644 --- a/profiles/apollo/configuration.nix +++ b/profiles/apollo/configuration.nix @@ -1,4 +1,4 @@ -args@{ inputs, outputs, lib, pkgs, home-manager, self, username, useremail, hostname, sysversion, ... }: { +args@{ self, inputs, outputs, lib, pkgs, home-manager, username, useremail, hostname, sysversion, ... }: { # You can import other NixOS modules here imports = [ @@ -30,7 +30,7 @@ args@{ inputs, outputs, lib, pkgs, home-manager, self, username, useremail, host # home-manager.useGlobalPkgs = true; # home-manager.useUserPackages = true; home-manager.extraSpecialArgs = { - inherit inputs outputs hostname username useremail sysversion; + inherit self inputs outputs hostname username useremail sysversion; }; home-manager.users."${username}" = { ... }: { imports = [ diff --git a/profiles/apollo/hm/ssh/default.nix b/profiles/apollo/hm/ssh/default.nix index 7a1e40e..5d2a1f8 100644 --- a/profiles/apollo/hm/ssh/default.nix +++ b/profiles/apollo/hm/ssh/default.nix @@ -1,10 +1,9 @@ -{ config, ... }: -{ +{ config, ... }: { programs.ssh = { enable = true; }; home.file.".ssh/config" = { - source = ./config; + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.nix/profiles/apollo/hm/ssh/config"; }; } diff --git a/profiles/apollo/network.nix b/profiles/apollo/network.nix index 34405d6..c699d57 100644 --- a/profiles/apollo/network.nix +++ b/profiles/apollo/network.nix @@ -18,6 +18,12 @@ # Set up bridge network interfaces.eno1 = { useDHCP = false; + wakeOnLan = { + enable = true; + policy = [ + "magic" + ]; + }; }; bridges = {