From cbb676bf00a08c7c3d6784210416657ce8bf1833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sun, 28 Feb 2021 08:01:51 +0100 Subject: [PATCH] chore: organize battery, steam and praesenzlehre into imports --- configs/battery.nix | 17 ++++++ systems/makanek/configuration.nix | 83 +++++++++++++++--------------- systems/manakish/configuration.nix | 20 ++----- systems/wilde/configuration.nix | 17 +----- 4 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 configs/battery.nix diff --git a/configs/battery.nix b/configs/battery.nix new file mode 100644 index 0000000..e9ed3ff --- /dev/null +++ b/configs/battery.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: +{ + boot.extraModulePackages = with config.boot.kernelPackages; [ + tp_smapi + acpi_call + ]; + boot.kernelModules = [ "tp_smapi" "acpi_call" ]; + environment.systemPackages = [ pkgs.tpacpi-bat ]; + + services.tlp = { + enable = true; + settings = { + START_CHARGE_THRESH_BAT0 = 80; + STOP_CHARGE_THRESH_BAT0 = 95; + }; + }; +} diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index 6f6a1b2..bc09e9f 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -4,6 +4,48 @@ let in { imports = [ + { + systemd.services.praesenzlehre = { + description = "Live Ticker zu praesenzlehre-berlin.org"; + wants = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + startAt = "daily"; + path = [ pkgs.curl pkgs.pup pkgs.bc ]; + environment.BOT_TOKEN = lib.strings.fileContents ; + script = '' + set -efu + + count_file=/tmp/praesenzlehre-berlin.org + + set_count() { + echo $* > "$count_file" + } + + get_count() { + cat "$count_file" + } + + notify() { + curl -sSL -X POST -H 'Content-Type: application/json' \ + -d "{\"chat_id\": \"@praesenzlehre_berlin\", \"text\": \"$*\"}" \ + "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" + } + + test -f "$count_file" || set_count 0 + + count="$(get_count)" + + new_count="$(curl -sSL https://praesenzlehre-berlin.org/ | pup '.dk-speakout-signature-count span text{}')" + + if [ "$new_count" -gt "$count" ]; then + diff="$(echo "$new_count - $count" | bc)" + echo "$new_count (+ $diff)" + notify "$new_count Unterzeichner:innen! (+ $diff)" + set_count "$new_count" + fi + ''; + }; + } ./hardware-configuration.nix @@ -64,45 +106,4 @@ in }; environment.systemPackages = [ pkgs.vim pkgs.git pkgs.tmux ]; - - systemd.services.praesenzlehre = { - description = "Live Ticker zu praesenzlehre-berlin.org"; - wants = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - startAt = "daily"; - path = [ pkgs.curl pkgs.pup pkgs.bc ]; - environment.BOT_TOKEN = lib.strings.fileContents ; - script = '' - set -efu - - count_file=/tmp/praesenzlehre-berlin.org - - set_count() { - echo $* > "$count_file" - } - - get_count() { - cat "$count_file" - } - - notify() { - curl -sSL -X POST -H 'Content-Type: application/json' \ - -d "{\"chat_id\": \"@praesenzlehre_berlin\", \"text\": \"$*\"}" \ - "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" - } - - test -f "$count_file" || set_count 0 - - count="$(get_count)" - - new_count="$(curl -sSL https://praesenzlehre-berlin.org/ | pup '.dk-speakout-signature-count span text{}')" - - if [ "$new_count" -gt "$count" ]; then - diff="$(echo "$new_count - $count" | bc)" - echo "$new_count (+ $diff)" - notify "$new_count Unterzeichner:innen! (+ $diff)" - set_count "$new_count" - fi - ''; - }; } diff --git a/systems/manakish/configuration.nix b/systems/manakish/configuration.nix index 820dfd9..1dd0ef9 100644 --- a/systems/manakish/configuration.nix +++ b/systems/manakish/configuration.nix @@ -7,21 +7,10 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + { - boot.extraModulePackages = with config.boot.kernelPackages; [ - tp_smapi - acpi_call - ]; - boot.kernelModules = [ "tp_smapi" "acpi_call" ]; - environment.systemPackages = [ pkgs.tpacpi-bat ]; - - services.tlp = { - enable = true; - settings = { - START_CHARGE_THRESH_BAT0 = 80; - STOP_CHARGE_THRESH_BAT0 = 95; - }; - }; + programs.steam.enable = true; + nixpkgs.config.steam.java = true; } ]; @@ -48,9 +37,6 @@ ipv6 = "42:0:3c46:ac99:ae36:cb8:c551:ba27"; }; - programs.steam.enable = true; - nixpkgs.config.steam.java = true; - networking.hostName = "manakish"; system.stateVersion = "20.09"; # Did you read the comment? diff --git a/systems/wilde/configuration.nix b/systems/wilde/configuration.nix index 35cddf7..a187d81 100644 --- a/systems/wilde/configuration.nix +++ b/systems/wilde/configuration.nix @@ -5,24 +5,9 @@ in { imports = [ + ./hardware-configuration.nix - { - boot.extraModulePackages = with config.boot.kernelPackages; [ - tp_smapi - acpi_call - ]; - boot.kernelModules = [ "tp_smapi" "acpi_call" ]; - environment.systemPackages = [ pkgs.tpacpi-bat ]; - - services.tlp = { - enable = true; - settings = { - START_CHARGE_THRESH_BAT0 = 80; - STOP_CHARGE_THRESH_BAT0 = 95; - }; - }; - } ]; niveum = {