mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-23 05:18:44 +08:00
整理 hardware
This commit is contained in:
parent
e55d604798
commit
3c1e72a5c1
@ -7,38 +7,39 @@ inputs:
|
||||
printer.enable = mkOption { type = types.bool; default = false; };
|
||||
sound.enable = mkOption { type = types.bool; default = false; };
|
||||
};
|
||||
config =
|
||||
{
|
||||
hardware = {}
|
||||
// (if inputs.config.nixos.hardware.bluetooth.enable then { bluetooth.enable = true; } else {})
|
||||
// (if inputs.config.nixos.hardware.joystick.enable then { xone.enable = true; xpadneo.enable = true; } else {})
|
||||
// (if inputs.config.nixos.hardware.sound.enable then { pulseaudio.enable = false; } else {});
|
||||
services = {}
|
||||
// (if inputs.config.nixos.hardware.printer.enable then
|
||||
config = let inherit (inputs.lib) mkMerge mkIf; in mkMerge
|
||||
[
|
||||
(mkIf inputs.config.nixos.hardware.bluetooth.enable { hardware.bluetooth.enable = true; })
|
||||
(mkIf inputs.config.nixos.hardware.joystick.enable { hardware = { xone.enable = true; xpadneo.enable = true; }; })
|
||||
(
|
||||
mkIf inputs.config.nixos.hardware.printer.enable
|
||||
{
|
||||
services =
|
||||
{
|
||||
printing = { enable = true; drivers = [ inputs.pkgs.cnijfilter2 ]; };
|
||||
avahi = { enable = true; nssmdns = true; openFirewall = true; };
|
||||
}
|
||||
else {})
|
||||
// (if inputs.config.nixos.hardware.sound.enable then
|
||||
{ pipewire = { enable = true; alsa = { enable = true; support32Bit = true; }; pulse.enable = true; }; }
|
||||
else {});
|
||||
}
|
||||
// (if inputs.config.nixos.hardware.sound.enable then
|
||||
{
|
||||
sound.enable = true;
|
||||
security.rtkit.enable = true;
|
||||
environment.etc."wireplumber/main.lua.d/50-alsa-config.lua".text =
|
||||
let
|
||||
content = builtins.readFile
|
||||
("/." + inputs.pkgs.wireplumber + "/share/wireplumber/main.lua.d/50-alsa-config.lua");
|
||||
matched = builtins.match
|
||||
".*\n([[:space:]]*)(--\\[\"session\\.suspend-timeout-seconds\"][^\n]*)[\n].*" content;
|
||||
spaces = builtins.elemAt matched 0;
|
||||
comment = builtins.elemAt matched 1;
|
||||
config = "[\"session.suspend-timeout-seconds\"] = 0";
|
||||
in
|
||||
builtins.replaceStrings [(spaces + comment)] [(spaces + config)] content;
|
||||
}
|
||||
else {});
|
||||
};
|
||||
}
|
||||
)
|
||||
(
|
||||
mkIf inputs.config.nixos.hardware.sound.enable
|
||||
{
|
||||
hardware.pulseaudio.enable = false;
|
||||
services.pipewire = { enable = true; alsa = { enable = true; support32Bit = true; }; pulse.enable = true; };
|
||||
sound.enable = true;
|
||||
security.rtkit.enable = true;
|
||||
environment.etc."wireplumber/main.lua.d/50-alsa-config.lua".text =
|
||||
let
|
||||
content = builtins.readFile
|
||||
("/." + inputs.pkgs.wireplumber + "/share/wireplumber/main.lua.d/50-alsa-config.lua");
|
||||
matched = builtins.match
|
||||
".*\n([[:space:]]*)(--\\[\"session\\.suspend-timeout-seconds\"][^\n]*)[\n].*" content;
|
||||
spaces = builtins.elemAt matched 0;
|
||||
comment = builtins.elemAt matched 1;
|
||||
config = "[\"session.suspend-timeout-seconds\"] = 0";
|
||||
in
|
||||
builtins.replaceStrings [(spaces + comment)] [(spaces + config)] content;
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user