From 722c44532d3896b5275a514aaf6fcf1c37748ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=BChl?= Date: Tue, 9 Sep 2025 14:47:53 +0200 Subject: [PATCH] Use lnxlink in place of custom shutdown script --- .../christopher@cobalt/misc/browser.nix | 5 +- .../christopher@cobalt/misc/everything.nix | 1 + modules/nixos/services/default.nix | 2 +- modules/nixos/services/lnxlink.nix | 64 ++++++++++++++ modules/nixos/services/lnxlink.yaml | 84 +++++++++++++++++++ modules/nixos/services/shutdown.nix | 58 ------------- packages/solidtime-desktop/default.nix | 5 ++ systems/x86_64-linux/cobalt/default.nix | 6 +- systems/x86_64-linux/cobalt/disk-config.nix | 23 +++++ systems/x86_64-linux/cobalt/hardware.nix | 11 --- 10 files changed, 184 insertions(+), 75 deletions(-) create mode 100644 modules/nixos/services/lnxlink.nix create mode 100644 modules/nixos/services/lnxlink.yaml delete mode 100644 modules/nixos/services/shutdown.nix create mode 100644 packages/solidtime-desktop/default.nix diff --git a/homes/x86_64-linux/christopher@cobalt/misc/browser.nix b/homes/x86_64-linux/christopher@cobalt/misc/browser.nix index cd7ca5e..063b07f 100644 --- a/homes/x86_64-linux/christopher@cobalt/misc/browser.nix +++ b/homes/x86_64-linux/christopher@cobalt/misc/browser.nix @@ -1,6 +1,7 @@ {pkgs, ...}: { home.packages = with pkgs; [ firefox + vivaldi ]; xdg.mimeApps = { @@ -13,7 +14,7 @@ # profile-sync-daemon manages browser profiles in tmpfs services.psd = { - enable = true; - resyncTimer = "10m"; + enable = false; + # resyncTimer = "10m"; }; } diff --git a/homes/x86_64-linux/christopher@cobalt/misc/everything.nix b/homes/x86_64-linux/christopher@cobalt/misc/everything.nix index dfd2ba2..6e52539 100644 --- a/homes/x86_64-linux/christopher@cobalt/misc/everything.nix +++ b/homes/x86_64-linux/christopher@cobalt/misc/everything.nix @@ -27,6 +27,7 @@ obs-studio # OBS Studio wasistlos # WhatsApp client libreoffice # Productivity Suite (like Microsoft Office) + onlyoffice-bin # libreoffice alternative cider # Apple Music player filezilla # FTP Client zathura # Document viewer diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index b87ca06..bf74e67 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -1,5 +1,5 @@ {...}: { imports = [ - ./shutdown.nix + ./lnxlink.nix ]; } diff --git a/modules/nixos/services/lnxlink.nix b/modules/nixos/services/lnxlink.nix new file mode 100644 index 0000000..7422766 --- /dev/null +++ b/modules/nixos/services/lnxlink.nix @@ -0,0 +1,64 @@ +{ + pkgs, + config, + lib, + inputs, + ... +}: +with lib; let + cfg = config.services.lnxlink; + + lnxlink = pkgs.python3Packages.buildPythonApplication { + pname = "lnxlink"; + version = "2025.7.0"; + pyproject = true; + + # Linking my fork here which allows for newer versions of setuptools and wheel. + # Also includes some fixes that make the program actually work with NixOS. + src = pkgs.fetchFromGitHub { + owner = "padarom"; + repo = "lnxlink"; + rev = "7202e48"; + hash = "sha256-E2J1d9D5SJWGEutAPAo1BM98cMzH7QrqIz3yrlXpzGE="; + }; + + build-system = with pkgs.python3Packages; [setuptools wheel]; + dependencies = with pkgs.python3Packages; [ + distro + pyyaml + paho-mqtt + requests + psutil + inotify + jeepney + ]; + + meta = { + homepage = "https://github.com/bkbilly/lnxlink"; + description = "Effortlessly manage your Linux machine using MQTT."; + license = licenses.mit; + mainProgram = "lnxlink"; + }; + }; +in { + options.services = { + lnxlink = { + enable = mkEnableOption "Enable LNXlink"; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [lnxlink]; + + systemd.services.lnxlink = { + enable = true; + wantedBy = ["multi-user.target"]; + serviceConfig = { + # Note: Logging will also be done to the working directory, so logs will + # be lost upon a restart. + WorkingDirectory = "/tmp"; + ExecStart = "${lnxlink}/bin/lnxlink -i -c ${./lnxlink.yaml}"; + }; + }; + }; +} diff --git a/modules/nixos/services/lnxlink.yaml b/modules/nixos/services/lnxlink.yaml new file mode 100644 index 0000000..67e6360 --- /dev/null +++ b/modules/nixos/services/lnxlink.yaml @@ -0,0 +1,84 @@ +mqtt: + prefix: lnxlink + clientId: cobalt + server: nanomq.intern.muehl.dev + port: 1883 + auth: + user: cobalt + pass: cobalt + tls: false + keyfile: '' + certfile: '' + ca_certs: '' + discovery: + enabled: true + lwt: + enabled: true + qos: 1 + clear_on_off: true +update_interval: 5 +update_on_change: false +hass_url: null +hass_api: null +modules: null +custom_modules: null +exclude: +- audio_select +- active_window +- bash +- battery +- beacondb +- bluetooth +- boot_select +- brightness +- fullscreen +- gpio +- gpu +- idle +- inference_time +- ir_remote +- keep_alive +- keyboard_hotkeys +- media +- mouse +- network +- notify +- power_profile +- restful +- screen_onoff +- screenshot +- send_keys +- speech_recognition +- systemd +- sys_updates +- steam +- wifi +- webcam +- xdg_open +- wol +- docker +settings: + systemd: null + gpio: + inputs: null + outputs: null + hotkeys: null + battery: + include_batteries: [] + exclude_batteries: [] + disk_usage: + include_disks: [] + exclude_disks: [] + statistics: https://analyzer.bkbilly.workers.dev + bash: + allow_any_command: false + expose: null + mounts: + autocheck: false + directories: [] + ir_remote: + receiver: null + transmitter: null + buttons: [] + restful: + port: 8112 diff --git a/modules/nixos/services/shutdown.nix b/modules/nixos/services/shutdown.nix deleted file mode 100644 index a52a742..0000000 --- a/modules/nixos/services/shutdown.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; let - # The command to run in order to shut down the computer - command = "${pkgs.systemd}/bin/systemctl poweroff -i"; - - # Write this command into a shell script - bin = pkgs.writeShellScriptBin "shutdown" command; - - cfg = config.services.homeassistant-shutdown; -in { - options.services = { - homeassistant-shutdown = { - enable = mkEnableOption "HomeAssistant shutdown service"; - }; - }; - - config = mkIf cfg.enable { - users.users.hass = { - isNormalUser = true; - home = "/home/hass"; - description = "HomeAssistant automations"; - extraGroups = []; - openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICzLKowPwiQtAIgrY1wSvdolcDkbXokWrda//EEzQfR5 root@homeassistant"]; - }; - - # Create a symlink to the shell script we created to the absolute path - # /etc/shutdown-script - environment.etc.shutdown-script.source = "${bin}/bin/shutdown"; - - security.sudo.extraRules = [ - { - users = ["hass"]; - commands = [ - { - # Allow the 'hass' user to run the shutdown script - command = "/etc/shutdown-script"; - options = ["NOPASSWD"]; - } - ]; - } - ]; - - # Allow the 'hass' user to log in, but not via password authentication. - # The authorized key is specified above. - services.openssh = { - enable = true; - settings = { - PasswordAuthentication = false; - AllowUsers = ["hass"]; - }; - }; - }; -} diff --git a/packages/solidtime-desktop/default.nix b/packages/solidtime-desktop/default.nix new file mode 100644 index 0000000..1fc8da2 --- /dev/null +++ b/packages/solidtime-desktop/default.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: +pkgs.writeShellApplication { + name = "connect-to-mercury"; + text = builtins.readFile ./connect-to-mercury; +} diff --git a/systems/x86_64-linux/cobalt/default.nix b/systems/x86_64-linux/cobalt/default.nix index be6acb1..32beb09 100644 --- a/systems/x86_64-linux/cobalt/default.nix +++ b/systems/x86_64-linux/cobalt/default.nix @@ -3,9 +3,7 @@ # Main tower workstation environment { pkgs, - inputs, lib, - config, ... }: with lib._elements; { @@ -39,6 +37,7 @@ with lib._elements; { networking = { hostName = "cobalt"; firewall.enable = false; + interfaces.eno1.wakeOnLan.enable = true; }; # Set your time zone. @@ -88,7 +87,8 @@ with lib._elements; { # Bluetooth manager blueman.enable = true; - homeassistant-shutdown.enable = true; + # Linux link via MQTT + lnxlink.enable = true; pulseaudio.enable = true; pulseaudio.support32Bit = true; diff --git a/systems/x86_64-linux/cobalt/disk-config.nix b/systems/x86_64-linux/cobalt/disk-config.nix index 660b17c..9354fa9 100644 --- a/systems/x86_64-linux/cobalt/disk-config.nix +++ b/systems/x86_64-linux/cobalt/disk-config.nix @@ -31,6 +31,29 @@ }; }; }; + + gaming = { + type = "disk"; + device = "/dev/sdd"; + content = { + type = "gpt"; + partitions = { + gaming = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = ["-f"]; + mountpoint = "/mnt/games/hdd"; + mountOptions = [ + "compress=zstd" + "noatime" + "nofail" + ]; + }; + }; + }; + }; + }; }; }; } diff --git a/systems/x86_64-linux/cobalt/hardware.nix b/systems/x86_64-linux/cobalt/hardware.nix index 8fb269a..1f68e31 100644 --- a/systems/x86_64-linux/cobalt/hardware.nix +++ b/systems/x86_64-linux/cobalt/hardware.nix @@ -28,17 +28,6 @@ ]; }; - fileSystems."/mnt/games/hdd" = { - device = "/dev/disk/by-label/Spiele"; - fsType = "ntfs"; - options = [ - "nofail" - "exec" - "users" - "permissions" - ]; - }; - environment.systemPackages = [pkgs.rclone]; environment.etc."rclone-beryllium.conf".text = '' [beryllium]