This commit is contained in:
2026-07-27 16:49:48 +09:00
parent 684acef46c
commit 3e32c9874b
8 changed files with 143 additions and 0 deletions
+2
View File
@@ -2,5 +2,7 @@
{ {
description = "niri Wayland compositor"; description = "niri Wayland compositor";
includes = [ "systems.wayland" ];
imports.nixos = [ inputs.niri-flake.nixosModules.niri ]; imports.nixos = [ inputs.niri-flake.nixosModules.niri ];
} }
+11
View File
@@ -0,0 +1,11 @@
{
services.openssh = {
enable = true;
extraConfig = ''
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
'';
};
}
+12
View File
@@ -0,0 +1,12 @@
{
services.openssh = {
enable = true;
openFirewall = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
PubkeyAuthentication = "yes";
};
};
}
+67
View File
@@ -0,0 +1,67 @@
{ lib, pkgs, ... }:
let
brightnessctl = lib.getExe pkgs.brightnessctl;
niri = lib.getExe pkgs.niri;
rm = "${pkgs.coreutils}/bin/rm";
systemctl = lib.getExe' pkgs.systemd "systemctl";
brightnessState = "$XDG_RUNTIME_DIR/swayidle-brightness";
skipIfOnAC = ''
for supply in /sys/class/power_supply/*; do
if [ -f "$supply/type" ] \
&& [ "$(< "$supply/type")" = "Mains" ] \
&& [ -f "$supply/online" ] \
&& [ "$(< "$supply/online")" = "1" ]; then
exit 0
fi
done
'';
dimScreen = pkgs.writeShellScript "swayidle-dim-screen" ''
${skipIfOnAC}
${brightnessctl} get > "${brightnessState}" 2>/dev/null || exit 0
${brightnessctl} set 10% >/dev/null 2>&1 || true
'';
restoreBrightness = pkgs.writeShellScript "swayidle-restore-brightness" ''
if [ -f "${brightnessState}" ]; then
saved=$(< "${brightnessState}")
${brightnessctl} set "$saved" >/dev/null 2>&1 || true
${rm} -f "${brightnessState}"
fi
'';
suspendOnBattery = pkgs.writeShellScript "swayidle-suspend-on-battery" ''
${skipIfOnAC}
exec ${systemctl} suspend
'';
afterResume = pkgs.writeShellScript "swayidle-after-resume" ''
${niri} msg action power-on-monitors
${restoreBrightness}
'';
in
lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
services.swayidle = {
enable = true;
systemdTargets = [ "graphical-session.target" ];
timeouts = [
{
timeout = 300;
command = "${dimScreen}";
resumeCommand = "${restoreBrightness}";
}
{
timeout = 360;
command = "${suspendOnBattery}";
}
];
events.after-resume = "${afterResume}";
};
systemd.user.services.swayidle.Service.PassEnvironment = [
"WAYLAND_DISPLAY"
"XDG_RUNTIME_DIR"
"DBUS_SESSION_BUS_ADDRESS"
];
}
+5
View File
@@ -0,0 +1,5 @@
{
description = "swayidle idle management for Niri";
includes = [ "applications.niri" ];
}
+3
View File
@@ -0,0 +1,3 @@
{
services.tailscale.enable = true;
}
+11
View File
@@ -0,0 +1,11 @@
{
services.tailscale = {
enable = true;
openFirewall = false;
useRoutingFeatures = "client";
extraSetFlags = [
"--accept-dns=false"
"--accept-routes=true"
];
};
}
+32
View File
@@ -0,0 +1,32 @@
{ pkgs, ... }:
{
programs.xwayland.enable = true;
xdg.portal = {
enable = true;
extraPortals = [
pkgs.xdg-desktop-portal-gnome
pkgs.xdg-desktop-portal-gtk
];
xdgOpenUsePortal = true;
config = {
common.default = [ "gtk" ];
gnome.default = [
"gnome"
"gtk"
];
};
};
environment.variables.NIXOS_OZONE_WL = "1";
environment.sessionVariables = {
ELECTRON_OZONE_PLATFORM_HINT = "wayland";
QT_QPA_PLATFORM = "wayland;xcb";
NIXOS_OZONE_WL = "1";
};
environment.systemPackages = [
pkgs.xwayland-satellite
pkgs.uwsm
];
}