mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:59:23 +08:00
整理很多东西
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.bugs = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.listOf (types.enum
|
||||
let
|
||||
bugs =
|
||||
[
|
||||
# intel i915 hdmi
|
||||
"intel-hdmi"
|
||||
@@ -12,54 +10,58 @@ inputs:
|
||||
"hibernate-iwlwifi"
|
||||
# disable wakeup on lid open
|
||||
"suspend-lid-no-wakeup"
|
||||
]);
|
||||
default = [];
|
||||
};
|
||||
config =
|
||||
let
|
||||
inherit (inputs.localLib) stripeTabs;
|
||||
inherit (builtins) map;
|
||||
inherit (inputs.lib) mkMerge mkIf;
|
||||
inherit (inputs.config) bugs;
|
||||
patches =
|
||||
];
|
||||
in
|
||||
{
|
||||
options.nixos.bugs = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
intel-hdmi.boot.kernelPatches = { name = "intel-hdmi"; patch = ./intel-hdmi.patch; };
|
||||
suspend-hibernate-no-platform.systemd.sleep.extraConfig = stripeTabs
|
||||
"
|
||||
SuspendState=freeze
|
||||
HibernateMode=shutdown
|
||||
";
|
||||
hibernate-iwlwifi.systemd.services.reload-iwlwifi-after-hibernate =
|
||||
{
|
||||
description = "reload iwlwifi after resume from hibernate";
|
||||
after = [ "systemd-hibernate.service" ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = let modprobe = "${inputs.pkgs.kmod}/bin/modprobe"; in stripeTabs
|
||||
"
|
||||
${modprobe} -r iwlwifi
|
||||
${modprobe} iwlwifi
|
||||
echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
|
||||
";
|
||||
wantedBy = [ "systemd-hibernate.service" ];
|
||||
};
|
||||
suspend-lid-no-wakeup.systemd.services.lid-no-wakeup =
|
||||
{
|
||||
description = "lid no wake up";
|
||||
serviceConfig.Type = "oneshot";
|
||||
script =
|
||||
let
|
||||
cat = "${inputs.pkgs.coreutils}/bin/cat";
|
||||
grep = "${inputs.pkgs.gnugrep}/bin/grep";
|
||||
in stripeTabs
|
||||
"
|
||||
if ${cat} /proc/acpi/wakeup | ${grep} LID0 | ${grep} -q enabled
|
||||
then
|
||||
echo LID0 > /proc/acpi/wakeup
|
||||
fi
|
||||
";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
type = types.listOf (types.enum bugs);
|
||||
default = [];
|
||||
};
|
||||
in
|
||||
mkMerge (map (bug: patches.${bug}) bugs);
|
||||
}
|
||||
config =
|
||||
let
|
||||
inherit (inputs.localLib) stripeTabs;
|
||||
inherit (builtins) map;
|
||||
inherit (inputs.lib) mkMerge mkIf;
|
||||
patches =
|
||||
{
|
||||
intel-hdmi.boot.kernelPatches = [{ name = "intel-hdmi"; patch = ./intel-hdmi.patch; }];
|
||||
suspend-hibernate-no-platform.systemd.sleep.extraConfig = stripeTabs
|
||||
"
|
||||
SuspendState=freeze
|
||||
HibernateMode=shutdown
|
||||
";
|
||||
hibernate-iwlwifi.systemd.services.reload-iwlwifi-after-hibernate =
|
||||
{
|
||||
description = "reload iwlwifi after resume from hibernate";
|
||||
after = [ "systemd-hibernate.service" ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = let modprobe = "${inputs.pkgs.kmod}/bin/modprobe"; in stripeTabs
|
||||
"
|
||||
${modprobe} -r iwlwifi
|
||||
${modprobe} iwlwifi
|
||||
echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
|
||||
";
|
||||
wantedBy = [ "systemd-hibernate.service" ];
|
||||
};
|
||||
suspend-lid-no-wakeup.systemd.services.lid-no-wakeup =
|
||||
{
|
||||
description = "lid no wake up";
|
||||
serviceConfig.Type = "oneshot";
|
||||
script =
|
||||
let
|
||||
cat = "${inputs.pkgs.coreutils}/bin/cat";
|
||||
grep = "${inputs.pkgs.gnugrep}/bin/grep";
|
||||
in stripeTabs
|
||||
"
|
||||
if ${cat} /proc/acpi/wakeup | ${grep} LID0 | ${grep} -q enabled
|
||||
then
|
||||
echo LID0 > /proc/acpi/wakeup
|
||||
fi
|
||||
";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
mkMerge (map (bug: mkIf (builtins.elem bug inputs.config.nixos.bugs) patches.${bug}) bugs);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,6 @@ inputs:
|
||||
mode = "0440";
|
||||
owner = "v2ray";
|
||||
group = "v2ray";
|
||||
# restartUnits = [ "xray.service" ];
|
||||
content = builtins.toJSON
|
||||
{
|
||||
log.loglevel = "warning";
|
||||
@@ -330,15 +329,19 @@ inputs:
|
||||
secrets = listToAttrs
|
||||
(map (name: { name = "xray-client/${name}"; value = {}; }) [ "server" "serverName" "uuid" ]);
|
||||
};
|
||||
systemd.services.xray.serviceConfig =
|
||||
systemd.services.xray =
|
||||
{
|
||||
DynamicUser = inputs.lib.mkForce false;
|
||||
User = "v2ray";
|
||||
Group = "v2ray";
|
||||
CapabilityBoundingSet = "CAP_NET_ADMIN CAP_NET_BIND_SERVICE";
|
||||
AmbientCapabilities = "CAP_NET_ADMIN CAP_NET_BIND_SERVICE";
|
||||
LimitNPROC = 10000;
|
||||
LimitNOFILE = 1000000;
|
||||
serviceConfig =
|
||||
{
|
||||
DynamicUser = inputs.lib.mkForce false;
|
||||
User = "v2ray";
|
||||
Group = "v2ray";
|
||||
CapabilityBoundingSet = "CAP_NET_ADMIN CAP_NET_BIND_SERVICE";
|
||||
AmbientCapabilities = "CAP_NET_ADMIN CAP_NET_BIND_SERVICE";
|
||||
LimitNPROC = 10000;
|
||||
LimitNOFILE = 1000000;
|
||||
};
|
||||
restartTriggers = [ inputs.config.sops.templates."xray-client.json".file ];
|
||||
};
|
||||
users = { users.v2ray = { isSystemUser = true; group = "v2ray"; }; groups.v2ray = {}; };
|
||||
environment.etc."resolv.conf".text = "nameserver 127.0.0.1";
|
||||
|
||||
Reference in New Issue
Block a user