From 9757bf7ff6df22bb5b498e142bafbf3e87e9f2c9 Mon Sep 17 00:00:00 2001 From: joachimschmidt557 Date: Sun, 17 Jul 2022 14:07:16 +0200 Subject: [PATCH] dustbowl: make swayidle a systemd service + run nixpkgs-fmt --- flake.nix | 10 +++++---- nixos/cachix.nix | 6 +++--- nixos/cachix/nimmm.nix | 1 - nixos/cachix/nix-community.nix | 1 - nixos/cachix/winewayland.nix | 1 - nixos/cachix/zig-nightly.nix | 1 - nixos/cachix/zigpkgs.nix | 1 - nixos/dustbowl.nix | 37 +++++++++++++++++++++++++++++----- sway/config | 14 ------------- 9 files changed, 41 insertions(+), 31 deletions(-) diff --git a/flake.nix b/flake.nix index 197f468..2eac8dd 100644 --- a/flake.nix +++ b/flake.nix @@ -34,10 +34,12 @@ nixosConfigurations = { dustbowl = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - modules = [ (import ./nixos/dustbowl.nix { - emacs-overlay = emacs-overlay; - nixpkgs = nixpkgs; - }) ]; + modules = [ + (import ./nixos/dustbowl.nix { + emacs-overlay = emacs-overlay; + nixpkgs = nixpkgs; + }) + ]; }; }; diff --git a/nixos/cachix.nix b/nixos/cachix.nix index 2dfd6ac..14dbfd8 100644 --- a/nixos/cachix.nix +++ b/nixos/cachix.nix @@ -1,4 +1,3 @@ - # WARN: this file will get overwritten by $ cachix use { pkgs, lib, ... }: @@ -7,7 +6,8 @@ let toImport = name: value: folder + ("/" + name); filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key; imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); -in { +in +{ inherit imports; - nix.settings.trusted-substituters = ["https://cache.nixos.org/"]; + nix.settings.trusted-substituters = [ "https://cache.nixos.org/" ]; } diff --git a/nixos/cachix/nimmm.nix b/nixos/cachix/nimmm.nix index 499efeb..494a991 100644 --- a/nixos/cachix/nimmm.nix +++ b/nixos/cachix/nimmm.nix @@ -1,4 +1,3 @@ - { nix.settings = { trusted-substituters = [ diff --git a/nixos/cachix/nix-community.nix b/nixos/cachix/nix-community.nix index 2d7393b..8734670 100644 --- a/nixos/cachix/nix-community.nix +++ b/nixos/cachix/nix-community.nix @@ -1,4 +1,3 @@ - { nix.settings = { trusted-substituters = [ diff --git a/nixos/cachix/winewayland.nix b/nixos/cachix/winewayland.nix index f2b2f37..d19f7ec 100644 --- a/nixos/cachix/winewayland.nix +++ b/nixos/cachix/winewayland.nix @@ -1,4 +1,3 @@ - { nix.settings = { trusted-substituters = [ diff --git a/nixos/cachix/zig-nightly.nix b/nixos/cachix/zig-nightly.nix index 5df45c6..9dba200 100644 --- a/nixos/cachix/zig-nightly.nix +++ b/nixos/cachix/zig-nightly.nix @@ -1,4 +1,3 @@ - { nix.settings = { trusted-substituters = [ diff --git a/nixos/cachix/zigpkgs.nix b/nixos/cachix/zigpkgs.nix index ae47aba..129e6bb 100644 --- a/nixos/cachix/zigpkgs.nix +++ b/nixos/cachix/zigpkgs.nix @@ -1,4 +1,3 @@ - { nix.settings = { trusted-substituters = [ diff --git a/nixos/dustbowl.nix b/nixos/dustbowl.nix index c170731..d3fc447 100644 --- a/nixos/dustbowl.nix +++ b/nixos/dustbowl.nix @@ -7,7 +7,8 @@ { imports = - [ # Include the results of the hardware scan. + [ + # Include the results of the hardware scan. /etc/nixos/hardware-configuration.nix /etc/nixos/private.nix ./cachix.nix @@ -47,6 +48,12 @@ }; }; + # Enable systemd watchdog + systemd.watchdog = { + runtimeTime = "30s"; + rebootTime = "10m"; + }; + boot.extraModulePackages = [ config.boot.kernelPackages.v4l2loopback.out ]; @@ -71,7 +78,7 @@ services.fwupd.enable = true; networking.hostName = "dustbowl"; # Define your hostname. - networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. networking.wireless.interfaces = [ "wlp2s0" ]; networking.wireguard.enable = true; @@ -189,7 +196,7 @@ enable = true; extraRules = [ { - groups = ["wheel"]; + groups = [ "wheel" ]; persist = true; keepEnv = true; } @@ -201,7 +208,7 @@ group = "root"; capabilities = "cap_perfmon=ip"; source = "${pkgs.rr}/bin/rr"; - }; + }; security.wrappers.intel_gpu_top = { owner = "root"; @@ -257,6 +264,24 @@ }; }; + systemd.user.services.swayidle = { + description = "swayidle idle manager for Wayland"; + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + path = with pkgs; [ bash sway swaylock ]; + serviceConfig = { + ExecStart = '' + ${pkgs.swayidle}/bin/swayidle -w \ + timeout 300 'swaylock -f -c 000000' \ + timeout 600 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + before-sleep 'swaylock -f -c 000000' + ''; + RestartSec = 3; + Restart = "always"; + }; + }; + # Enable sound. sound.enable = true; @@ -319,7 +344,9 @@ # Fonts fonts.fonts = with pkgs; [ fira-code - noto-fonts noto-fonts-emoji noto-fonts-extra + noto-fonts + noto-fonts-emoji + noto-fonts-extra ]; fonts.fontconfig = { enable = true; diff --git a/sway/config b/sway/config index 400236e..6c97f6b 100644 --- a/sway/config +++ b/sway/config @@ -22,20 +22,6 @@ set $term env XCURSOR_THEME=Adwaita footclient # on the original workspace that the command was run on. # set $menu dmenu_path | dmenu | xargs swaymsg exec -- -### Idle configuration -# -# Example configuration: -# -exec swayidle -w \ - timeout 300 'swaylock -f -c 000000' \ - timeout 600 'swaymsg "output * dpms off"' \ - resume 'swaymsg "output * dpms on"' \ - before-sleep 'swaylock -f -c 000000' - -# This will lock your screen after 300 seconds of inactivity, then turn off -# your displays after another 300 seconds, and turn your screens back on when -# resumed. It will also lock your screen before your computer goes to sleep. - ### Start foot server exec foot --server