Compare commits
1
Commits
main
..
ad6e1504db
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad6e1504db |
No files matched your search
@@ -9,7 +9,7 @@ let
|
|||||||
flakePath = config.config-manager.flakePath;
|
flakePath = config.config-manager.flakePath;
|
||||||
nixosConfiguration = config.config-manager.nixosConfiguration;
|
nixosConfiguration = config.config-manager.nixosConfiguration;
|
||||||
|
|
||||||
nh = inputs.nh.packages."${pkgs.stdenv.hostPlatform.system}".default;
|
nh = inputs.nh.packages."${pkgs.system}".default;
|
||||||
|
|
||||||
config-manager =
|
config-manager =
|
||||||
if flakePath == "" then
|
if flakePath == "" then
|
||||||
|
|||||||
Generated
+78
-848
File diff suppressed because it is too large.
Load diff
@@ -12,7 +12,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
nh = {
|
nh = {
|
||||||
url = "github:nix-community/nh/b00a24b39944efd4ec7944f02e0bd9113d991767";
|
url = "github:viperML/nh";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
nix-gc-env.url = "github:Julow/nix-gc-env";
|
nix-gc-env.url = "github:Julow/nix-gc-env";
|
||||||
@@ -32,100 +33,28 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
hyprland = {
|
|
||||||
url = "github:hyprwm/Hyprland";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
hyprland-contrib = {
|
hyprland-contrib = {
|
||||||
url = "github:hyprwm/contrib";
|
url = "github:hyprwm/contrib";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
nix-jetbrains-plugins = {
|
|
||||||
url = "github:nix-community/nix-jetbrains-plugins";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
naviterm = {
|
naviterm = {
|
||||||
url = "gitlab:detoxify92/naviterm";
|
url = "gitlab:detoxify92/naviterm";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
ndp = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/ndp.git?ref=main";
|
|
||||||
# url = "git+file:///home/alex/code/own/ndp?ref=main";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
pppdotpm-site = {
|
pppdotpm-site = {
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/ppp.pm-site.git?ref=main";
|
url = "git+ssh://gitea@git.ppp.pm:1122/alex/ppp.pm-site.git?ref=main";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
heldtenkeltdotse-site = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/heldtenkelt.se-site.git?ref=main";
|
|
||||||
# url = "git+file:///home/alex/code/heldtenkelt.se-site?ref=main";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
whib-backend = {
|
whib-backend = {
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/whib.git?ref=master";
|
url = "git+ssh://gitea@git.ppp.pm:1122/alex/whib.git?ref=master";
|
||||||
# url = "path:/home/alex/code/own/whib";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
whib-frontend = {
|
whib-frontend = {
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/whib-react.git?ref=master";
|
url = "git+ssh://gitea@git.ppp.pm:1122/alex/whib-react.git?ref=master";
|
||||||
# url = "path:/home/alex/code/own/whib-react";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
komga-comictracker = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/komga-comictracker.git?ref=main";
|
|
||||||
# url = "path:/home/alex/code/own/komga-comictracker";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
komga-bookmanager = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/komga-bookmanager.git?ref=main";
|
|
||||||
# url = "path:/home/alex/code/own/komga-bookmanager";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
komga-reading-stats = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/komga-reading-stats.git?ref=main";
|
|
||||||
# url = "path:/home/alex/code/own/komga-reading-stats";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
puppy-tracker = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/puppy-tracker.git?ref=main";
|
|
||||||
# url = "path:/home/alex/code/puppy-tracker";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
schema = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/schema.git?ref=main";
|
|
||||||
# url = "path:/home/alex/code/schema";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
todo = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/todo.git?ref=main";
|
|
||||||
# url = "git+file:///home/alex/code/todo?ref=main";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
dagbok = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/dagbok.git?ref=main";
|
|
||||||
# url = "git+file:///home/alex/code/own/dagbok?ref=main";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
ct = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/ct.git?ref=main";
|
|
||||||
# url = "git+file:///home/alex/code/own/ct?ref=main";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -141,6 +70,7 @@
|
|||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
./hosts/pinwheel/configuration.nix
|
./hosts/pinwheel/configuration.nix
|
||||||
|
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-10th-gen
|
||||||
./hosts/pinwheel/home.nix
|
./hosts/pinwheel/home.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@@ -180,7 +110,6 @@
|
|||||||
./hosts/tadpole/configuration.nix
|
./hosts/tadpole/configuration.nix
|
||||||
./hosts/tadpole/home.nix
|
./hosts/tadpole/home.nix
|
||||||
inputs.whib-backend.nixosModules.${system}.default
|
inputs.whib-backend.nixosModules.${system}.default
|
||||||
inputs.whib-frontend.nixosModules.${system}.default
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -208,7 +137,7 @@
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
${system}.default = pkgs.mkShell {
|
${system}.default = pkgs.mkShell {
|
||||||
packages = [ pkgs.nixfmt ];
|
packages = [ pkgs.nixfmt-rfc-style ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../config-manager/default.nix
|
../../config-manager/default.nix
|
||||||
|
../../shared-modules/syncthing.nix
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./modules
|
./modules
|
||||||
];
|
];
|
||||||
@@ -21,13 +22,6 @@
|
|||||||
alsa.enable = true;
|
alsa.enable = true;
|
||||||
alsa.support32Bit = true;
|
alsa.support32Bit = true;
|
||||||
pulse.enable = true;
|
pulse.enable = true;
|
||||||
|
|
||||||
extraConfig.pipewire."90-hdmi-fix" = {
|
|
||||||
"context.properties" = {
|
|
||||||
"default.clock.rate" = 48000;
|
|
||||||
"default.clock.allowed-rates" = [ 48000 ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware = {
|
hardware = {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
inputs.agenix.packages."${pkgs.stdenv.hostPlatform.system}".default
|
inputs.agenix.packages."${pkgs.system}".default
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
inputs,
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
@@ -7,6 +8,8 @@ let
|
|||||||
configurationLimit = config.mod.gc.configurationLimit;
|
configurationLimit = config.mod.gc.configurationLimit;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ inputs.nix-gc-env.nixosModules.default ];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
mod.gc = {
|
mod.gc = {
|
||||||
configurationLimit = lib.mkOption {
|
configurationLimit = lib.mkOption {
|
||||||
@@ -18,22 +21,15 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
# `nix.gc` cannot prune generations under `~/.local/state/nix/profiles`
|
nix.gc = {
|
||||||
# when run as root (NixOS/nix#8508), so home-manager generations piled up.
|
automatic = true;
|
||||||
# `nh clean` walks those per-user profiles too.
|
dates = "weekly";
|
||||||
programs.nh = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
clean = {
|
# `delete_generations` added by nix-gc-env
|
||||||
enable = true;
|
delete_generations = "+${builtins.toString configurationLimit}";
|
||||||
dates = "weekly";
|
|
||||||
extraArgs = "--keep ${builtins.toString configurationLimit}";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
tmp.cleanOnBoot = true;
|
|
||||||
|
|
||||||
loader = {
|
loader = {
|
||||||
systemd-boot = {
|
systemd-boot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -42,20 +38,6 @@ in
|
|||||||
|
|
||||||
efi.canTouchEfiVariables = true;
|
efi.canTouchEfiVariables = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
blacklistedKernelModules = [ "hid_nintendo" ];
|
|
||||||
|
|
||||||
kernelParams = [
|
|
||||||
"i915.enable_dc=0"
|
|
||||||
"i915.disable_power_well=0"
|
|
||||||
];
|
|
||||||
|
|
||||||
extraModprobeConfig = ''
|
|
||||||
options snd-intel-dspcfg dsp_driver=1
|
|
||||||
options snd_hda_intel power_save=0 power_save_controller=N
|
|
||||||
options rtw88_core disable_lps_deep=y
|
|
||||||
options rtw88_pci disable_aspm=y
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@ in
|
|||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
git.enable = true;
|
git.enable = true;
|
||||||
nginx.enable = true;
|
nginx.enable = true;
|
||||||
|
syncthing.enable = true;
|
||||||
|
restic.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -46,12 +46,6 @@ in
|
|||||||
|
|
||||||
package = wrapped;
|
package = wrapped;
|
||||||
|
|
||||||
# Pin the legacy profile location. The default changed to the XDG path
|
|
||||||
# (`$XDG_CONFIG_HOME/mozilla/firefox`) for stateVersion >= "26.05";
|
|
||||||
# keep the old `~/.mozilla/firefox` so the existing profile isn't
|
|
||||||
# stranded (migrating would require moving the profile dir by hand).
|
|
||||||
configPath = ".mozilla/firefox";
|
|
||||||
|
|
||||||
profiles = {
|
profiles = {
|
||||||
alex = {
|
alex = {
|
||||||
id = 0;
|
id = 0;
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
programs.steam.enable = true;
|
|
||||||
|
|
||||||
services.udev.extraRules = ''
|
|
||||||
# 8BitDo in Nintendo Switch mode - allow Steam hidraw access
|
|
||||||
KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", \
|
|
||||||
MODE="0660", GROUP="input", TAG+="uaccess"
|
|
||||||
'';
|
|
||||||
|
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
pkgs.nethack
|
pkgs.nethack
|
||||||
|
|||||||
@@ -4,3 +4,6 @@
|
|||||||
|
|
||||||
[url "git@github.com:"]
|
[url "git@github.com:"]
|
||||||
insteadOf = https://github.com/
|
insteadOf = https://github.com/
|
||||||
|
|
||||||
|
[url "git@codeberg.org:"]
|
||||||
|
insteadOf = https://codeberg.org/
|
||||||
@@ -8,14 +8,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
desktopManager = {
|
|
||||||
gnome.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
displayManager = {
|
|
||||||
gdm.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
xserver = {
|
xserver = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
@@ -23,6 +15,14 @@
|
|||||||
layout = "se";
|
layout = "se";
|
||||||
variant = "";
|
variant = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
desktopManager = {
|
||||||
|
gnome.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
displayManager = {
|
||||||
|
gdm.enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
{ lib, pkgs, ... }:
|
|
||||||
let
|
|
||||||
py = pkgs.python3Packages;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# The K400 Plus firmware turns two-finger swipes into coarse wheel ticks.
|
|
||||||
# This switches its touchpad to raw HID++ reporting and exposes it as a
|
|
||||||
# native multitouch touchpad, so GNOME scrolls it smoothly.
|
|
||||||
systemd.services.k400-touchpad = {
|
|
||||||
description = "Logitech K400 Plus raw touchpad bridge";
|
|
||||||
wants = [ "systemd-udevd.service" ];
|
|
||||||
after = [ "systemd-udevd.service" ];
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
# `toPythonModule` exposes Solaar's `logitech_receiver`. Not a
|
|
||||||
# `withPackages` env, since Solaar bundles a conflicting `hid_parser`.
|
|
||||||
PYTHONPATH = py.makePythonPath [
|
|
||||||
(py.toPythonModule pkgs.solaar)
|
|
||||||
py.evdev
|
|
||||||
py.pygobject3
|
|
||||||
];
|
|
||||||
|
|
||||||
# `logitech_receiver` imports Gdk at load time
|
|
||||||
GI_TYPELIB_PATH = lib.makeSearchPath "lib/girepository-1.0" [
|
|
||||||
pkgs.gtk3
|
|
||||||
pkgs.pango.out
|
|
||||||
pkgs.gdk-pixbuf
|
|
||||||
pkgs.harfbuzz
|
|
||||||
pkgs.gobject-introspection
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = "${py.python.interpreter} ${./k400-touchpad.py}";
|
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = 3;
|
|
||||||
TimeoutStopSec = 8;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.kernelModules = [ "uinput" ];
|
|
||||||
}
|
|
||||||
@@ -1,648 +0,0 @@
|
|||||||
# Logitech K400 Plus raw touchpad bridge.
|
|
||||||
#
|
|
||||||
# Trimmed copy of the touchpad mode of k400-raw
|
|
||||||
# (https://github.com/Infinality/k400-raw, commit 04f2e58). The K400 Plus
|
|
||||||
# firmware quantizes touchpad movement into coarse mouse/wheel steps. This
|
|
||||||
# switches the touchpad to HID++ TOUCHPAD_RAW_XY (0x6100) reporting and
|
|
||||||
# exposes the raw contacts as a two-finger multitouch touchpad, so
|
|
||||||
# libinput/GNOME handle motion, tapping and scrolling. The keyboard and the
|
|
||||||
# physical buttons stay on the kernel's input device.
|
|
||||||
#
|
|
||||||
# Dropped from upstream: pointer mode, F-key configuration, CLI tunables and
|
|
||||||
# receiver/slot overrides.
|
|
||||||
#
|
|
||||||
# MIT License
|
|
||||||
#
|
|
||||||
# Copyright (c) 2026 Infinality
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
|
||||||
# copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
# SOFTWARE.
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import logging
|
|
||||||
import signal
|
|
||||||
import struct
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
from evdev import AbsInfo, UInput, ecodes
|
|
||||||
|
|
||||||
# Solaar warns at import time when libnotify is missing; nothing here sends
|
|
||||||
# desktop notifications
|
|
||||||
logging.getLogger("logitech_receiver.desktop_notifications").setLevel(logging.ERROR)
|
|
||||||
|
|
||||||
from logitech_receiver import base, listener # noqa: E402
|
|
||||||
from logitech_receiver import receiver as receiver_mod # noqa: E402
|
|
||||||
from logitech_receiver.hidpp20_constants import SupportedFeature # noqa: E402
|
|
||||||
|
|
||||||
LOG = logging.getLogger("k400-touchpad")
|
|
||||||
|
|
||||||
WPID_K400_PLUS = "404D"
|
|
||||||
RAW_FEATURE = SupportedFeature.TOUCHPAD_RAW_XY
|
|
||||||
RAW_FLAG = 0x01
|
|
||||||
ENHANCED_FLAG = 0x04
|
|
||||||
RAW_ENHANCED = RAW_FLAG | ENHANCED_FLAG
|
|
||||||
ORIGIN_LOWER_LEFT = 0x01
|
|
||||||
ORIGIN_LOWER_RIGHT = 0x02
|
|
||||||
ORIGIN_UPPER_RIGHT = 0x04
|
|
||||||
|
|
||||||
TOUCHPAD_NAME = "Logitech K400 Raw Touchpad"
|
|
||||||
FEATURE_WAIT_SECONDS = 15.0
|
|
||||||
RECONNECT_DELAY_SECONDS = 2.0
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceNotReady(RuntimeError):
|
|
||||||
"""Expected transient state: the K400 is paired but asleep/offline."""
|
|
||||||
|
|
||||||
|
|
||||||
# --- HID++ raw report parsing ------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Touch:
|
|
||||||
finger_id: int
|
|
||||||
contact_status: int
|
|
||||||
x: int
|
|
||||||
y: int
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class RawFrame:
|
|
||||||
spurious: bool
|
|
||||||
touches: tuple[Touch, Touch]
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class TouchpadInfo:
|
|
||||||
x_size: int
|
|
||||||
y_size: int
|
|
||||||
max_fingers: int
|
|
||||||
origin: int
|
|
||||||
dpi: int
|
|
||||||
|
|
||||||
|
|
||||||
def parse_touch(data: bytes, offset: int) -> Touch:
|
|
||||||
x_high = data[offset]
|
|
||||||
y_high = data[offset + 2]
|
|
||||||
return Touch(
|
|
||||||
finger_id=data[offset + 6] >> 4,
|
|
||||||
contact_status=y_high >> 6,
|
|
||||||
x=((x_high & 0x3F) << 8) | data[offset + 1],
|
|
||||||
y=((y_high & 0x3F) << 8) | data[offset + 3],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_frame(data: bytes) -> RawFrame | None:
|
|
||||||
if len(data) < 16:
|
|
||||||
return None
|
|
||||||
return RawFrame(
|
|
||||||
spurious=bool(data[8] & 0x02),
|
|
||||||
touches=(parse_touch(data, 2), parse_touch(data, 9)),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_info(data: bytes) -> TouchpadInfo:
|
|
||||||
if not data or len(data) < 15:
|
|
||||||
raise RuntimeError(f"Short/empty TOUCHPAD_RAW_XY GetTouchpadInfo response: {data!r}")
|
|
||||||
return TouchpadInfo(
|
|
||||||
x_size=int.from_bytes(data[0:2], "big"),
|
|
||||||
y_size=int.from_bytes(data[2:4], "big"),
|
|
||||||
max_fingers=data[7],
|
|
||||||
origin=data[8],
|
|
||||||
dpi=int.from_bytes(data[13:15], "big"),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def active_touches(frame: RawFrame) -> list[Touch]:
|
|
||||||
touches = [t for t in frame.touches if t.finger_id != 0 and t.contact_status != 0]
|
|
||||||
if touches:
|
|
||||||
return touches
|
|
||||||
|
|
||||||
# Defensive fallback in case this firmware represents contact status
|
|
||||||
# differently while still supplying finger IDs.
|
|
||||||
return [t for t in frame.touches if t.finger_id != 0]
|
|
||||||
|
|
||||||
|
|
||||||
def origin_inversions(origin: int) -> tuple[bool, bool]:
|
|
||||||
# Screen-relative coordinates: +X right, +Y down.
|
|
||||||
invert_x = origin in (ORIGIN_LOWER_RIGHT, ORIGIN_UPPER_RIGHT)
|
|
||||||
invert_y = origin in (ORIGIN_LOWER_LEFT, ORIGIN_LOWER_RIGHT)
|
|
||||||
return invert_x, invert_y
|
|
||||||
|
|
||||||
|
|
||||||
# --- HID++ device access (via Solaar's logitech_receiver) --------------------
|
|
||||||
|
|
||||||
|
|
||||||
class StartedEventsListener(listener.EventsListener):
|
|
||||||
def __init__(self, receiver, callback):
|
|
||||||
self.started_event = threading.Event()
|
|
||||||
super().__init__(receiver, callback)
|
|
||||||
|
|
||||||
def has_started(self):
|
|
||||||
self.started_event.set()
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Candidate:
|
|
||||||
receiver: object
|
|
||||||
device: object
|
|
||||||
path: str
|
|
||||||
online: bool
|
|
||||||
has_raw_feature: bool
|
|
||||||
|
|
||||||
|
|
||||||
def find_k400():
|
|
||||||
"""Find the paired K400 Plus.
|
|
||||||
|
|
||||||
Prefer one that is awake and answers TOUCHPAD_RAW_XY, then one that is
|
|
||||||
awake. A sole paired K400 is used even while asleep; wait_for_feature()
|
|
||||||
then waits for it to wake.
|
|
||||||
"""
|
|
||||||
opened = []
|
|
||||||
candidates = []
|
|
||||||
|
|
||||||
for dev_info in base.receivers():
|
|
||||||
try:
|
|
||||||
r = receiver_mod.create_receiver(base, dev_info)
|
|
||||||
if not r:
|
|
||||||
continue
|
|
||||||
opened.append(r)
|
|
||||||
|
|
||||||
# Solaar stops iterating after the receiver's paired-device count
|
|
||||||
for dev in list(r):
|
|
||||||
if (dev.wpid or "").upper() != WPID_K400_PLUS:
|
|
||||||
continue
|
|
||||||
|
|
||||||
try:
|
|
||||||
online = bool(dev.ping())
|
|
||||||
except Exception:
|
|
||||||
online = False
|
|
||||||
|
|
||||||
has_raw_feature = False
|
|
||||||
if online:
|
|
||||||
try:
|
|
||||||
has_raw_feature = bool(dev.features[RAW_FEATURE])
|
|
||||||
except Exception as exc:
|
|
||||||
LOG.debug("K400 slot %d could not probe 0x6100: %s", dev.number, exc)
|
|
||||||
|
|
||||||
candidates.append(Candidate(r, dev, dev_info.path, online, has_raw_feature))
|
|
||||||
except Exception as exc:
|
|
||||||
LOG.debug("Unable to inspect receiver %s: %s", dev_info.path, exc)
|
|
||||||
|
|
||||||
preferred = (
|
|
||||||
[c for c in candidates if c.online and c.has_raw_feature]
|
|
||||||
or [c for c in candidates if c.online]
|
|
||||||
or candidates
|
|
||||||
)
|
|
||||||
selected = preferred[0] if len(preferred) == 1 else None
|
|
||||||
|
|
||||||
for r in opened:
|
|
||||||
if selected is None or r is not selected.receiver:
|
|
||||||
try:
|
|
||||||
r.close()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if selected is None:
|
|
||||||
if not preferred:
|
|
||||||
raise RuntimeError("Could not find a paired Logitech K400 Plus")
|
|
||||||
if not any(c.online for c in preferred):
|
|
||||||
raise DeviceNotReady("Multiple paired K400 Plus records, none responding; waiting for one to wake")
|
|
||||||
locations = ", ".join(f"{c.path} slot {c.device.number}" for c in preferred)
|
|
||||||
raise RuntimeError(f"Found multiple responding K400 Plus devices: {locations}")
|
|
||||||
|
|
||||||
LOG.info(
|
|
||||||
"Selected K400 Plus on receiver %s slot %d (online=%s)",
|
|
||||||
selected.path, selected.device.number, selected.online,
|
|
||||||
)
|
|
||||||
return selected.receiver, selected.device
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for_feature(dev, timeout_seconds: float, interval_seconds: float = 0.25) -> int:
|
|
||||||
"""Wake the device and wait for TOUCHPAD_RAW_XY to become queryable.
|
|
||||||
|
|
||||||
Solaar's FeaturesArray refuses feature discovery while dev.online is false,
|
|
||||||
and a K400 may be paired but asleep. Retry ping/feature discovery, falling
|
|
||||||
back to a direct ROOT.GetFeature query. If a transient lookup cached False,
|
|
||||||
the false entry is removed before installing the known-good feature index.
|
|
||||||
"""
|
|
||||||
deadline = time.monotonic() + timeout_seconds
|
|
||||||
last_error = None
|
|
||||||
|
|
||||||
while time.monotonic() < deadline:
|
|
||||||
try:
|
|
||||||
dev.ping()
|
|
||||||
except Exception as exc:
|
|
||||||
last_error = exc
|
|
||||||
|
|
||||||
if dev.online:
|
|
||||||
try:
|
|
||||||
index = dev.features[RAW_FEATURE]
|
|
||||||
if index:
|
|
||||||
return index
|
|
||||||
except Exception as exc:
|
|
||||||
last_error = exc
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = dev.request(0x0000, struct.pack("!H", int(RAW_FEATURE)))
|
|
||||||
if response and response[0]:
|
|
||||||
index = response[0]
|
|
||||||
|
|
||||||
# FeaturesArray forbids deletion through its public API, so
|
|
||||||
# use the underlying dict operation only for this recovery
|
|
||||||
if dict.get(dev.features, RAW_FEATURE) is False:
|
|
||||||
dict.__delitem__(dev.features, RAW_FEATURE)
|
|
||||||
|
|
||||||
dev.features[RAW_FEATURE] = index
|
|
||||||
if len(response) > 1:
|
|
||||||
dev.features.flags[RAW_FEATURE] = response[1]
|
|
||||||
if len(response) > 2:
|
|
||||||
dev.features.version[RAW_FEATURE] = response[2]
|
|
||||||
return index
|
|
||||||
except Exception as exc:
|
|
||||||
last_error = exc
|
|
||||||
|
|
||||||
time.sleep(interval_seconds)
|
|
||||||
|
|
||||||
message = (
|
|
||||||
f"Timed out waiting for HID++ feature 0x{int(RAW_FEATURE):04X} "
|
|
||||||
f"(online={dev.online}; last error: {last_error!r})"
|
|
||||||
)
|
|
||||||
if not dev.online:
|
|
||||||
raise DeviceNotReady(message)
|
|
||||||
raise RuntimeError(message)
|
|
||||||
|
|
||||||
|
|
||||||
def enable_raw_reports(dev) -> None:
|
|
||||||
dev.feature_request(RAW_FEATURE, 0x20, bytes([RAW_ENHANCED]))
|
|
||||||
reply = dev.feature_request(RAW_FEATURE, 0x10)
|
|
||||||
if not reply or (reply[0] & RAW_FLAG) == 0:
|
|
||||||
raise RuntimeError(f"Failed to enable HID++ raw reporting; readback was {reply!r}")
|
|
||||||
if reply[0] != RAW_ENHANCED:
|
|
||||||
LOG.warning(
|
|
||||||
"Device did not preserve every requested state bit: requested=0x%02X actual=0x%02X",
|
|
||||||
RAW_ENHANCED, reply[0],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# --- Virtual touchpad --------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
def make_absinfo(maximum: int, resolution: int = 0) -> AbsInfo:
|
|
||||||
return AbsInfo(value=0, min=0, max=maximum, fuzz=0, flat=0, resolution=resolution)
|
|
||||||
|
|
||||||
|
|
||||||
class VirtualTouchpad:
|
|
||||||
"""Translate K400 raw contacts into a two-slot Linux Type-B MT touchpad.
|
|
||||||
|
|
||||||
The uinput device is created on first connect and kept across HID++
|
|
||||||
reconnects, so the desktop keeps its settings for it.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.ui = None
|
|
||||||
self.geometry = None
|
|
||||||
self.invert_x = False
|
|
||||||
self.invert_y = False
|
|
||||||
# The HID++ listener thread and the reconnect loop both write events
|
|
||||||
self.lock = threading.Lock()
|
|
||||||
|
|
||||||
self.finger_to_slot: dict[int, int] = {}
|
|
||||||
self.slot_to_finger: dict[int, int] = {}
|
|
||||||
self.slot_xy: dict[int, tuple[int, int]] = {}
|
|
||||||
self.next_tracking_id = 1
|
|
||||||
|
|
||||||
self.last_btn_touch = 0
|
|
||||||
self.last_tool_finger = 0
|
|
||||||
self.last_tool_doubletap = 0
|
|
||||||
|
|
||||||
def configure(self, info: TouchpadInfo):
|
|
||||||
self.invert_x, self.invert_y = origin_inversions(info.origin)
|
|
||||||
resolution = max(1, round(info.dpi / 25.4))
|
|
||||||
geometry = (info.x_size, info.y_size, resolution)
|
|
||||||
|
|
||||||
if self.ui is not None:
|
|
||||||
if geometry != self.geometry:
|
|
||||||
LOG.warning(
|
|
||||||
"K400 geometry changed after reconnect: was %s now %s; keeping the original",
|
|
||||||
self.geometry, geometry,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
self.geometry = geometry
|
|
||||||
x_max, y_max, _ = geometry
|
|
||||||
self.ui = UInput(
|
|
||||||
{
|
|
||||||
ecodes.EV_KEY: [ecodes.BTN_TOUCH, ecodes.BTN_TOOL_FINGER, ecodes.BTN_TOOL_DOUBLETAP],
|
|
||||||
ecodes.EV_ABS: [
|
|
||||||
(ecodes.ABS_X, make_absinfo(x_max, resolution)),
|
|
||||||
(ecodes.ABS_Y, make_absinfo(y_max, resolution)),
|
|
||||||
(ecodes.ABS_MT_SLOT, make_absinfo(1)),
|
|
||||||
(ecodes.ABS_MT_TRACKING_ID, make_absinfo(65535)),
|
|
||||||
(ecodes.ABS_MT_POSITION_X, make_absinfo(x_max, resolution)),
|
|
||||||
(ecodes.ABS_MT_POSITION_Y, make_absinfo(y_max, resolution)),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
name=TOUCHPAD_NAME,
|
|
||||||
# Logitech's vendor ID with a deliberately synthetic product ID
|
|
||||||
vendor=0x046D,
|
|
||||||
product=0xF400,
|
|
||||||
version=1,
|
|
||||||
bustype=ecodes.BUS_USB,
|
|
||||||
phys="k400-touchpad/input0",
|
|
||||||
# Indirect pointing device, not a touchscreen
|
|
||||||
input_props=[ecodes.INPUT_PROP_POINTER],
|
|
||||||
)
|
|
||||||
LOG.info(
|
|
||||||
"Created virtual touchpad %s, %dx%d, %d units/mm (~%.1fx%.1f mm)",
|
|
||||||
self.ui.device.path if self.ui.device else self.ui.devnode,
|
|
||||||
x_max, y_max, resolution, x_max / resolution, y_max / resolution,
|
|
||||||
)
|
|
||||||
# Give udev/libinput time to pick up the device before the first events
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
def _xy(self, touch: Touch) -> tuple[int, int]:
|
|
||||||
x_max, y_max, _ = self.geometry
|
|
||||||
x = x_max - touch.x if self.invert_x else touch.x
|
|
||||||
y = y_max - touch.y if self.invert_y else touch.y
|
|
||||||
return max(0, min(x_max, x)), max(0, min(y_max, y))
|
|
||||||
|
|
||||||
def _new_tracking_id(self) -> int:
|
|
||||||
tid = self.next_tracking_id
|
|
||||||
self.next_tracking_id = tid + 1 if tid < 65535 else 1
|
|
||||||
return tid
|
|
||||||
|
|
||||||
def release_all(self):
|
|
||||||
with self.lock:
|
|
||||||
if self.ui is None:
|
|
||||||
return
|
|
||||||
changed = False
|
|
||||||
|
|
||||||
for slot in sorted(self.slot_to_finger):
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, slot)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_TRACKING_ID, -1)
|
|
||||||
changed = True
|
|
||||||
|
|
||||||
self.finger_to_slot.clear()
|
|
||||||
self.slot_to_finger.clear()
|
|
||||||
self.slot_xy.clear()
|
|
||||||
|
|
||||||
for code, attr in (
|
|
||||||
(ecodes.BTN_TOUCH, "last_btn_touch"),
|
|
||||||
(ecodes.BTN_TOOL_FINGER, "last_tool_finger"),
|
|
||||||
(ecodes.BTN_TOOL_DOUBLETAP, "last_tool_doubletap"),
|
|
||||||
):
|
|
||||||
if getattr(self, attr):
|
|
||||||
self.ui.write(ecodes.EV_KEY, code, 0)
|
|
||||||
setattr(self, attr, 0)
|
|
||||||
changed = True
|
|
||||||
|
|
||||||
if changed:
|
|
||||||
self.ui.syn()
|
|
||||||
|
|
||||||
def process(self, frame: RawFrame):
|
|
||||||
if frame.spurious:
|
|
||||||
return
|
|
||||||
|
|
||||||
# The K400 reports at most two contacts. If malformed data ever
|
|
||||||
# contains duplicate IDs, keep only the first occurrence.
|
|
||||||
current = {}
|
|
||||||
for touch in active_touches(frame):
|
|
||||||
current.setdefault(touch.finger_id, touch)
|
|
||||||
|
|
||||||
with self.lock:
|
|
||||||
if self.ui is None:
|
|
||||||
return
|
|
||||||
old_ids = set(self.finger_to_slot)
|
|
||||||
new_ids = set(current)
|
|
||||||
|
|
||||||
# Release vanished contacts first so a slot can be reused this frame
|
|
||||||
for finger_id in sorted(old_ids - new_ids):
|
|
||||||
slot = self.finger_to_slot.pop(finger_id)
|
|
||||||
self.slot_to_finger.pop(slot, None)
|
|
||||||
self.slot_xy.pop(slot, None)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, slot)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_TRACKING_ID, -1)
|
|
||||||
|
|
||||||
for finger_id in sorted(new_ids - old_ids):
|
|
||||||
free = next((s for s in (0, 1) if s not in self.slot_to_finger), None)
|
|
||||||
if free is None:
|
|
||||||
LOG.warning("More contacts than MT slots; ignoring finger id %d", finger_id)
|
|
||||||
continue
|
|
||||||
self.finger_to_slot[finger_id] = free
|
|
||||||
self.slot_to_finger[free] = finger_id
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, free)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_TRACKING_ID, self._new_tracking_id())
|
|
||||||
|
|
||||||
# Emit every tracked contact each frame so libinput sees the raw
|
|
||||||
# sensor report cadence
|
|
||||||
for finger_id, slot in sorted(self.finger_to_slot.items(), key=lambda p: p[1]):
|
|
||||||
touch = current.get(finger_id)
|
|
||||||
if touch is None:
|
|
||||||
continue
|
|
||||||
x, y = self._xy(touch)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, slot)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_POSITION_X, x)
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_POSITION_Y, y)
|
|
||||||
self.slot_xy[slot] = (x, y)
|
|
||||||
|
|
||||||
count = len(self.slot_to_finger)
|
|
||||||
|
|
||||||
# Touchpads also need the legacy single-touch axes; mirror the
|
|
||||||
# lowest-numbered active slot
|
|
||||||
if count:
|
|
||||||
xy = self.slot_xy.get(min(self.slot_to_finger))
|
|
||||||
if xy is not None:
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_X, xy[0])
|
|
||||||
self.ui.write(ecodes.EV_ABS, ecodes.ABS_Y, xy[1])
|
|
||||||
|
|
||||||
for code, attr, value in (
|
|
||||||
(ecodes.BTN_TOUCH, "last_btn_touch", int(count > 0)),
|
|
||||||
(ecodes.BTN_TOOL_FINGER, "last_tool_finger", int(count == 1)),
|
|
||||||
(ecodes.BTN_TOOL_DOUBLETAP, "last_tool_doubletap", int(count >= 2)),
|
|
||||||
):
|
|
||||||
if value != getattr(self, attr):
|
|
||||||
self.ui.write(ecodes.EV_KEY, code, value)
|
|
||||||
setattr(self, attr, value)
|
|
||||||
|
|
||||||
self.ui.syn()
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
self.release_all()
|
|
||||||
if self.ui is not None:
|
|
||||||
self.ui.close()
|
|
||||||
self.ui = None
|
|
||||||
|
|
||||||
|
|
||||||
# --- Session / reconnect loop ------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
def run(touchpad: VirtualTouchpad, stop: threading.Event):
|
|
||||||
session = 0
|
|
||||||
|
|
||||||
while not stop.is_set():
|
|
||||||
session += 1
|
|
||||||
r = dev = events = None
|
|
||||||
feature_index = None
|
|
||||||
old_raw_state = None
|
|
||||||
raw_enabled = False
|
|
||||||
reconfigure = threading.Event()
|
|
||||||
reconfigure_failures = 0
|
|
||||||
|
|
||||||
try:
|
|
||||||
r, dev = find_k400()
|
|
||||||
feature_index = wait_for_feature(dev, FEATURE_WAIT_SECONDS)
|
|
||||||
|
|
||||||
info = parse_info(dev.feature_request(RAW_FEATURE, 0x00))
|
|
||||||
LOG.info(
|
|
||||||
"K400 raw surface: %dx%d, dpi=%d, origin=%d, max_fingers=%d",
|
|
||||||
info.x_size, info.y_size, info.dpi, info.origin, info.max_fingers,
|
|
||||||
)
|
|
||||||
touchpad.configure(info)
|
|
||||||
|
|
||||||
def callback(n):
|
|
||||||
if n.devnumber != dev.number:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Receiver connection notification; the K400 forgets raw mode
|
|
||||||
# while asleep, so re-enable it on every link-up
|
|
||||||
if n.sub_id == 0x41:
|
|
||||||
flags = (n.data[0] & 0xF0) if n.data else 0x40
|
|
||||||
dev.online = not (flags & 0x40)
|
|
||||||
touchpad.release_all()
|
|
||||||
if dev.online:
|
|
||||||
LOG.debug("K400 link established; re-enabling raw mode")
|
|
||||||
reconfigure.set()
|
|
||||||
else:
|
|
||||||
LOG.debug("K400 asleep/offline")
|
|
||||||
return
|
|
||||||
|
|
||||||
if n.sub_id != feature_index or (n.address >> 4) != 0x00:
|
|
||||||
return
|
|
||||||
frame = parse_frame(n.data)
|
|
||||||
if frame is None:
|
|
||||||
LOG.warning("Short raw XY notification: %r", n.data)
|
|
||||||
return
|
|
||||||
touchpad.process(frame)
|
|
||||||
|
|
||||||
events = StartedEventsListener(r, callback)
|
|
||||||
events.start()
|
|
||||||
if not events.started_event.wait(timeout=3.0):
|
|
||||||
raise RuntimeError("Timed out starting HID++ receiver listener")
|
|
||||||
|
|
||||||
state_reply = dev.feature_request(RAW_FEATURE, 0x10)
|
|
||||||
old_raw_state = state_reply[0] if state_reply else 0x00
|
|
||||||
enable_raw_reports(dev)
|
|
||||||
raw_enabled = True
|
|
||||||
LOG.info("K400 raw touchpad active (receiver slot %d)", dev.number)
|
|
||||||
|
|
||||||
while not stop.is_set():
|
|
||||||
if not events.is_alive():
|
|
||||||
raise ConnectionError("HID++ receiver listener stopped")
|
|
||||||
if not reconfigure.wait(timeout=1.0):
|
|
||||||
continue
|
|
||||||
reconfigure.clear()
|
|
||||||
if stop.is_set():
|
|
||||||
break
|
|
||||||
|
|
||||||
touchpad.release_all()
|
|
||||||
try:
|
|
||||||
feature_index = wait_for_feature(dev, min(FEATURE_WAIT_SECONDS, 4.0))
|
|
||||||
enable_raw_reports(dev)
|
|
||||||
reconfigure_failures = 0
|
|
||||||
LOG.info("K400 raw mode re-enabled after wake")
|
|
||||||
except DeviceNotReady as exc:
|
|
||||||
reconfigure_failures = 0
|
|
||||||
LOG.debug("K400 went offline during re-enable (%s); waiting for next link-up", exc)
|
|
||||||
except Exception as exc:
|
|
||||||
reconfigure_failures += 1
|
|
||||||
if not events.is_alive() or reconfigure_failures >= 3:
|
|
||||||
raise ConnectionError("Repeated raw-mode re-enable failure") from exc
|
|
||||||
LOG.debug("Transient re-enable failure %d/3: %s", reconfigure_failures, exc)
|
|
||||||
if stop.wait(RECONNECT_DELAY_SECONDS):
|
|
||||||
break
|
|
||||||
reconfigure.set()
|
|
||||||
|
|
||||||
except DeviceNotReady as exc:
|
|
||||||
LOG.debug("K400 not ready (%s); retrying", exc)
|
|
||||||
except Exception as exc:
|
|
||||||
if stop.is_set():
|
|
||||||
break
|
|
||||||
LOG.warning(
|
|
||||||
"K400 HID++ session #%d lost (%s). Retrying in %.1f s.",
|
|
||||||
session, exc, RECONNECT_DELAY_SECONDS,
|
|
||||||
exc_info=LOG.isEnabledFor(logging.DEBUG),
|
|
||||||
)
|
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
touchpad.release_all()
|
|
||||||
except Exception:
|
|
||||||
LOG.debug("Error releasing touches", exc_info=True)
|
|
||||||
|
|
||||||
if stop.is_set() and dev is not None and raw_enabled:
|
|
||||||
try:
|
|
||||||
restore = 0x00 if old_raw_state is None else old_raw_state
|
|
||||||
dev.feature_request(RAW_FEATURE, 0x20, bytes([restore]))
|
|
||||||
LOG.info("Restored HID++ raw-report state to 0x%02X", restore)
|
|
||||||
except Exception:
|
|
||||||
LOG.warning("Could not restore raw-report state during shutdown")
|
|
||||||
|
|
||||||
if events is not None:
|
|
||||||
try:
|
|
||||||
events.stop()
|
|
||||||
events.join(timeout=2.0)
|
|
||||||
except Exception:
|
|
||||||
LOG.debug("Error stopping receiver listener", exc_info=True)
|
|
||||||
if r is not None:
|
|
||||||
try:
|
|
||||||
r.close()
|
|
||||||
except Exception:
|
|
||||||
LOG.debug("Error closing receiver", exc_info=True)
|
|
||||||
|
|
||||||
if not stop.is_set():
|
|
||||||
stop.wait(RECONNECT_DELAY_SECONDS)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description="Logitech K400 Plus raw touchpad bridge")
|
|
||||||
parser.add_argument("-v", "--verbose", action="count", default=0, help="-v for info, -vv for debug")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Keep Solaar's own logging at WARNING so journald isn't flooded with
|
|
||||||
# HID++ frames
|
|
||||||
logging.basicConfig(level=logging.WARNING, format="%(levelname)-8s %(name)s: %(message)s")
|
|
||||||
LOG.setLevel([logging.WARNING, logging.INFO, logging.DEBUG][min(args.verbose, 2)])
|
|
||||||
|
|
||||||
touchpad = VirtualTouchpad()
|
|
||||||
stop = threading.Event()
|
|
||||||
|
|
||||||
def on_signal(signum, _frame):
|
|
||||||
LOG.info("Received signal %s; stopping", signum)
|
|
||||||
stop.set()
|
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, on_signal)
|
|
||||||
signal.signal(signal.SIGTERM, on_signal)
|
|
||||||
try:
|
|
||||||
run(touchpad, stop)
|
|
||||||
finally:
|
|
||||||
touchpad.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -3,40 +3,33 @@
|
|||||||
networking = {
|
networking = {
|
||||||
hostName = "backwards";
|
hostName = "backwards";
|
||||||
|
|
||||||
wireless.enable = false;
|
networkmanager.enable = false;
|
||||||
|
|
||||||
networkmanager = {
|
#wireless.networks are defined in the secret `wpa_supplicant.conf`
|
||||||
|
wireless = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
wifi.backend = "iwd";
|
secretsFile = config.age.secrets.wireless-network-secrets.path;
|
||||||
|
|
||||||
ensureProfiles = {
|
networks = {
|
||||||
environmentFiles = [
|
"w1-f1_5G" = {
|
||||||
config.age.secrets.wireless-network-secrets.path
|
pskRaw = "ext:w1-f1_psk";
|
||||||
];
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
profiles = {
|
defaultGateway = "192.168.50.1";
|
||||||
w1-f1_5G = {
|
nameservers = [ "1.1.1.1" ];
|
||||||
connection = {
|
interfaces = {
|
||||||
id = "w1-f1_5G";
|
wlp1s0 = {
|
||||||
type = "wifi";
|
useDHCP = false;
|
||||||
interface-name = "wlp1s0";
|
ipv4 = {
|
||||||
};
|
addresses = [
|
||||||
wifi = {
|
{
|
||||||
ssid = "w1-f1_5G";
|
address = "192.168.50.202";
|
||||||
mode = "infrastructure";
|
prefixLength = 24;
|
||||||
};
|
}
|
||||||
wifi-security = {
|
];
|
||||||
key-mgmt = "wpa-psk";
|
|
||||||
psk = "$w1_f1_psk";
|
|
||||||
};
|
|
||||||
ipv4 = {
|
|
||||||
method = "manual";
|
|
||||||
addresses = "192.168.50.202/24";
|
|
||||||
gateway = "192.168.50.1";
|
|
||||||
dns = "1.1.1.1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
enabled = config.mod.restic.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
mod.restic = {
|
||||||
|
enable = lib.mkEnableOption "Enable restic";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf enabled {
|
||||||
|
fileSystems."/home/alex/backup" = {
|
||||||
|
device = "/dev/disk/by-uuid/34601701-65e6-4b2c-ac4d-8bef3dfd743f";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [ "nofail" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
|
restic.backups = {
|
||||||
|
"sync-to-external" = {
|
||||||
|
initialize = true;
|
||||||
|
|
||||||
|
passwordFile = config.age.secrets.restic-password.path;
|
||||||
|
|
||||||
|
paths = [ "/home/alex/sync" ];
|
||||||
|
repository = "/home/alex/backup/restic";
|
||||||
|
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "*-*-* 0/12:00:00"; # Every 12th hour, i.e. twice a day
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
pruneOpts = [
|
||||||
|
"--keep-daily 1"
|
||||||
|
"--keep-weekly 7"
|
||||||
|
"--keep-yearly 12"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
"sync-to-cloud" = {
|
||||||
|
initialize = true;
|
||||||
|
|
||||||
|
passwordFile = config.age.secrets.restic-password.path;
|
||||||
|
environmentFile = config.age.secrets.restic-cloud-sync-key.path;
|
||||||
|
repositoryFile = config.age.secrets.restic-cloud-sync-repository.path;
|
||||||
|
|
||||||
|
paths = [ "/home/alex/sync" ];
|
||||||
|
exclude = [ "/home/alex/sync/reading-material" ];
|
||||||
|
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "*-*-* 0/12:00:00"; # Every 12th hour, i.e. twice a day
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
pruneOpts = [
|
||||||
|
"--keep-daily 1"
|
||||||
|
"--keep-weekly 7"
|
||||||
|
"--keep-yearly 12"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
age = {
|
||||||
|
secrets = {
|
||||||
|
"restic-password".file = ../../../../secrets/backwards/restic-password.age;
|
||||||
|
"restic-cloud-sync-key".file = ../../../../secrets/backwards/restic-cloud-sync-key.age;
|
||||||
|
"restic-cloud-sync-repository".file =
|
||||||
|
../../../../secrets/backwards/restic-cloud-sync-repository.age;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -21,39 +21,23 @@ in
|
|||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
programs.ssh = {
|
programs.ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableDefaultConfig = false;
|
|
||||||
|
|
||||||
settings = {
|
matchBlocks = {
|
||||||
"manatee" = {
|
"manatee" = {
|
||||||
HostName = "manatee";
|
hostname = "manatee";
|
||||||
User = "alex";
|
user = "alex";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.backwards-manatee";
|
identityFile = "/home/alex/.ssh/alex.backwards-manatee";
|
||||||
Port = 1122;
|
port = 1122;
|
||||||
};
|
|
||||||
|
|
||||||
"pinwheel" = {
|
|
||||||
HostName = "pinwheel";
|
|
||||||
User = "alex";
|
|
||||||
IdentityFile = "/home/alex/.ssh/alex.backwards-pinwheel";
|
|
||||||
Port = 1122;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
"git.ppp.pm" = {
|
"git.ppp.pm" = {
|
||||||
HostName = "git.ppp.pm";
|
hostname = "git.ppp.pm";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.backwards-git.ppp.pm";
|
identityFile = "/home/alex/.ssh/alex.backwards-git.ppp.pm";
|
||||||
};
|
};
|
||||||
|
|
||||||
"*" = {
|
"codeberg.org" = {
|
||||||
ForwardAgent = false;
|
hostname = "codeberg.org";
|
||||||
AddKeysToAgent = "no";
|
identityFile = "/home/alex/.ssh/alex.backwards-codeberg.org";
|
||||||
Compression = false;
|
|
||||||
ServerAliveInterval = 0;
|
|
||||||
ServerAliveCountMax = 3;
|
|
||||||
HashKnownHosts = false;
|
|
||||||
UserKnownHostsFile = "~/.ssh/known_hosts";
|
|
||||||
ControlMaster = "no";
|
|
||||||
ControlPath = "~/.ssh/master-%r@%n:%p";
|
|
||||||
ControlPersist = "no";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -122,19 +106,6 @@ in
|
|||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
"alex.backwards-pinwheel" = {
|
|
||||||
file = ../../../../secrets/backwards/alex.backwards-pinwheel.age;
|
|
||||||
path = "/home/alex/.ssh/alex.backwards-pinwheel";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
"alex.backwards-pinwheel.pub" = {
|
|
||||||
file = ../../../../secrets/backwards/alex.backwards-pinwheel.pub.age;
|
|
||||||
path = "/home/alex/.ssh/alex.backwards-pinwheel.pub";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
|
|
||||||
"alex.pinwheel-backwards.pub" = {
|
"alex.pinwheel-backwards.pub" = {
|
||||||
file = ../../../../secrets/pinwheel/alex.pinwheel-backwards.pub.age;
|
file = ../../../../secrets/pinwheel/alex.pinwheel-backwards.pub.age;
|
||||||
path = "${authorizedKeysPath}/alex.pinwheel-backwards.pub";
|
path = "${authorizedKeysPath}/alex.pinwheel-backwards.pub";
|
||||||
@@ -152,6 +123,19 @@ in
|
|||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"alex.backwards-codeberg.org" = {
|
||||||
|
file = ../../../../secrets/backwards/alex.backwards-codeberg.org.age;
|
||||||
|
path = "/home/alex/.ssh/alex.backwards-codeberg.org";
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
|
"alex.backwards-codeberg.org.pub" = {
|
||||||
|
file = ../../../../secrets/backwards/alex.backwards-codeberg.org.pub.age;
|
||||||
|
path = "/home/alex/.ssh/alex.backwards-codeberg.org.pub";
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
enabled = config.mod.syncthing.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
mod.syncthing = {
|
||||||
|
enable = lib.mkEnableOption "Enable syncthing module";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf enabled {
|
||||||
|
services.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
openDefaultPorts = true;
|
||||||
|
|
||||||
|
cert = config.age.secrets.syncthing-cert.path;
|
||||||
|
key = config.age.secrets.syncthing-key.path;
|
||||||
|
|
||||||
|
user = "alex";
|
||||||
|
group = "users";
|
||||||
|
|
||||||
|
dataDir = "/home/alex/sync";
|
||||||
|
|
||||||
|
guiAddress = "0.0.0.0:8384";
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
gui = {
|
||||||
|
user = "syncthing";
|
||||||
|
password = "$2a$12$J/h/JOUiW24ZXsLYLEl2kOZUS1LftxANi0OlZxLy8Dst3/jpBd0v2";
|
||||||
|
insecureSkipHostcheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
devices = {
|
||||||
|
phone.id = config.lib.syncthing.phone;
|
||||||
|
pinwheel.id = config.lib.syncthing.pinwheel;
|
||||||
|
tablet.id = config.lib.syncthing.tablet;
|
||||||
|
};
|
||||||
|
|
||||||
|
folders = {
|
||||||
|
org = {
|
||||||
|
path = "/home/alex/sync/org";
|
||||||
|
devices = [
|
||||||
|
"phone"
|
||||||
|
"pinwheel"
|
||||||
|
];
|
||||||
|
versioning = {
|
||||||
|
type = "staggered";
|
||||||
|
params = {
|
||||||
|
maxage = "2592000"; # 30 days
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
personal = {
|
||||||
|
path = "/home/alex/sync/personal";
|
||||||
|
devices = [ "pinwheel" ];
|
||||||
|
versioning = {
|
||||||
|
type = "staggered";
|
||||||
|
params = {
|
||||||
|
maxAge = "2592000"; # 30 days
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
work = {
|
||||||
|
path = "/home/alex/sync/work";
|
||||||
|
devices = [ "pinwheel" ];
|
||||||
|
versioning = {
|
||||||
|
type = "staggered";
|
||||||
|
params = {
|
||||||
|
maxAge = "2592000"; # 30 days
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
books = {
|
||||||
|
path = "/home/alex/sync/reading-material/books";
|
||||||
|
devices = [ "pinwheel" ];
|
||||||
|
versioning = {
|
||||||
|
type = "staggered";
|
||||||
|
params = {
|
||||||
|
maxAge = "2592000"; # 30 days
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
"phone-gps" = {
|
||||||
|
path = "/home/alex/sync/phone-gps";
|
||||||
|
devices = [ "phone" ];
|
||||||
|
versioning = {
|
||||||
|
type = "staggered";
|
||||||
|
params = {
|
||||||
|
maxage = "2592000"; # 30 days
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
age = {
|
||||||
|
secrets = {
|
||||||
|
"syncthing-cert".file = ../../../../secrets/backwards/syncthing-cert.age;
|
||||||
|
"syncthing-key".file = ../../../../secrets/backwards/syncthing-key.age;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,49 +1,9 @@
|
|||||||
|
{ ... }:
|
||||||
{
|
{
|
||||||
config,
|
services.tailscale.enable = true;
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
services.tailscale = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
# Required for the systray to control tailscale without root
|
|
||||||
extraSetFlags = [ "--operator=alex" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
checkReversePath = "loose";
|
checkReversePath = "loose";
|
||||||
allowedUDPPorts = [ 41641 ];
|
allowedUDPPorts = [ 41641 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager.users.alex = {
|
|
||||||
# The official tailscale systray, including the node list and exit nodes
|
|
||||||
services.tailscale-systray = {
|
|
||||||
enable = true;
|
|
||||||
package = config.services.tailscale.package;
|
|
||||||
};
|
|
||||||
|
|
||||||
# The systray never retries if no tray exists when it starts, so wait for the
|
|
||||||
# AppIndicator extension to provide one. This is done in the main process,
|
|
||||||
# rather than `ExecStartPre`, to not block activation while waiting
|
|
||||||
systemd.user.services.tailscale-systray.Service.ExecStart = lib.mkForce (toString (
|
|
||||||
pkgs.writeShellScript "tailscale-systray" ''
|
|
||||||
until ${pkgs.systemd}/bin/busctl --user status org.kde.StatusNotifierWatcher >/dev/null 2>&1; do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
exec ${lib.getExe config.services.tailscale.package} systray
|
|
||||||
''
|
|
||||||
));
|
|
||||||
|
|
||||||
programs.gnome-shell = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
extensions = [
|
|
||||||
# GNOME has no system tray without it
|
|
||||||
{ package = pkgs.gnomeExtensions.appindicator; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -79,19 +79,11 @@
|
|||||||
{ device = config.disko.devices.disk.root.device; }
|
{ device = config.disko.devices.disk.root.device; }
|
||||||
{ device = config.disko.devices.disk.disk1.device; }
|
{ device = config.disko.devices.disk.disk1.device; }
|
||||||
{ device = config.disko.devices.disk.disk2.device; }
|
{ device = config.disko.devices.disk.disk2.device; }
|
||||||
{ device = config.disko.devices.disk.disk3.device; }
|
|
||||||
{ device = config.disko.devices.disk.disk4.device; }
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.zfs.autoScrub.enable = true;
|
services.zfs.autoScrub.enable = true;
|
||||||
|
|
||||||
# Cap the ARC at 4 GiB (default is ~all of RAM); leaves room for services on this low-memory host.
|
|
||||||
boot.kernelParams = [ "zfs.zfs_arc_max=${toString (4 * 1024 * 1024 * 1024)}" ];
|
|
||||||
|
|
||||||
# Don't force-import the pool if it appears in use elsewhere; safer default in 26.11+.
|
|
||||||
boot.zfs.forceImportRoot = false;
|
|
||||||
|
|
||||||
networking.hostId = "0a9474e7"; # Required by ZFS
|
networking.hostId = "0a9474e7"; # Required by ZFS
|
||||||
disko.devices = {
|
disko.devices = {
|
||||||
disk = {
|
disk = {
|
||||||
@@ -157,39 +149,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
disk3 = {
|
|
||||||
type = "disk";
|
|
||||||
device = "/dev/disk/by-id/ata-TOSHIBA_MG10ACA20TE_85K2A0UCF4MJ";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
zfs = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "zfs";
|
|
||||||
pool = "storage";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
disk4 = {
|
|
||||||
type = "disk";
|
|
||||||
device = "/dev/disk/by-id/ata-TOSHIBA_MG10ACA20TE_85K2A0V6F4MJ";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
zfs = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "zfs";
|
|
||||||
pool = "storage";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
zpool = {
|
zpool = {
|
||||||
@@ -207,13 +166,6 @@
|
|||||||
"disk2"
|
"disk2"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
|
||||||
mode = "mirror";
|
|
||||||
members = [
|
|
||||||
"disk3"
|
|
||||||
"disk4"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,13 +26,6 @@
|
|||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
swapDevices = [
|
|
||||||
{
|
|
||||||
device = "/swapfile";
|
|
||||||
size = 32 * 1024; # 32GB
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
# still possible to use this option, but it's recommended to use it in conjunction
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ inputs, pkgs, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
imports = [ inputs.home-manager.nixosModules.home-manager ];
|
imports = [ inputs.home-manager.nixosModules.home-manager ];
|
||||||
|
|
||||||
@@ -13,11 +13,7 @@
|
|||||||
home.username = "alex";
|
home.username = "alex";
|
||||||
home.homeDirectory = "/home/alex";
|
home.homeDirectory = "/home/alex";
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [ ];
|
||||||
pkgs.streamrip
|
|
||||||
pkgs.claude-code
|
|
||||||
pkgs.wl-clipboard
|
|
||||||
];
|
|
||||||
|
|
||||||
home.stateVersion = "24.11";
|
home.stateVersion = "24.11";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
inputs.agenix.packages."${pkgs.stdenv.hostPlatform.system}".default
|
inputs.agenix.packages."${pkgs.system}".default
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{ lib, config, ... }:
|
|
||||||
let
|
|
||||||
enabled = config.mod.atuin.enable;
|
|
||||||
port = 8889;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.atuin = {
|
|
||||||
enable = lib.mkEnableOption "Enable atuin module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
services.atuin = {
|
|
||||||
enable = true;
|
|
||||||
host = "0.0.0.0";
|
|
||||||
inherit port;
|
|
||||||
openFirewall = true;
|
|
||||||
openRegistration = false;
|
|
||||||
database.createLocally = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -10,14 +10,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Audiobookshelf";
|
|
||||||
port = 8000;
|
|
||||||
description = "Audiobooks & podcasts";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
users.users.audiobookshelf = {
|
users.users.audiobookshelf = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
description = "audiobookshelf";
|
description = "audiobookshelf";
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
tmp.cleanOnBoot = true;
|
|
||||||
|
|
||||||
loader = {
|
loader = {
|
||||||
systemd-boot = {
|
systemd-boot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
enabled = config.mod.calibre-web.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
mod.calibre-web = {
|
||||||
|
enable = lib.mkEnableOption "add calibre-web module";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf enabled {
|
||||||
|
services = {
|
||||||
|
calibre-web = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
user = "storage";
|
||||||
|
group = "storage";
|
||||||
|
|
||||||
|
listen = {
|
||||||
|
ip = "0.0.0.0";
|
||||||
|
port = 8083;
|
||||||
|
};
|
||||||
|
|
||||||
|
dataDir = "/mnt/media/public/books";
|
||||||
|
|
||||||
|
options = {
|
||||||
|
calibreLibrary = "/mnt/media/public/books";
|
||||||
|
enableBookUploading = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nginx = {
|
||||||
|
virtualHosts."books.ppp.pm" = {
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
client_max_body_size 1024M;
|
||||||
|
'';
|
||||||
|
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://0.0.0.0:8083"; # TODO add option for port + host
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
{ config, lib, ... }:
|
|
||||||
let
|
|
||||||
# Every host is issued the same way: a DNS-01 challenge through Hetzner.
|
|
||||||
hetznerCert = {
|
|
||||||
dnsProvider = "hetzner";
|
|
||||||
environmentFile = config.age.secrets.hetzner-dns.path;
|
|
||||||
group = "nginx";
|
|
||||||
|
|
||||||
# Flag names are lego v5's (v4 spelled them --dns.propagation-wait and
|
|
||||||
# --dns-timeout).
|
|
||||||
extraLegoFlags = [
|
|
||||||
"--dns.resolvers=1.1.1.1:53,8.8.8.8:53"
|
|
||||||
"--dns.propagation.wait=60s" # Wait for 60 seconds for DNS propagation
|
|
||||||
"--dns.timeout=60"
|
|
||||||
"--http-timeout=60"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
security.acme = {
|
|
||||||
acceptTerms = true;
|
|
||||||
|
|
||||||
defaults = {
|
|
||||||
email = "acme@ppp.pm";
|
|
||||||
};
|
|
||||||
|
|
||||||
certs = lib.genAttrs [
|
|
||||||
"ha.ppp.pm"
|
|
||||||
"komga.ppp.pm"
|
|
||||||
"romm.ppp.pm"
|
|
||||||
"puppy.ppp.pm"
|
|
||||||
"todo.ppp.pm"
|
|
||||||
"schema.ppp.pm"
|
|
||||||
"dagbok.ppp.pm"
|
|
||||||
] (_: hetznerCert);
|
|
||||||
};
|
|
||||||
|
|
||||||
age = {
|
|
||||||
secrets = {
|
|
||||||
"hetzner-dns".file = ../../../../secrets/manatee/hetzner-dns.age;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.dagbok.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
port = 8093;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.dagbok = {
|
|
||||||
enable = lib.mkEnableOption "Enable dagbok module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.dagbok.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Dagbok";
|
|
||||||
port = port;
|
|
||||||
description = "Work and personal journal";
|
|
||||||
url = "https://dagbok.ppp.pm";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services.dagbok = {
|
|
||||||
enable = true;
|
|
||||||
address = "127.0.0.1";
|
|
||||||
inherit port;
|
|
||||||
secureCookies = true;
|
|
||||||
timeZone = "Europe/Stockholm";
|
|
||||||
publicUrl = "https://dagbok.ppp.pm";
|
|
||||||
tokenFile = config.age.secrets."dagbok-token".path;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = lib.mkIf nginxEnabled {
|
|
||||||
virtualHosts."dagbok.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "dagbok.ppp.pm";
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size 32m;
|
|
||||||
'';
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:${toString port}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."dagbok-token".file = ../../../../secrets/manatee/dagbok-token.age;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -12,25 +12,14 @@ in
|
|||||||
|
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
git.enable = true;
|
git.enable = true;
|
||||||
tmux.enable = true;
|
|
||||||
|
|
||||||
nginx.enable = true;
|
nginx.enable = true;
|
||||||
syncthing.enable = true;
|
syncthing.enable = true;
|
||||||
restic.enable = true;
|
|
||||||
transmission.enable = true;
|
transmission.enable = true;
|
||||||
|
calibre-web.enable = true;
|
||||||
audiobookshelf.enable = true;
|
audiobookshelf.enable = true;
|
||||||
jellyfin.enable = true;
|
jellyfin.enable = true;
|
||||||
immich.enable = false;
|
immich.enable = true;
|
||||||
navidrome.enable = true;
|
|
||||||
komga.enable = true;
|
|
||||||
romm.enable = true;
|
|
||||||
homepage.enable = true;
|
|
||||||
disk-smart.enable = true;
|
|
||||||
puppy-tracker.enable = true;
|
|
||||||
todo.enable = true;
|
|
||||||
schema.enable = true;
|
|
||||||
atuin.enable = true;
|
|
||||||
dagbok.enable = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.disk-smart.enable;
|
|
||||||
|
|
||||||
disks = [
|
|
||||||
{ path = "/dev/disk/by-id/ata-ST8000VN004-3CP101_WWZ8QCG4"; name = "seagate_8tb_1"; label = "Seagate 8TB #1"; }
|
|
||||||
{ path = "/dev/disk/by-id/ata-ST8000VN004-3CP101_WWZ8QDJ5"; name = "seagate_8tb_2"; label = "Seagate 8TB #2"; }
|
|
||||||
{ path = "/dev/disk/by-id/ata-TOSHIBA_MG10ACA20TE_85K2A0UCF4MJ"; name = "toshiba_20tb_1"; label = "Toshiba 20TB #1"; }
|
|
||||||
{ path = "/dev/disk/by-id/ata-TOSHIBA_MG10ACA20TE_85K2A0V6F4MJ"; name = "toshiba_20tb_2"; label = "Toshiba 20TB #2"; }
|
|
||||||
];
|
|
||||||
|
|
||||||
outputDir = "/var/lib/disk-smart";
|
|
||||||
|
|
||||||
collectScript = pkgs.writeShellScript "disk-smart-collect" ''
|
|
||||||
set -euo pipefail
|
|
||||||
export PATH="${lib.makeBinPath [ pkgs.smartmontools pkgs.jq pkgs.coreutils ]}"
|
|
||||||
|
|
||||||
mkdir -p ${outputDir}
|
|
||||||
|
|
||||||
result="{"
|
|
||||||
|
|
||||||
${lib.concatMapStringsSep "\n" (disk: ''
|
|
||||||
raw=$(smartctl -j -A -H ${disk.path} 2>/dev/null || true)
|
|
||||||
|
|
||||||
temp=$(echo "$raw" | jq -r '.temperature.current // empty')
|
|
||||||
power_on=$(echo "$raw" | jq -r '.power_on_time.hours // empty')
|
|
||||||
smart_status=$(echo "$raw" | jq -r '.smart_status.passed // empty')
|
|
||||||
reallocated=$(echo "$raw" | jq -r '[.ata_smart_attributes.table[] | select(.name == "Reallocated_Sector_Ct")][0].raw.value // empty')
|
|
||||||
pending=$(echo "$raw" | jq -r '[.ata_smart_attributes.table[] | select(.name == "Current_Pending_Sector")][0].raw.value // empty')
|
|
||||||
|
|
||||||
result="$result\"${disk.name}\":{\"temperature\":$temp,\"power_on_hours\":$power_on,\"smart_passed\":$smart_status,\"reallocated_sectors\":$reallocated,\"pending_sectors\":$pending},"
|
|
||||||
'') disks}
|
|
||||||
|
|
||||||
# Remove trailing comma, close object
|
|
||||||
result="''${result%,}}"
|
|
||||||
|
|
||||||
echo "$result" | jq . > ${outputDir}/smart.json.tmp
|
|
||||||
mv ${outputDir}/smart.json.tmp ${outputDir}/smart.json
|
|
||||||
'';
|
|
||||||
|
|
||||||
indent = prefix: s:
|
|
||||||
lib.concatMapStringsSep "\n"
|
|
||||||
(line: if line == "" then line else prefix + line)
|
|
||||||
(lib.splitString "\n" s);
|
|
||||||
|
|
||||||
mkSensor = disk: ''
|
|
||||||
- name: "${disk.label} Temperature"
|
|
||||||
value_template: "{{ value_json.${disk.name}.temperature }}"
|
|
||||||
unit_of_measurement: "°C"
|
|
||||||
device_class: temperature
|
|
||||||
state_class: measurement
|
|
||||||
- name: "${disk.label} Power On Hours"
|
|
||||||
value_template: "{{ value_json.${disk.name}.power_on_hours }}"
|
|
||||||
unit_of_measurement: "h"
|
|
||||||
state_class: total_increasing
|
|
||||||
- name: "${disk.label} SMART Passed"
|
|
||||||
value_template: "{{ value_json.${disk.name}.smart_passed }}"
|
|
||||||
- name: "${disk.label} Reallocated Sectors"
|
|
||||||
value_template: "{{ value_json.${disk.name}.reallocated_sectors }}"
|
|
||||||
state_class: measurement
|
|
||||||
- name: "${disk.label} Pending Sectors"
|
|
||||||
value_template: "{{ value_json.${disk.name}.pending_sectors }}"
|
|
||||||
state_class: measurement
|
|
||||||
'';
|
|
||||||
|
|
||||||
sensorYaml = indent " " (lib.concatMapStrings mkSensor disks);
|
|
||||||
|
|
||||||
sectorEntities = lib.concatMap (disk: [
|
|
||||||
"sensor.${disk.name}_reallocated_sectors"
|
|
||||||
"sensor.${disk.name}_pending_sectors"
|
|
||||||
]) disks;
|
|
||||||
|
|
||||||
sectorEntitiesYaml = lib.concatMapStringsSep "\n"
|
|
||||||
(id: " - ${id}") sectorEntities;
|
|
||||||
|
|
||||||
smartPassedEntities = map (disk: "sensor.${disk.name}_smart_passed") disks;
|
|
||||||
|
|
||||||
smartPassedEntitiesYaml = lib.concatMapStringsSep "\n"
|
|
||||||
(id: " - ${id}") smartPassedEntities;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.disk-smart = {
|
|
||||||
enable = lib.mkEnableOption "Enable disk SMART monitoring module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.home-assistant.extraConfig = ''
|
|
||||||
rest:
|
|
||||||
- resource: http://127.0.0.1:9633/smart.json
|
|
||||||
scan_interval: 60
|
|
||||||
sensor:
|
|
||||||
${sensorYaml}
|
|
||||||
automation disk_smart:
|
|
||||||
- alias: "Disk sector count increased"
|
|
||||||
trigger:
|
|
||||||
- platform: state
|
|
||||||
entity_id:
|
|
||||||
${sectorEntitiesYaml}
|
|
||||||
condition:
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ trigger.from_state.state | int(-1) >= 0 and trigger.to_state.state | int(0) > trigger.from_state.state | int(0) }}"
|
|
||||||
action:
|
|
||||||
- service: notify.mobile_app_pixel_9_pro
|
|
||||||
data:
|
|
||||||
title: "Disk SMART warning"
|
|
||||||
message: "{{ trigger.to_state.attributes.friendly_name }} increased from {{ trigger.from_state.state }} to {{ trigger.to_state.state }}"
|
|
||||||
- alias: "Disk SMART check failed"
|
|
||||||
trigger:
|
|
||||||
- platform: state
|
|
||||||
entity_id:
|
|
||||||
${smartPassedEntitiesYaml}
|
|
||||||
condition:
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ trigger.to_state.state | lower == 'false' }}"
|
|
||||||
action:
|
|
||||||
- service: notify.mobile_app_pixel_9_pro
|
|
||||||
data:
|
|
||||||
title: "Disk SMART FAILURE"
|
|
||||||
message: "{{ trigger.to_state.attributes.friendly_name }} reports SMART failure — drive is likely failing"
|
|
||||||
'';
|
|
||||||
|
|
||||||
systemd.services.disk-smart-collect = {
|
|
||||||
description = "Collect disk SMART data";
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
ExecStart = collectScript;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.timers.disk-smart-collect = {
|
|
||||||
description = "Periodically collect disk SMART data";
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnBootSec = "1min";
|
|
||||||
OnUnitActiveSec = "1min";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx.virtualHosts."127.0.0.1" = {
|
|
||||||
listen = [
|
|
||||||
{ addr = "127.0.0.1"; port = 9633; }
|
|
||||||
];
|
|
||||||
|
|
||||||
locations."= /smart.json" = {
|
|
||||||
alias = "${outputDir}/smart.json";
|
|
||||||
extraConfig = ''
|
|
||||||
default_type application/json;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ in
|
|||||||
{ path = ./gitconfig; }
|
{ path = ./gitconfig; }
|
||||||
];
|
];
|
||||||
|
|
||||||
settings = {
|
extraConfig = {
|
||||||
rerere.enable = true;
|
rerere.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,371 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
cfg = config.mod.home-assistant;
|
|
||||||
|
|
||||||
configFile = pkgs.writeText "ha-configuration.yaml" ''
|
|
||||||
# Loads default set of integrations. Do not remove.
|
|
||||||
default_config:
|
|
||||||
|
|
||||||
http:
|
|
||||||
use_x_forwarded_for: true
|
|
||||||
trusted_proxies:
|
|
||||||
- 127.0.0.1
|
|
||||||
|
|
||||||
# Load frontend themes from the themes folder
|
|
||||||
frontend:
|
|
||||||
themes: !include_dir_merge_named themes
|
|
||||||
|
|
||||||
automation: !include automations.yaml
|
|
||||||
automation nix:
|
|
||||||
# pyplejd keeps using a dead BLE client forever ("Service Discovery has not
|
|
||||||
# been performed yet") instead of reconnecting; reloading the integration fixes it
|
|
||||||
- alias: Reload Plejd when its BLE link goes stale
|
|
||||||
mode: single
|
|
||||||
triggers:
|
|
||||||
- trigger: event
|
|
||||||
event_type: system_log_event
|
|
||||||
event_data:
|
|
||||||
level: WARNING
|
|
||||||
conditions:
|
|
||||||
- "{{ 'pyplejd' in trigger.event.data.name and 'Service Discovery has not been performed yet' in (trigger.event.data.message | join(' ')) }}"
|
|
||||||
actions:
|
|
||||||
- action: homeassistant.reload_config_entry
|
|
||||||
target:
|
|
||||||
entity_id: light.takbelysning
|
|
||||||
# With mode: single, this caps it at one reload per 5 minutes
|
|
||||||
- delay: "00:05:00"
|
|
||||||
|
|
||||||
script: !include scripts.yaml
|
|
||||||
scene: !include scenes.yaml
|
|
||||||
|
|
||||||
recorder:
|
|
||||||
purge_keep_days: 365
|
|
||||||
|
|
||||||
# Turns logged warnings/errors into `system_log_event`s that automations can react to
|
|
||||||
system_log:
|
|
||||||
fire_event: true
|
|
||||||
|
|
||||||
notify:
|
|
||||||
# Send notifications to `phones` so they reach every phone
|
|
||||||
- platform: group
|
|
||||||
name: phones
|
|
||||||
services:
|
|
||||||
- action: mobile_app_pixel_9_pro
|
|
||||||
- action: mobile_app_iphone
|
|
||||||
|
|
||||||
template:
|
|
||||||
- binary_sensor:
|
|
||||||
- name: Galleriet too warm
|
|
||||||
unique_id: galleriet_too_warm
|
|
||||||
state: "{{ states('sensor.3rd_temp_och_fuktmatare_temperature') | float(0) > 23 }}"
|
|
||||||
availability: "{{ has_value('sensor.3rd_temp_och_fuktmatare_temperature') }}"
|
|
||||||
# Stops a temperature hovering around 23 from re-triggering the alert
|
|
||||||
delay_off: "00:15:00"
|
|
||||||
|
|
||||||
alert:
|
|
||||||
fridge_door:
|
|
||||||
name: Fridge is open
|
|
||||||
done_message: Fride is closed
|
|
||||||
entity_id: binary_sensor.kyldorr
|
|
||||||
state: "on"
|
|
||||||
repeat: 2
|
|
||||||
skip_first: true
|
|
||||||
notifiers:
|
|
||||||
- phones
|
|
||||||
|
|
||||||
kitchen_water_leak:
|
|
||||||
name: Water leak detected in the kitchen
|
|
||||||
done_message: Kitchen is dry again
|
|
||||||
entity_id: binary_sensor.vattenlackage_1_flood
|
|
||||||
state: "on"
|
|
||||||
repeat: 5
|
|
||||||
notifiers:
|
|
||||||
- phones
|
|
||||||
data:
|
|
||||||
ttl: 0
|
|
||||||
priority: high
|
|
||||||
# Plays on the alarm stream so it sounds even when the phone is silenced
|
|
||||||
channel: alarm_stream
|
|
||||||
# iOS equivalent: a critical alert, which bypasses silent mode and Focus
|
|
||||||
push:
|
|
||||||
sound:
|
|
||||||
name: default
|
|
||||||
critical: 1
|
|
||||||
volume: 1.0
|
|
||||||
|
|
||||||
galleriet_too_warm:
|
|
||||||
name: Galleriet is above 23°C
|
|
||||||
message: "Galleriet is {{ states('sensor.3rd_temp_och_fuktmatare_temperature') }}°C"
|
|
||||||
done_message: Galleriet is below 23°C again
|
|
||||||
entity_id: binary_sensor.galleriet_too_warm
|
|
||||||
state: "on"
|
|
||||||
repeat: 60
|
|
||||||
notifiers:
|
|
||||||
- mobile_app_pixel_9_pro
|
|
||||||
|
|
||||||
${cfg.extraConfig}'';
|
|
||||||
|
|
||||||
btResetScript = pkgs.writeShellScript "bt-reset" ''
|
|
||||||
set -euo pipefail
|
|
||||||
export PATH="${
|
|
||||||
lib.makeBinPath [
|
|
||||||
pkgs.bluez
|
|
||||||
pkgs.util-linux
|
|
||||||
pkgs.kmod
|
|
||||||
pkgs.gnugrep
|
|
||||||
pkgs.coreutils
|
|
||||||
pkgs.systemd
|
|
||||||
]
|
|
||||||
}"
|
|
||||||
|
|
||||||
logger -t bt-reset "Starting Bluetooth adapter reset..."
|
|
||||||
|
|
||||||
# Exit early if the adapter is already present and running
|
|
||||||
if hciconfig hci0 2>/dev/null | grep -q "UP RUNNING"; then
|
|
||||||
logger -t bt-reset "hci0 is already UP RUNNING — nothing to do"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If hci0 exists but isn't UP, try bringing it up
|
|
||||||
if hciconfig hci0 2>/dev/null; then
|
|
||||||
logger -t bt-reset "hci0 exists but not running — bringing it up"
|
|
||||||
hciconfig hci0 up || true
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
if hciconfig hci0 2>/dev/null | grep -q "UP RUNNING"; then
|
|
||||||
logger -t bt-reset "hci0 is UP now"
|
|
||||||
systemctl restart bluetooth.service
|
|
||||||
logger -t bt-reset "bluetooth.service restarted — done"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Hard reset: reload the btusb kernel module (works for USB adapters)
|
|
||||||
logger -t bt-reset "hci0 missing — reloading btusb module..."
|
|
||||||
modprobe -r btusb 2>/dev/null || true
|
|
||||||
sleep 3
|
|
||||||
modprobe btusb
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
if hciconfig hci0 2>/dev/null; then
|
|
||||||
hciconfig hci0 up
|
|
||||||
logger -t bt-reset "hci0 restored after module reload"
|
|
||||||
else
|
|
||||||
logger -t bt-reset "ERROR: hci0 not found after module reload"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the bluetooth systemd service so bluetoothd picks up the adapter
|
|
||||||
systemctl restart bluetooth.service
|
|
||||||
logger -t bt-reset "bluetooth.service restarted — done"
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.home-assistant = {
|
|
||||||
extraConfig = lib.mkOption {
|
|
||||||
type = lib.types.lines;
|
|
||||||
default = "";
|
|
||||||
description = "Extra YAML to append to Home Assistant's configuration.yaml";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Home Assistant";
|
|
||||||
port = 8123;
|
|
||||||
description = "Home automation";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
hardware.bluetooth.enable = true;
|
|
||||||
|
|
||||||
# Give up and enter a `failed` state (visible in `systemctl --failed`) if the
|
|
||||||
# container restarts more than 5 times in 5 minutes, instead of crash-looping
|
|
||||||
# forever. The window is deliberately long: a slow crash-loop (~5s per attempt)
|
|
||||||
# stays under systemd's default 5-starts-per-10s limit and would otherwise
|
|
||||||
# retry indefinitely.
|
|
||||||
systemd.services.podman-homeassistant = {
|
|
||||||
startLimitIntervalSec = 300;
|
|
||||||
startLimitBurst = 5;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtualisation.oci-containers = {
|
|
||||||
backend = "podman";
|
|
||||||
|
|
||||||
containers.homeassistant = {
|
|
||||||
image = "ghcr.io/home-assistant/home-assistant:stable";
|
|
||||||
|
|
||||||
volumes = [
|
|
||||||
"/home/alex/.config/home-assistant:/config"
|
|
||||||
"${configFile}:/config/configuration.yaml:ro"
|
|
||||||
# Pass in bluetooth
|
|
||||||
"/run/dbus:/run/dbus:ro"
|
|
||||||
];
|
|
||||||
|
|
||||||
environment.TZ = "Europe/Stockholm";
|
|
||||||
|
|
||||||
extraOptions = [
|
|
||||||
"--network=host"
|
|
||||||
|
|
||||||
# Allows HA to perform low-level network operations (scan/reset adapter)
|
|
||||||
"--cap-add=NET_ADMIN"
|
|
||||||
"--cap-add=NET_RAW"
|
|
||||||
|
|
||||||
# Pass in Zigbee antenna
|
|
||||||
"--device=/dev/serial/by-id/usb-Nabu_Casa_ZBT-2_9C139EAAD464-if00:/dev/ttyACM0"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services = {
|
|
||||||
blueman.enable = true;
|
|
||||||
|
|
||||||
nginx = lib.mkIf nginxEnabled {
|
|
||||||
recommendedProxySettings = true;
|
|
||||||
|
|
||||||
virtualHosts."ha.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "ha.ppp.pm";
|
|
||||||
|
|
||||||
extraConfig = ''
|
|
||||||
proxy_buffering off;
|
|
||||||
'';
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:8123";
|
|
||||||
proxyWebsockets = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Trigger reset via udev when hci0 disappears
|
|
||||||
udev.extraRules = ''
|
|
||||||
ACTION=="remove", SUBSYSTEM=="bluetooth", KERNEL=="hci0", \
|
|
||||||
TAG+="systemd", ENV{SYSTEMD_WANTS}+="bt-reset.service"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd = {
|
|
||||||
services = {
|
|
||||||
# Trigger reset on bluetoothd failure
|
|
||||||
bluetooth = {
|
|
||||||
unitConfig.OnFailure = [ "bt-reset.service" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
bt-reset = {
|
|
||||||
description = "Reset Bluetooth adapter";
|
|
||||||
after = [ "bluetooth.service" ];
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
ExecStart = btResetScript;
|
|
||||||
|
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = "10s";
|
|
||||||
StartLimitIntervalSec = "120";
|
|
||||||
StartLimitBurst = 3;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
timers.bt-reset = {
|
|
||||||
description = "Periodically reset Bluetooth adapter";
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnBootSec = "5min"; # first run 5 min after boot
|
|
||||||
OnUnitActiveSec = "4h"; # then every 4 hours
|
|
||||||
RandomizedDelaySec = "5min";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
user = {
|
|
||||||
timers = {
|
|
||||||
"update-hetzner-dns" = {
|
|
||||||
unitConfig = {
|
|
||||||
Description = "updates Hetzner DNS records";
|
|
||||||
};
|
|
||||||
|
|
||||||
timerConfig = {
|
|
||||||
Unit = "update-hetzner-dns.service";
|
|
||||||
OnCalendar = "*-*-* *:00/30:00";
|
|
||||||
Persistent = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services = {
|
|
||||||
"update-hetzner-dns" = {
|
|
||||||
unitConfig = {
|
|
||||||
Description = "updates Hetzner DNS records";
|
|
||||||
};
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "exec";
|
|
||||||
EnvironmentFile = config.age.secrets.hetzner-dns.path;
|
|
||||||
};
|
|
||||||
|
|
||||||
path = [
|
|
||||||
pkgs.curl
|
|
||||||
pkgs.coreutils
|
|
||||||
pkgs.jq
|
|
||||||
];
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
SUBDOMAINS="ha komga romm puppy todo schema dagbok"
|
|
||||||
INTERFACE="enp3s0"
|
|
||||||
|
|
||||||
CURRENT_IP=$(curl -s --fail --interface "$INTERFACE" ifconfig.me)
|
|
||||||
|
|
||||||
for SUBDOMAIN in $SUBDOMAINS; do
|
|
||||||
LAST_IP_FILE="/tmp/hetzner-dns-''${SUBDOMAIN}-ip"
|
|
||||||
|
|
||||||
LAST_IP=""
|
|
||||||
if [[ -f "$LAST_IP_FILE" ]]; then
|
|
||||||
LAST_IP=$(cat "$LAST_IP_FILE")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$CURRENT_IP" == "$LAST_IP" ]]; then
|
|
||||||
echo "$SUBDOMAIN: IP unchanged, NOOP update."
|
|
||||||
else
|
|
||||||
echo "$SUBDOMAIN: Updating IP"
|
|
||||||
|
|
||||||
JSON_BODY=$(jq -n --arg ip "$CURRENT_IP" '{records: [{value: $ip}]}')
|
|
||||||
|
|
||||||
curl \
|
|
||||||
--fail \
|
|
||||||
-X POST \
|
|
||||||
-H "Authorization: Bearer $HETZNER_API_TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$JSON_BODY" \
|
|
||||||
"https://api.hetzner.cloud/v1/zones/ppp.pm/rrsets/''${SUBDOMAIN}/A/actions/set_records" \
|
|
||||||
&& echo $CURRENT_IP > $LAST_IP_FILE
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age = {
|
|
||||||
secrets = {
|
|
||||||
"hetzner-dns" = {
|
|
||||||
file = ../../../../secrets/manatee/hetzner-dns.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.homepage.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
services = config.mod.homepage.services;
|
|
||||||
|
|
||||||
serviceToCard =
|
|
||||||
svc:
|
|
||||||
let
|
|
||||||
href = if svc.url != null then svc.url else "http://manatee:${toString svc.port}";
|
|
||||||
in
|
|
||||||
''
|
|
||||||
<a class="card" href="${href}">
|
|
||||||
<div class="name">${svc.name}</div>
|
|
||||||
<div class="desc">${svc.description}</div>
|
|
||||||
<div class="port">:${toString svc.port}</div>
|
|
||||||
</a>
|
|
||||||
'';
|
|
||||||
|
|
||||||
page = pkgs.writeTextDir "index.html" ''
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>manatee</title>
|
|
||||||
<style>
|
|
||||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
||||||
body {
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
||||||
background: #1a1b26;
|
|
||||||
color: #c0caf5;
|
|
||||||
min-height: 100vh;
|
|
||||||
padding: 3rem 1.5rem;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 400;
|
|
||||||
color: #7aa2f7;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
.grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
||||||
gap: 1rem;
|
|
||||||
max-width: 900px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
.card {
|
|
||||||
display: block;
|
|
||||||
background: #24283b;
|
|
||||||
border: 1px solid #414868;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 1.25rem;
|
|
||||||
text-decoration: none;
|
|
||||||
color: inherit;
|
|
||||||
transition: border-color 0.15s;
|
|
||||||
}
|
|
||||||
.card:hover { border-color: #7aa2f7; }
|
|
||||||
.name { font-size: 1.1rem; font-weight: 600; color: #c0caf5; }
|
|
||||||
.desc { font-size: 0.85rem; color: #565f89; margin-top: 0.35rem; }
|
|
||||||
.port { font-size: 0.8rem; color: #414868; margin-top: 0.5rem; font-family: monospace; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>manatee</h1>
|
|
||||||
<div class="grid">
|
|
||||||
${lib.concatMapStrings serviceToCard services}
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.homepage = {
|
|
||||||
enable = lib.mkEnableOption "Enable homepage module";
|
|
||||||
services = lib.mkOption {
|
|
||||||
type = lib.types.listOf (
|
|
||||||
lib.types.submodule {
|
|
||||||
options = {
|
|
||||||
name = lib.mkOption { type = lib.types.str; };
|
|
||||||
port = lib.mkOption { type = lib.types.port; };
|
|
||||||
description = lib.mkOption { type = lib.types.str; };
|
|
||||||
url = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
description = "Link target for the card; defaults to http://manatee:<port>.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
default = [ ];
|
|
||||||
description = "Services to display on the homepage";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf (enabled && nginxEnabled) {
|
|
||||||
services.nginx.virtualHosts."homepage" = {
|
|
||||||
listen = [
|
|
||||||
{
|
|
||||||
addr = "0.0.0.0";
|
|
||||||
port = 9999;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
root = page;
|
|
||||||
locations."/" = {
|
|
||||||
index = "index.html";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 9999 ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -10,14 +10,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Immich";
|
|
||||||
port = 2283;
|
|
||||||
description = "Photo library";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
users.users.immich = {
|
users.users.immich = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = "storage";
|
group = "storage";
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ in
|
|||||||
extraPackages = [
|
extraPackages = [
|
||||||
pkgs.intel-media-driver # Modern Intel VA-API driver (needed for N305)
|
pkgs.intel-media-driver # Modern Intel VA-API driver (needed for N305)
|
||||||
pkgs.libvdpau-va-gl # VDPAU backend for VA-API GLX interop
|
pkgs.libvdpau-va-gl # VDPAU backend for VA-API GLX interop
|
||||||
pkgs.intel-compute-runtime # OpenCL support
|
|
||||||
];
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -47,18 +46,6 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Jellyfin";
|
|
||||||
port = 8096;
|
|
||||||
description = "Media streaming";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
networking = {
|
|
||||||
firewall.allowedTCPPorts = [ 8096 ];
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.jellyfin
|
pkgs.jellyfin
|
||||||
pkgs.jellyfin-web
|
pkgs.jellyfin-web
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.komga.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.komga = {
|
|
||||||
enable = lib.mkEnableOption "Enable komga module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.komga-comictracker.nixosModules.default
|
|
||||||
inputs.komga-bookmanager.nixosModules.default
|
|
||||||
inputs.komga-reading-stats.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Komga";
|
|
||||||
port = 8002;
|
|
||||||
description = "Comic library";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "Komga Reader";
|
|
||||||
port = 8888;
|
|
||||||
description = "Comic reader";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "Komga Book Manager";
|
|
||||||
port = 8686;
|
|
||||||
description = "Book manager";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "Komga Reading Stats";
|
|
||||||
port = 8787;
|
|
||||||
description = "Reading stats";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
users.users.komga = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = "storage";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.komga = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
user = "komga";
|
|
||||||
group = "storage";
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
server.port = 8002;
|
|
||||||
komga."cors.allowed-origins" = [
|
|
||||||
"http://manatee:8888"
|
|
||||||
"https://komga.ppp.pm"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
openFirewall = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = lib.mkIf nginxEnabled {
|
|
||||||
virtualHosts."komga-reader" = {
|
|
||||||
listen = [
|
|
||||||
{
|
|
||||||
addr = "0.0.0.0";
|
|
||||||
port = 8888;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
root = (pkgs.writeTextDir "komga-reader.html" (builtins.readFile ./komga-reader.html));
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
index = "komga-reader.html";
|
|
||||||
tryFiles = "$uri $uri/ /komga-reader.html";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
virtualHosts."komga.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "komga.ppp.pm";
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:8002";
|
|
||||||
proxyWebsockets = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 8888 ];
|
|
||||||
|
|
||||||
programs.comictracker = {
|
|
||||||
enable = true;
|
|
||||||
komgaUrl = "http://127.0.0.1:8002";
|
|
||||||
komgaLibraryId = "0NVZH5AK3RPE1";
|
|
||||||
secretsFile = config.age.secrets.komga-comicbooktracker-credentials.path;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.komga-book-manager = {
|
|
||||||
enable = true;
|
|
||||||
port = 8686;
|
|
||||||
group = "storage";
|
|
||||||
komgaUrl = "http://127.0.0.1:8002";
|
|
||||||
credentialsFile = config.age.secrets.komga-bookmanager-credentials.path;
|
|
||||||
libraryRoot = "/mnt/media/public/books";
|
|
||||||
libraryId = "0PNE1NEPY6995";
|
|
||||||
};
|
|
||||||
|
|
||||||
# `libraryRoot` is bind mounted into the service's own mount namespace when it
|
|
||||||
# starts, so starting before the ZFS dataset is mounted leaves it with an empty folder
|
|
||||||
systemd.services.komga-book-manager.unitConfig.RequiresMountsFor = [
|
|
||||||
config.services.komga-book-manager.libraryRoot
|
|
||||||
];
|
|
||||||
|
|
||||||
services.komga-reading-stats = {
|
|
||||||
enable = true;
|
|
||||||
host = "0.0.0.0";
|
|
||||||
port = 8787;
|
|
||||||
origin = "http://manatee:8787";
|
|
||||||
|
|
||||||
anthropicApiKeyFile = config.age.secrets.komga-reading-stats-claude-api-key.path;
|
|
||||||
claudeModel = "claude-sonnet-4-6";
|
|
||||||
komga = {
|
|
||||||
url = "http://127.0.0.1:8002";
|
|
||||||
apiKeyFile = config.age.secrets.komga-reading-stats-komga-api-key.path;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets = {
|
|
||||||
"komga-comicbooktracker-credentials" = {
|
|
||||||
file = ../../../../secrets/manatee/komga-comicbooktracker-credentials.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
|
|
||||||
"komga-bookmanager-credentials" = {
|
|
||||||
file = ../../../../secrets/manatee/komga-bookmanager-credentials.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
|
|
||||||
"komga-reading-stats-claude-api-key" = {
|
|
||||||
file = ../../../../secrets/manatee/komga-reading-stats-claude-api-key.age;
|
|
||||||
};
|
|
||||||
|
|
||||||
"komga-reading-stats-komga-api-key" = {
|
|
||||||
file = ../../../../secrets/manatee/komga-reading-stats-komga-api-key.age;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
navidromeEnabled = config.mod.navidrome.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = [ inputs.ndp.nixosModules.lbsync ];
|
|
||||||
|
|
||||||
options = {
|
|
||||||
mod.navidrome = {
|
|
||||||
enable = lib.mkEnableOption "Enable navidrome module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
mod.homepage.services = lib.mkIf navidromeEnabled [
|
|
||||||
{
|
|
||||||
name = "Navidrome";
|
|
||||||
port = 4533;
|
|
||||||
description = "Music streaming";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services = lib.mkIf navidromeEnabled {
|
|
||||||
navidrome = {
|
|
||||||
enable = true;
|
|
||||||
openFirewall = true;
|
|
||||||
|
|
||||||
user = "navidrome";
|
|
||||||
group = "storage";
|
|
||||||
settings = {
|
|
||||||
Port = 4533;
|
|
||||||
Address = "0.0.0.0";
|
|
||||||
MusicFolder = "/mnt/media/public/music";
|
|
||||||
};
|
|
||||||
|
|
||||||
lbsync = {
|
|
||||||
enable = true;
|
|
||||||
settingsFile = config.age.secrets."lbsync-config".path;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."lbsync-config" = lib.mkIf navidromeEnabled {
|
|
||||||
file = ../../../../secrets/manatee/lbsync-config.age;
|
|
||||||
};
|
|
||||||
|
|
||||||
# `MusicFolder` is bind mounted into the service's own mount namespace when it
|
|
||||||
# starts, so starting before the ZFS dataset is mounted leaves it with an empty folder
|
|
||||||
systemd.services.navidrome = lib.mkIf navidromeEnabled {
|
|
||||||
unitConfig.RequiresMountsFor = [ config.services.navidrome.settings.MusicFolder ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
let
|
|
||||||
hostAddress = "192.168.50.203";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "manatee";
|
hostName = "manatee";
|
||||||
|
|
||||||
# Required for asymmetric routing (sending replies out a different interface
|
|
||||||
# than the default route). Without this, the kernel drops the return traffic.
|
|
||||||
firewall.checkReversePath = "loose";
|
|
||||||
|
|
||||||
defaultGateway = "192.168.50.1";
|
defaultGateway = "192.168.50.1";
|
||||||
nameservers = [ "1.1.1.1" ];
|
nameservers = [ "1.1.1.1" ];
|
||||||
interfaces = {
|
interfaces = {
|
||||||
@@ -18,33 +11,12 @@ in
|
|||||||
ipv4 = {
|
ipv4 = {
|
||||||
addresses = [
|
addresses = [
|
||||||
{
|
{
|
||||||
address = hostAddress;
|
address = "192.168.50.203";
|
||||||
prefixLength = 24;
|
prefixLength = 24;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
ipv4.routes = [
|
|
||||||
{
|
|
||||||
address = "0.0.0.0";
|
|
||||||
prefixLength = 0;
|
|
||||||
via = "192.168.50.1"; # Router
|
|
||||||
options = {
|
|
||||||
table = "100";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
localCommands = ''
|
|
||||||
# Ensure local LAN traffic uses the main table, e.g. responds to the local machine
|
|
||||||
ip rule list | grep -q "192.168.50.0/24 lookup main" || \
|
|
||||||
ip rule add to 192.168.50.0/24 lookup main priority 4999
|
|
||||||
|
|
||||||
# All other traffic from this IP uses Table 100 (e.g. responds to router and back out)
|
|
||||||
ip rule list | grep -q "from ${hostAddress} lookup 100" || \
|
|
||||||
ip rule add from ${hostAddress} lookup 100 priority 5000
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -18,11 +18,5 @@ in
|
|||||||
recommendedTlsSettings = true;
|
recommendedTlsSettings = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
|
||||||
firewall = {
|
|
||||||
allowedTCPPorts = [ 443 ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.puppy-tracker.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
port = 8089;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.puppy-tracker = {
|
|
||||||
enable = lib.mkEnableOption "Enable puppy-tracker module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.puppy-tracker.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Puppy Tracker";
|
|
||||||
port = port;
|
|
||||||
description = "Sleep, meals, pees, poos";
|
|
||||||
# Login needs HTTPS (Secure cookies), so link to the public vhost.
|
|
||||||
url = "https://puppy.ppp.pm";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services.puppy-tracker = {
|
|
||||||
enable = true;
|
|
||||||
inherit port;
|
|
||||||
openFirewall = true;
|
|
||||||
# Served publicly over HTTPS via the nginx vhost below.
|
|
||||||
secureCookies = true;
|
|
||||||
# Shared registration secret; the file holds `PUPPY_INVITE_CODE=...`.
|
|
||||||
inviteCodeFile = config.age.secrets."puppy-tracker-invite-code".path;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = lib.mkIf nginxEnabled {
|
|
||||||
virtualHosts."puppy.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "puppy.ppp.pm";
|
|
||||||
|
|
||||||
# Photo uploads are up to 15 MB; give nginx headroom over its 1 MB default.
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size 20m;
|
|
||||||
'';
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:${toString port}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."puppy-tracker-invite-code".file =
|
|
||||||
../../../../secrets/manatee/puppy-tracker-invite-code.age;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.restic.enable;
|
|
||||||
|
|
||||||
# Where the consistent, restic-ready copies of service state are staged.
|
|
||||||
# Lives on the external backup disk. root-only (0700): these dumps contain
|
|
||||||
# credentials (HA .storage, secrets.yaml, session tokens, the romm database).
|
|
||||||
stateDir = "/mnt/backup/public/state";
|
|
||||||
|
|
||||||
# Produce consistent, restore-ready copies of every service's state under
|
|
||||||
# ${stateDir}. Runs as root before the state backups. SQLite DBs are copied
|
|
||||||
# via the online-backup API (safe on a live, WAL-mode DB); the romm MariaDB is
|
|
||||||
# dumped logically with mariadb-dump --single-transaction. Rebuildable caches
|
|
||||||
# and indexes are skipped to keep the offsite copy lean.
|
|
||||||
stateDumpScript = pkgs.writeShellScript "state-backup-dump" ''
|
|
||||||
export PATH=${
|
|
||||||
lib.makeBinPath [
|
|
||||||
pkgs.sqlite
|
|
||||||
pkgs.rsync
|
|
||||||
pkgs.podman
|
|
||||||
pkgs.coreutils
|
|
||||||
pkgs.findutils
|
|
||||||
]
|
|
||||||
}
|
|
||||||
set -euo pipefail
|
|
||||||
umask 077
|
|
||||||
|
|
||||||
STATE=${lib.escapeShellArg stateDir}
|
|
||||||
install -d -m700 "$STATE"
|
|
||||||
|
|
||||||
# snapshot SRC DEST [extra rsync excludes...]
|
|
||||||
# Copies plain files with rsync (excluding live DBs, their WAL/SHM sidecars
|
|
||||||
# and logs), then makes a consistent online copy of each *.db / *.sqlite.
|
|
||||||
snapshot() {
|
|
||||||
local src="$1" dst="$2"
|
|
||||||
shift 2
|
|
||||||
if [ ! -e "$src" ]; then
|
|
||||||
echo "state-backup: skip (missing) $src"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
install -d -m700 "$dst"
|
|
||||||
rsync -a --delete \
|
|
||||||
--exclude='*.sqlite' --exclude='*.sqlite-shm' --exclude='*.sqlite-wal' \
|
|
||||||
--exclude='*.db' --exclude='*.db-shm' --exclude='*.db-wal' \
|
|
||||||
--exclude='*.log' --exclude='*.log.*' \
|
|
||||||
--exclude='__pycache__/' \
|
|
||||||
"$@" \
|
|
||||||
"$src/" "$dst/"
|
|
||||||
# find -H: with DynamicUser, /var/lib/<name> is a symlink into
|
|
||||||
# /var/lib/private, and plain find stops at the link and finds no
|
|
||||||
# databases (rsync follows "$src/", but excludes them on purpose).
|
|
||||||
while IFS= read -r db; do
|
|
||||||
local rel="''${db#"$src"/}"
|
|
||||||
install -d -m700 "$dst/$(dirname "$rel")"
|
|
||||||
sqlite3 "$db" ".backup '$dst/$rel'"
|
|
||||||
done < <(find -H "$src" -maxdepth 4 -type f \( -name '*.sqlite' -o -name '*.db' \))
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- romm: logical MariaDB dump + user assets (saves/states/screenshots) ---
|
|
||||||
# Cover art under resources/ is intentionally skipped (refetched from
|
|
||||||
# metadata providers); redis is a rebuildable cache.
|
|
||||||
if podman exec romm-db true 2>/dev/null; then
|
|
||||||
install -d -m700 "$STATE/romm"
|
|
||||||
podman exec romm-db sh -c \
|
|
||||||
'exec mariadb-dump --user="$MARIADB_USER" --password="$MARIADB_PASSWORD" --single-transaction --no-tablespaces "$MARIADB_DATABASE"' \
|
|
||||||
> "$STATE/romm/romm.sql"
|
|
||||||
rsync -a --delete /var/lib/romm/assets/ "$STATE/romm/assets/"
|
|
||||||
else
|
|
||||||
echo "state-backup: skip (romm-db not running)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- komga: only database.sqlite matters (read progress, users, collections).
|
|
||||||
# tasks.sqlite is transient and the lucene/ index is rebuilt on demand. ---
|
|
||||||
if [ -e /var/lib/komga/database.sqlite ]; then
|
|
||||||
install -d -m700 "$STATE/komga"
|
|
||||||
sqlite3 /var/lib/komga/database.sqlite ".backup '$STATE/komga/database.sqlite'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- home-assistant: config, credentials and integrations, plus the two live
|
|
||||||
# SQLite DBs. Recorder history (home-assistant_v2.db) is included per choice.
|
|
||||||
# deps/ and tts/ are reinstalled/regenerated; logs are dropped. ---
|
|
||||||
HA=/home/alex/.config/home-assistant
|
|
||||||
if [ -e "$HA" ]; then
|
|
||||||
install -d -m700 "$STATE/home-assistant"
|
|
||||||
rsync -a --delete \
|
|
||||||
--exclude='home-assistant_v2.db' --exclude='home-assistant_v2.db-shm' --exclude='home-assistant_v2.db-wal' \
|
|
||||||
--exclude='zigbee.db' --exclude='zigbee.db-shm' --exclude='zigbee.db-wal' \
|
|
||||||
--exclude='*.log' --exclude='*.log.*' --exclude='*.log.fault' \
|
|
||||||
--exclude='deps/' --exclude='tts/' --exclude='__pycache__/' \
|
|
||||||
"$HA/" "$STATE/home-assistant/"
|
|
||||||
for db in home-assistant_v2.db zigbee.db; do
|
|
||||||
if [ -e "$HA/$db" ]; then
|
|
||||||
sqlite3 "$HA/$db" ".backup '$STATE/home-assistant/$db'"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- remaining NixOS services: generic snapshot, skipping rebuildable caches ---
|
|
||||||
snapshot /var/lib/navidrome "$STATE/navidrome" --exclude='cache/'
|
|
||||||
snapshot /var/lib/jellyfin "$STATE/jellyfin" --exclude='transcodes/' --exclude='cache/' --exclude='metadata/' --exclude='log/' --exclude='data/subtitles/'
|
|
||||||
snapshot /var/lib/audiobookshelf "$STATE/audiobookshelf" --exclude='metadata/'
|
|
||||||
snapshot /var/lib/puppy-tracker "$STATE/puppy-tracker"
|
|
||||||
snapshot /var/lib/todo "$STATE/todo"
|
|
||||||
snapshot /var/lib/schema "$STATE/schema"
|
|
||||||
snapshot /var/lib/dagbok "$STATE/dagbok"
|
|
||||||
snapshot /var/lib/komga-book-manager "$STATE/komga-book-manager"
|
|
||||||
snapshot /var/lib/komga-reading-stats "$STATE/komga-reading-stats"
|
|
||||||
|
|
||||||
echo "state-backup: dump complete"
|
|
||||||
'';
|
|
||||||
|
|
||||||
# A run killed mid-way (e.g. DNS dropping during an upload) leaves its lock
|
|
||||||
# behind, and every later run then fails in the pre-start "cat config"
|
|
||||||
# check. unlock only removes stale locks; "|| true" keeps a first run
|
|
||||||
# against a not-yet-initialized repo working.
|
|
||||||
backupPrepareCommand = "${pkgs.restic}/bin/restic unlock || true";
|
|
||||||
|
|
||||||
# Retention shared by all jobs.
|
|
||||||
pruneOpts = [
|
|
||||||
"--keep-daily 1"
|
|
||||||
"--keep-weekly 7"
|
|
||||||
"--keep-yearly 12"
|
|
||||||
];
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.mod.restic.enable = lib.mkEnableOption "Enable restic";
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
fileSystems."/mnt/backup" = {
|
|
||||||
device = "/dev/disk/by-uuid/34601701-65e6-4b2c-ac4d-8bef3dfd743f";
|
|
||||||
fsType = "ext4";
|
|
||||||
options = [ "nofail" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.restic.backups = {
|
|
||||||
"sync-to-external" = {
|
|
||||||
initialize = true;
|
|
||||||
passwordFile = config.age.secrets.restic-password.path;
|
|
||||||
paths = [ "/mnt/sync/public" ];
|
|
||||||
repository = "/mnt/backup/restic";
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = "*-*-* 0/12:00:00";
|
|
||||||
Persistent = true;
|
|
||||||
};
|
|
||||||
inherit pruneOpts backupPrepareCommand;
|
|
||||||
};
|
|
||||||
|
|
||||||
"sync-to-cloud" = {
|
|
||||||
initialize = true;
|
|
||||||
passwordFile = config.age.secrets.restic-password.path;
|
|
||||||
environmentFile = config.age.secrets.restic-cloud-sync-key.path;
|
|
||||||
repositoryFile = config.age.secrets.restic-cloud-sync-repository.path;
|
|
||||||
paths = [ "/mnt/sync/public" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = "*-*-* 0/12:00:00";
|
|
||||||
Persistent = true;
|
|
||||||
};
|
|
||||||
inherit pruneOpts backupPrepareCommand;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Service state (databases etc.). No timer of their own: the state-backup
|
|
||||||
# orchestrator below runs the dump once and then triggers these in order,
|
|
||||||
# so both back up the same consistent staging dir without racing it.
|
|
||||||
"state-to-external" = {
|
|
||||||
initialize = true;
|
|
||||||
passwordFile = config.age.secrets.restic-password.path;
|
|
||||||
paths = [ stateDir ];
|
|
||||||
repository = "/mnt/backup/restic";
|
|
||||||
timerConfig = null;
|
|
||||||
inherit pruneOpts backupPrepareCommand;
|
|
||||||
};
|
|
||||||
|
|
||||||
"state-to-cloud" = {
|
|
||||||
initialize = true;
|
|
||||||
passwordFile = config.age.secrets.restic-password.path;
|
|
||||||
environmentFile = config.age.secrets.restic-cloud-sync-key.path;
|
|
||||||
repositoryFile = config.age.secrets.restic-cloud-sync-repository.path;
|
|
||||||
paths = [ stateDir ];
|
|
||||||
timerConfig = null;
|
|
||||||
inherit pruneOpts backupPrepareCommand;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Dump service state, then push it to the external disk and the cloud, in
|
|
||||||
# that order. A "-" prefix means a failure of one restic target does not
|
|
||||||
# block the other; a failed dump (no prefix) aborts before either runs.
|
|
||||||
systemd.services.state-backup = {
|
|
||||||
description = "Dump service state and back it up (external + cloud)";
|
|
||||||
after = [ "podman.service" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
ExecStart = [
|
|
||||||
"${stateDumpScript}"
|
|
||||||
"-${pkgs.systemd}/bin/systemctl start --wait restic-backups-state-to-external.service"
|
|
||||||
"-${pkgs.systemd}/bin/systemctl start --wait restic-backups-state-to-cloud.service"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.timers.state-backup = {
|
|
||||||
description = "Timer for service-state backups";
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnCalendar = "*-*-* 0/12:00:00";
|
|
||||||
Persistent = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets = {
|
|
||||||
"restic-password".file = ../../../../secrets/manatee/restic-password.age;
|
|
||||||
"restic-cloud-sync-key".file = ../../../../secrets/manatee/restic-cloud-sync-key.age;
|
|
||||||
"restic-cloud-sync-repository".file = ../../../../secrets/manatee/restic-cloud-sync-repository.age;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.romm.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
|
|
||||||
configFile = pkgs.writeText "romm-config.yml" ''
|
|
||||||
filesystem:
|
|
||||||
skip_hash_calculation: false
|
|
||||||
exclude:
|
|
||||||
roms:
|
|
||||||
single_file:
|
|
||||||
extensions:
|
|
||||||
- xml
|
|
||||||
- txt
|
|
||||||
- nfo
|
|
||||||
- dat
|
|
||||||
- jpg
|
|
||||||
- png
|
|
||||||
names:
|
|
||||||
- '._*'
|
|
||||||
- 'Thumbs.db'
|
|
||||||
- '.DS_Store'
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Give up and enter a `failed` state (visible in `systemctl --failed`) if a
|
|
||||||
# container restarts more than 5 times in 5 minutes, instead of crash-looping
|
|
||||||
# forever. The window is deliberately long: a slow crash-loop (~5s per attempt)
|
|
||||||
# stays under systemd's default 5-starts-per-10s limit and would otherwise
|
|
||||||
# retry indefinitely.
|
|
||||||
crashLoopGuard = {
|
|
||||||
startLimitIntervalSec = 300;
|
|
||||||
startLimitBurst = 5;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.romm = {
|
|
||||||
enable = lib.mkEnableOption "Enable romm module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "RomM";
|
|
||||||
port = 8085;
|
|
||||||
description = "ROM library manager";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /var/lib/romm 0755 root root -"
|
|
||||||
# Owned by the container's mysql user (999). tmpfiles re-applies owner
|
|
||||||
# and mode on every switch; as root:root it left a running MariaDB unable
|
|
||||||
# to delete tc.log on shutdown, so the next start failed "crash recovery"
|
|
||||||
# with "Bad magic header in tc log".
|
|
||||||
"d /var/lib/romm/db 0755 999 999 -"
|
|
||||||
"d /var/lib/romm/redis 0755 999 1000 -"
|
|
||||||
"d /var/lib/romm/resources 0755 root root -"
|
|
||||||
"d /var/lib/romm/assets 0755 root root -"
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.services.podman-romm = crashLoopGuard;
|
|
||||||
systemd.services.podman-romm-db = crashLoopGuard;
|
|
||||||
systemd.services.podman-romm-redis = crashLoopGuard;
|
|
||||||
|
|
||||||
systemd.services.romm-net = {
|
|
||||||
description = "Create Podman network for RomM";
|
|
||||||
after = [ "podman.service" ];
|
|
||||||
requires = [ "podman.service" ];
|
|
||||||
before = [
|
|
||||||
"podman-romm.service"
|
|
||||||
"podman-romm-db.service"
|
|
||||||
"podman-romm-redis.service"
|
|
||||||
];
|
|
||||||
requiredBy = [
|
|
||||||
"podman-romm.service"
|
|
||||||
"podman-romm-db.service"
|
|
||||||
"podman-romm-redis.service"
|
|
||||||
];
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
ExecStart = pkgs.writeShellScript "romm-net-create" ''
|
|
||||||
${pkgs.podman}/bin/podman network exists romm-net \
|
|
||||||
|| ${pkgs.podman}/bin/podman network create romm-net
|
|
||||||
'';
|
|
||||||
ExecStop = "${pkgs.podman}/bin/podman network rm -f romm-net";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
virtualisation.oci-containers = {
|
|
||||||
backend = "podman";
|
|
||||||
|
|
||||||
containers.romm-db = {
|
|
||||||
image = "mariadb:latest";
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
MARIADB_DATABASE = "romm";
|
|
||||||
MARIADB_USER = "romm";
|
|
||||||
};
|
|
||||||
|
|
||||||
environmentFiles = [
|
|
||||||
config.age.secrets.romm-db-password.path
|
|
||||||
];
|
|
||||||
|
|
||||||
volumes = [
|
|
||||||
"/var/lib/romm/db:/var/lib/mysql"
|
|
||||||
];
|
|
||||||
|
|
||||||
extraOptions = [
|
|
||||||
"--network=romm-net"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
containers.romm-redis = {
|
|
||||||
image = "redis:alpine";
|
|
||||||
|
|
||||||
volumes = [
|
|
||||||
"/var/lib/romm/redis:/data"
|
|
||||||
];
|
|
||||||
|
|
||||||
extraOptions = [
|
|
||||||
"--network=romm-net"
|
|
||||||
"--user=root"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
containers.romm = {
|
|
||||||
image = "rommapp/romm:latest";
|
|
||||||
|
|
||||||
dependsOn = [
|
|
||||||
"romm-db"
|
|
||||||
"romm-redis"
|
|
||||||
];
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
DB_HOST = "romm-db";
|
|
||||||
DB_PORT = "3306";
|
|
||||||
DB_NAME = "romm";
|
|
||||||
DB_USER = "romm";
|
|
||||||
REDIS_HOST = "romm-redis";
|
|
||||||
REDIS_PORT = "6379";
|
|
||||||
ROMM_AUTH_ENABLED = "true";
|
|
||||||
};
|
|
||||||
|
|
||||||
environmentFiles = [
|
|
||||||
config.age.secrets.romm-auth-secret-key.path
|
|
||||||
config.age.secrets.romm-db-password.path
|
|
||||||
config.age.secrets.romm-metadata-api-keys.path
|
|
||||||
];
|
|
||||||
|
|
||||||
ports = [
|
|
||||||
"127.0.0.1:8086:8080"
|
|
||||||
];
|
|
||||||
|
|
||||||
volumes = [
|
|
||||||
"${configFile}:/romm/config/config.yml:ro"
|
|
||||||
"/mnt/media/public/games:/romm/library"
|
|
||||||
"/var/lib/romm/resources:/romm/resources"
|
|
||||||
"/var/lib/romm/assets:/romm/assets"
|
|
||||||
];
|
|
||||||
|
|
||||||
extraOptions = [
|
|
||||||
"--network=romm-net"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = lib.mkIf nginxEnabled {
|
|
||||||
virtualHosts."romm-local" = {
|
|
||||||
listen = [
|
|
||||||
{
|
|
||||||
addr = "0.0.0.0";
|
|
||||||
port = 8085;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size 0;
|
|
||||||
'';
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:8086";
|
|
||||||
proxyWebsockets = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
virtualHosts."romm.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "romm.ppp.pm";
|
|
||||||
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size 0;
|
|
||||||
'';
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:8086";
|
|
||||||
proxyWebsockets = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 8085 ];
|
|
||||||
|
|
||||||
age.secrets = {
|
|
||||||
"romm-auth-secret-key" = {
|
|
||||||
file = ../../../../secrets/manatee/romm-auth-secret-key.age;
|
|
||||||
owner = "root";
|
|
||||||
group = "root";
|
|
||||||
};
|
|
||||||
|
|
||||||
"romm-db-password" = {
|
|
||||||
file = ../../../../secrets/manatee/romm-db-password.age;
|
|
||||||
owner = "root";
|
|
||||||
group = "root";
|
|
||||||
};
|
|
||||||
|
|
||||||
"romm-metadata-api-keys" = {
|
|
||||||
file = ../../../../secrets/manatee/romm-metadata-api-keys.age;
|
|
||||||
owner = "root";
|
|
||||||
group = "root";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.schema.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
port = 8092;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.schema = {
|
|
||||||
enable = lib.mkEnableOption "Enable schema module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.schema.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Schema";
|
|
||||||
port = port;
|
|
||||||
description = "Our week: chores, meals, dog";
|
|
||||||
# Login needs HTTPS (Secure cookies), so link to the public vhost.
|
|
||||||
url = "https://schema.ppp.pm";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services.schema = {
|
|
||||||
enable = true;
|
|
||||||
address = "127.0.0.1";
|
|
||||||
inherit port;
|
|
||||||
# Served publicly over HTTPS via the nginx vhost below.
|
|
||||||
secureCookies = true;
|
|
||||||
inviteCodeFile = config.age.secrets."schema-invite-code".path;
|
|
||||||
timeZone = "Europe/Stockholm";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = lib.mkIf nginxEnabled {
|
|
||||||
virtualHosts."schema.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "schema.ppp.pm";
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:${toString port}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."schema-invite-code".file = ../../../../secrets/manatee/schema-invite-code.age;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -21,33 +21,12 @@ in
|
|||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
programs.ssh = {
|
programs.ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableDefaultConfig = false;
|
|
||||||
|
|
||||||
settings = {
|
matchBlocks = {
|
||||||
"git.ppp.pm" = {
|
"git.ppp.pm" = {
|
||||||
hostname = "git.ppp.pm";
|
hostname = "git.ppp.pm";
|
||||||
identityFile = "/home/alex/.ssh/alex.manatee-git.ppp.pm";
|
identityFile = "/home/alex/.ssh/alex.manatee-git.ppp.pm";
|
||||||
};
|
};
|
||||||
|
|
||||||
"tadpole" = {
|
|
||||||
hostname = "65.21.106.222";
|
|
||||||
user = "alex";
|
|
||||||
identityFile = "/home/alex/.ssh/alex.manatee-tadpole";
|
|
||||||
port = 1122;
|
|
||||||
};
|
|
||||||
|
|
||||||
"*" = {
|
|
||||||
forwardAgent = false;
|
|
||||||
addKeysToAgent = "no";
|
|
||||||
compression = false;
|
|
||||||
serverAliveInterval = 0;
|
|
||||||
serverAliveCountMax = 3;
|
|
||||||
hashKnownHosts = false;
|
|
||||||
userKnownHostsFile = "~/.ssh/known_hosts";
|
|
||||||
controlMaster = "no";
|
|
||||||
controlPath = "~/.ssh/master-%r@%n:%p";
|
|
||||||
controlPersist = "no";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -122,19 +101,6 @@ in
|
|||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
"alex.manatee-tadpole" = {
|
|
||||||
file = ../../../../secrets/manatee/alex.manatee-tadpole.age;
|
|
||||||
path = "/home/alex/.ssh/alex.manatee-tadpole";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
"alex.manatee-tadpole.pub" = {
|
|
||||||
file = ../../../../secrets/manatee/alex.manatee-tadpole.pub.age;
|
|
||||||
path = "/home/alex/.ssh/alex.manatee-tadpole.pub";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -10,14 +10,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Syncthing";
|
|
||||||
port = 8384;
|
|
||||||
description = "File sync";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services.syncthing = {
|
services.syncthing = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
@@ -39,7 +31,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
devices = {
|
devices = {
|
||||||
phone.id = config.lib.syncthing.phone;
|
|
||||||
pinwheel.id = config.lib.syncthing.pinwheel;
|
pinwheel.id = config.lib.syncthing.pinwheel;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,7 +38,6 @@ in
|
|||||||
org = {
|
org = {
|
||||||
path = "/mnt/sync/public/org";
|
path = "/mnt/sync/public/org";
|
||||||
devices = [
|
devices = [
|
||||||
"phone"
|
|
||||||
"pinwheel"
|
"pinwheel"
|
||||||
];
|
];
|
||||||
versioning = {
|
versioning = {
|
||||||
@@ -57,39 +47,6 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
personal = {
|
|
||||||
path = "/mnt/sync/public/personal";
|
|
||||||
devices = [ "pinwheel" ];
|
|
||||||
versioning = {
|
|
||||||
type = "staggered";
|
|
||||||
params = {
|
|
||||||
maxage = "2592000"; # 30 days
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
work = {
|
|
||||||
path = "/mnt/sync/public/work";
|
|
||||||
devices = [ "pinwheel" ];
|
|
||||||
versioning = {
|
|
||||||
type = "staggered";
|
|
||||||
params = {
|
|
||||||
maxage = "2592000"; # 30 days
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
"phone-gps" = {
|
|
||||||
path = "/mnt/sync/public/phone-gps";
|
|
||||||
devices = [ "phone" ];
|
|
||||||
versioning = {
|
|
||||||
type = "staggered";
|
|
||||||
params = {
|
|
||||||
maxage = "2592000"; # 30 days
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.tmux.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.tmux = {
|
|
||||||
enable = lib.mkEnableOption "enable tmux module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
home-manager.users.alex = {
|
|
||||||
programs.tmux = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
baseIndex = 1;
|
|
||||||
keyMode = "vi";
|
|
||||||
|
|
||||||
# Allow vi mode to be enabled instantly
|
|
||||||
escapeTime = 0;
|
|
||||||
|
|
||||||
plugins = [ pkgs.tmuxPlugins.sensible ];
|
|
||||||
|
|
||||||
extraConfig = ''
|
|
||||||
set -g renumber-windows on
|
|
||||||
|
|
||||||
# https://old.reddit.com/r/tmux/comments/mesrci/tmux_2_doesnt_seem_to_use_256_colors/
|
|
||||||
set -g default-terminal "xterm-256color"
|
|
||||||
set -ga terminal-overrides ",*256col*:Tc"
|
|
||||||
set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[ q'
|
|
||||||
set-environment -g COLORTERM "truecolor"
|
|
||||||
|
|
||||||
set-option -g allow-rename off
|
|
||||||
|
|
||||||
# Remove date/time etc. on the right side
|
|
||||||
set -g status-right ""
|
|
||||||
|
|
||||||
# Remove accidental `suspend-client` triggers
|
|
||||||
unbind C-z
|
|
||||||
|
|
||||||
bind | split-window -h -c "#{pane_current_path}"
|
|
||||||
bind - split-window -v -c "#{pane_current_path}"
|
|
||||||
|
|
||||||
# Move panes shortcuts
|
|
||||||
bind h select-pane -L
|
|
||||||
bind j select-pane -D
|
|
||||||
bind k select-pane -U
|
|
||||||
bind l select-pane -R
|
|
||||||
|
|
||||||
# Resize panes
|
|
||||||
bind -r H resize-pane -L 5
|
|
||||||
bind -r J resize-pane -D 5
|
|
||||||
bind -r K resize-pane -U 5
|
|
||||||
bind -r L resize-pane -R 5
|
|
||||||
|
|
||||||
# Move windows
|
|
||||||
bind -r Left swap-window -t -1 \; select-window -t -1
|
|
||||||
bind -r Right swap-window -t +1 \; select-window -t +1
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.todo.enable;
|
|
||||||
nginxEnabled = config.mod.nginx.enable;
|
|
||||||
port = 8091;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.todo = {
|
|
||||||
enable = lib.mkEnableOption "Enable todo module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.todo.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Todo";
|
|
||||||
port = port;
|
|
||||||
description = "Offline-first todo";
|
|
||||||
# Login needs HTTPS (Secure cookies), so link to the public vhost.
|
|
||||||
url = "https://todo.ppp.pm";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services.todo = {
|
|
||||||
enable = true;
|
|
||||||
address = "127.0.0.1";
|
|
||||||
inherit port;
|
|
||||||
# Served publicly over HTTPS via the nginx vhost below.
|
|
||||||
secureCookies = true;
|
|
||||||
tokenFile = config.age.secrets."todo-token".path;
|
|
||||||
# sessionSecretFile is left unset: the app generates one in its state dir
|
|
||||||
# (/var/lib/todo) on first boot, mode 0600.
|
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx = lib.mkIf nginxEnabled {
|
|
||||||
virtualHosts."todo.ppp.pm" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "todo.ppp.pm";
|
|
||||||
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://127.0.0.1:${toString port}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."todo-token".file = ../../../../secrets/manatee/todo-token.age;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -15,14 +15,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Transmission";
|
|
||||||
port = 9091;
|
|
||||||
description = "Torrent client";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
transmission = {
|
transmission = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -52,12 +44,5 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Both paths are bind mounted into the service's own mount namespace when it
|
|
||||||
# starts, so starting before the ZFS dataset is mounted writes to the root disk
|
|
||||||
systemd.services.transmission.unitConfig.RequiresMountsFor = [
|
|
||||||
config.services.transmission.home
|
|
||||||
config.services.transmission.settings.download-dir
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../config-manager/default.nix
|
../../config-manager/default.nix
|
||||||
@@ -14,16 +14,10 @@
|
|||||||
];
|
];
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
hardware.trackpoint.device = "TPPS/2 Synaptics TrackPoint";
|
|
||||||
services.thermald.enable = lib.mkDefault true;
|
|
||||||
|
|
||||||
users.users.alex = {
|
users.users.alex = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
description = "alex";
|
description = "alex";
|
||||||
extraGroups = [
|
extraGroups = [ "wheel" ];
|
||||||
"wheel"
|
|
||||||
"networkmanager"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
|||||||
@@ -1,34 +1,56 @@
|
|||||||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
# and may be overwritten by future invocations. Please make changes
|
# and may be overwritten by future invocations. Please make changes
|
||||||
# to /etc/nixos/configuration.nix instead.
|
# to /etc/nixos/configuration.nix instead.
|
||||||
{ config, lib, pkgs, modulesPath, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports =
|
imports = [
|
||||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
|
boot.initrd.availableKernelModules = [
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
"nvme"
|
||||||
|
"usb_storage"
|
||||||
|
"sd_mod"
|
||||||
|
];
|
||||||
boot.initrd.kernelModules = [ ];
|
boot.initrd.kernelModules = [ ];
|
||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" = {
|
||||||
{ device = "/dev/mapper/luks-b05ba0f3-51f9-48d1-8d14-fcbff7c13c5b";
|
device = "/dev/disk/by-uuid/9c3ef2ad-0244-4310-9984-2e548ced3e22";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.initrd.luks.devices."luks-b05ba0f3-51f9-48d1-8d14-fcbff7c13c5b".device = "/dev/disk/by-uuid/b05ba0f3-51f9-48d1-8d14-fcbff7c13c5b";
|
boot.initrd.luks.devices."luks-f569d036-e500-4839-bc78-ce4b032840d8".device = "/dev/disk/by-uuid/f569d036-e500-4839-bc78-ce4b032840d8";
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" = {
|
||||||
{ device = "/dev/disk/by-uuid/D449-C034";
|
device = "/dev/disk/by-uuid/FCAE-6849";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
options = [ "fmask=0077" "dmask=0077" ];
|
};
|
||||||
};
|
|
||||||
|
|
||||||
swapDevices = [ ];
|
swapDevices = [
|
||||||
|
{
|
||||||
|
device = "/swapfile";
|
||||||
|
size = 48 * 1024; # 48GB
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
hardware.cpu.intel.npu.enable = true;
|
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
}
|
}
|
||||||
@@ -14,19 +14,18 @@
|
|||||||
home.homeDirectory = "/home/alex";
|
home.homeDirectory = "/home/alex";
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
inputs.whib-backend.packages.${pkgs.stdenv.hostPlatform.system}.whib-import
|
inputs.whib-backend.packages.${pkgs.system}.whib-import
|
||||||
# pkgs.beekeeper-studio
|
# pkgs.beekeeper-studio
|
||||||
|
pkgs.bitwarden-desktop
|
||||||
pkgs.gimp
|
pkgs.gimp
|
||||||
pkgs.zip
|
pkgs.zip
|
||||||
pkgs.unzip
|
|
||||||
pkgs.unar
|
pkgs.unar
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
pkgs.dbeaver-bin
|
pkgs.dbeaver-bin
|
||||||
pkgs.htop
|
pkgs.htop
|
||||||
pkgs.onlyoffice-desktopeditors
|
pkgs.onlyoffice-bin
|
||||||
pkgs.wdisplays
|
pkgs.wdisplays
|
||||||
pkgs.vlc
|
pkgs.vlc
|
||||||
pkgs.opencode
|
|
||||||
];
|
];
|
||||||
|
|
||||||
home.stateVersion = "23.05";
|
home.stateVersion = "23.05";
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
inputs.agenix.packages."${pkgs.stdenv.hostPlatform.system}".default
|
inputs.agenix.packages."${pkgs.system}".default
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.ai.enable;
|
|
||||||
|
|
||||||
# Shared statusline: show the logged-in account email.
|
|
||||||
statusLine = {
|
|
||||||
type = "command";
|
|
||||||
command = "jq -r '.oauthAccount.emailAddress' \"$CLAUDE_CONFIG_DIR/.claude.json\"";
|
|
||||||
};
|
|
||||||
|
|
||||||
# PostToolUse hook: echoes a JSON payload that injects a comment-policy
|
|
||||||
# reminder as additional context after every Write/Edit.
|
|
||||||
commentPolicyPayload = builtins.toJSON {
|
|
||||||
suppressOutput = true;
|
|
||||||
hookSpecificOutput = {
|
|
||||||
hookEventName = "PostToolUse";
|
|
||||||
additionalContext = "Comment policy: default to ZERO code comments. Review what you just wrote and delete any comment that narrates the change, restates the code, states the obvious, is tangential, or explains design/why rationale -- put that reasoning in your chat reply instead, never in the code. Never use em dashes or en dashes anywhere in file content; use a plain ASCII hyphen or reword.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
settings = builtins.toJSON {
|
|
||||||
inherit statusLine;
|
|
||||||
theme = "dark";
|
|
||||||
editorMode = "vim";
|
|
||||||
cleanupPeriodDays = 3650;
|
|
||||||
attribution = {
|
|
||||||
commit = "";
|
|
||||||
pr = "";
|
|
||||||
};
|
|
||||||
hooks = {
|
|
||||||
SessionStart = [
|
|
||||||
{
|
|
||||||
hooks = [
|
|
||||||
{
|
|
||||||
type = "command";
|
|
||||||
command = "tmux-panes claude-session";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
PostToolUse = [
|
|
||||||
{
|
|
||||||
matcher = "Write|Edit";
|
|
||||||
hooks = [
|
|
||||||
{
|
|
||||||
type = "command";
|
|
||||||
command = "echo ${lib.escapeShellArg commentPolicyPayload}";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
settingsFile = pkgs.writeText "claude-settings.json" settings;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.ai = {
|
|
||||||
enable = lib.mkEnableOption "enable ai module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkMerge [
|
|
||||||
{ home-manager.sharedModules = [ inputs.ct.homeManagerModules.default ]; }
|
|
||||||
|
|
||||||
(lib.mkIf enabled {
|
|
||||||
home-manager.users.alex = {
|
|
||||||
home.packages = [ pkgs.claude-code ];
|
|
||||||
|
|
||||||
programs.zsh.shellAliases = {
|
|
||||||
claude = "pclaude";
|
|
||||||
wclaude = "CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude";
|
|
||||||
pclaude = "CLAUDE_CONFIG_DIR=$HOME/.claude-personal command claude";
|
|
||||||
};
|
|
||||||
|
|
||||||
home.activation.claudeSettings = {
|
|
||||||
after = [ "linkGeneration" ];
|
|
||||||
before = [ ];
|
|
||||||
data = ''
|
|
||||||
for f in "$HOME"/.claude-{work,personal}/settings.json; do
|
|
||||||
current="$(cat "$f" 2>/dev/null || echo '{}')"
|
|
||||||
run mkdir -p "$(dirname "$f")"
|
|
||||||
run rm -f "$f"
|
|
||||||
echo "$current" | ${pkgs.jq}/bin/jq -s '.[0] * .[1]' ${settingsFile} - | run tee "$f" > /dev/null
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
programs.ct = {
|
|
||||||
enable = true;
|
|
||||||
web.enable = true;
|
|
||||||
settings.profiles = {
|
|
||||||
work.configDir = "/home/alex/.claude-work";
|
|
||||||
personal.configDir = "/home/alex/.claude-personal";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
{ lib, config, ... }:
|
|
||||||
let
|
|
||||||
enabled = config.mod.atuin.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.atuin = {
|
|
||||||
enable = lib.mkEnableOption "enable atuin module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
home-manager.users.alex = {
|
|
||||||
programs.atuin = {
|
|
||||||
enable = true;
|
|
||||||
enableZshIntegration = true;
|
|
||||||
flags = [ "--disable-up-arrow" ];
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
sync_address = "http://manatee:8889";
|
|
||||||
auto_sync = true;
|
|
||||||
sync_frequency = "5m";
|
|
||||||
key_path = config.age.secrets."atuin-key".path;
|
|
||||||
ctrl_n_shortcuts = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
programs.fzf.historyWidget.command = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."atuin-key" = {
|
|
||||||
file = ../../../../secrets/pinwheel/atuin-key.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -28,14 +28,7 @@ in
|
|||||||
|
|
||||||
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
||||||
settings = {
|
settings = {
|
||||||
bind = [
|
bind = [ "$mod, SPACE, exec, ${bmr}" ];
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"SUPER + SPACE"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${bmr}")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ in
|
|||||||
# Low battery notification for bluetooth devices
|
# Low battery notification for bluetooth devices
|
||||||
systemd.user =
|
systemd.user =
|
||||||
let
|
let
|
||||||
|
trackpad = {
|
||||||
|
id = "battery_hid_a8o91o3doe5ofeo38_battery";
|
||||||
|
name = "trackpad";
|
||||||
|
threshold = "20";
|
||||||
|
};
|
||||||
|
|
||||||
headphones = {
|
headphones = {
|
||||||
id = "headset_dev_38_18_4C_18_A4_6E";
|
id = "headset_dev_38_18_4C_18_A4_6E";
|
||||||
name = "headphones";
|
name = "headphones";
|
||||||
@@ -59,6 +65,7 @@ in
|
|||||||
in
|
in
|
||||||
builtins.listToAttrs (
|
builtins.listToAttrs (
|
||||||
builtins.map mkTimer [
|
builtins.map mkTimer [
|
||||||
|
trackpad
|
||||||
headphones
|
headphones
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -112,6 +119,7 @@ in
|
|||||||
in
|
in
|
||||||
builtins.listToAttrs (
|
builtins.listToAttrs (
|
||||||
builtins.map mkService [
|
builtins.map mkService [
|
||||||
|
trackpad
|
||||||
headphones
|
headphones
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ in
|
|||||||
|
|
||||||
efi.canTouchEfiVariables = true;
|
efi.canTouchEfiVariables = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
initrd.secrets = {
|
||||||
|
"/crypto_keyfile.bin" = null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,45 +1,12 @@
|
|||||||
let
|
|
||||||
bar = "2c2c2c";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
lib = {
|
lib = {
|
||||||
colors = {
|
colors = {
|
||||||
foreground = "ffb347";
|
foreground = "bd93f9";
|
||||||
foreground-dim = "8a5a20";
|
foreground-dim = "644294";
|
||||||
background = bar;
|
background = "1E1E2F";
|
||||||
|
|
||||||
gray = "3a3a3a";
|
gray = "3a3a3a";
|
||||||
warning = "e0473c";
|
warning = "ff6969";
|
||||||
|
|
||||||
terminal = {
|
|
||||||
foreground = "e2e2e2";
|
|
||||||
background = "222222";
|
|
||||||
cursor = "b8843a";
|
|
||||||
selection = "4a3820";
|
|
||||||
status = bar;
|
|
||||||
|
|
||||||
regular = [
|
|
||||||
"181818" # black
|
|
||||||
"e0473c" # red
|
|
||||||
"7fb35a" # green
|
|
||||||
"b8904a" # yellow
|
|
||||||
"8a8a8a" # blue
|
|
||||||
"a05048" # magenta
|
|
||||||
"9e9e9e" # cyan
|
|
||||||
"e2e2e2" # white
|
|
||||||
];
|
|
||||||
|
|
||||||
bright = [
|
|
||||||
"5a5a5a" # black
|
|
||||||
"ff5f52" # red
|
|
||||||
"9fd078" # green
|
|
||||||
"d8b070" # yellow
|
|
||||||
"aaaaaa" # blue
|
|
||||||
"c06058" # magenta
|
|
||||||
"bebebe" # cyan
|
|
||||||
"fafafa" # white
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ in
|
|||||||
nix-index.enable = false;
|
nix-index.enable = false;
|
||||||
greetd.enable = true;
|
greetd.enable = true;
|
||||||
hyprland.enable = true;
|
hyprland.enable = true;
|
||||||
hyprlock.enable = true;
|
swaylock.enable = true;
|
||||||
physlock.enable = false;
|
physlock.enable = false;
|
||||||
|
|
||||||
power.enable = true;
|
power.enable = true;
|
||||||
@@ -25,7 +25,6 @@ in
|
|||||||
|
|
||||||
git.enable = true;
|
git.enable = true;
|
||||||
zsh.enable = true;
|
zsh.enable = true;
|
||||||
atuin.enable = true;
|
|
||||||
|
|
||||||
openvpn.enable = true;
|
openvpn.enable = true;
|
||||||
|
|
||||||
@@ -34,7 +33,6 @@ in
|
|||||||
rust.enable = true;
|
rust.enable = true;
|
||||||
scala.enable = true;
|
scala.enable = true;
|
||||||
python.enable = true;
|
python.enable = true;
|
||||||
gleam.enable = true;
|
|
||||||
|
|
||||||
keyboard.enable = true;
|
keyboard.enable = true;
|
||||||
containers = {
|
containers = {
|
||||||
@@ -43,8 +41,6 @@ in
|
|||||||
};
|
};
|
||||||
vm.enable = true;
|
vm.enable = true;
|
||||||
scripts.enable = true;
|
scripts.enable = true;
|
||||||
|
|
||||||
ai.enable = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** This makes emacsclient startup faster in TUI-mode
|
*** This makes emacsclient startup faster in TUI-mode
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(setq-default xterm-query-timeout 0.1)
|
(setq-default xterm-query-timeout nil)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Disable startup messages
|
*** Disable startup messages
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
@@ -86,24 +86,8 @@
|
|||||||
* Setup
|
* Setup
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Use wl-clipboard and OSC 52 for interprocess copy/paste
|
** Use wl-clipboard for interprocess copy/paste
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(setq kill-do-not-save-duplicates t)
|
|
||||||
|
|
||||||
(defun alex/osc52-copy (text)
|
|
||||||
(unless (display-graphic-p)
|
|
||||||
(send-string-to-terminal
|
|
||||||
(concat "\e]52;c;"
|
|
||||||
(base64-encode-string (encode-coding-string text 'utf-8) t)
|
|
||||||
"\a"))))
|
|
||||||
|
|
||||||
(defun alex/clipboard-copy (text)
|
|
||||||
(alex/osc52-copy text)
|
|
||||||
(when (fboundp 'wl-copy)
|
|
||||||
(wl-copy text)))
|
|
||||||
|
|
||||||
(setq interprogram-cut-function 'alex/clipboard-copy)
|
|
||||||
|
|
||||||
(setq wl-copy-process nil)
|
(setq wl-copy-process nil)
|
||||||
(when (string-prefix-p "wayland" (getenv "WAYLAND_DISPLAY"))
|
(when (string-prefix-p "wayland" (getenv "WAYLAND_DISPLAY"))
|
||||||
(defun wl-copy (text)
|
(defun wl-copy (text)
|
||||||
@@ -119,6 +103,7 @@
|
|||||||
nil ; should return nil if we're the current paste owner
|
nil ; should return nil if we're the current paste owner
|
||||||
(shell-command-to-string "wl-paste -n | tr -d \r")))
|
(shell-command-to-string "wl-paste -n | tr -d \r")))
|
||||||
|
|
||||||
|
(setq interprogram-cut-function 'wl-copy)
|
||||||
(setq interprogram-paste-function 'wl-paste))
|
(setq interprogram-paste-function 'wl-paste))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Don't create backup files, don't create #autosave# files
|
** Don't create backup files, don't create #autosave# files
|
||||||
@@ -159,7 +144,7 @@
|
|||||||
** Theme
|
** Theme
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package doom-themes
|
(use-package doom-themes
|
||||||
:config (load-theme 'sodium t))
|
:init (load-theme 'doom-dracula t))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Disable the menu bar
|
** Disable the menu bar
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
@@ -332,41 +317,6 @@ https://github.com/justbur/emacs-which-key
|
|||||||
(setq history-length 25)
|
(setq history-length 25)
|
||||||
(savehist-mode 1)
|
(savehist-mode 1)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Remember open buffers per tmux pane
|
|
||||||
Used by `tmux-panes` to reopen buffers when tmux-resurrect restores a pane
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(defun tmux-panes--state-file ()
|
|
||||||
(when-let* ((pane (getenv "TMUX_PANE")))
|
|
||||||
(expand-file-name (concat "tmux-panes/" (substring pane 1) "/emacs")
|
|
||||||
(or (getenv "XDG_STATE_HOME") "~/.local/state"))))
|
|
||||||
|
|
||||||
(defun tmux-panes-save-buffers ()
|
|
||||||
(when-let* ((file (tmux-panes--state-file)))
|
|
||||||
(make-directory (file-name-directory file) t)
|
|
||||||
(let ((buffers (delq nil (mapcar (lambda (buffer)
|
|
||||||
(when-let* ((name (buffer-file-name buffer)))
|
|
||||||
(cons name (with-current-buffer buffer (point)))))
|
|
||||||
(buffer-list)))))
|
|
||||||
(with-temp-file file
|
|
||||||
(prin1 buffers (current-buffer))))))
|
|
||||||
|
|
||||||
(defun tmux-panes-restore-buffers ()
|
|
||||||
(when-let* ((file (getenv "TMUX_PANES_RESTORE")))
|
|
||||||
(setenv "TMUX_PANES_RESTORE" nil)
|
|
||||||
(when (file-readable-p file)
|
|
||||||
(let ((buffers (with-temp-buffer
|
|
||||||
(insert-file-contents file)
|
|
||||||
(read (current-buffer)))))
|
|
||||||
(dolist (entry (reverse buffers))
|
|
||||||
(when (file-exists-p (car entry))
|
|
||||||
(find-file (car entry))
|
|
||||||
(goto-char (cdr entry)))))
|
|
||||||
(delete-file file)))
|
|
||||||
(tmux-panes-save-buffers))
|
|
||||||
|
|
||||||
(add-hook 'emacs-startup-hook #'tmux-panes-restore-buffers)
|
|
||||||
(run-with-idle-timer 30 t #'tmux-panes-save-buffers)
|
|
||||||
#+END_SRC
|
|
||||||
** Vertico
|
** Vertico
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package vertico
|
(use-package vertico
|
||||||
@@ -460,32 +410,6 @@ Setup prefix for keybindings.
|
|||||||
"t" '(:ignore t :which-key "text")
|
"t" '(:ignore t :which-key "text")
|
||||||
"ts" '(hydra-text-scale/body :which-key "scale text"))
|
"ts" '(hydra-text-scale/body :which-key "scale text"))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Copy file path with line number
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(defun alex/copy-path-with-line ()
|
|
||||||
"Copy /abs/path:LINE, or /abs/path:START-END when a region is active."
|
|
||||||
(interactive)
|
|
||||||
(unless buffer-file-name (user-error "Buffer is not visiting a file"))
|
|
||||||
(let* ((path (expand-file-name buffer-file-name))
|
|
||||||
(ref (if (use-region-p)
|
|
||||||
(let* ((beg (region-beginning))
|
|
||||||
(end (if (and (> (region-end) beg)
|
|
||||||
(save-excursion (goto-char (region-end)) (bolp)))
|
|
||||||
(1- (region-end))
|
|
||||||
(region-end)))
|
|
||||||
(start-line (line-number-at-pos beg))
|
|
||||||
(end-line (line-number-at-pos end)))
|
|
||||||
(if (= start-line end-line)
|
|
||||||
(format "%s:%d" path start-line)
|
|
||||||
(format "%s:%d-%d" path start-line end-line)))
|
|
||||||
(format "%s:%d" path (line-number-at-pos)))))
|
|
||||||
(kill-new ref)
|
|
||||||
(deactivate-mark)
|
|
||||||
(message "Copied %s" ref)))
|
|
||||||
|
|
||||||
(alex/keybindings
|
|
||||||
"y" '(alex/copy-path-with-line :which-key "copy path:line"))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* Browser
|
* Browser
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
@@ -555,34 +479,7 @@ Setup prefix for keybindings.
|
|||||||
|
|
||||||
* Flycheck
|
* Flycheck
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package flycheck
|
(use-package flycheck)
|
||||||
:preface
|
|
||||||
(defun mp-flycheck-eldoc (callback &rest _ignored)
|
|
||||||
"Print flycheck messages at point by calling CALLBACK."
|
|
||||||
(when-let ((flycheck-errors (and flycheck-mode (flycheck-overlay-errors-at (point)))))
|
|
||||||
(mapc
|
|
||||||
(lambda (err)
|
|
||||||
(funcall callback
|
|
||||||
(format "%s: %s"
|
|
||||||
(let ((level (flycheck-error-level err)))
|
|
||||||
(pcase level
|
|
||||||
('info (propertize "I" 'face 'flycheck-error-list-info))
|
|
||||||
('error (propertize "E" 'face 'flycheck-error-list-error))
|
|
||||||
('warning (propertize "W" 'face 'flycheck-error-list-warning))
|
|
||||||
(_ level)))
|
|
||||||
(flycheck-error-message err))
|
|
||||||
:thing (or (flycheck-error-id err)
|
|
||||||
(flycheck-error-group err))
|
|
||||||
:face 'font-lock-doc-face))
|
|
||||||
flycheck-errors)))
|
|
||||||
|
|
||||||
(defun mp-flycheck-prefer-eldoc ()
|
|
||||||
(add-hook 'eldoc-documentation-functions #'mp-flycheck-eldoc nil t)
|
|
||||||
(setq eldoc-documentation-strategy 'eldoc-documentation-compose-eagerly)
|
|
||||||
(setq flycheck-display-errors-function nil)
|
|
||||||
(setq flycheck-help-echo-function nil))
|
|
||||||
|
|
||||||
:hook ((flycheck-mode . mp-flycheck-prefer-eldoc)))
|
|
||||||
|
|
||||||
(use-package flycheck-eglot
|
(use-package flycheck-eglot
|
||||||
:after (flycheck eglot)
|
:after (flycheck eglot)
|
||||||
@@ -606,12 +503,6 @@ Setup prefix for keybindings.
|
|||||||
(add-hook 'before-save-hook #'eglot-format-buffer -10 t))))
|
(add-hook 'before-save-hook #'eglot-format-buffer -10 t))))
|
||||||
|
|
||||||
(use-package eglot
|
(use-package eglot
|
||||||
:preface
|
|
||||||
(defun mp-eglot-eldoc ()
|
|
||||||
(setq eldoc-echo-area-use-multiline-p nil)
|
|
||||||
(setq eldoc-documentation-strategy
|
|
||||||
'eldoc-documentation-compose-eagerly))
|
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(add-to-list 'eglot-server-programs
|
(add-to-list 'eglot-server-programs
|
||||||
'(scala-mode .
|
'(scala-mode .
|
||||||
@@ -620,9 +511,6 @@ Setup prefix for keybindings.
|
|||||||
(add-to-list 'eglot-server-programs
|
(add-to-list 'eglot-server-programs
|
||||||
'(nix-mode . ("nixd")))
|
'(nix-mode . ("nixd")))
|
||||||
|
|
||||||
(add-to-list 'eglot-server-programs
|
|
||||||
'(gleam-ts-mode . ("gleam" "lsp")))
|
|
||||||
|
|
||||||
(setq-default eglot-workspace-configuration
|
(setq-default eglot-workspace-configuration
|
||||||
'(
|
'(
|
||||||
:metals (
|
:metals (
|
||||||
@@ -631,11 +519,7 @@ Setup prefix for keybindings.
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
:custom
|
|
||||||
(refactor-indications nil)
|
|
||||||
|
|
||||||
:hook (
|
:hook (
|
||||||
(eglot-managed-mode . mp-eglot-eldoc)
|
|
||||||
(go-mode . eglot-ensure)
|
(go-mode . eglot-ensure)
|
||||||
(go-mode . alex/organize-imports-on-save)
|
(go-mode . alex/organize-imports-on-save)
|
||||||
(go-mode . alex/format-on-save)
|
(go-mode . alex/format-on-save)
|
||||||
@@ -645,9 +529,6 @@ Setup prefix for keybindings.
|
|||||||
(nix-mode . eglot-ensure)
|
(nix-mode . eglot-ensure)
|
||||||
(nix-mode . alex/format-on-save)
|
(nix-mode . alex/format-on-save)
|
||||||
|
|
||||||
(gleam-ts-mode . eglot-ensure)
|
|
||||||
(gleam-ts-mode . alex/format-on-save)
|
|
||||||
|
|
||||||
(python-mode . eglot-ensure)
|
(python-mode . eglot-ensure)
|
||||||
(javascript-mode . eglot-ensure)
|
(javascript-mode . eglot-ensure)
|
||||||
(js-mode . eglot-ensure)
|
(js-mode . eglot-ensure)
|
||||||
@@ -664,6 +545,16 @@ Setup prefix for keybindings.
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(use-package eglot-booster
|
||||||
|
:after eglot
|
||||||
|
:config (eglot-booster-mode))
|
||||||
|
#+END_SRC
|
||||||
|
** Eldoc-box
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package eldoc-box
|
||||||
|
:after eglot
|
||||||
|
:bind (:map eglot-mode-map
|
||||||
|
("M-h" . eldoc-box-help-at-point)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Go
|
** Go
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
@@ -682,12 +573,6 @@ Setup prefix for keybindings.
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Gleam
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(use-package gleam-ts-mode
|
|
||||||
:mode "\\.gleam\\'"
|
|
||||||
)
|
|
||||||
#+END_SRC
|
|
||||||
** YAML
|
** YAML
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package yaml-mode
|
(use-package yaml-mode
|
||||||
@@ -715,21 +600,6 @@ Setup prefix for keybindings.
|
|||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package markdown-mode)
|
(use-package markdown-mode)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Dagbok
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(use-package dagbok
|
|
||||||
:commands (dagbok-today dagbok-year dagbok-next-day dagbok-previous-day
|
|
||||||
dagbok-switch-journal dagbok-note dagbok-tasks dagbok-questions dagbok-search
|
|
||||||
dagbok-add-task dagbok-ask dagbok-set-status dagbok-toggle-flag
|
|
||||||
dagbok-toggle-highlight dagbok-toggle-completed dagbok-backlinks
|
|
||||||
dagbok-set-property dagbok-toggle-toc dagbok-goto-heading
|
|
||||||
dagbok-refresh dagbok-browse)
|
|
||||||
:custom
|
|
||||||
(dagbok-url "https://dagbok.ppp.pm")
|
|
||||||
(dagbok-token-file "/run/agenix/dagbok-token")
|
|
||||||
:init
|
|
||||||
(alex/keybindings "d" '(:keymap dagbok-command-map :package dagbok :which-key "dagbok")))
|
|
||||||
#+END_SRC
|
|
||||||
** Javascript
|
** Javascript
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(setq
|
(setq
|
||||||
|
|||||||
@@ -8,17 +8,27 @@ let
|
|||||||
alwaysEnsure = true;
|
alwaysEnsure = true;
|
||||||
alwaysTangle = true;
|
alwaysTangle = true;
|
||||||
|
|
||||||
override = inputs.dagbok.overlays.emacs;
|
|
||||||
|
|
||||||
extraEmacsPackages = epkgs: [
|
extraEmacsPackages = epkgs: [
|
||||||
epkgs.flymake-go-staticcheck
|
epkgs.flymake-go-staticcheck
|
||||||
epkgs.tree-sitter-langs
|
epkgs.tree-sitter-langs
|
||||||
epkgs.treesit-grammars.with-all-grammars
|
epkgs.treesit-grammars.with-all-grammars
|
||||||
|
|
||||||
|
(epkgs.trivialBuild {
|
||||||
|
pname = "eglot-booster";
|
||||||
|
version = "main-2024-04-11";
|
||||||
|
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "jdtsmith";
|
||||||
|
repo = "eglot-booster";
|
||||||
|
rev = "e19dd7ea81bada84c66e8bdd121408d9c0761fe6";
|
||||||
|
hash = "sha256-vF34ZoUUj8RENyH9OeKGSPk34G6KXZhEZozQKEcRNhs=";
|
||||||
|
};
|
||||||
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
e = pkgs.writeShellScriptBin "e" ''
|
e = pkgs.writeShellScriptBin "e" ''
|
||||||
exec ${emacs}/bin/emacs -nw "$@"
|
${emacs}/bin/emacs -nw $@
|
||||||
'';
|
'';
|
||||||
|
|
||||||
ec = pkgs.writeShellScriptBin "ec" ''
|
ec = pkgs.writeShellScriptBin "ec" ''
|
||||||
@@ -35,22 +45,15 @@ in
|
|||||||
TIG_EDITOR = "${e}/bin/e $@";
|
TIG_EDITOR = "${e}/bin/e $@";
|
||||||
};
|
};
|
||||||
|
|
||||||
home.file.".emacs.d/sodium-theme.el".source = ./sodium-theme.el;
|
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
e
|
e
|
||||||
ec
|
ec
|
||||||
emacs
|
emacs
|
||||||
pkgs.wl-clipboard
|
pkgs.wl-clipboard
|
||||||
|
pkgs.emacs-lsp-booster
|
||||||
pkgs.nixd
|
pkgs.nixd
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.ripgrep ];
|
environment.systemPackages = [ pkgs.ripgrep ];
|
||||||
|
|
||||||
age.secrets."dagbok-token" = {
|
|
||||||
file = ../../../../secrets/manatee/dagbok-token.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
;;; sodium-theme.el --- Grayscale with amber accents, like sodium streetlights at night -*- lexical-binding: t; no-byte-compile: t; -*-
|
|
||||||
(require 'doom-themes)
|
|
||||||
|
|
||||||
(def-doom-theme sodium
|
|
||||||
"Grayscale with amber accents, like sodium streetlights at night."
|
|
||||||
((bg '("#222222" nil nil))
|
|
||||||
(bg-alt '("#181818" nil nil))
|
|
||||||
(base0 '("#121212" nil nil))
|
|
||||||
(base1 '("#181818" nil nil))
|
|
||||||
(base2 '("#242424" nil nil))
|
|
||||||
(base3 '("#2c2c2c" nil nil))
|
|
||||||
(base4 '("#404040" nil nil))
|
|
||||||
(base5 '("#626262" nil nil))
|
|
||||||
(base6 '("#858585" nil nil))
|
|
||||||
(base7 '("#a0a0a0" nil nil))
|
|
||||||
(base8 '("#f4f4f4" nil nil))
|
|
||||||
(fg '("#e2e2e2" nil nil))
|
|
||||||
(fg-alt '("#9a9a9a" nil nil))
|
|
||||||
|
|
||||||
(grey base5)
|
|
||||||
(red '("#e0473c" nil nil))
|
|
||||||
(orange '("#ffb347" nil nil))
|
|
||||||
(green '("#f4f4f4" nil nil))
|
|
||||||
(teal '("#aaaaaa" nil nil))
|
|
||||||
(yellow '("#ffb347" nil nil))
|
|
||||||
(blue '("#aaaaaa" nil nil))
|
|
||||||
(dark-blue '("#7a7a7a" nil nil))
|
|
||||||
(magenta '("#ffb347" nil nil))
|
|
||||||
(violet '("#9a9a9a" nil nil))
|
|
||||||
(cyan '("#bebebe" nil nil))
|
|
||||||
(dark-cyan '("#8a8a8a" nil nil))
|
|
||||||
(added '("#7fb35a" nil nil))
|
|
||||||
|
|
||||||
(highlight orange)
|
|
||||||
(vertical-bar base3)
|
|
||||||
(selection base3)
|
|
||||||
(builtin fg)
|
|
||||||
(comments base5)
|
|
||||||
(doc-comments base6)
|
|
||||||
(constants yellow)
|
|
||||||
(functions base8)
|
|
||||||
(keywords orange)
|
|
||||||
(methods base8)
|
|
||||||
(operators fg-alt)
|
|
||||||
(type fg)
|
|
||||||
(strings base7)
|
|
||||||
(variables fg)
|
|
||||||
(numbers yellow)
|
|
||||||
(region '("#4a3820" nil nil))
|
|
||||||
(error red)
|
|
||||||
(warning red)
|
|
||||||
(success green)
|
|
||||||
(vc-modified base6)
|
|
||||||
(vc-added added)
|
|
||||||
(vc-deleted red)
|
|
||||||
|
|
||||||
(modeline-fg fg)
|
|
||||||
(modeline-fg-alt base6)
|
|
||||||
(modeline-bg base2)
|
|
||||||
(modeline-bg-alt bg-alt)
|
|
||||||
(modeline-bg-inactive bg-alt)
|
|
||||||
(modeline-bg-inactive-l bg-alt))
|
|
||||||
|
|
||||||
(((custom-group-subtitle &override) :foreground orange)
|
|
||||||
((diff-added &override) :foreground added)
|
|
||||||
((diff-indicator-added &override) :foreground added)
|
|
||||||
((magit-diff-added &override) :foreground added)
|
|
||||||
((magit-diff-added-highlight &override) :foreground added)
|
|
||||||
((magit-diffstat-added &override) :foreground added)
|
|
||||||
((hl-todo &override) :foreground orange)
|
|
||||||
((magit-blame-date &override) :foreground orange)
|
|
||||||
((markdown-list-face &override) :foreground orange)
|
|
||||||
((markdown-metadata-key-face &override) :foreground orange)
|
|
||||||
((org-journal-calendar-scheduled-face &override) :foreground orange)
|
|
||||||
((org-priority &override) :foreground orange)
|
|
||||||
((paren-face-match &override) :foreground orange)
|
|
||||||
((widget-button-pressed &override) :foreground orange)))
|
|
||||||
|
|
||||||
;;; sodium-theme.el ends here
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{ pkgs, config, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
wrapped = pkgs.wrapFirefox pkgs.firefox-devedition-unwrapped {
|
wrapped = pkgs.wrapFirefox pkgs.firefox-devedition-unwrapped {
|
||||||
extraPolicies = {
|
extraPolicies = {
|
||||||
@@ -40,32 +40,10 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
ff-work = pkgs.writeShellApplication {
|
|
||||||
name = "ff-work";
|
|
||||||
text = ''
|
|
||||||
${wrapped}/bin/firefox-devedition -P work --new-window "$@"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Links opened from work checkouts (e.g. `gcloud auth login` in a work
|
|
||||||
# devshell, which ships its own `gcloud`, or `gt`) go to the work profile.
|
|
||||||
# Used both as `$BROWSER` and as the default handler for `xdg-open`.
|
|
||||||
browser = pkgs.writeShellApplication {
|
|
||||||
name = "browser";
|
|
||||||
text = ''
|
|
||||||
case "$PWD/" in
|
|
||||||
"$HOME/code/work/"*) exec ${ff-work}/bin/ff-work "$@" ;;
|
|
||||||
*) exec ${ff-alex}/bin/ff-alex "$@" ;;
|
|
||||||
esac
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
sharedSettings = {
|
sharedSettings = {
|
||||||
"general.smoothScroll" = true;
|
"general.smoothScroll" = true;
|
||||||
"apz.gtk.kinetic_scroll.enabled" = false;
|
"apz.gtk.kinetic_scroll.enabled" = false;
|
||||||
"network.dns.force_waiting_https_rr" = false;
|
"network.dns.force_waiting_https_rr" = false;
|
||||||
"browser.smartwindow.enabled" = false;
|
|
||||||
"browser.smartwindow.isDefaultWindow" = false;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -75,12 +53,6 @@ in
|
|||||||
|
|
||||||
package = wrapped;
|
package = wrapped;
|
||||||
|
|
||||||
# Pin the legacy profile location. The default changed to the XDG path
|
|
||||||
# (`$XDG_CONFIG_HOME/mozilla/firefox`) for stateVersion >= "26.05";
|
|
||||||
# keep the old `~/.mozilla/firefox` so the existing profile isn't
|
|
||||||
# stranded (migrating would require moving the profile dir by hand).
|
|
||||||
configPath = ".mozilla/firefox";
|
|
||||||
|
|
||||||
profiles = {
|
profiles = {
|
||||||
alex = {
|
alex = {
|
||||||
id = 0;
|
id = 0;
|
||||||
@@ -96,16 +68,11 @@ in
|
|||||||
|
|
||||||
settings = sharedSettings // {
|
settings = sharedSettings // {
|
||||||
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
|
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
|
||||||
"network.lna.skip-domains" = "music-admin-staging.soundtr.ac,api-internal.apps-us.platform.staging.internal.syb.sh";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
userChrome = ''
|
userChrome = ''
|
||||||
#navigator-toolbox,
|
.tab-content {
|
||||||
#nav-bar {
|
border-top: solid #9400FF !important;
|
||||||
background-image: linear-gradient(
|
|
||||||
color-mix(in srgb, #${config.lib.colors.foreground} 5%, transparent),
|
|
||||||
color-mix(in srgb, #${config.lib.colors.foreground} 5%, transparent)
|
|
||||||
) !important;
|
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -120,27 +87,21 @@ in
|
|||||||
exec = "${ff-alex}/bin/ff-alex %U";
|
exec = "${ff-alex}/bin/ff-alex %U";
|
||||||
terminal = false;
|
terminal = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
browser = {
|
|
||||||
name = "browser";
|
|
||||||
exec = "${browser}/bin/browser %U";
|
|
||||||
terminal = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mimeApps = {
|
mimeApps = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
defaultApplications = {
|
defaultApplications = {
|
||||||
"text/html" = "browser.desktop";
|
"text/html" = "ff-alex.desktop";
|
||||||
"x-scheme-handler/http" = "browser.desktop";
|
"x-scheme-handler/http" = "ff-alex.desktop";
|
||||||
"x-scheme-handler/https" = "browser.desktop";
|
"x-scheme-handler/https" = "ff-alex.desktop";
|
||||||
"application/x-exension-htm" = "browser.desktop";
|
"application/x-exension-htm" = "ff-alex.desktop";
|
||||||
"application/x-exension-html" = "browser.desktop";
|
"application/x-exension-html" = "ff-alex.desktop";
|
||||||
"application/x-exension-shtml" = "browser.desktop";
|
"application/x-exension-shtml" = "ff-alex.desktop";
|
||||||
"application/xhtml+xml" = "browser.desktop";
|
"application/xhtml+xml" = "ff-alex.desktop";
|
||||||
"application/x-exension-xhtml" = "browser.desktop";
|
"application/x-exension-xhtml" = "ff-alex.desktop";
|
||||||
"application/x-exension-xht" = "browser.desktop";
|
"application/x-exension-xht" = "ff-alex.desktop";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -151,12 +112,11 @@ in
|
|||||||
home.packages = [
|
home.packages = [
|
||||||
ff
|
ff
|
||||||
ff-alex
|
ff-alex
|
||||||
ff-work
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
MOZ_ENABLE_WAYLAND = 1;
|
MOZ_ENABLE_WAYLAND = 1;
|
||||||
BROWSER = "${browser}/bin/browser";
|
BROWSER = "${ff-alex}/bin/ff-alex $@";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
fonts.packages = [
|
fonts.packages = [
|
||||||
pkgs.noto-fonts
|
pkgs.noto-fonts
|
||||||
pkgs.noto-fonts-cjk-sans
|
pkgs.noto-fonts-cjk-sans
|
||||||
pkgs.noto-fonts-color-emoji
|
pkgs.noto-fonts-emoji
|
||||||
pkgs.nerd-fonts.jetbrains-mono
|
pkgs.nerd-fonts.jetbrains-mono
|
||||||
pkgs.liberation_ttf
|
pkgs.liberation_ttf
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ let
|
|||||||
enabled = config.mod.foot.enable;
|
enabled = config.mod.foot.enable;
|
||||||
|
|
||||||
hyprlandEnabled = config.mod.hyprland.enable;
|
hyprlandEnabled = config.mod.hyprland.enable;
|
||||||
|
|
||||||
colors = config.lib.colors.terminal;
|
|
||||||
indexed = prefix: list: lib.listToAttrs (lib.imap0 (i: c: lib.nameValuePair "${prefix}${toString i}" c) list);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@@ -27,30 +24,16 @@ in
|
|||||||
settings = {
|
settings = {
|
||||||
main = {
|
main = {
|
||||||
term = "xterm-256color";
|
term = "xterm-256color";
|
||||||
font = "JetBrainsMono Nerd Font:size=17";
|
font = "JetBrainsMono Nerd Font:size=15";
|
||||||
|
include = "${pkgs.foot.themes}/share/foot/themes/dracula";
|
||||||
};
|
};
|
||||||
|
|
||||||
colors-dark = {
|
|
||||||
foreground = colors.foreground;
|
|
||||||
background = colors.background;
|
|
||||||
cursor = "${colors.background} ${colors.cursor}";
|
|
||||||
selection-foreground = colors.foreground;
|
|
||||||
selection-background = colors.selection;
|
|
||||||
}
|
|
||||||
// indexed "regular" colors.regular
|
|
||||||
// indexed "bright" colors.bright;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
||||||
settings = {
|
settings = {
|
||||||
bind = [
|
bind = [
|
||||||
{
|
"$mod, RETURN, exec, ${pkgs.foot}/bin/foot"
|
||||||
_args = [
|
|
||||||
"SUPER + RETURN"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pkgs.foot}/bin/foot")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
programs.fzf = {
|
programs.fzf = {
|
||||||
|
|||||||
@@ -6,38 +6,6 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
enabled = config.mod.git.enable;
|
enabled = config.mod.git.enable;
|
||||||
|
|
||||||
# Wrapper around `ssh-keygen` used as git's SSH signing program. Before a
|
|
||||||
# signing operation it ensures the passphrase-protected signing key is loaded
|
|
||||||
# into the agent — `ssh-keygen -Y sign` reads the key from disk and re-prompts
|
|
||||||
# every commit otherwise, since `AddKeysToAgent` only ever caches auth keys.
|
|
||||||
# Loading it once (through the GUI askpass) lets later commits reuse the
|
|
||||||
# cached key from the agent. Verification and every other op pass straight
|
|
||||||
# through to the real ssh-keygen untouched.
|
|
||||||
sshSignWrapper = pkgs.writeShellApplication {
|
|
||||||
name = "git-ssh-sign";
|
|
||||||
runtimeInputs = [
|
|
||||||
pkgs.openssh
|
|
||||||
pkgs.gawk
|
|
||||||
pkgs.gnugrep
|
|
||||||
];
|
|
||||||
text = ''
|
|
||||||
key="${config.age.secrets."alex.pinwheel-github.com-signing".path}"
|
|
||||||
|
|
||||||
case " $* " in
|
|
||||||
*" -Y sign "*)
|
|
||||||
fp=""
|
|
||||||
fp="$(ssh-keygen -lf "$key.pub" 2>/dev/null | awk '{print $2}')" || true
|
|
||||||
if [ -n "$fp" ] && ! ssh-add -l 2>/dev/null | grep -qF "$fp"; then
|
|
||||||
# </dev/null detaches stdin so ssh-add uses SSH_ASKPASS (the GUI).
|
|
||||||
ssh-add "$key" </dev/null || true
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exec ssh-keygen "$@"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@@ -47,7 +15,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
home-manager.users.alex = { lib, ... }: {
|
home-manager.users.alex = {
|
||||||
programs.git = {
|
programs.git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
@@ -55,82 +23,17 @@ in
|
|||||||
{ path = ./gitconfig; }
|
{ path = ./gitconfig; }
|
||||||
];
|
];
|
||||||
|
|
||||||
signing = {
|
extraConfig = {
|
||||||
key = config.age.secrets."alex.pinwheel-github.com-signing.pub".path;
|
|
||||||
signByDefault = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
rerere.enable = true;
|
rerere.enable = true;
|
||||||
|
|
||||||
# Tells Git to use SSH instead of the default GPG
|
|
||||||
gpg.format = "ssh";
|
|
||||||
|
|
||||||
# Sign via a wrapper that loads the signing key into the agent on
|
|
||||||
# first use, so subsequent signed commits reuse the cached key
|
|
||||||
# instead of re-prompting for the passphrase every time.
|
|
||||||
gpg.ssh.program = "${sshSignWrapper}/bin/git-ssh-sign";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
home.file.".ssh/config".target = ".ssh/config_source";
|
|
||||||
|
|
||||||
home.activation.sshConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
||||||
run cat ~/.ssh/config_source > ~/.ssh/config
|
|
||||||
run chmod 600 ~/.ssh/config
|
|
||||||
'';
|
|
||||||
|
|
||||||
home.packages = [ pkgs.tig ];
|
home.packages = [ pkgs.tig ];
|
||||||
|
|
||||||
home.file.".tigrc".text = ''
|
home.file.".tigrc".text = ''
|
||||||
set main-view-line-number = yes
|
set main-view-line-number = yes
|
||||||
set main-view-line-number-interval = 1
|
set main-view-line-number-interval = 1
|
||||||
|
|
||||||
color default default default
|
|
||||||
color cursor color0 yellow bold
|
|
||||||
color search-result color0 yellow
|
|
||||||
color title-focus white color8 bold
|
|
||||||
color title-blur color8 default
|
|
||||||
color status white default
|
|
||||||
color delimiter color8 default
|
|
||||||
color line-number color8 default
|
|
||||||
|
|
||||||
color id yellow default
|
|
||||||
color date color8 default
|
|
||||||
color author cyan default
|
|
||||||
color mode cyan default
|
|
||||||
color graph-commit yellow default
|
|
||||||
color main-commit default default
|
|
||||||
color main-head yellow default bold
|
|
||||||
color main-ref yellow default
|
|
||||||
color main-local-tag color11 default
|
|
||||||
color main-tag color11 default bold
|
|
||||||
color main-remote color8 default
|
|
||||||
color main-tracked yellow default bold
|
|
||||||
color main-replace cyan default
|
|
||||||
|
|
||||||
color diff-header color15 default bold
|
|
||||||
color diff-index color8 default
|
|
||||||
color diff-chunk cyan default
|
|
||||||
color diff-add green default
|
|
||||||
color diff-del red default
|
|
||||||
color diff-stat cyan default
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets = {
|
|
||||||
"alex.pinwheel-github.com-signing" = {
|
|
||||||
file = ../../../../secrets/pinwheel/alex.pinwheel-github.com-signing.age;
|
|
||||||
path = "/home/alex/.ssh/alex.pinwheel-github.com-signing";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
"alex.pinwheel-github.com-signing.pub" = {
|
|
||||||
file = ../../../../secrets/pinwheel/alex.pinwheel-github.com-signing.pub.age;
|
|
||||||
path = "/home/alex/.ssh/alex.pinwheel-github.com-signing.pub";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -5,5 +5,8 @@
|
|||||||
[url "git@github.com:"]
|
[url "git@github.com:"]
|
||||||
insteadOf = https://github.com/
|
insteadOf = https://github.com/
|
||||||
|
|
||||||
|
[url "git@codeberg.org:"]
|
||||||
|
insteadOf = https://codeberg.org/
|
||||||
|
|
||||||
[url "gitea@git.ppp.pm:"]
|
[url "gitea@git.ppp.pm:"]
|
||||||
insteadOf = https://git.ppp.pm/
|
insteadOf = https://git.ppp.pm/
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.gleam.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.gleam = {
|
|
||||||
enable = lib.mkEnableOption "enable gleam module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
home-manager.users.alex = {
|
|
||||||
home.packages = [
|
|
||||||
pkgs.gleam
|
|
||||||
pkgs.beamPackages.erlang
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,7 @@ in
|
|||||||
|
|
||||||
package = pkgs.go;
|
package = pkgs.go;
|
||||||
env = {
|
env = {
|
||||||
GOPATH = "/home/alex/code/go";
|
GOPATH = "code/go";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ in
|
|||||||
let
|
let
|
||||||
session = {
|
session = {
|
||||||
user = "alex";
|
user = "alex";
|
||||||
command = "uwsm start hyprland-uwsm.desktop";
|
command = "${pkgs.hyprland}/bin/Hyprland";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
@@ -7,73 +6,6 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
enabled = config.mod.hyprland.enable;
|
enabled = config.mod.hyprland.enable;
|
||||||
|
|
||||||
mod = "SUPER";
|
|
||||||
|
|
||||||
monitorScript = pkgs.writeShellScript "hyprland-monitor-handler" ''
|
|
||||||
INTERNAL="eDP-1"
|
|
||||||
EXTERNAL_MONITORS="HDMI-A-1 DP-3"
|
|
||||||
HYPRCTL="${pkgs.hyprland}/bin/hyprctl"
|
|
||||||
JQ="${pkgs.jq}/bin/jq"
|
|
||||||
|
|
||||||
get_active_external() {
|
|
||||||
# Return the first connected external monitor
|
|
||||||
for mon in $EXTERNAL_MONITORS; do
|
|
||||||
if $HYPRCTL monitors -j | $JQ -e ".[] | select(.name == \"$mon\")" > /dev/null 2>&1; then
|
|
||||||
echo "$mon"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
bind_workspaces() {
|
|
||||||
local external batch=""
|
|
||||||
|
|
||||||
if external=$(get_active_external); then
|
|
||||||
# External monitor connected: move workspaces 1-5 to external, 6-10 to internal
|
|
||||||
for ws in 1 2 3 4 5; do
|
|
||||||
batch="$batch dispatch hl.dsp.workspace.move({ monitor = \"$external\", workspace = $ws });"
|
|
||||||
done
|
|
||||||
for ws in 6 7 8 9 10; do
|
|
||||||
batch="$batch dispatch hl.dsp.workspace.move({ monitor = \"$INTERNAL\", workspace = $ws });"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
# No external monitor: move all workspaces to internal
|
|
||||||
for ws in 1 2 3 4 5 6 7 8 9 10; do
|
|
||||||
batch="$batch dispatch hl.dsp.workspace.move({ monitor = \"$INTERNAL\", workspace = $ws });"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
$HYPRCTL --batch "$batch"
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_event() {
|
|
||||||
case $1 in
|
|
||||||
monitoradded*|monitorremoved*)
|
|
||||||
sleep 0.5
|
|
||||||
bind_workspaces
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Start the event listener first so monitoradded events emitted during
|
|
||||||
# session startup are not lost in the gap before we begin reading them.
|
|
||||||
${pkgs.socat}/bin/socat -U - UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do
|
|
||||||
handle_event "$line"
|
|
||||||
done &
|
|
||||||
LISTENER_PID=$!
|
|
||||||
|
|
||||||
# Give socat a moment to actually connect before the initial bind.
|
|
||||||
sleep 0.2
|
|
||||||
bind_workspaces
|
|
||||||
|
|
||||||
# Re-bind once more after the DRM subsystem has had time to enumerate
|
|
||||||
# external connectors, in case they were not yet present at session start.
|
|
||||||
(sleep 3; bind_workspaces) &
|
|
||||||
|
|
||||||
wait $LISTENER_PID
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@@ -83,196 +15,85 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
config = lib.mkIf enabled {
|
||||||
programs.hyprland = {
|
|
||||||
enable = true;
|
|
||||||
withUWSM = true;
|
|
||||||
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
|
|
||||||
portalPackage =
|
|
||||||
inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
|
|
||||||
|
|
||||||
xwayland = {
|
|
||||||
enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
wayland.windowManager.hyprland = {
|
wayland.windowManager.hyprland = {
|
||||||
enable = true;
|
enable = true;
|
||||||
systemd.enable = false;
|
|
||||||
configType = "lua";
|
xwayland = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
exec-once=waybar
|
||||||
|
exec-once=hyprctl setcursor Adwaita 24
|
||||||
|
|
||||||
|
env = GDK_DPI_SCALE,1.5
|
||||||
|
env = HYPRCURSOR_THEME,Adwaita
|
||||||
|
env = HYPRCURSOR_SIZE,24
|
||||||
|
|
||||||
|
monitor=eDP-1, 1920x1200, auto-center-down, 1
|
||||||
|
monitor=HDMI-A-1, 2560x1440@100, auto-center-up, 1
|
||||||
|
|
||||||
|
workspace = 1, monitor:HDMI-A-1
|
||||||
|
workspace = 2, monitor:HDMI-A-1
|
||||||
|
workspace = 3, monitor:HDMI-A-1
|
||||||
|
workspace = 4, monitor:HDMI-A-1
|
||||||
|
workspace = 5, monitor:HDMI-A-1
|
||||||
|
workspace = 6, monitor:eDP-1
|
||||||
|
workspace = 7, monitor:eDP-1
|
||||||
|
workspace = 8, monitor:eDP-1
|
||||||
|
workspace = 9, monitor:eDP-1
|
||||||
|
workspace = 10, monitor:eDP-1
|
||||||
|
|
||||||
|
workspace = w[tv1], gapsout:0, gapsin:0
|
||||||
|
workspace = f[1], gapsout:0, gapsin:0
|
||||||
|
windowrulev2 = bordersize 0, floating:0, onworkspace:w[tv1]
|
||||||
|
windowrulev2 = rounding 0, floating:0, onworkspace:w[tv1]
|
||||||
|
windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
|
||||||
|
windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
|
||||||
|
|
||||||
|
exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
|
||||||
|
'';
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
config = {
|
"$mod" = "SUPER";
|
||||||
xwayland.force_zero_scaling = true;
|
|
||||||
|
|
||||||
input = {
|
animations.enabled = false;
|
||||||
kb_layout = "se";
|
|
||||||
|
|
||||||
# 2 - Cursor focus will be detached from keyboard focus. Clicking on a window will move keyboard focus to that window.
|
xwayland = {
|
||||||
follow_mouse = 2;
|
force_zero_scaling = true;
|
||||||
|
|
||||||
sensitivity = 0.3;
|
|
||||||
accel_profile = "flat";
|
|
||||||
touchpad = {
|
|
||||||
natural_scroll = false;
|
|
||||||
tap_and_drag = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
cursor = {
|
|
||||||
zoom_factor = 1;
|
|
||||||
zoom_rigid = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
general = {
|
|
||||||
layout = "dwindle";
|
|
||||||
|
|
||||||
gaps_in = 0; # gaps between windows
|
|
||||||
gaps_out = 0; # gaps between windows and monitor edges
|
|
||||||
|
|
||||||
col = {
|
|
||||||
active_border = "rgba(${config.lib.colors.foreground}ff)";
|
|
||||||
inactive_border = "rgba(${config.lib.colors.background}ff)";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
dwindle.force_split = 2;
|
|
||||||
|
|
||||||
misc = {
|
|
||||||
disable_hyprland_logo = true;
|
|
||||||
disable_splash_rendering = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
animations.enabled = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
monitor = [
|
input = {
|
||||||
{
|
kb_layout = "se";
|
||||||
output = "eDP-1";
|
|
||||||
mode = "1920x1200";
|
|
||||||
position = "auto-center-down";
|
|
||||||
scale = "1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
output = "HDMI-A-1";
|
|
||||||
mode = "2560x1440@100";
|
|
||||||
position = "auto-center-up";
|
|
||||||
scale = "1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
output = "DP-3";
|
|
||||||
mode = "2560x1440@60";
|
|
||||||
position = "auto-center-up";
|
|
||||||
scale = "1";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
# Static defaults only: a workspace can only have one `monitor` in
|
# 2 - Cursor focus will be detached from keyboard focus. Clicking on a window will move keyboard focus to that window.
|
||||||
# hl.workspace_rule (later calls overwrite it, unlike hyprlang's
|
follow_mouse = 2;
|
||||||
# rule list). The hyprland-monitors service re-dispatches these to
|
|
||||||
# whichever external monitor is actually connected at startup and
|
|
||||||
# on hotplug, so this only matters for the brief window before it
|
|
||||||
# runs.
|
|
||||||
workspace_rule = [
|
|
||||||
{
|
|
||||||
workspace = "1";
|
|
||||||
monitor = "HDMI-A-1";
|
|
||||||
default = true;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "2";
|
|
||||||
monitor = "HDMI-A-1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "3";
|
|
||||||
monitor = "HDMI-A-1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "4";
|
|
||||||
monitor = "HDMI-A-1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "5";
|
|
||||||
monitor = "HDMI-A-1";
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
sensitivity = 0.3;
|
||||||
workspace = "6";
|
touchpad = {
|
||||||
monitor = "eDP-1";
|
natural_scroll = false;
|
||||||
default = true;
|
tap-and-drag = false;
|
||||||
}
|
};
|
||||||
{
|
};
|
||||||
workspace = "7";
|
|
||||||
monitor = "eDP-1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "8";
|
|
||||||
monitor = "eDP-1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "9";
|
|
||||||
monitor = "eDP-1";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "10";
|
|
||||||
monitor = "eDP-1";
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
cursor = {
|
||||||
workspace = "w[tv1]";
|
zoom_factor = 1;
|
||||||
gaps_out = 0;
|
zoom_rigid = true;
|
||||||
gaps_in = 0;
|
};
|
||||||
}
|
|
||||||
{
|
|
||||||
workspace = "f[1]";
|
|
||||||
gaps_out = 0;
|
|
||||||
gaps_in = 0;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
window_rule = [
|
general = {
|
||||||
{
|
layout = "dwindle";
|
||||||
name = "no-gaps-wtv1";
|
|
||||||
match = {
|
|
||||||
float = false;
|
|
||||||
workspace = "w[tv1]";
|
|
||||||
};
|
|
||||||
border_size = 0;
|
|
||||||
rounding = 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "no-gaps-f1";
|
|
||||||
match = {
|
|
||||||
float = false;
|
|
||||||
workspace = "f[1]";
|
|
||||||
};
|
|
||||||
border_size = 0;
|
|
||||||
rounding = 0;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
# https://wiki.archlinux.org/title/Hyprland#Jetbrains_apps_focus_issues
|
|
||||||
name = "xwayland-no-initial-focus";
|
|
||||||
match.xwayland = true;
|
|
||||||
no_initial_focus = true;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
env = [
|
gaps_in = 0; # gaps between windows
|
||||||
{ _args = [ "GDK_DPI_SCALE" "1.5" ]; }
|
gaps_out = 0; # gaps between windows and monitor edges
|
||||||
{ _args = [ "HYPRCURSOR_THEME" "Adwaita" ]; }
|
|
||||||
{ _args = [ "HYPRCURSOR_SIZE" "24" ]; }
|
|
||||||
];
|
|
||||||
|
|
||||||
on = {
|
"col.active_border" = "rgba(${config.lib.colors.foreground}ff)";
|
||||||
_args = [
|
"col.inactive_border" = "rgba(${config.lib.colors.background}ff)";
|
||||||
"hyprland.start"
|
};
|
||||||
(lib.generators.mkLuaInline ''
|
|
||||||
function()
|
dwindle = {
|
||||||
hl.exec_cmd("uwsm app -- waybar")
|
force_split = 2;
|
||||||
hl.exec_cmd("uwsm app -- hyprctl setcursor Adwaita 24")
|
|
||||||
end
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bind =
|
bind =
|
||||||
@@ -284,23 +105,10 @@ in
|
|||||||
in
|
in
|
||||||
builtins.toString n;
|
builtins.toString n;
|
||||||
|
|
||||||
focusWs = x: {
|
select = builtins.genList (x: "$mod, ${ws x}, workspace, ${builtins.toString (x + 1)}") 10;
|
||||||
_args = [
|
move = builtins.genList (
|
||||||
"${mod} + ${ws x}"
|
x: "$mod SHIFT, ${ws x}, movetoworkspacesilent, ${builtins.toString (x + 1)}"
|
||||||
(lib.generators.mkLuaInline "hl.dsp.focus({ workspace = ${builtins.toString (x + 1)} })")
|
) 10;
|
||||||
];
|
|
||||||
};
|
|
||||||
moveToWs = x: {
|
|
||||||
_args = [
|
|
||||||
"${mod} + SHIFT + ${ws x}"
|
|
||||||
(lib.generators.mkLuaInline
|
|
||||||
"hl.dsp.window.move({ workspace = ${builtins.toString (x + 1)}, follow = false })"
|
|
||||||
)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
select = builtins.genList focusWs 10;
|
|
||||||
move = builtins.genList moveToWs 10;
|
|
||||||
|
|
||||||
magnifier = pkgs.writeShellScript "magnifier" ''
|
magnifier = pkgs.writeShellScript "magnifier" ''
|
||||||
CURRENT=$(${pkgs.hyprland}/bin/hyprctl getoption cursor:zoom_factor -j | ${pkgs.jq}/bin/jq .float)
|
CURRENT=$(${pkgs.hyprland}/bin/hyprctl getoption cursor:zoom_factor -j | ${pkgs.jq}/bin/jq .float)
|
||||||
@@ -323,87 +131,31 @@ in
|
|||||||
select
|
select
|
||||||
++ move
|
++ move
|
||||||
++ [
|
++ [
|
||||||
{
|
"$mod, ESCAPE, killactive"
|
||||||
_args = [
|
|
||||||
"${mod} + ESCAPE"
|
|
||||||
(lib.generators.mkLuaInline "hl.dsp.window.close()")
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
"$mod, f, fullscreen, 1"
|
||||||
_args = [
|
"$mod SHIFT, f, togglefloating, active"
|
||||||
"${mod} + f"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.window.fullscreen({ mode = "maximized" })'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + SHIFT + f"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.window.float({ action = "toggle" })'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
"$mod, h, movefocus, l"
|
||||||
_args = [
|
"$mod, j, movefocus, d"
|
||||||
"${mod} + h"
|
"$mod, k, movefocus, u"
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.focus({ direction = "left" })'')
|
"$mod, l, movefocus, r"
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + j"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.focus({ direction = "down" })'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + k"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.focus({ direction = "up" })'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + l"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.focus({ direction = "right" })'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
"$mod CONTROL, 1, exec, ${magnifier} --increase"
|
||||||
_args = [
|
"$mod CONTROL, 2, exec, ${magnifier} --decrease"
|
||||||
"${mod} + CONTROL + 1"
|
"$mod CONTROL, 3, exec, ${magnifier} --reset"
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${magnifier} --increase")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + CONTROL + 2"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${magnifier} --decrease")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + CONTROL + 3"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${magnifier} --reset")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
# mouse movements: hyprland's lua API has no separate `bindm`,
|
|
||||||
# mouse binds are plain `hl.bind` with `{ mouse = true }`.
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + mouse:272" # left click
|
|
||||||
(lib.generators.mkLuaInline "hl.dsp.window.drag()")
|
|
||||||
{ mouse = true; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"${mod} + mouse:273" # right click
|
|
||||||
(lib.generators.mkLuaInline "hl.dsp.window.resize()")
|
|
||||||
{ mouse = true; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
bindm = [
|
||||||
|
# mouse movements
|
||||||
|
"$mod, mouse:272, movewindow" # left click
|
||||||
|
"$mod, mouse:273, resizewindow" # right click
|
||||||
|
];
|
||||||
|
|
||||||
|
misc = {
|
||||||
|
disable_hyprland_logo = true;
|
||||||
|
disable_splash_rendering = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -411,23 +163,6 @@ in
|
|||||||
pkgs.wdisplays
|
pkgs.wdisplays
|
||||||
pkgs.bc
|
pkgs.bc
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.services.hyprland-monitors = {
|
|
||||||
Unit = {
|
|
||||||
Description = "Hyprland monitor hotplug handler";
|
|
||||||
PartOf = [ "graphical-session.target" ];
|
|
||||||
After = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
Service = {
|
|
||||||
Type = "simple";
|
|
||||||
ExecStart = "${monitorScript}";
|
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = 5;
|
|
||||||
};
|
|
||||||
Install = {
|
|
||||||
WantedBy = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# To start electron apps like `chromium` with wayland support
|
# To start electron apps like `chromium` with wayland support
|
||||||
@@ -445,7 +180,5 @@ in
|
|||||||
|
|
||||||
# openGL is needed for wayland/hyprland
|
# openGL is needed for wayland/hyprland
|
||||||
hardware.graphics.enable = true;
|
hardware.graphics.enable = true;
|
||||||
|
|
||||||
boot.kernelParams = [ "i915.enable_psr=0" ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.hyprlock.enable;
|
|
||||||
hyprlandEnabled = config.mod.hyprland.enable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.hyprlock = {
|
|
||||||
enable = lib.mkEnableOption "enable hyprlock module";
|
|
||||||
|
|
||||||
dpmsTimeout = lib.mkOption {
|
|
||||||
description = "timeout in seconds before DPMS is turned on";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "10";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
home-manager.users.alex = {
|
|
||||||
programs.hyprlock = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
general = {
|
|
||||||
hide_cursor = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
background = [
|
|
||||||
{
|
|
||||||
color = "rgb(000000)";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
input-field = [
|
|
||||||
{
|
|
||||||
size = "250, 50";
|
|
||||||
position = "0, 0";
|
|
||||||
halign = "center";
|
|
||||||
valign = "center";
|
|
||||||
outline_thickness = 2;
|
|
||||||
dots_center = true;
|
|
||||||
fade_on_empty = false;
|
|
||||||
placeholder_text = "";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
|
||||||
settings = {
|
|
||||||
bind =
|
|
||||||
let
|
|
||||||
pause-music = "${pkgs.playerctl}/bin/playerctl -a pause";
|
|
||||||
|
|
||||||
dpmsTimeout = config.mod.hyprlock.dpmsTimeout;
|
|
||||||
|
|
||||||
dpmsOff = pkgs.writeShellScript "dpms-off" ''
|
|
||||||
${pkgs.hyprland}/bin/hyprctl dispatch 'hl.dsp.dpms({ action = "off" })'
|
|
||||||
'';
|
|
||||||
dpmsOn = pkgs.writeShellScript "dpms-on" ''
|
|
||||||
${pkgs.hyprland}/bin/hyprctl dispatch 'hl.dsp.dpms({ action = "on" })'
|
|
||||||
'';
|
|
||||||
|
|
||||||
dpms-lock = pkgs.writeShellScript "dpms-lock" ''
|
|
||||||
${pkgs.swayidle}/bin/swayidle \
|
|
||||||
timeout ${dpmsTimeout} ${dpmsOff} \
|
|
||||||
resume ${dpmsOn} &
|
|
||||||
|
|
||||||
${pkgs.hyprlock}/bin/hyprlock; ${pkgs.procps}/bin/pkill swayidle
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
[
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"SUPER + x"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pause-music}; ${dpms-lock}")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"switch:on:Lid Switch"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pkgs.procps}/bin/pidof hyprlock || { ${pause-music}; ${dpms-lock}; }")'')
|
|
||||||
{ locked = true; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"SUPER + SHIFT + x"
|
|
||||||
(lib.generators.mkLuaInline
|
|
||||||
''hl.dsp.exec_cmd("${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend-then-hibernate")''
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
security = {
|
|
||||||
polkit.enable = true;
|
|
||||||
|
|
||||||
pam.services.hyprlock = {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
home.packages = [ pkgs.typescript-language-server ];
|
home.packages = [ pkgs.nodePackages.typescript-language-server ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -9,23 +9,14 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
users.users.alex.extraGroups = [ "video" ];
|
users.users.alex.extraGroups = [ "video" ];
|
||||||
|
programs.light.enable = true;
|
||||||
|
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
||||||
settings = {
|
settings = {
|
||||||
bind = [
|
bind = [
|
||||||
{
|
", XF86MonBrightnessUp, exec, ${pkgs.light}/bin/light -A 5"
|
||||||
_args = [
|
", XF86MonBrightnessDown, exec, ${pkgs.light}/bin/light -U 5"
|
||||||
"XF86MonBrightnessUp"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pkgs.brightnessctl}/bin/brightnessctl set +5%")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"XF86MonBrightnessDown"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pkgs.brightnessctl}/bin/brightnessctl set 5%-")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,25 +14,18 @@ in
|
|||||||
settings = {
|
settings = {
|
||||||
bind =
|
bind =
|
||||||
let
|
let
|
||||||
prev = "${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spotify previous";
|
prev = "${pkgs.playerctl}/bin/playerctl -p naviterm,spotify previous";
|
||||||
next = "${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spotify next";
|
next = "${pkgs.playerctl}/bin/playerctl -p naviterm,spotify next";
|
||||||
|
|
||||||
mkExec = key: cmd: {
|
|
||||||
_args = [
|
|
||||||
key
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${cmd}")'')
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
(mkExec "XF86AudioPrev" prev)
|
", XF86AudioPrev, exec, ${prev}"
|
||||||
(mkExec "XF86AudioNext" next)
|
", XF86AudioNext, exec, ${next}"
|
||||||
(mkExec "XF86AudioPlay" "${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spotify play-pause")
|
", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl -p naviterm,spotify play-pause"
|
||||||
(mkExec "XF86AudioPause" "${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spoitfy play-pause")
|
", XF86AudioPause, exec, ${pkgs.playerctl}/bin/playerctl -p naviterm,spoitfy play-pause"
|
||||||
|
|
||||||
(mkExec "SUPER + ALT + LEFT" prev)
|
"$mod ALT, LEFT, exec, ${prev}"
|
||||||
(mkExec "SUPER + ALT + RIGHT" next)
|
"$mod ALT, RIGHT, exec, ${next}"
|
||||||
(mkExec "SUPER + ALT + DOWN" "${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spotify play-pause")
|
"$mod ALT, DOWN, exec, ${pkgs.playerctl}/bin/playerctl -p naviterm,spotify play-pause"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -40,22 +33,10 @@ in
|
|||||||
home.packages = [
|
home.packages = [
|
||||||
pkgs.playerctl
|
pkgs.playerctl
|
||||||
pkgs.spotify
|
pkgs.spotify
|
||||||
inputs.naviterm.packages.${pkgs.stdenv.hostPlatform.system}.default
|
inputs.naviterm.packages.${pkgs.system}.default
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.ndp = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
server = "http://manatee:4533";
|
|
||||||
user = "navi";
|
|
||||||
passwordCommand = "cat ${config.age.secrets."navidrome-password".path}";
|
|
||||||
anthropicKeyCommand = "cat ${config.age.secrets."ndp-llm-api-key".path}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager.sharedModules = [ inputs.ndp.homeManagerModules.default ];
|
|
||||||
|
|
||||||
systemd.user.services.playerctld = {
|
systemd.user.services.playerctld = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "starts playerctld daemon";
|
Description = "starts playerctld daemon";
|
||||||
@@ -66,29 +47,4 @@ in
|
|||||||
ExecStart = "${pkgs.playerctl}/bin/playerctld";
|
ExecStart = "${pkgs.playerctl}/bin/playerctld";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Ensure the parent dir of the secret's path is owned by alex; otherwise
|
|
||||||
# agenix creates it as root.
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /home/alex/.config/naviterm 0755 alex users -"
|
|
||||||
];
|
|
||||||
|
|
||||||
age.secrets."naviterm-config" = {
|
|
||||||
file = ../../../../secrets/pinwheel/naviterm-config.age;
|
|
||||||
path = "/home/alex/.config/naviterm/config.ini";
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."navidrome-password" = {
|
|
||||||
file = ../../../../secrets/pinwheel/navidrome-password.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."ndp-llm-api-key" = {
|
|
||||||
file = ../../../../secrets/pinwheel/ndp-llm-api-key.age;
|
|
||||||
owner = "alex";
|
|
||||||
group = "users";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,21 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
{
|
{
|
||||||
home-manager = {
|
services.connman = {
|
||||||
users.alex = {
|
enable = true;
|
||||||
home.packages = [ pkgs.networkmanager ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
networking = {
|
wifi = {
|
||||||
wireless.enable = false; # Wireless is managed by networkmanager
|
backend = "iwd";
|
||||||
|
|
||||||
networkmanager = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
wifi = {
|
|
||||||
backend = "iwd";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networkInterfaceBlacklist = [
|
||||||
|
"vmnet"
|
||||||
|
"vboxnet"
|
||||||
|
"virbr"
|
||||||
|
"ifb"
|
||||||
|
"ve"
|
||||||
|
"docker"
|
||||||
|
"br-"
|
||||||
|
"wg-"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
pkgs.nixfmt
|
pkgs.nixfmt-rfc-style
|
||||||
pkgs.nix-tree
|
pkgs.nix-tree
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ in
|
|||||||
|
|
||||||
services.resolved = {
|
services.resolved = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
dnssec = "false";
|
||||||
Resolve = {
|
domains = [ "~." ];
|
||||||
Domains = [ "~." ];
|
fallbackDns = [
|
||||||
DNSSEC = false;
|
"1.1.1.1#one.one.one.one"
|
||||||
DNSOverTLS = true;
|
"1.0.0.1#one.one.one.one"
|
||||||
};
|
];
|
||||||
};
|
extraConfig = ''
|
||||||
|
DNSOverTLS=yes
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -38,20 +38,8 @@ in
|
|||||||
in
|
in
|
||||||
[
|
[
|
||||||
# will lock the screen with `physlock`, see `lockOn.suspend
|
# will lock the screen with `physlock`, see `lockOn.suspend
|
||||||
{
|
"$mod SHIFT, x, exec, ${pause-music}; systemctl suspend"
|
||||||
_args = [
|
"$mod, x, exec, ${pause-music}; ${config.security.wrapperDir}/physlock -d -s -m"
|
||||||
"SUPER + SHIFT + x"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pause-music}; systemctl suspend")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
_args = [
|
|
||||||
"SUPER + x"
|
|
||||||
(lib.generators.mkLuaInline
|
|
||||||
''hl.dsp.exec_cmd("${pause-music}; ${config.security.wrapperDir}/physlock -d -s -m")''
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
let
|
|
||||||
picard = pkgs.symlinkJoin {
|
|
||||||
name = "picard";
|
|
||||||
paths = [ pkgs.picard ];
|
|
||||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
|
||||||
postBuild = ''
|
|
||||||
wrapProgram $out/bin/picard --set QT_SCREEN_SCALE_FACTORS 1.5
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
plugins = pkgs.linkFarm "picard-plugins" {
|
|
||||||
replaygain2 = pkgs.fetchFromGitHub {
|
|
||||||
owner = "metabrainz";
|
|
||||||
repo = "picard-plugin-replaygain2";
|
|
||||||
tag = "v2.3.1";
|
|
||||||
hash = "sha256-NBn/LgjDRVCHmbI+bU4j29UhrL33ctV9jXj6CfFRBWA=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home-manager.users.alex = { lib, ... }: {
|
|
||||||
home.packages = [
|
|
||||||
picard
|
|
||||||
pkgs.rsgain
|
|
||||||
];
|
|
||||||
|
|
||||||
home.activation.picardReplayGainPlugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
||||||
if ! ${pkgs.picard}/bin/picard-cli plugins info replaygain2 2>/dev/null | grep -qF "${plugins}/replaygain2"; then
|
|
||||||
run ${pkgs.picard}/bin/picard-cli --yes plugins install --no-git --reinstall "${plugins}/replaygain2" \
|
|
||||||
|| warnEcho "Failed to install Picard plugin replaygain2"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -27,33 +27,17 @@ in
|
|||||||
description = "Notify low battery at this level";
|
description = "Notify low battery at this level";
|
||||||
};
|
};
|
||||||
|
|
||||||
hibernateCapacity = lib.mkOption {
|
suspendCapacity = lib.mkOption {
|
||||||
default = 10;
|
default = 10;
|
||||||
description = "Warn at this level and then hibernate if power is not plugged in";
|
description = "Warn at this level and then suspend if power is not plugged in";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
swapDevices = lib.mkIf enabled [
|
|
||||||
{
|
|
||||||
device = "/var/lib/swapfile";
|
|
||||||
size = 64 * 1024; # MiB
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services = lib.mkIf enabled {
|
services = lib.mkIf enabled {
|
||||||
upower = {
|
upower = {
|
||||||
enable = true;
|
enable = true;
|
||||||
criticalPowerAction = "Hibernate";
|
|
||||||
};
|
|
||||||
|
|
||||||
logind.settings.Login = {
|
|
||||||
HandleLidSwitch = "ignore";
|
|
||||||
HandleLidSwitchExternalPower = "ignore";
|
|
||||||
HandleLidSwitchDocked = "ignore";
|
|
||||||
HandleSuspendKey = "ignore";
|
|
||||||
HandleHibernateKey = "ignore";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tlp = {
|
tlp = {
|
||||||
@@ -70,7 +54,7 @@ in
|
|||||||
timers = {
|
timers = {
|
||||||
"monitor-low-battery" = {
|
"monitor-low-battery" = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "monitors battery level and hibernates computer if battery is low";
|
Description = "monitors battery level and suspends computer if battery is low";
|
||||||
};
|
};
|
||||||
|
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
@@ -86,7 +70,7 @@ in
|
|||||||
services = {
|
services = {
|
||||||
"monitor-low-battery" = {
|
"monitor-low-battery" = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "monitors battery level and hibernates computer if battery is low";
|
Description = "monitors battery level and suspends computer if battery is low";
|
||||||
};
|
};
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
@@ -96,12 +80,12 @@ in
|
|||||||
path = [
|
path = [
|
||||||
pkgs.coreutils # For `cat`
|
pkgs.coreutils # For `cat`
|
||||||
pkgs.libnotify
|
pkgs.libnotify
|
||||||
pkgs.hyprlock
|
pkgs.swaylock
|
||||||
];
|
];
|
||||||
|
|
||||||
script =
|
script =
|
||||||
let
|
let
|
||||||
pause-music = "${pkgs.playerctl}/bin/playerctl -a pause";
|
pause-music = "${pkgs.playerctl}/bin/playerctl -p spotify pause";
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
BATTERY_CAPACITY=$(cat /sys/class/power_supply/${lowbat.battery}/capacity)
|
BATTERY_CAPACITY=$(cat /sys/class/power_supply/${lowbat.battery}/capacity)
|
||||||
@@ -113,13 +97,13 @@ in
|
|||||||
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.hibernateCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.suspendCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||||
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Hibernating in 60 seconds if power is not plugged in"
|
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Suspending in 60 seconds if power is not plugged in"
|
||||||
sleep 60s
|
sleep 60s
|
||||||
|
|
||||||
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
||||||
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
||||||
${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl hibernate
|
${pause-music}; ${pkgs.swaylock}/bin/swaylock -f; systemctl suspend
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -8,40 +8,19 @@
|
|||||||
let
|
let
|
||||||
hyprlandEnabled = config.mod.hyprland.enable;
|
hyprlandEnabled = config.mod.hyprland.enable;
|
||||||
|
|
||||||
grimblast = inputs.hyprland-contrib.packages.${pkgs.stdenv.hostPlatform.system}.grimblast;
|
grimblast = inputs.hyprland-contrib.packages.${pkgs.system}.grimblast;
|
||||||
satty = "${pkgs.satty}/bin/satty --filename - --copy-command ${pkgs.wl-clipboard}/bin/wl-copy --initial-tool brush --actions-on-enter save-to-clipboard,exit --early-exit copy";
|
area = "${pkgs.libnotify}/bin/notify-send 'ps: selected area' && ${grimblast}/bin/grimblast copy area";
|
||||||
|
screen = "${pkgs.libnotify}/bin/notify-send 'ps: selected screen' &&${grimblast}/bin/grimblast copy output";
|
||||||
# Short timeout so the notification is gone before the capture happens.
|
|
||||||
# Output captures are instant, so they wait for it to disappear.
|
|
||||||
notify = msg: "${pkgs.libnotify}/bin/notify-send -t 500 'ps: ${msg}'";
|
|
||||||
waitForNotify = "${pkgs.coreutils}/bin/sleep 0.6";
|
|
||||||
|
|
||||||
area = "${notify "selected area"} && ${grimblast}/bin/grimblast copy area";
|
|
||||||
screen = "${notify "selected screen"} && ${waitForNotify} && ${grimblast}/bin/grimblast copy output";
|
|
||||||
annotateArea = "${notify "annotate area"} && ${grimblast}/bin/grimblast save area - | ${satty}";
|
|
||||||
annotateScreen = "${notify "annotate screen"} && ${waitForNotify} && ${grimblast}/bin/grimblast save output - | ${satty}";
|
|
||||||
|
|
||||||
bind = keys: cmd: {
|
|
||||||
_args = [
|
|
||||||
keys
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${cmd}")'')
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
home.packages = [
|
home.packages = [ grimblast ];
|
||||||
grimblast
|
|
||||||
pkgs.satty
|
|
||||||
];
|
|
||||||
|
|
||||||
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
||||||
settings = {
|
settings = {
|
||||||
bind = [
|
bind = [
|
||||||
(bind "SUPER + Print" area)
|
"$mod, Print, exec, ${area}"
|
||||||
(bind "SUPER + CTRL + Print" screen)
|
"$mod CTRL, Print, exec, ${screen}"
|
||||||
(bind "SUPER + SHIFT + Print" annotateArea)
|
|
||||||
(bind "SUPER + CTRL + SHIFT + Print" annotateScreen)
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,19 +38,12 @@ in
|
|||||||
MUTED=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep MUTED | wc -l)
|
MUTED=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep MUTED | wc -l)
|
||||||
echo $MUTED > /sys/class/leds/platform::micmute/brightness
|
echo $MUTED > /sys/class/leds/platform::micmute/brightness
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mkExec = key: cmd: {
|
|
||||||
_args = [
|
|
||||||
key
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${cmd}")'')
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
(mkExec "XF86AudioRaiseVolume" "${pkgs.wireplumber}/bin/wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 2%+")
|
", XF86AudioRaiseVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 2%+"
|
||||||
(mkExec "XF86AudioLowerVolume" "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%-")
|
", XF86AudioLowerVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%-"
|
||||||
(mkExec "XF86AudioMute" "${toggle-output-mute}")
|
", XF86AudioMute, exec, ${toggle-output-mute}"
|
||||||
(mkExec "XF86AudioMicMute" "${toggle-input-mute}")
|
", XF86AudioMicMute, exec, ${toggle-input-mute}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,95 +1,55 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
|
||||||
authorizedKeysPath = "/home/alex/.ssh/authorized-keys";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
# Enable gnome-keyring at system level for PAM integration
|
|
||||||
services.gnome.gnome-keyring.enable = true;
|
|
||||||
|
|
||||||
# Use openssh's own ssh-agent — gcr's ssh-agent stalls signing RSA keys.
|
|
||||||
services.gnome.gcr-ssh-agent.enable = false;
|
|
||||||
programs.ssh.startAgent = true;
|
|
||||||
|
|
||||||
# Create the setuid `fusermount3` wrapper that `sshfs` execs to mount. The
|
|
||||||
# `programs.fuse` module used to install this unconditionally; newer nixpkgs
|
|
||||||
# gates it behind this option (default off), so opt in explicitly.
|
|
||||||
programs.fuse.enable = true;
|
|
||||||
|
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
services.gnome-keyring = {
|
|
||||||
enable = true;
|
|
||||||
components = [ "secrets" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
home.sessionVariables = {
|
|
||||||
# gnome-keyring's PAM hooks export SSH_AUTH_SOCK pointing at a dead gcr
|
|
||||||
# socket (gcr-ssh-agent is disabled above), which shadows openssh's own
|
|
||||||
# agent and silently breaks passphrase caching. Force it back to the
|
|
||||||
# openssh agent started by `programs.ssh.startAgent`.
|
|
||||||
SSH_AUTH_SOCK = "$XDG_RUNTIME_DIR/ssh-agent";
|
|
||||||
|
|
||||||
# Route passphrase prompts through seahorse's GUI askpass instead of the
|
|
||||||
# terminal. `prefer` uses the GUI even when a tty is attached (ssh only
|
|
||||||
# falls back to askpass with no controlling terminal otherwise).
|
|
||||||
SSH_ASKPASS = "${pkgs.seahorse}/libexec/seahorse/ssh-askpass";
|
|
||||||
SSH_ASKPASS_REQUIRE = "prefer";
|
|
||||||
};
|
|
||||||
|
|
||||||
programs.ssh = {
|
programs.ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableDefaultConfig = false;
|
|
||||||
|
|
||||||
settings = {
|
matchBlocks = {
|
||||||
"manatee" = {
|
"manatee" = {
|
||||||
HostName = "manatee";
|
hostname = "manatee";
|
||||||
User = "alex";
|
user = "alex";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.pinwheel-manatee";
|
identityFile = "/home/alex/.ssh/alex.pinwheel-manatee";
|
||||||
Port = 1122;
|
port = 1122;
|
||||||
};
|
};
|
||||||
|
|
||||||
"backwards" = {
|
"backwards" = {
|
||||||
HostName = "backwards";
|
hostname = "backwards";
|
||||||
User = "alex";
|
user = "alex";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.pinwheel-backwards";
|
identityFile = "/home/alex/.ssh/alex.pinwheel-backwards";
|
||||||
Port = 1122;
|
port = 1122;
|
||||||
|
};
|
||||||
|
|
||||||
|
"andromeda" = {
|
||||||
|
hostname = "andromeda.a2x.se";
|
||||||
|
user = "alex";
|
||||||
|
identityFile = "/home/alex/.ssh/alex.pinwheel-andromeda";
|
||||||
};
|
};
|
||||||
|
|
||||||
"tadpole" = {
|
"tadpole" = {
|
||||||
HostName = "65.21.106.222";
|
hostname = "65.21.106.222";
|
||||||
User = "alex";
|
user = "alex";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.pinwheel-tadpole";
|
identityFile = "/home/alex/.ssh/alex.pinwheel-tadpole";
|
||||||
Port = 1122;
|
port = 1122;
|
||||||
};
|
};
|
||||||
|
|
||||||
"github.com" = {
|
"github.com" = {
|
||||||
HostName = "github.com";
|
hostname = "github.com";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.pinwheel-github.com";
|
identityFile = "/home/alex/.ssh/alex.pinwheel-github.com";
|
||||||
|
};
|
||||||
|
|
||||||
|
"codeberg.org" = {
|
||||||
|
hostname = "codeberg.org";
|
||||||
|
identityFile = "/home/alex/.ssh/alex.pinwheel-codeberg.org";
|
||||||
};
|
};
|
||||||
|
|
||||||
"git.ppp.pm" = {
|
"git.ppp.pm" = {
|
||||||
HostName = "git.ppp.pm";
|
hostname = "git.ppp.pm";
|
||||||
IdentityFile = "/home/alex/.ssh/alex.pinwheel-git.ppp.pm";
|
identityFile = "/home/alex/.ssh/alex.pinwheel-git.ppp.pm";
|
||||||
};
|
|
||||||
|
|
||||||
"*" = {
|
|
||||||
ForwardAgent = false;
|
|
||||||
AddKeysToAgent = "yes";
|
|
||||||
Compression = false;
|
|
||||||
ServerAliveInterval = 0;
|
|
||||||
ServerAliveCountMax = 3;
|
|
||||||
HashKnownHosts = false;
|
|
||||||
UserKnownHostsFile = "~/.ssh/known_hosts";
|
|
||||||
ControlMaster = "no";
|
|
||||||
ControlPath = "~/.ssh/master-%r@%n:%p";
|
|
||||||
ControlPersist = "no";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [ pkgs.sshfs ];
|
||||||
pkgs.sshfs
|
|
||||||
pkgs.seahorse # GUI for managing gnome-keyring
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
@@ -132,6 +92,19 @@ in
|
|||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"alex.pinwheel-codeberg.org" = {
|
||||||
|
file = ../../../../secrets/pinwheel/alex.pinwheel-codeberg.org.age;
|
||||||
|
path = "/home/alex/.ssh/alex.pinwheel-codeberg.org";
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
|
"alex.pinwheel-codeberg.org.pub" = {
|
||||||
|
file = ../../../../secrets/pinwheel/alex.pinwheel-codeberg.org.pub.age;
|
||||||
|
path = "/home/alex/.ssh/alex.pinwheel-codeberg.org.pub";
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
|
|
||||||
"alex.pinwheel-git.ppp.pm" = {
|
"alex.pinwheel-git.ppp.pm" = {
|
||||||
file = ../../../../secrets/pinwheel/alex.pinwheel-git.ppp.pm.age;
|
file = ../../../../secrets/pinwheel/alex.pinwheel-git.ppp.pm.age;
|
||||||
path = "/home/alex/.ssh/alex.pinwheel-git.ppp.pm";
|
path = "/home/alex/.ssh/alex.pinwheel-git.ppp.pm";
|
||||||
@@ -145,6 +118,19 @@ in
|
|||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"alex.pinwheel-andromeda" = {
|
||||||
|
file = ../../../../secrets/pinwheel/alex.pinwheel-andromeda.age;
|
||||||
|
path = "/home/alex/.ssh/alex.pinwheel-andromeda";
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
|
"alex.pinwheel-andromeda.pub" = {
|
||||||
|
file = ../../../../secrets/pinwheel/alex.pinwheel-andromeda.pub.age;
|
||||||
|
path = "/home/alex/.ssh/alex.pinwheel-andromeda.pub";
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
|
|
||||||
"alex.pinwheel-tadpole" = {
|
"alex.pinwheel-tadpole" = {
|
||||||
file = ../../../../secrets/pinwheel/alex.pinwheel-tadpole.age;
|
file = ../../../../secrets/pinwheel/alex.pinwheel-tadpole.age;
|
||||||
path = "/home/alex/.ssh/alex.pinwheel-tadpole";
|
path = "/home/alex/.ssh/alex.pinwheel-tadpole";
|
||||||
@@ -157,21 +143,6 @@ in
|
|||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
"alex.backwards-pinwheel.pub" = {
|
|
||||||
file = ../../../../secrets/backwards/alex.backwards-pinwheel.pub.age;
|
|
||||||
path = "${authorizedKeysPath}/alex.backwards-pinwheel.pub";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.etc."ssh/authorized_keys_command" = {
|
|
||||||
mode = "0755";
|
|
||||||
text = ''
|
|
||||||
#!${pkgs.bash}/bin/bash
|
|
||||||
for file in ${authorizedKeysPath}/*; do
|
|
||||||
${pkgs.coreutils}/bin/cat "$file"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
@@ -184,8 +155,5 @@ in
|
|||||||
type = "ed25519";
|
type = "ed25519";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
authorizedKeysCommand = "/etc/ssh/authorized_keys_command";
|
|
||||||
authorizedKeysCommandUser = "root";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
enabled = config.mod.swaylock.enable;
|
||||||
|
hyprlandEnabled = config.mod.hyprland.enable;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
mod.swaylock = {
|
||||||
|
enable = lib.mkEnableOption "enable swaylock module";
|
||||||
|
|
||||||
|
dpmsTimeout = lib.mkOption {
|
||||||
|
description = "timeout in seconds before DPMS is turned on";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "10";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf enabled {
|
||||||
|
home-manager.users.alex = {
|
||||||
|
programs.swaylock = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
color = "000000";
|
||||||
|
indicator-idle-visible = false;
|
||||||
|
show-failed-attempts = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
||||||
|
settings = {
|
||||||
|
bind =
|
||||||
|
let
|
||||||
|
pause-music = "${pkgs.playerctl}/bin/playerctl -p spotify pause";
|
||||||
|
|
||||||
|
dpmsTimeout = config.mod.swaylock.dpmsTimeout;
|
||||||
|
dpms-lock = pkgs.writeShellScript "dpms-lock" ''
|
||||||
|
${pkgs.swayidle}/bin/swayidle \
|
||||||
|
timeout ${dpmsTimeout} "${pkgs.hyprland}/bin/hyprctl dispatch dpms off" \
|
||||||
|
resume "${pkgs.hyprland}/bin/hyprctl dispatch dpms on" &
|
||||||
|
|
||||||
|
${pkgs.swaylock}/bin/swaylock && ${pkgs.procps}/bin/pkill swayidle
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
[
|
||||||
|
"$mod, x, exec, ${pause-music}; ${dpms-lock}"
|
||||||
|
"$mod SHIFT, x, exec, ${pause-music}; ${pkgs.swaylock}/bin/swaylock -f; systemctl suspend"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
security = {
|
||||||
|
polkit.enable = true;
|
||||||
|
|
||||||
|
pam.services.swaylock.text = ''
|
||||||
|
# PAM configuration file for the swaylock screen locker. By default, it includes
|
||||||
|
# the 'login' configuration file (see /etc/pam.d/login)
|
||||||
|
auth include login
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
settings = {
|
settings = {
|
||||||
devices = {
|
devices = {
|
||||||
phone.id = config.lib.syncthing.phone;
|
phone.id = config.lib.syncthing.phone;
|
||||||
|
backwards.id = config.lib.syncthing.backwards;
|
||||||
manatee.id = config.lib.syncthing.manatee;
|
manatee.id = config.lib.syncthing.manatee;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
path = "/home/alex/sync/org";
|
path = "/home/alex/sync/org";
|
||||||
devices = [
|
devices = [
|
||||||
"phone"
|
"phone"
|
||||||
|
"backwards"
|
||||||
"manatee"
|
"manatee"
|
||||||
];
|
];
|
||||||
versioning = {
|
versioning = {
|
||||||
@@ -35,7 +37,7 @@
|
|||||||
|
|
||||||
personal = {
|
personal = {
|
||||||
path = "/home/alex/sync/personal";
|
path = "/home/alex/sync/personal";
|
||||||
devices = [ "manatee" ];
|
devices = [ "backwards" ];
|
||||||
versioning = {
|
versioning = {
|
||||||
type = "staggered";
|
type = "staggered";
|
||||||
params = {
|
params = {
|
||||||
@@ -46,7 +48,18 @@
|
|||||||
|
|
||||||
work = {
|
work = {
|
||||||
path = "/home/alex/sync/work";
|
path = "/home/alex/sync/work";
|
||||||
devices = [ "manatee" ];
|
devices = [ "backwards" ];
|
||||||
|
versioning = {
|
||||||
|
type = "staggered";
|
||||||
|
params = {
|
||||||
|
maxAge = "2592000"; # 30 days
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
books = {
|
||||||
|
path = "/home/alex/sync/reading-material/books";
|
||||||
|
devices = [ "backwards" ];
|
||||||
versioning = {
|
versioning = {
|
||||||
type = "staggered";
|
type = "staggered";
|
||||||
params = {
|
params = {
|
||||||
@@ -69,13 +82,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Ensure dataDir is owned by the syncthing user; otherwise the module creates it
|
|
||||||
# as root when making configDir (dataDir/.config/syncthing) on a fresh machine.
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /home/alex/sync 0755 alex users -"
|
|
||||||
"d /home/alex/sync/.config 0755 alex users -"
|
|
||||||
];
|
|
||||||
|
|
||||||
age = {
|
age = {
|
||||||
secrets = {
|
secrets = {
|
||||||
"syncthing-cert".file = ../../../../secrets/pinwheel/syncthing-cert.age;
|
"syncthing-cert".file = ../../../../secrets/pinwheel/syncthing-cert.age;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
services.tailscale.enable = true;
|
services.tailscale.enable = true;
|
||||||
services.tailscale.extraSetFlags = [ "--operator=alex" ];
|
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
checkReversePath = "loose";
|
checkReversePath = "loose";
|
||||||
|
|||||||
@@ -1,21 +1,6 @@
|
|||||||
{ pkgs, config, ... }:
|
{ pkgs, config, ... }:
|
||||||
let
|
|
||||||
colors = config.lib.colors.terminal;
|
|
||||||
dim = builtins.elemAt colors.bright 0;
|
|
||||||
|
|
||||||
tmuxPanes = pkgs.writeShellApplication {
|
|
||||||
name = "tmux-panes";
|
|
||||||
runtimeInputs = [
|
|
||||||
pkgs.jq
|
|
||||||
pkgs.tmux
|
|
||||||
];
|
|
||||||
text = builtins.readFile ./panes.sh;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
home.packages = [ tmuxPanes ];
|
|
||||||
|
|
||||||
programs.tmux = {
|
programs.tmux = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
@@ -25,27 +10,7 @@ in
|
|||||||
# Allow vi mode to be enabled instantly
|
# Allow vi mode to be enabled instantly
|
||||||
escapeTime = 0;
|
escapeTime = 0;
|
||||||
|
|
||||||
plugins = [
|
plugins = [ pkgs.tmuxPlugins.sensible ];
|
||||||
pkgs.tmuxPlugins.sensible
|
|
||||||
{
|
|
||||||
plugin = pkgs.tmuxPlugins.resurrect;
|
|
||||||
extraConfig = ''
|
|
||||||
set -g @resurrect-capture-pane-contents 'on'
|
|
||||||
set -g @resurrect-processes '"~bin/claude->${tmuxPanes}/bin/tmux-panes restore claude" "~bin/emacs -nw->${tmuxPanes}/bin/tmux-panes restore emacs"'
|
|
||||||
set -g @resurrect-hook-post-save-all '${tmuxPanes}/bin/tmux-panes save'
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.tmuxPlugins.continuum;
|
|
||||||
extraConfig = ''
|
|
||||||
# Remove date/time etc. on the right side
|
|
||||||
set -g status-right ""
|
|
||||||
|
|
||||||
set -g @continuum-restore 'on'
|
|
||||||
set -g @continuum-save-interval '10'
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
set -g renumber-windows on
|
set -g renumber-windows on
|
||||||
@@ -53,27 +18,28 @@ in
|
|||||||
# https://old.reddit.com/r/tmux/comments/mesrci/tmux_2_doesnt_seem_to_use_256_colors/
|
# https://old.reddit.com/r/tmux/comments/mesrci/tmux_2_doesnt_seem_to_use_256_colors/
|
||||||
set -g default-terminal "xterm-256color"
|
set -g default-terminal "xterm-256color"
|
||||||
set -ga terminal-overrides ",*256col*:Tc"
|
set -ga terminal-overrides ",*256col*:Tc"
|
||||||
set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[ q'
|
set -ga terminal-overrides "*:Ss=\E[%p1%d q:Se=\E[ q"
|
||||||
set-environment -g COLORTERM "truecolor"
|
set-environment -g COLORTERM "truecolor"
|
||||||
|
|
||||||
set-option -g allow-rename off
|
set-option -g allow-rename off
|
||||||
|
|
||||||
set -s extended-keys on
|
|
||||||
|
|
||||||
set -g set-clipboard on
|
|
||||||
|
|
||||||
# Status line colors
|
# Status line colors
|
||||||
set -g status-fg '#${colors.foreground}'
|
set -g status-fg '#${config.lib.colors.foreground}'
|
||||||
set -g status-bg '#${colors.status}'
|
set -g status-bg '#${config.lib.colors.background}'
|
||||||
|
|
||||||
|
# Remove date/time etc. on the right side
|
||||||
|
set -g status-right ""
|
||||||
|
|
||||||
# Status window colors
|
# Status window colors
|
||||||
set -g window-status-current-style bg='#${colors.status}',fg='#${colors.cursor}'
|
set -g window-status-current-style bg='#${config.lib.colors.background}',fg='#${config.lib.colors.foreground}'
|
||||||
set -g window-status-style bg='#${colors.status}',fg='#${dim}'
|
set -g window-status-style bg='#${config.lib.colors.background}',fg='#${config.lib.colors.foreground-dim}'
|
||||||
|
|
||||||
set -g pane-border-style fg='#${dim}'
|
set -g pane-border-style fg='#${config.lib.colors.background}'
|
||||||
set -g pane-active-border-style fg='#${dim}'
|
set -g pane-active-border-style fg='#${config.lib.colors.background}'
|
||||||
set -g pane-border-lines "heavy"
|
set -g pane-border-lines "heavy"
|
||||||
|
|
||||||
|
bind r source-file ~/.config/tmux/tmux.conf \; display "Config reloaded"
|
||||||
|
|
||||||
# Remove accidental `suspend-client` triggers
|
# Remove accidental `suspend-client` triggers
|
||||||
unbind C-z
|
unbind C-z
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
state_root="${XDG_STATE_HOME:-$HOME/.local/state}/tmux-panes"
|
|
||||||
snapshot_root="${XDG_DATA_HOME:-$HOME/.local/share}/tmux/resurrect/panes"
|
|
||||||
|
|
||||||
pane_state() {
|
|
||||||
echo "$state_root/${1#%}"
|
|
||||||
}
|
|
||||||
|
|
||||||
pane_snapshot() {
|
|
||||||
echo "$snapshot_root/${1//\//_}"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "${1:-}" in
|
|
||||||
claude-session)
|
|
||||||
[ -n "${TMUX_PANE:-}" ] || exit 0
|
|
||||||
session_id="$(jq -r '.session_id')"
|
|
||||||
dir="$(pane_state "$TMUX_PANE")"
|
|
||||||
mkdir -p "$dir"
|
|
||||||
printf '%s\n%s\n' "${CLAUDE_CONFIG_DIR:-}" "$session_id" > "$dir/claude"
|
|
||||||
;;
|
|
||||||
|
|
||||||
save)
|
|
||||||
mkdir -p "$(dirname "$snapshot_root")" "$state_root"
|
|
||||||
snapshot="$(mktemp -d "$snapshot_root.XXXXXX")"
|
|
||||||
live=()
|
|
||||||
|
|
||||||
while IFS=$'\t' read -r id pos cmd; do
|
|
||||||
live+=("${id#%}")
|
|
||||||
case "$cmd" in
|
|
||||||
claude | emacs) ;;
|
|
||||||
*) continue ;;
|
|
||||||
esac
|
|
||||||
src="$(pane_state "$id")/$cmd"
|
|
||||||
[ -f "$src" ] || continue
|
|
||||||
dst="$snapshot/${pos//\//_}"
|
|
||||||
mkdir -p "$dst"
|
|
||||||
cp "$src" "$dst/$cmd"
|
|
||||||
done < <(tmux list-panes -a -F '#{pane_id} #S:#I.#P #{pane_current_command}')
|
|
||||||
|
|
||||||
rm -rf "$snapshot_root"
|
|
||||||
mv "$snapshot" "$snapshot_root"
|
|
||||||
|
|
||||||
for dir in "$state_root"/*/; do
|
|
||||||
[ -d "$dir" ] || continue
|
|
||||||
name="$(basename "$dir")"
|
|
||||||
[[ " ${live[*]} " == *" $name "* ]] || rm -rf "$dir"
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
restore)
|
|
||||||
pos="$(tmux display-message -p -t "$TMUX_PANE" '#S:#I.#P')"
|
|
||||||
file="$(pane_snapshot "$pos")/${2:-}"
|
|
||||||
|
|
||||||
case "${2:-}" in
|
|
||||||
claude)
|
|
||||||
if [ ! -f "$file" ]; then
|
|
||||||
echo "tmux-panes: no saved claude session for $pos" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
{ read -r config_dir; read -r session_id; } < "$file"
|
|
||||||
CLAUDE_CONFIG_DIR="$config_dir" exec claude --resume "$session_id"
|
|
||||||
;;
|
|
||||||
emacs)
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
buffers="$(mktemp)"
|
|
||||||
cp "$file" "$buffers"
|
|
||||||
TMUX_PANES_RESTORE="$buffers" exec e
|
|
||||||
fi
|
|
||||||
exec e
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "usage: tmux-panes restore claude|emacs" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "usage: tmux-panes claude-session|save|restore <claude|emacs>" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
@@ -18,7 +18,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
programs.git = lib.mkIf gitEnabled {
|
programs.git = lib.mkIf gitEnabled {
|
||||||
settings = {
|
extraConfig = {
|
||||||
core = {
|
core = {
|
||||||
editor = "vim";
|
editor = "vim";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ let
|
|||||||
hyprlandEnabled = config.mod.hyprland.enable;
|
hyprlandEnabled = config.mod.hyprland.enable;
|
||||||
|
|
||||||
music-status = pkgs.writeShellScript "music-status" ''
|
music-status = pkgs.writeShellScript "music-status" ''
|
||||||
STATUS=$(${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spotify status 2>&1)
|
STATUS=$(${pkgs.playerctl}/bin/playerctl -p naviterm,spotify status 2>&1)
|
||||||
|
|
||||||
if [ "$STATUS" = "No players found" ]; then
|
if [ "$STATUS" = "No players found" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
else
|
else
|
||||||
FORMAT="{{markup_escape(xesam:title)}} - {{markup_escape(xesam:artist)}}"
|
FORMAT="{{markup_escape(xesam:title)}} - {{markup_escape(xesam:artist)}}"
|
||||||
OUTPUT=$(${pkgs.playerctl}/bin/playerctl -p ndp,naviterm,spotify metadata --format "$FORMAT")
|
OUTPUT=$(${pkgs.playerctl}/bin/playerctl -p naviterm,spotify metadata --format "$FORMAT")
|
||||||
case "$STATUS" in
|
case "$STATUS" in
|
||||||
"Playing")
|
"Playing")
|
||||||
echo "<span font='14' rise='-3000'></span> $OUTPUT"
|
echo "<span font='14' rise='-3000'></span> $OUTPUT"
|
||||||
@@ -22,9 +22,6 @@ let
|
|||||||
"Paused")
|
"Paused")
|
||||||
echo "<span font='14' rise='-3000'></span> $OUTPUT"
|
echo "<span font='14' rise='-3000'></span> $OUTPUT"
|
||||||
;;
|
;;
|
||||||
"Stopped")
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "Unknown status: $STATUS"
|
echo "Unknown status: $STATUS"
|
||||||
;;
|
;;
|
||||||
@@ -75,12 +72,7 @@ let
|
|||||||
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
||||||
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
||||||
else
|
else
|
||||||
tailscale set --exit-node=$PREFERRED_EXIT_NODE || exit 1
|
tailscale set --exit-node=$PREFERRED_EXIT_NODE && ${pkgs.libnotify}/bin/notify-send "Connected to Exit Node"
|
||||||
|
|
||||||
EXIT_NODE_NAME=$(tailscale status --json | ${pkgs.jq}/bin/jq -r '
|
|
||||||
.Peer.[] | select(.ExitNode)
|
|
||||||
| .HostName + (if .Location then " (\(.Location.City), \(.Location.Country))" else "" end)')
|
|
||||||
${pkgs.libnotify}/bin/notify-send "Connected to Exit Node" "$EXIT_NODE_NAME"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,33 +84,12 @@ let
|
|||||||
esac
|
esac
|
||||||
'';
|
'';
|
||||||
|
|
||||||
work-vpn = pkgs.writeShellScript "work-vpn" ''
|
work-vpn-status = pkgs.writeShellScript "work-vpn-status" ''
|
||||||
connected() {
|
STAGING=$(systemctl is-active openvpn-work-staging.service)
|
||||||
systemctl is-active --quiet openvpn-work-staging.service openvpn-work-production.service
|
[ "$STAGING" == "active" ] && echo "WORK-VPN STAGING ON" && exit 0
|
||||||
}
|
|
||||||
|
|
||||||
output() {
|
PRODUCTION=$(systemctl is-active openvpn-work-production.service)
|
||||||
if connected; then
|
[ "$PRODUCTION" == "active" ] && echo "WORK-VPN PRODUCTION ON" && exit 0
|
||||||
echo '{ "text": "WORK-VPN ON", "class": "connected" }'
|
|
||||||
else
|
|
||||||
echo "{ \"text\": \"<span font='16' rise='-3000'></span>\", \"tooltip\": \"Work VPN off\", \"class\": \"disconnected\" }"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle() {
|
|
||||||
if connected; then
|
|
||||||
systemctl stop work-vpn.target && ${pkgs.libnotify}/bin/notify-send "Disconnected from work VPN"
|
|
||||||
else
|
|
||||||
systemctl start work-vpn.target && ${pkgs.libnotify}/bin/notify-send "Connected to work VPN"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
--toggle)
|
|
||||||
toggle ;;
|
|
||||||
--output)
|
|
||||||
output ;;
|
|
||||||
esac
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" ''
|
toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" ''
|
||||||
@@ -154,22 +125,20 @@ in
|
|||||||
|
|
||||||
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
||||||
modules-right = [
|
modules-right = [
|
||||||
|
"custom/work-vpn-status"
|
||||||
"custom/music"
|
"custom/music"
|
||||||
"custom/container-status"
|
"custom/container-status"
|
||||||
"custom/dunst"
|
"custom/dunst"
|
||||||
"bluetooth"
|
"bluetooth"
|
||||||
"wireplumber"
|
"wireplumber"
|
||||||
"custom/work-vpn"
|
|
||||||
"custom/tailscale"
|
"custom/tailscale"
|
||||||
"network"
|
"network"
|
||||||
"battery"
|
"battery"
|
||||||
"clock"
|
"clock"
|
||||||
];
|
];
|
||||||
|
|
||||||
"custom/work-vpn" = {
|
"custom/work-vpn-status" = {
|
||||||
exec = "${work-vpn} --output";
|
exec = "${work-vpn-status}";
|
||||||
return-type = "json";
|
|
||||||
on-click-right = "${work-vpn} --toggle";
|
|
||||||
interval = 2;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -225,7 +194,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
battery = {
|
battery = {
|
||||||
"bat" = "BAT0";
|
|
||||||
"interval" = 60;
|
"interval" = 60;
|
||||||
"format" = "<span font='10' rise='1000'>{icon}</span> {capacity}%";
|
"format" = "<span font='10' rise='1000'>{icon}</span> {capacity}%";
|
||||||
"format-time" = "{H}h {M}min";
|
"format-time" = "{H}h {M}min";
|
||||||
@@ -261,14 +229,12 @@ in
|
|||||||
|
|
||||||
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
||||||
modules-right = [
|
modules-right = [
|
||||||
"custom/work-vpn"
|
"custom/work-vpn-status"
|
||||||
"clock"
|
"clock"
|
||||||
];
|
];
|
||||||
|
|
||||||
"custom/work-vpn" = {
|
"custom/work-vpn-status" = {
|
||||||
exec = "${work-vpn} --output";
|
exec = "${work-vpn-status}";
|
||||||
return-type = "json";
|
|
||||||
on-click-right = "${work-vpn} --toggle";
|
|
||||||
interval = 2;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -322,14 +288,10 @@ in
|
|||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-work-vpn.connected {
|
#custom-work-vpn-status {
|
||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-work-vpn.disconnected {
|
|
||||||
color: #${config.lib.colors.foreground-dim};
|
|
||||||
}
|
|
||||||
|
|
||||||
#custom-container-status.running {
|
#custom-container-status.running {
|
||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
|
|
||||||
|
|
||||||
mkPatchedModules =
|
|
||||||
{
|
|
||||||
pname,
|
|
||||||
srcPaths,
|
|
||||||
dir,
|
|
||||||
patches,
|
|
||||||
postPatch,
|
|
||||||
}:
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
inherit pname patches postPatch;
|
|
||||||
inherit (kernel) version;
|
|
||||||
|
|
||||||
__structuredAttrs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
tar -xf ${kernel.src} --strip-components=1 --wildcards \
|
|
||||||
${lib.escapeShellArgs (map (path: "*/${path}") srcPaths)}
|
|
||||||
'';
|
|
||||||
|
|
||||||
makeFlags = kernelModuleMakeFlags ++ [
|
|
||||||
"KERNELRELEASE=${kernel.modDirVersion}"
|
|
||||||
];
|
|
||||||
|
|
||||||
installFlags = [
|
|
||||||
"DEPMOD=true"
|
|
||||||
"INSTALL_MOD_PATH=${placeholder "out"}"
|
|
||||||
];
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
|
||||||
M=$(pwd)/${dir} "''${makeFlags[@]}"
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
|
||||||
M=$(pwd)/${dir} modules_install \
|
|
||||||
"''${makeFlags[@]}" "''${installFlags[@]}"
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
ipu6-isys = mkPatchedModules {
|
|
||||||
pname = "ipu6-isys";
|
|
||||||
srcPaths = [ "drivers/media/pci/intel/ipu6/*" ];
|
|
||||||
dir = "drivers/media/pci/intel/ipu6";
|
|
||||||
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
|
|
||||||
postPatch = ''
|
|
||||||
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
usbio = mkPatchedModules {
|
|
||||||
pname = "usbio";
|
|
||||||
srcPaths = [
|
|
||||||
"drivers/usb/misc/usbio.c"
|
|
||||||
"drivers/gpio/gpio-usbio.c"
|
|
||||||
"include/linux/usb/usbio.h"
|
|
||||||
];
|
|
||||||
dir = "usbio";
|
|
||||||
patches = [ ./usbio-reset-resume.patch ];
|
|
||||||
postPatch = ''
|
|
||||||
mkdir -p usbio/include/linux/usb
|
|
||||||
cp drivers/usb/misc/usbio.c drivers/gpio/gpio-usbio.c usbio/
|
|
||||||
cp include/linux/usb/usbio.h usbio/include/linux/usb/
|
|
||||||
echo 'LINUXINCLUDE := -I$(src)/include $(LINUXINCLUDE)' > usbio/Kbuild
|
|
||||||
echo 'obj-m += usbio.o gpio-usbio.o' >> usbio/Kbuild
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
nixpkgs.overlays = [
|
|
||||||
(final: prev: {
|
|
||||||
ipu6epmtl-camera-hal = prev.ipu6epmtl-camera-hal.overrideAttrs (old: {
|
|
||||||
postPatch = (old.postPatch or "") + ''
|
|
||||||
substituteInPlace src/v4l2/MediaControl.cpp \
|
|
||||||
--replace-fail 'static const string ivscName = "Intel IVSC CSI";' \
|
|
||||||
'static const string ivscName = "Intel CVS";'
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
gst_all_1 = prev.gst_all_1 // {
|
|
||||||
icamerasrc-ipu6epmtl =
|
|
||||||
(prev.gst_all_1.icamerasrc-ipu6epmtl.override {
|
|
||||||
ipu6-camera-hal = final.ipu6epmtl-camera-hal;
|
|
||||||
}).overrideAttrs
|
|
||||||
(old: {
|
|
||||||
version = "20250923_ov02e";
|
|
||||||
src = final.fetchFromGitHub {
|
|
||||||
owner = "intel";
|
|
||||||
repo = "icamerasrc";
|
|
||||||
tag = "20250923_ov02e";
|
|
||||||
hash = "sha256-mKRK0Z3dnyvzvoL6BotpVFRtkb53GQw9wUOrHIUoEsA=";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
boot.extraModulePackages = [
|
|
||||||
ipu6-isys
|
|
||||||
usbio
|
|
||||||
];
|
|
||||||
|
|
||||||
hardware.ipu6 = {
|
|
||||||
enable = true;
|
|
||||||
platform = "ipu6epmtl";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.v4l2-relayd.instances.ipu6.input = {
|
|
||||||
pipeline = lib.mkForce "icamerasrc buffer-count=10";
|
|
||||||
width = 1920;
|
|
||||||
height = 1080;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.v4l2-relayd-ipu6 = {
|
|
||||||
preStart = lib.mkOverride 40 ''
|
|
||||||
mkdir -p "$(dirname "$V4L2_DEVICE_FILE")"
|
|
||||||
${config.boot.kernelPackages.v4l2loopback.bin}/bin/v4l2loopback-ctl \
|
|
||||||
add --name "Intel MIPI Camera" --exclusive-caps=1 --buffers 8 \
|
|
||||||
${toString config.hardware.ipu6.videoDeviceNumber} || [ $? -eq 17 ]
|
|
||||||
echo /dev/video${toString config.hardware.ipu6.videoDeviceNumber} > "$V4L2_DEVICE_FILE"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.c
|
|
||||||
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c
|
|
||||||
@@ -858,6 +858,9 @@
|
|
||||||
unsigned long flags;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
+ if (!isys)
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
ret = ipu6_mmu_hw_init(adev->mmu);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
@@ -885,6 +888,9 @@
|
|
||||||
struct ipu6_isys *isys = dev_get_drvdata(dev);
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
+ if (!isys)
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
spin_lock_irqsave(&isys->power_lock, flags);
|
|
||||||
isys->power = 0;
|
|
||||||
spin_unlock_irqrestore(&isys->power_lock, flags);
|
|
||||||
@@ -1,320 +0,0 @@
|
|||||||
--- a/drivers/usb/misc/usbio.c
|
|
||||||
+++ b/drivers/usb/misc/usbio.c
|
|
||||||
@@ -83,6 +83,7 @@
|
|
||||||
* @gpios: GPIO bank descriptors
|
|
||||||
* @nr_gpio_banks: Number of I2C busses
|
|
||||||
* @gpios: I2C bank descriptors
|
|
||||||
+ * @reset_count: Number of times the bridge was reset while bound
|
|
||||||
*/
|
|
||||||
struct usbio_device {
|
|
||||||
struct device *dev;
|
|
||||||
@@ -115,6 +116,8 @@
|
|
||||||
|
|
||||||
unsigned int nr_i2c_buses;
|
|
||||||
struct usbio_i2c_bus_desc i2cs[USBIO_MAX_I2CBUSES];
|
|
||||||
+
|
|
||||||
+ unsigned int reset_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -428,6 +431,21 @@
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_NS_GPL(usbio_get_quirks, "USBIO");
|
|
||||||
|
|
||||||
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev)
|
|
||||||
+{
|
|
||||||
+ struct usbio_client *client = adev_to_client(adev);
|
|
||||||
+ struct usbio_device *usbio;
|
|
||||||
+
|
|
||||||
+ guard(mutex)(&client->mutex);
|
|
||||||
+
|
|
||||||
+ usbio = client->bridge;
|
|
||||||
+ if (!usbio)
|
|
||||||
+ return 0; /* Disconnected */
|
|
||||||
+
|
|
||||||
+ return usbio->reset_count;
|
|
||||||
+}
|
|
||||||
+EXPORT_SYMBOL_NS_GPL(usbio_get_reset_count, "USBIO");
|
|
||||||
+
|
|
||||||
static void usbio_auxdev_release(struct device *dev)
|
|
||||||
{
|
|
||||||
struct auxiliary_device *adev = to_auxiliary_dev(dev);
|
|
||||||
@@ -503,6 +521,47 @@
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int usbio_init_bridge(struct usbio_device *usbio)
|
|
||||||
+{
|
|
||||||
+ struct usbio_protver protver;
|
|
||||||
+ struct usbio_fwver fwver;
|
|
||||||
+ int ret;
|
|
||||||
+
|
|
||||||
+ guard(mutex)(&usbio->ctrl_mutex);
|
|
||||||
+
|
|
||||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
|
|
||||||
+ if (ret < 0)
|
|
||||||
+ return ret;
|
|
||||||
+
|
|
||||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
|
|
||||||
+ &protver, sizeof(protver));
|
|
||||||
+ if (ret < 0)
|
|
||||||
+ return ret;
|
|
||||||
+
|
|
||||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
|
|
||||||
+ &fwver, sizeof(fwver));
|
|
||||||
+ if (ret < 0)
|
|
||||||
+ return ret;
|
|
||||||
+
|
|
||||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
|
|
||||||
+ usbio->gpios, sizeof(usbio->gpios));
|
|
||||||
+ if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc))
|
|
||||||
+ return (ret < 0) ? ret : -EPROTO;
|
|
||||||
+ usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
|
|
||||||
+
|
|
||||||
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
|
|
||||||
+ usbio->i2cs, sizeof(usbio->i2cs));
|
|
||||||
+ if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc))
|
|
||||||
+ return (ret < 0) ? ret : -EPROTO;
|
|
||||||
+ usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
|
|
||||||
+
|
|
||||||
+ dev_dbg(usbio->dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
|
|
||||||
+ protver.ver, fwver.major, fwver.minor,
|
|
||||||
+ le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int usbio_suspend(struct usb_interface *intf, pm_message_t msg)
|
|
||||||
{
|
|
||||||
struct usbio_device *usbio = usb_get_intfdata(intf);
|
|
||||||
@@ -519,6 +578,26 @@
|
|
||||||
return usb_submit_urb(usbio->urb, GFP_KERNEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int usbio_reset_resume(struct usb_interface *intf)
|
|
||||||
+{
|
|
||||||
+ struct usbio_device *usbio = usb_get_intfdata(intf);
|
|
||||||
+ int ret;
|
|
||||||
+
|
|
||||||
+ ret = usb_submit_urb(usbio->urb, GFP_KERNEL);
|
|
||||||
+ if (ret)
|
|
||||||
+ return ret;
|
|
||||||
+
|
|
||||||
+ ret = usbio_init_bridge(usbio);
|
|
||||||
+ if (ret) {
|
|
||||||
+ usb_kill_urb(usbio->urb);
|
|
||||||
+ return ret;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ usbio->reset_count++;
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void usbio_disconnect(struct usb_interface *intf)
|
|
||||||
{
|
|
||||||
struct usbio_device *usbio = usb_get_intfdata(intf);
|
|
||||||
@@ -550,9 +629,7 @@
|
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
|
||||||
struct usb_endpoint_descriptor *ep_in, *ep_out;
|
|
||||||
struct device *dev = &intf->dev;
|
|
||||||
- struct usbio_protver protver;
|
|
||||||
struct usbio_device *usbio;
|
|
||||||
- struct usbio_fwver fwver;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
usbio = devm_kzalloc(dev, sizeof(*usbio), GFP_KERNEL);
|
|
||||||
@@ -623,51 +700,16 @@
|
|
||||||
goto err_free_urb;
|
|
||||||
}
|
|
||||||
|
|
||||||
- mutex_lock(&usbio->ctrl_mutex);
|
|
||||||
-
|
|
||||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
|
|
||||||
- if (ret < 0)
|
|
||||||
- goto err_unlock;
|
|
||||||
-
|
|
||||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
|
|
||||||
- &protver, sizeof(protver));
|
|
||||||
- if (ret < 0)
|
|
||||||
- goto err_unlock;
|
|
||||||
-
|
|
||||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
|
|
||||||
- &fwver, sizeof(fwver));
|
|
||||||
- if (ret < 0)
|
|
||||||
- goto err_unlock;
|
|
||||||
-
|
|
||||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
|
|
||||||
- usbio->gpios, sizeof(usbio->gpios));
|
|
||||||
- if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc)) {
|
|
||||||
- ret = (ret < 0) ? ret : -EPROTO;
|
|
||||||
- goto err_unlock;
|
|
||||||
- }
|
|
||||||
- usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
|
|
||||||
-
|
|
||||||
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
|
|
||||||
- usbio->i2cs, sizeof(usbio->i2cs));
|
|
||||||
- if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc)) {
|
|
||||||
- ret = (ret < 0) ? ret : -EPROTO;
|
|
||||||
- goto err_unlock;
|
|
||||||
- }
|
|
||||||
- usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
|
|
||||||
-
|
|
||||||
- mutex_unlock(&usbio->ctrl_mutex);
|
|
||||||
-
|
|
||||||
- dev_dbg(dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
|
|
||||||
- protver.ver, fwver.major, fwver.minor,
|
|
||||||
- le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
|
|
||||||
+ ret = usbio_init_bridge(usbio);
|
|
||||||
+ if (ret)
|
|
||||||
+ goto err_kill_urb;
|
|
||||||
|
|
||||||
usbio_enum_gpios(usbio);
|
|
||||||
usbio_enum_i2cs(usbio);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
-err_unlock:
|
|
||||||
- mutex_unlock(&usbio->ctrl_mutex);
|
|
||||||
+err_kill_urb:
|
|
||||||
usb_kill_urb(usbio->urb);
|
|
||||||
err_free_urb:
|
|
||||||
usb_free_urb(usbio->urb);
|
|
||||||
@@ -694,6 +736,7 @@
|
|
||||||
.disconnect = usbio_disconnect,
|
|
||||||
.suspend = usbio_suspend,
|
|
||||||
.resume = usbio_resume,
|
|
||||||
+ .reset_resume = usbio_reset_resume,
|
|
||||||
.id_table = usbio_table,
|
|
||||||
.supports_autosuspend = 1,
|
|
||||||
};
|
|
||||||
--- a/drivers/gpio/gpio-usbio.c
|
|
||||||
+++ b/drivers/gpio/gpio-usbio.c
|
|
||||||
@@ -15,14 +15,16 @@
|
|
||||||
|
|
||||||
struct usbio_gpio_bank {
|
|
||||||
u8 config[USBIO_GPIOSPERBANK];
|
|
||||||
+ u32 value;
|
|
||||||
u32 bitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct usbio_gpio {
|
|
||||||
- struct mutex config_mutex; /* Protects banks[x].config */
|
|
||||||
+ struct mutex config_mutex; /* Protects banks[x].config and banks[x].value */
|
|
||||||
struct usbio_gpio_bank banks[USBIO_MAX_GPIOBANKS];
|
|
||||||
struct gpio_chip gc;
|
|
||||||
struct auxiliary_device *adev;
|
|
||||||
+ unsigned int reset_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct acpi_device_id usbio_gpio_acpi_hids[] = {
|
|
||||||
@@ -101,6 +103,13 @@
|
|
||||||
|
|
||||||
usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
|
|
||||||
|
|
||||||
+ scoped_guard(mutex, &gpio->config_mutex) {
|
|
||||||
+ if (value)
|
|
||||||
+ bank->value |= BIT(pin);
|
|
||||||
+ else
|
|
||||||
+ bank->value &= ~BIT(pin);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
gbuf.bankid = offset / USBIO_GPIOSPERBANK;
|
|
||||||
gbuf.pincount = 1;
|
|
||||||
gbuf.pin = pin;
|
|
||||||
@@ -178,6 +187,66 @@
|
|
||||||
return usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINCFG_MASK, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int usbio_gpio_restore(struct usbio_gpio *gpio)
|
|
||||||
+{
|
|
||||||
+ struct usbio_gpio_init ginit;
|
|
||||||
+ struct usbio_gpio_rw gbuf;
|
|
||||||
+ int ret;
|
|
||||||
+
|
|
||||||
+ guard(mutex)(&gpio->config_mutex);
|
|
||||||
+
|
|
||||||
+ for (unsigned int b = 0; b < USBIO_MAX_GPIOBANKS; b++) {
|
|
||||||
+ struct usbio_gpio_bank *bank = &gpio->banks[b];
|
|
||||||
+
|
|
||||||
+ for (unsigned int pin = 0; pin < USBIO_GPIOSPERBANK; pin++) {
|
|
||||||
+ u8 mode = bank->config[pin] & USBIO_GPIO_PINMOD_MASK;
|
|
||||||
+
|
|
||||||
+ if (mode == USBIO_GPIO_PINMOD_INVAL)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ ginit.bankid = b;
|
|
||||||
+ ginit.config = bank->config[pin];
|
|
||||||
+ ginit.pincount = 1;
|
|
||||||
+ ginit.pin = pin;
|
|
||||||
+
|
|
||||||
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_INIT,
|
|
||||||
+ &ginit, sizeof(ginit), NULL, 0);
|
|
||||||
+ if (ret)
|
|
||||||
+ return ret;
|
|
||||||
+
|
|
||||||
+ if (mode != USBIO_GPIO_PINMOD_OUTPUT)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ gbuf.bankid = b;
|
|
||||||
+ gbuf.pincount = 1;
|
|
||||||
+ gbuf.pin = pin;
|
|
||||||
+ gbuf.value = cpu_to_le32(bank->value & BIT(pin));
|
|
||||||
+
|
|
||||||
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_WRITE,
|
|
||||||
+ &gbuf, sizeof(gbuf), NULL, 0);
|
|
||||||
+ if (ret)
|
|
||||||
+ return ret;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int usbio_gpio_resume(struct device *dev)
|
|
||||||
+{
|
|
||||||
+ struct usbio_gpio *gpio = dev_get_drvdata(dev);
|
|
||||||
+ unsigned int reset_count = usbio_get_reset_count(gpio->adev);
|
|
||||||
+
|
|
||||||
+ if (reset_count == gpio->reset_count)
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
+ gpio->reset_count = reset_count;
|
|
||||||
+
|
|
||||||
+ return usbio_gpio_restore(gpio);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static DEFINE_SIMPLE_DEV_PM_OPS(usbio_gpio_pm_ops, NULL, usbio_gpio_resume);
|
|
||||||
+
|
|
||||||
static int usbio_gpio_probe(struct auxiliary_device *adev,
|
|
||||||
const struct auxiliary_device_id *adev_id)
|
|
||||||
{
|
|
||||||
@@ -199,6 +268,8 @@
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
gpio->adev = adev;
|
|
||||||
+ gpio->reset_count = usbio_get_reset_count(adev);
|
|
||||||
+ dev_set_drvdata(dev, gpio);
|
|
||||||
|
|
||||||
usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
|
|
||||||
|
|
||||||
@@ -238,7 +309,8 @@
|
|
||||||
static struct auxiliary_driver usbio_gpio_driver = {
|
|
||||||
.name = USBIO_GPIO_CLIENT,
|
|
||||||
.probe = usbio_gpio_probe,
|
|
||||||
- .id_table = usbio_gpio_id_table
|
|
||||||
+ .id_table = usbio_gpio_id_table,
|
|
||||||
+ .driver.pm = pm_sleep_ptr(&usbio_gpio_pm_ops),
|
|
||||||
};
|
|
||||||
module_auxiliary_driver(usbio_gpio_driver);
|
|
||||||
|
|
||||||
--- a/include/linux/usb/usbio.h
|
|
||||||
+++ b/include/linux/usb/usbio.h
|
|
||||||
@@ -172,6 +172,7 @@
|
|
||||||
void usbio_release(struct auxiliary_device *adev);
|
|
||||||
void usbio_get_txrxbuf_len(struct auxiliary_device *adev, u16 *txbuf_len, u16 *rxbuf_len);
|
|
||||||
unsigned long usbio_get_quirks(struct auxiliary_device *adev);
|
|
||||||
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev);
|
|
||||||
void usbio_acpi_bind(struct auxiliary_device *adev, const struct acpi_device_id *hids);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -8,9 +8,6 @@ let
|
|||||||
enabled = config.mod.wezterm.enable;
|
enabled = config.mod.wezterm.enable;
|
||||||
|
|
||||||
hyprlandEnabled = config.mod.hyprland.enable;
|
hyprlandEnabled = config.mod.hyprland.enable;
|
||||||
|
|
||||||
colors = config.lib.colors.terminal;
|
|
||||||
luaList = list: "{ " + lib.concatMapStringsSep ", " (c: "'#${c}'") list + " }";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@@ -30,17 +27,7 @@ in
|
|||||||
|
|
||||||
local config = wezterm.config_builder()
|
local config = wezterm.config_builder()
|
||||||
|
|
||||||
config.colors = {
|
config.color_scheme = 'Dracula (Official)'
|
||||||
foreground = '#${colors.foreground}',
|
|
||||||
background = '#${colors.background}',
|
|
||||||
cursor_bg = '#${colors.cursor}',
|
|
||||||
cursor_border = '#${colors.cursor}',
|
|
||||||
cursor_fg = '#${colors.background}',
|
|
||||||
selection_bg = '#${colors.selection}',
|
|
||||||
selection_fg = '#${colors.foreground}',
|
|
||||||
ansi = ${luaList colors.regular},
|
|
||||||
brights = ${luaList colors.bright},
|
|
||||||
}
|
|
||||||
|
|
||||||
config.font = wezterm.font 'JetBrainsMono Nerd Font'
|
config.font = wezterm.font 'JetBrainsMono Nerd Font'
|
||||||
-- to get "perfect" scaling to the right
|
-- to get "perfect" scaling to the right
|
||||||
@@ -91,12 +78,7 @@ in
|
|||||||
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
|
||||||
settings = {
|
settings = {
|
||||||
bind = [
|
bind = [
|
||||||
{
|
"$mod, RETURN, exec, ${pkgs.wezterm}/bin/wezterm"
|
||||||
_args = [
|
|
||||||
"SUPER + RETURN"
|
|
||||||
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${pkgs.wezterm}/bin/wezterm")'')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
@@ -12,66 +11,16 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
# Ensure bashInteractive is first in PATH inside nix devshells.
|
|
||||||
# stdenv provides a non-interactive bash that breaks Copilot shell commands.
|
|
||||||
# Adding bashInteractive to home.packages alone isn't enough because devshell
|
|
||||||
# packages are prepended to PATH. This precmd hook runs after direnv's hook
|
|
||||||
# and re-prepends bashInteractive so it takes priority.
|
|
||||||
programs.zsh.initContent = ''
|
|
||||||
_ensure_bash_interactive() {
|
|
||||||
[[ "$PATH" == "${pkgs.bashInteractive}/bin:"* ]] || export PATH="${pkgs.bashInteractive}/bin:$PATH"
|
|
||||||
}
|
|
||||||
precmd_functions+=(_ensure_bash_interactive)
|
|
||||||
|
|
||||||
# Source the zsh-specific rc file that nix-direnv emits ($DIRENV_ZSH_RC)
|
|
||||||
# so devshell completions and zsh setup are picked up. direnv itself only
|
|
||||||
# exports env vars, so without this hook the zsh side of the devshell is
|
|
||||||
# never loaded. Guarded by LAST_LOADED_DIRENV_ZSH_RC so we don't re-source
|
|
||||||
# it on every precmd.
|
|
||||||
_nix_direnv_bridge_hook() {
|
|
||||||
if [[ -n "$DIRENV_ZSH_RC" && "$LAST_LOADED_DIRENV_ZSH_RC" != "$DIRENV_ZSH_RC" ]]; then
|
|
||||||
if [[ -f "$DIRENV_ZSH_RC" ]]; then
|
|
||||||
source "$DIRENV_ZSH_RC"
|
|
||||||
export LAST_LOADED_DIRENV_ZSH_RC="$DIRENV_ZSH_RC"
|
|
||||||
echo "❄️ direnv zsh loaded..."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
autoload -Uz add-zsh-hook
|
|
||||||
add-zsh-hook precmd _nix_direnv_bridge_hook
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Configure IntelliJ to exclude .direnv from indexing
|
|
||||||
home.activation.intellijIgnoreDirenv = ''
|
|
||||||
for idea_config in $HOME/.config/JetBrains/IntelliJIdea*; do
|
|
||||||
if [ -d "$idea_config" ]; then
|
|
||||||
$DRY_RUN_CMD mkdir -p "$idea_config/options"
|
|
||||||
$DRY_RUN_CMD tee "$idea_config/options/filetypes.xml" > /dev/null <<'EOF'
|
|
||||||
<application>
|
|
||||||
<component name="FileTypeManager" version="18">
|
|
||||||
<ignoreFiles list="*.pyc;*.pyo;*.rbc;*.yarb;*~;.DS_Store;.git;.hg;.svn;CVS;__pycache__;_svn;vssver.scc;vssver2.scc;.direnv" />
|
|
||||||
</component>
|
|
||||||
</application>
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
GITHUB_ACTOR = "Alexander Heldt";
|
GITHUB_ACTOR = "Alexander Heldt";
|
||||||
GITHUB_TOKEN = "$(${pkgs.coreutils}/bin/cat ${config.age.secrets.work-github-token.path})";
|
GITHUB_TOKEN = "$(${pkgs.coreutils}/bin/cat ${config.age.secrets.work-github-token.path})";
|
||||||
};
|
};
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
# (pkgs.callPackage ./pants.nix { inherit (pkgs) stdenv.hostPlatform.system; })
|
# (pkgs.callPackage ./pants.nix { inherit (pkgs) system; })
|
||||||
# (pkgs.callPackage ./syb-cli.nix { })
|
# (pkgs.callPackage ./syb-cli.nix { })
|
||||||
|
|
||||||
(inputs.nix-jetbrains-plugins.lib.buildIdeWithPlugins pkgs "idea" [
|
(pkgs.jetbrains.plugins.addPlugins pkgs.jetbrains.idea-ultimate [ "ideavim" ])
|
||||||
"IdeaVIM"
|
|
||||||
"com.github.copilot"
|
|
||||||
])
|
|
||||||
pkgs.bashInteractive
|
|
||||||
|
|
||||||
(pkgs.google-cloud-sdk.withExtraComponents [
|
(pkgs.google-cloud-sdk.withExtraComponents [
|
||||||
pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin
|
pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin
|
||||||
@@ -82,22 +31,9 @@ EOF
|
|||||||
pkgs.postman
|
pkgs.postman
|
||||||
pkgs.grpcurl
|
pkgs.grpcurl
|
||||||
|
|
||||||
pkgs.slack
|
|
||||||
|
|
||||||
# for `radio`
|
# for `radio`
|
||||||
pkgs.go-mockery
|
pkgs.go-mockery
|
||||||
pkgs.golangci-lint
|
pkgs.golangci-lint
|
||||||
|
|
||||||
(pkgs.writeShellScriptBin "work-vpn" ''
|
|
||||||
case $1 in
|
|
||||||
up)
|
|
||||||
systemctl start work-vpn.target
|
|
||||||
;;
|
|
||||||
down)
|
|
||||||
systemctl stop work-vpn.target
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
'')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.go = lib.mkIf goEnabled {
|
programs.go = lib.mkIf goEnabled {
|
||||||
@@ -116,20 +52,6 @@ EOF
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Ensure ~/code/work is owned by alex; it was previously created as root by
|
|
||||||
# agenix when secrets had a custom path there.
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /home/alex/code 0755 alex users -"
|
|
||||||
"d /home/alex/code/work 0755 alex users -"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Needed for `copilot`
|
|
||||||
programs.nix-ld.enable = true;
|
|
||||||
programs.nix-ld.libraries = [
|
|
||||||
pkgs.stdenv.cc.cc.lib
|
|
||||||
pkgs.zlib
|
|
||||||
];
|
|
||||||
|
|
||||||
services.openvpn.servers = lib.mkIf openvpnEnabled {
|
services.openvpn.servers = lib.mkIf openvpnEnabled {
|
||||||
work-staging = {
|
work-staging = {
|
||||||
config = "config ${config.age.secrets.work-staging-ovpn.path}";
|
config = "config ${config.age.secrets.work-staging-ovpn.path}";
|
||||||
@@ -142,49 +64,24 @@ EOF
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.targets.work-vpn = lib.mkIf openvpnEnabled {
|
|
||||||
description = "Work VPN";
|
|
||||||
requires = [
|
|
||||||
"openvpn-work-staging.service"
|
|
||||||
"openvpn-work-production.service"
|
|
||||||
];
|
|
||||||
after = [
|
|
||||||
"openvpn-work-staging.service"
|
|
||||||
"openvpn-work-production.service"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services = lib.mkIf openvpnEnabled {
|
|
||||||
openvpn-work-staging.partOf = [ "work-vpn.target" ];
|
|
||||||
openvpn-work-production.partOf = [ "work-vpn.target" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
security.polkit.extraConfig = lib.mkIf openvpnEnabled ''
|
|
||||||
polkit.addRule(function(action, subject) {
|
|
||||||
if (action.id == "org.freedesktop.systemd1.manage-units" &&
|
|
||||||
subject.user == "alex" &&
|
|
||||||
action.lookup("unit") == "work-vpn.target" &&
|
|
||||||
["start", "stop", "restart"].indexOf(action.lookup("verb")) >= 0) {
|
|
||||||
return polkit.Result.YES;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
'';
|
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
"work-gitconfig" = lib.mkIf gitEnabled {
|
"work-gitconfig" = lib.mkIf gitEnabled {
|
||||||
file = ../../../../secrets/pinwheel/work-gitconfig.age;
|
file = ../../../../secrets/pinwheel/work-gitconfig.age;
|
||||||
|
path = "/home/alex/code/work/.work-gitconfig";
|
||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
"work-github-token" = lib.mkIf gitEnabled {
|
"work-github-token" = lib.mkIf gitEnabled {
|
||||||
file = ../../../../secrets/pinwheel/work-github-token.age;
|
file = ../../../../secrets/pinwheel/work-github-token.age;
|
||||||
|
path = "/home/alex/code/work/.work-github-token";
|
||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
"work-go-private" = lib.mkIf goEnabled {
|
"work-go-private" = lib.mkIf goEnabled {
|
||||||
file = ../../../../secrets/pinwheel/work-go-private.age;
|
file = ../../../../secrets/pinwheel/work-go-private.age;
|
||||||
|
path = "/home/alex/code/work/.work-go-private";
|
||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
system,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
@@ -10,7 +11,7 @@ let
|
|||||||
match =
|
match =
|
||||||
v: l: builtins.elemAt (lib.lists.findFirst (x: (if_let v (builtins.elemAt x 0)) != null) null l) 1;
|
v: l: builtins.elemAt (lib.lists.findFirst (x: (if_let v (builtins.elemAt x 0)) != null) null l) 1;
|
||||||
|
|
||||||
package = match { platform = pkgs.stdenv.hostPlatform.system; } [
|
package = match { platform = system; } [
|
||||||
[
|
[
|
||||||
{ platform = "aarch64-linux"; }
|
{ platform = "aarch64-linux"; }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,14 +56,6 @@ in
|
|||||||
|
|
||||||
initContent = lib.strings.concatStringsSep "\n" [
|
initContent = lib.strings.concatStringsSep "\n" [
|
||||||
"export KEYTIMEOUT=1"
|
"export KEYTIMEOUT=1"
|
||||||
|
|
||||||
# Point every interactive shell at openssh's ssh-agent. home-manager's
|
|
||||||
# session vars set this too, but hm-session-vars runs once and is then
|
|
||||||
# inherited — so a tmux server that outlives this change (or started
|
|
||||||
# with the stale gcr socket) hands new panes a dead SSH_AUTH_SOCK.
|
|
||||||
# Re-exporting the fixed path per-shell keeps every pane on the same
|
|
||||||
# agent, so each key is only ever prompted for once per session.
|
|
||||||
''export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"''
|
|
||||||
"bindkey -v '^?' backward-delete-char"
|
"bindkey -v '^?' backward-delete-char"
|
||||||
"bindkey '^a' beginning-of-line"
|
"bindkey '^a' beginning-of-line"
|
||||||
"bindkey '^e' end-of-line"
|
"bindkey '^e' end-of-line"
|
||||||
|
|||||||
Loaded 100 of 154 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user