diff --git a/.sops.yaml b/.sops.yaml index 337e55e..bcea545 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -5,7 +5,7 @@ creation_rules: key_groups: - age: - *primary - - path_regex: host/(Rias|Senko|Eclipse)/secrets/.+$ + - path_regex: host/(Rias|Senko|Inaho|Eclipse)/secrets/.+$ key_groups: - age: - *primary diff --git a/disko.nix b/disko.nix deleted file mode 100644 index 6046c50..0000000 --- a/disko.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - disko.devices = { - disk = { - my-disk = { - device = "/dev/sdb"; - type = "disk"; - content = { - type = "gpt"; - partitions = { - ESP = { - type = "EF00"; - size = "256M"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - }; - }; - - swap = { - size = "8G"; - content = { - type = "swap"; - resumeDevice = true; - }; - }; - - root = { - size = "100%"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - }; - }; - }; - }; - }; - }; -} diff --git a/flake.lock b/flake.lock index 22a1527..78242a5 100644 --- a/flake.lock +++ b/flake.lock @@ -162,6 +162,26 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1781152676, + "narHash": "sha256-RxWs5ND31KzTG7wvMM+PMfUjyNpmIEr999lqNARaM5o=", + "owner": "nix-community", + "repo": "disko", + "rev": "ff8702b4de27f72b4c78573dfb89ec74e36abdf1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "firefox-gnome-theme": { "flake": false, "locked": { @@ -906,6 +926,7 @@ "inputs": { "aagl": "aagl", "ags": "ags", + "disko": "disko", "helix-steel": "helix-steel", "home-manager": "home-manager", "hyprland": "hyprland", diff --git a/flake.nix b/flake.nix index 2c2192a..1959ded 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ "https://yazi.cachix.org" ]; extra-trusted-public-keys = [ - "main:kpwMe+9BsGJ/IUb7i3iadaV38y5/Yuqoct0mf7wI9ds=" + "main:tR2gNhCBJHKAlVgohPNHBhGnWL55tB8SxXmMWJe5lo8=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" "ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" @@ -23,6 +23,10 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-26.05"; nixpkgs-pinned.url = "github:nixos/nixpkgs/ec942ba042dad5ef097e2ef3a3effc034241f011"; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; sops-nix.url = "github:Mic92/sops-nix"; stylix.url = "github:danth/stylix"; ags.url = "github:Aylur/ags/3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6"; @@ -63,6 +67,7 @@ Senko = mkHost "Senko"; Eclipse = mkHost "Eclipse"; Impreza = mkHost "Impreza"; + Inaho = mkHost "Inaho"; }; }; } diff --git a/host/Inaho/README.md b/host/Inaho/README.md new file mode 100644 index 0000000..b218813 --- /dev/null +++ b/host/Inaho/README.md @@ -0,0 +1,49 @@ +ThinkPad T480 + +CPU: Intel i5-8350U +RAM: 16GB planned (8GB stock + 8GB SO-DIMM) +SSD: 256GB NVMe stock; disko assumes `/dev/nvme0n1` + +## Installation notes + +This host uses `disko` with GPT + unencrypted EFI System Partition + LUKS + Btrfs subvolumes. + +Before formatting, verify the target disk: + +```bash +lsblk +``` + +If the internal drive is not `/dev/nvme0n1`, edit `host/Inaho/disko.nix` first. +For a 2.5" SATA SSD/HDD it will usually be `/dev/sda`. + +Then partition, format and mount: + +```bash +sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- \ + --mode destroy,format,mount ./host/Inaho/disko.nix +``` + +This destroys the selected disk. + +After that install the host: + +```bash +sudo nixos-install --flake .#Inaho +``` + +The flake contains a new `disko` input. If `flake.lock` has not been updated yet, run: + +```bash +nix flake lock --update-input disko +``` + +## After first boot + +Update firmware, especially BIOS/UEFI and Thunderbolt, when batteries are installed and charged: + +```bash +sudo fwupdmgr refresh +sudo fwupdmgr get-updates +sudo fwupdmgr update +``` diff --git a/host/Inaho/configuration.nix b/host/Inaho/configuration.nix new file mode 100644 index 0000000..5d73a1f --- /dev/null +++ b/host/Inaho/configuration.nix @@ -0,0 +1,34 @@ +{ config, pkgs, pkgs-stable, pkgs-pinned, lib, inputs, ... }: { + imports = [ + inputs.disko.nixosModules.disko + ./disko.nix + ./secrets/secrets.nix + ./modules/grub.nix + ./modules/syncthing.nix + ../modules/thinkpad.nix + ../modules/gpu/intel.nix + + (import ../modules/common.nix { + inherit lib; + inherit inputs; + hostname = "Inaho"; + }) + + (import ../../user/common.nix { + inherit config; + inherit pkgs; + inherit pkgs-stable; + inherit pkgs-pinned; + inherit lib; + inherit inputs; + name = "sweetbread"; + fullname = "Sweet Bread"; + }) + ]; + + hardware.bluetooth.enable = true; + host.laptop = true; + + hardware.usb-modeswitch.enable = true; + networking.modemmanager.enable = true; +} diff --git a/host/Inaho/disko.nix b/host/Inaho/disko.nix new file mode 100644 index 0000000..952fdc1 --- /dev/null +++ b/host/Inaho/disko.nix @@ -0,0 +1,85 @@ +{ lib, ... }: + +let + # Verify with `lsblk` before running disko. For the stock T480 NVMe setup + # this is usually correct; for a 2.5" SATA SSD/HDD change it to /dev/sda. + disk = "/dev/sda"; + + btrfsMountOptions = [ + "compress=zstd" + "noatime" + "ssd" + "discard=async" + ]; +in { + disko.devices = { + disk = { + main = { + type = "disk"; + device = disk; + content = { + type = "gpt"; + partitions = { + ESP = { + priority = 1; + name = "ESP"; + start = "1M"; + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + + luks = { + priority = 2; + name = "cryptsystem"; + size = "100%"; + content = { + type = "luks"; + name = "crypted"; + settings = { + # Allows fstrim/discard through LUKS for SSDs. + allowDiscards = true; + }; + content = { + type = "btrfs"; + extraArgs = [ "-f" "-L" "NixOS" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = btrfsMountOptions; + }; + + "/home" = { + mountpoint = "/home"; + mountOptions = btrfsMountOptions; + }; + + "/nix" = { + mountpoint = "/nix"; + mountOptions = btrfsMountOptions; + }; + + "/log" = { + mountpoint = "/var/log"; + mountOptions = btrfsMountOptions; + }; + + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "16G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/host/Inaho/hardware-configuration.nix b/host/Inaho/hardware-configuration.nix new file mode 100644 index 0000000..1d4670f --- /dev/null +++ b/host/Inaho/hardware-configuration.nix @@ -0,0 +1,22 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + # File systems and swap are declared in ./disko.nix. + # If you regenerate this file after installation, use: + # nixos-generate-config --no-filesystems --root /mnt + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" "thinkpad_acpi" ]; + boot.extraModulePackages = [ ]; + + networking.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/host/Inaho/modules/grub.nix b/host/Inaho/modules/grub.nix new file mode 100644 index 0000000..a101564 --- /dev/null +++ b/host/Inaho/modules/grub.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: let + theme = pkgs.fetchFromGitHub { + owner = "Patato777"; + repo = "dotfiles"; + rev = "cc363921707807d7ad3e36b462f0df793a0fe18a"; + hash = "sha256-fpXGFNrzbV6K9hoZRX4tGieTLzhpPeGm6wn8CF4OGow="; + }; +in { + boot.loader.grub = { + gfxmodeEfi = "1920x1080"; + theme = "${theme}/grub/themes/virtuaverse"; + }; +} diff --git a/host/Inaho/modules/hyprland.nix b/host/Inaho/modules/hyprland.nix new file mode 100644 index 0000000..a74ec69 --- /dev/null +++ b/host/Inaho/modules/hyprland.nix @@ -0,0 +1,9 @@ +{ + wayland.windowManager.hyprland = { + settings = { + monitor = [ + "eDP-1, 1920x1080@60, 0x0, 1" + ]; + }; + }; +} \ No newline at end of file diff --git a/host/Inaho/modules/syncthing.nix b/host/Inaho/modules/syncthing.nix new file mode 100644 index 0000000..7ee1949 --- /dev/null +++ b/host/Inaho/modules/syncthing.nix @@ -0,0 +1,34 @@ +{ config, ... }: { + services.syncthing = { + enable = true; + openDefaultPorts = true; + + user = "sweetbread"; + dataDir = "/home/sweetbread/.config/syncthing"; + + key = config.sops.secrets.syncthing_key.path; + cert = config.sops.secrets.syncthing_cert.path; + + settings = { + devices = { + Rias.id = "EC5AGVN-2RKJDHN-NOSB7PQ-IRYCEEW-NPPDUGX-6QGSLUU-YIT5ZZZ-RVPTHQ6"; + Akeno.id = "QDW3WJX-J7ETS4R-32CUAIY-EGNM2RD-ZEHOUW2-CHOEOUG-USZOWTR-HHQS2QX"; + Koneko.id = "PJFWQRY-ZFUBGDR-NV7KVBL-UBDQ4HT-KPTYP34-MUDFPJU-4EZUHTT-ZLYRMAB"; + }; + + folders = { + "Music" = { + path = "/home/sweetbread/Music"; + devices = [ "Rias" "Akeno" "Koneko" ]; + }; + + "Obsidian" = { + path = "/home/sweetbread/Documents/Obsidian"; + devices = [ "Rias" "Akeno" "Koneko" ]; + }; + }; + }; + }; + + systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; +} diff --git a/host/Inaho/secrets/secrets.nix b/host/Inaho/secrets/secrets.nix new file mode 100644 index 0000000..7bc9fb1 --- /dev/null +++ b/host/Inaho/secrets/secrets.nix @@ -0,0 +1,20 @@ +{ + sops = { + age.keyFile = "/root/age.key"; + secrets = { + vpn_bolt = { + format = "binary"; + sopsFile = ../../Rias/secrets/vpn_bolt.db; + }; + + syncthing_cert = { + format = "binary"; + sopsFile = ./syncthing_cert.pem; + }; + syncthing_key = { + format = "binary"; + sopsFile = ./syncthing_key.pem; + }; + }; + }; +} diff --git a/host/Inaho/secrets/syncthing_cert.pem b/host/Inaho/secrets/syncthing_cert.pem new file mode 100644 index 0000000..0f2f6db --- /dev/null +++ b/host/Inaho/secrets/syncthing_cert.pem @@ -0,0 +1,14 @@ +{ + "data": "ENC[AES256_GCM,data:rMr83F9VyGV5dp2XqXGAh3X2sCczUb0chH/2Hn9N9tijfRsOLGqHuy/zy29aOHR0PJ4euTU3bhmxWrBV/7oTnnEfI7DFF0vX4eBDaK8BzwAzrzXHYJOAgcwuYSqEEyWiLvTGABuLhTEto9kIMLxVIssa679s7zQSRwemVJSA3fEdtYD0BLAiO/ZtiAEmitgEt4EBRp9DhJPqlh2YfMmP6DpkDSy0hk+S+0NZg7eyrp7fivldiLzjsYDwCsugFcZQtWOqLMHY0kYhou8c2CKXu8UyqVVx24DyWfBfD1TH2pOk1ZsXFsxhFFKp5wcsfi0xDF1BG4hANcHVa6pR6y5JxNzh53xaH3NuvNJFEQSGJw5fNMuCrDnkYLDpU3xezzjvvxI01y7i2A00zsLli1fc9HA67ZlP1OBzsI7FyMgZlnOXQpbqnkj+kZdYAdOTjjMzQvrPusVS3RvqvcWj1qZtnHa1ZGmWh7xG0J10lQB4uDmTSxWoUUi7VmLXTC16HQNMySd8GbFmD/4Nj+/SxDShgsiug7L4hICjPC8Isosy99tE2wRXpjmMYUdlD7zu/vyEMxVPhkWnJyZZPXG+DjGBc/Diaw4ufYNxUs4yIRDceMArirubt/sN/eUoGOBGVWxvGm0/olTott7Yr+YKRSrDyWo9SWCz1qgz/ydpXm+xE7bPtbj9eAObZwneB/0tZTyo8o1WKd9yUST89m91EMQ31R97yCBwDW19VftWVCZH2w+QHNunih4ZUNiALQS745T2petbvc63iNiZswu0l3qoVM8x3y1RhAPLbsZpwQWSca307iDfBTB6uVW4HwLtL30=,iv:ajC3mjCYKUqS7XGIN64NiJoG6wHMvGdcHhazSO860ms=,tag:31fWG7m2neW2Pft9TjmBGg==,type:str]", + "sops": { + "age": [ + { + "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBuQUNTSDVIeDRuMmtTWXZD\nU0x4OVJrUStFeW5QV0pOZ2hEZnJZQ09UbW5RCmwxbjhuWis1Q3BCTGtOdS8zNE0w\nL0pDK3dBY1hxZ2dCNG96RlA0dkNWVWMKLS0tIHFld2hUdm11dk5hT2ZtRXpId0VG\nRDM0L05jS0lGcnJBYWVNWElIazdlaUEKugvBGcCzYTZL6aC6mI6GCzhiPFYql75z\nSBfalDmqSVU2k1IBqsNHIYSxzOXwUiGS3MSHJUCf7M2y9X3dHJGeyw==\n-----END AGE ENCRYPTED FILE-----\n", + "recipient": "age1j3uuyax673fvl5x4dveupq3dylngnrq0e5uy7fmclsexkfd25vysk646wk" + } + ], + "lastmodified": "2026-07-21T20:27:59Z", + "mac": "ENC[AES256_GCM,data:lYZH1f3TyvcgqWI9hVOP3l2xImRh+LL0volXVUYSdGBnQTsAJfzMdsol/SsETwNNn+KrANC3ucO0/MXOWDK7ZPJ5Oq9R+OQnM8LK9/5mNfbzgodTw0RaH8FsrrtBCtHn3H2rlrBoPFEArblWKOh0G9iyrmufT09OREGt/G0tE5o=,iv:vmB1CY3sVajvLS8zAS/0I+NgnAOStbUkzQdw6XY45y4=,tag:mZP/eZVn+DJq+OT1ghtOkQ==,type:str]", + "version": "3.13.2" + } +} diff --git a/host/Inaho/secrets/syncthing_key.pem b/host/Inaho/secrets/syncthing_key.pem new file mode 100644 index 0000000..b97e8cd --- /dev/null +++ b/host/Inaho/secrets/syncthing_key.pem @@ -0,0 +1,14 @@ +{ + "data": "ENC[AES256_GCM,data:2nMwCxU1y0zE5VtnmEf3lT4XyI9e8dokPkipo3TXpxuRJZ9OXCOb0n4pHb4Xx9OlDgAeW2UX70cR1Wtj7QPQx9h/HYZTmUeIP4rvlTPhaxs/2F33ud1lPKceV2DK2q8G/EvPLnlCcLWMvy6BVsqBlNmjAzNonWI=,iv:7H0o0i3zp7K2demt1O2Pw4BNt+2q4PhHBw1K/jC7OH4=,tag:Bx82eo5kQqwlb6egYmopgQ==,type:str]", + "sops": { + "age": [ + { + "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA2Vzl3M3pFblY5SmRQRUtI\nNWFCbWZJQTJTOWFHdTd1YkJEbXFGOFhBTUNNClBKdWhGdmh3Q2dUNkpMUUU3Zmdq\nUFd1M2twNW1KRGErRHUvc1BLY2pMT3MKLS0tIElVZ0RVVFQrb1FuYnJ0OU44RWZK\nbnpJZnFLR3kzV3VRaytQRDMrYkg5S2sKkr97EwJmtcIsRYH4di+tadTWnWzuCDa9\ngY+CKCVEPUgD1AXSgCwCP2AVd/zaKUbm6d6UA2QzZyqGsRim56WFsQ==\n-----END AGE ENCRYPTED FILE-----\n", + "recipient": "age1j3uuyax673fvl5x4dveupq3dylngnrq0e5uy7fmclsexkfd25vysk646wk" + } + ], + "lastmodified": "2026-07-21T20:28:23Z", + "mac": "ENC[AES256_GCM,data:ohYjzIYDilW7lsmZFZXpF629yevO2p8laA7Zl0+NCvZ8dB4nthLUePsnLTYCrEo5ADbboM5Cka11FiYbmB1IMR4mEdRwTN37EsQtyYLZbZ+j4XPsuXO0UT0NmWWiFNJlQEWfTVbhaZRDQXcPpVvm+6qQfRub018/0C59oWpmbyA=,iv:SX1QDDUWZyxE0zODAImcGGHJI7KGKYx9/6Q9F+9SVCQ=,tag:AExTZIfAKTCeU9c3Qj+IUw==,type:str]", + "version": "3.13.2" + } +} diff --git a/host/Rias/modules/syncthing.nix b/host/Rias/modules/syncthing.nix index f5cf8de..4db523f 100644 --- a/host/Rias/modules/syncthing.nix +++ b/host/Rias/modules/syncthing.nix @@ -13,6 +13,7 @@ devices = { Akeno.id = "QDW3WJX-J7ETS4R-32CUAIY-EGNM2RD-ZEHOUW2-CHOEOUG-USZOWTR-HHQS2QX"; Koneko.id = "PJFWQRY-ZFUBGDR-NV7KVBL-UBDQ4HT-KPTYP34-MUDFPJU-4EZUHTT-ZLYRMAB"; + Inaho.id = "GEHWQFQ-MPIMQ7R-QEWSOEB-BIZAHSZ-5YOFATK-KDIXFMV-JX3OF6G-ZPNZMA4"; }; folders = { diff --git a/host/modules/thinkpad.nix b/host/modules/thinkpad.nix new file mode 100644 index 0000000..a2f65f8 --- /dev/null +++ b/host/modules/thinkpad.nix @@ -0,0 +1,83 @@ +{ config, lib, pkgs, ... }: { + # T480-specific hardware defaults. + hardware = { + enableRedistributableFirmware = true; + + trackpoint = { + enable = true; + emulateWheel = true; + }; + }; + + boot = { + supportedFilesystems = [ "btrfs" ]; + + initrd.availableKernelModules = [ + "nvme" + "ahci" + "xhci_pci" + "usb_storage" + "usbhid" + "sd_mod" + "rtsx_pci_sdmmc" + ]; + + kernelModules = [ "kvm-intel" "thinkpad_acpi" ]; + + kernelParams = [ + # Prefer S3/deep sleep when BIOS exposes it. If suspend behaves worse, + # remove this and use the BIOS sleep setting instead. + "mem_sleep_default=deep" + ]; + }; + + powerManagement.enable = true; + services = { + # Firmware updates for BIOS/UEFI, Thunderbolt, SSDs where LVFS supports it. + fwupd.enable = true; + + # Helps Intel laptops keep sane thermal behaviour under load. + thermald.enable = true; + + # Fingerprint reader support. If fprintd does not detect the reader, + # leaving this enabled is harmless; login can still use a password. + fprintd.enable = true; + + logind.settings.Login = { + HandleLidSwitch = "suspend"; + HandleLidSwitchExternalPower = "suspend"; + HandlePowerKey = "poweroff"; + }; + + tlp.settings = { + # Preserve batteries when the laptop is usually on AC. + # Raise STOP_* to 100 if maximum autonomy matters more than battery wear. + START_CHARGE_THRESH_BAT0 = 70; + STOP_CHARGE_THRESH_BAT0 = 95; + START_CHARGE_THRESH_BAT1 = 70; + STOP_CHARGE_THRESH_BAT1 = 85; + RESTORE_THRESHOLDS_ON_BAT = 1; + + # NVMe/SATA SSD power saving without making the system too sluggish. + AHCI_RUNTIME_PM_ON_AC = "on"; + AHCI_RUNTIME_PM_ON_BAT = "auto"; + SATA_LINKPWR_ON_AC = "med_power_with_dipm"; + SATA_LINKPWR_ON_BAT = "med_power_with_dipm"; + + # Usually safe on ThinkPads; disable if some USB device randomly disconnects. + USB_AUTOSUSPEND = 1; + }; + }; + + networking.networkmanager.wifi.powersave = true; + + environment.systemPackages = with pkgs; [ + acpi + lm_sensors + pciutils + powertop + smartmontools + usbutils + nvme-cli + ]; +} diff --git a/modules/host/laptop.nix b/modules/host/laptop.nix index a238b66..e1d420c 100644 --- a/modules/host/laptop.nix +++ b/modules/host/laptop.nix @@ -4,11 +4,11 @@ lib.mkIf config.host.laptop { services.tlp = { enable = true; settings = { - CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_AC = "powersave"; CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; - CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "balance_power"; CPU_MIN_PERF_ON_AC = 0; CPU_MAX_PERF_ON_AC = 100; diff --git a/user/sweetbread/modules/waybar.nix b/user/sweetbread/modules/waybar.nix index 3df9cbc..1afe71a 100644 --- a/user/sweetbread/modules/waybar.nix +++ b/user/sweetbread/modules/waybar.nix @@ -3,13 +3,16 @@ playerctl cava pulsemixer + libnotify monocraft font-awesome nerd-fonts.symbols-only ]; - programs.waybar = { + programs.waybar = let + multibat = osConfig.networking.hostName == "Inaho"; + in { enable = true; systemd.enable = true; @@ -31,7 +34,7 @@ "tray" "group/system" "pulseaudio" - "battery" + ( if multibat then "group/bat" else "battery" ) "clock" ]; @@ -71,6 +74,19 @@ dynamic-order = [ "title" "artist" "album" ]; }; + "group/bat" = lib.mkIf multibat { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = false; + }; + modules = [ + "battery" + "battery#int" + "battery#ext" + ]; + }; + battery = { interval = 5; states = { @@ -82,6 +98,33 @@ default = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; charging = ["󰢟" "󰢜" "󰂆" "󰂇" "󰂈" "󰢝" "󰂉" "󰢞" "󰂊" "󰂋" "󰂅"]; }; + events = { + on-discharging-warning = "notify-send -u normal 'Low Battery'"; + on-discharging-critical = "notify-send -u critical 'Very Low Battery'"; + }; + }; + + "battery#int" = lib.mkIf multibat { + bat = "BAT0"; + interval = 5; + states = { + warning = 30; + critical = 15; + }; + format = "I: {capacity}%"; + }; + + "battery#ext" = lib.mkIf multibat { + bat = "BAT1"; + interval = 5; + states = { + warning = 30; + critical = 15; + }; + format = "E: {capacity}%"; + events = { + on-discharging-critical = "notify-send -u normal 'External battery is critical"; + }; }; "keyboard-state" = { @@ -249,8 +292,9 @@ } } - #system .drawer-child > * { - margin-right: 4px + #system, + #bat { + & .drawer-child > * { margin-right: 4px } } #keyboard-state label.locked { @@ -259,7 +303,6 @@ } #battery { - &.plugged { color: ${colors.base0D}; } &.charging { color: ${accent}; } &:not(.charging) { &.warning { @@ -280,6 +323,10 @@ color: ${colors.base00}; background: ${accent}; } + &.plugged { + color: ${colors.base00}; + background: ${colors.base0D}; + } } @keyframes blink {