diff --git a/home/common/general.nix b/home/common/general.nix index 37a74b7..f671ebd 100644 --- a/home/common/general.nix +++ b/home/common/general.nix @@ -123,5 +123,6 @@ home.packages = with pkgs; [ rclone fuse jq appimage-run python3Full killall + comma ]; } diff --git a/home/common/gui.nix b/home/common/gui.nix index fe6e3f0..52db4ea 100644 --- a/home/common/gui.nix +++ b/home/common/gui.nix @@ -1,7 +1,10 @@ { config, pkgs, lib, ... }: { imports = [ ./terminal.nix ]; - home.sessionVariables."ALSOFT_CONF" = "${config.xdg.configHome}/.config/alsoft.conf"; + home.sessionVariables = { + ALSOFT_CONF = "${config.xdg.configHome}/.config/alsoft.conf"; + SDL_AUDIODRIVER = "pipewire"; + }; xdg.configFile."alsoft.conf".text = '' [general] hrtf = true diff --git a/home/common/i3-sway.nix b/home/common/i3-sway.nix index acc08cb..706db0a 100644 --- a/home/common/i3-sway.nix +++ b/home/common/i3-sway.nix @@ -50,44 +50,35 @@ commonConfig = { ]; colors = { focused = { - # background = "#913131"; - #background = "#5e4651c9"; - #border = "#5e4651c9"; childBorder = "#b0a3a5c0"; - background = "#24101ac0"; - border = "#24101ac0"; - # childBorder = "#5e4651c9"; + # background = "#24101ac0"; + background = "#4c4042e0"; + # border = "#24101ac0"; + border = "#4c4042e0"; indicator = "#b35656"; text = "#ebdadd"; }; focusedInactive = { - # background = "#782a2a"; - # border = "#782a2a"; - #background = "#5e4651c9"; - #border = "#5e4651c9"; - #childBorder = "#5e4651c9"; - background = "#24101ac0"; - border = "#24101ac0"; + # background = "#24101ac0"; + background = "#4c4042e0"; + # border = "#24101ac0"; + border = "#4c4042e0"; childBorder = "#24101ac0"; - # childBorder = "#b32d2d"; indicator = "#b32d2d"; text = "#ebdadd"; }; unfocused = { - # background = "#4d2525"; - # border = "#472222"; background = "#24101ac0"; - border = "#24101ac0"; + # border = "#24101ac0"; + border = "#4c4042e0"; childBorder = "#24101ac0"; - # childBorder = "#4d2525"; indicator = "#661a1a"; - text = "#8c8284"; + text = "#ebdadd"; }; urgent = { background = "#993d3d"; border = "#734545"; childBorder = "#734545"; - # childBorder = "#993d3d"; indicator = "#993d3d"; text = "#ebdadd"; }; @@ -280,7 +271,7 @@ in { command = "${config.programs.waybar.package}/bin/waybar"; mode = "dock"; - position = "bottom"; + position = "top"; hiddenState = "hide"; } ]; @@ -293,6 +284,10 @@ in }; } ]; assigns = { + "2" = [ + { app_id = "org.telegram.desktop"; } + { app_id = "nheko"; } + ]; "3" = [{ app_id = "org.keepassxc.KeePassXC"; }]; }; keybindings = genKeybindings options.wayland.windowManager.sway (with pkgs.sway-contrib; @@ -358,6 +353,9 @@ in always = true; command = "${pkgs.wl-clipboard}/bin/wl-paste -t text --watch ${pkgs.clipman}/bin/clipman store --no-persist"; } + { + command = "${pkgs.swayidle}/bin/swayidle -w timeout 300 '' resume '${pkgs.sway}/bin/swaymsg \"output * dpms on\"'"; + } ]; output = { "*" = { @@ -385,4 +383,58 @@ in export XDG_CURRENT_DESKTOP=sway ''; }; + services.swayidle = { + enable = true; + events = [ + { event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock"; } + # after-resume, lock, unlock + ]; + timeouts = [ + { timeout = 300; + command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\""; + resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\""; } + { timeout = 600; + command = "${pkgs.swaylock}/bin/swaylock"; } + ]; + }; + programs.swaylock.settings = let textColor = "#ebdadd"; bgColor = "#24101ac0"; in { + image = "${config.home.homeDirectory}/var/wallpaper.jpg"; + font = "Unifont"; + font-size = 64; + + indicator-caps-lock = true; + indicator-radius = 256; + indicator-thickness = 32; + separator-color = "#00000000"; + + layout-text-color = textColor; + layout-bg-color = bgColor; + layout-border-color = "#00000000"; + + line-uses-inside = true; + + inside-color = bgColor; + text-color = textColor; + ring-color = "#8cbf73"; # green + key-hl-color = "#6398bf"; # blue + bs-hl-color = "#e66e6e"; # red + + inside-caps-lock-color = bgColor; + text-caps-lock-color = textColor; + ring-caps-lock-color = "#ebbe5f"; # yellow + caps-lock-key-hl-color = "#6398bf"; # same as normal key-hl-color + caps-lock-bs-hl-color = "#e66e6e"; # same as normal bs-hl-color + + inside-clear-color = bgColor; + text-clear-color = textColor; + ring-clear-color = "#8cbf73"; # green + + inside-ver-color = bgColor; + text-ver-color = textColor; + ring-ver-color = "#a64999"; # purple + + inside-wrong-color = bgColor; + text-wrong-color = textColor; + ring-wrong-color = "#e64e4e"; # deep-ish red + }; } diff --git a/home/common/kakoune.nix b/home/common/kakoune.nix index cd4e878..240e677 100644 --- a/home/common/kakoune.nix +++ b/home/common/kakoune.nix @@ -36,8 +36,10 @@ in { extraConfig = '' eval %sh{kak-lsp --kakoune -s $kak_session} lsp-enable + hook global BufOpenFile .* autoconfigtab + hook global BufNewFile .* autoconfigtab ''; - plugins = with pkgs.kakounePlugins; [ kak-lsp sleuth-kak tabs-kak ]; + plugins = with pkgs.kakounePlugins; [ kak-lsp smarttab-kak tabs-kak ]; }; xdg.configFile."kak-lsp/kak-lsp.toml".text = '' # bash, clangd, json, html, css, python work out of the box diff --git a/home/flake.nix b/home/flake.nix index 01056ce..c47a39f 100644 --- a/home/flake.nix +++ b/home/flake.nix @@ -5,17 +5,13 @@ #nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; #instead take it from system config nur.url = "github:nix-community/NUR"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { self, nixpkgs, home-manager, nur, rust-overlay }: + outputs = { self, nixpkgs, home-manager, nur }: let # IRL-related private config priv = if builtins.pathExists ./private.nix then (import ./private.nix) else {}; @@ -23,7 +19,7 @@ in { homeConfigurations = { "user@nixmsi" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages."x86_64-linux".extend rust-overlay.overlays.default; + pkgs = nixpkgs.legacyPackages."x86_64-linux"; modules = [ nur.nixosModules.nur ./hosts/nixmsi.nix diff --git a/home/home-daemon/Cargo.lock b/home/home-daemon/Cargo.lock index c9de5a6..1232c1b 100644 --- a/home/home-daemon/Cargo.lock +++ b/home/home-daemon/Cargo.lock @@ -3,14 +3,37 @@ version = 3 [[package]] -name = "ahash" -version = "0.7.6" +name = "aho-corasick" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ - "getrandom", - "once_cell", - "version_check", + "memchr", +] + +[[package]] +name = "async-broadcast" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b19760fa2b7301cf235360ffd6d3558b1ed4249edd16d6cca8d690cee265b95" +dependencies = [ + "event-listener", + "futures-core", + "parking_lot", +] + +[[package]] +name = "async-executor" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" +dependencies = [ + "async-lock", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", ] [[package]] @@ -55,15 +78,21 @@ dependencies = [ [[package]] name = "async-recursion" -version = "0.3.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" +checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "async-task" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" + [[package]] name = "async-trait" version = "0.1.63" @@ -87,6 +116,21 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "bytes" version = "1.1.0" @@ -114,6 +158,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + [[package]] name = "crossbeam-utils" version = "0.8.14" @@ -124,58 +177,85 @@ dependencies = [ ] [[package]] -name = "dbus-async" -version = "2.3.1" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37657d5c76f7966ccee7cc3ab0cc0055bac1742021551ed212ea5ca3f72882aa" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ - "async-recursion", - "async-trait", - "bitflags", - "bytes", - "dbus-message-parser", - "dbus-server-address-parser", - "futures", - "hex", "libc", - "log", - "lru", - "retain_mut", - "thiserror", - "tokio", -] - -[[package]] -name = "dbus-message-parser" -version = "4.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1cadcd65b6ff5e016ab3848a6dcebb6578ddbf3a7373093381e6590899ea750" -dependencies = [ - "bitflags", - "bytes", - "cfg-if", - "lazy_static", - "thiserror", -] - -[[package]] -name = "dbus-server-address-parser" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba14fedfb911759c9b49fceee906d41f8e7e9442593d5f71a20cfb3effa9c4" -dependencies = [ - "thiserror", + "redox_users", + "winapi", ] [[package]] name = "dotfiles-home-daemon" version = "0.1.0" dependencies = [ - "dbus-async", - "dbus-message-parser", "futures-util", "swayipc-async", "tokio", + "zbus", +] + +[[package]] +name = "enumflags2" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -193,48 +273,12 @@ dependencies = [ "instant", ] -[[package]] -name = "futures" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" -dependencies = [ - "futures-core", - "futures-sink", -] - [[package]] name = "futures-core" version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" -[[package]] -name = "futures-executor" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - [[package]] name = "futures-io" version = "0.3.25" @@ -285,18 +329,25 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ - "futures-channel", "futures-core", - "futures-io", "futures-macro", "futures-sink", "futures-task", - "memchr", "pin-project-lite", "pin-utils", "slab", ] +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -313,9 +364,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] [[package]] name = "hex" @@ -323,6 +371,16 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "instant" version = "0.1.12" @@ -350,6 +408,16 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -359,15 +427,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "lru" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" -dependencies = [ - "hashbrown", -] - [[package]] name = "memchr" version = "2.5.0" @@ -375,34 +434,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] -name = "mio" -version = "0.7.14" +name = "memoffset" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "miow", - "ntapi", - "winapi", + "wasi", + "windows-sys", ] [[package]] -name = "miow" -version = "0.3.7" +name = "nix" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ - "winapi", + "autocfg", + "bitflags", + "cfg-if", + "libc", + "memoffset", + "pin-utils", ] [[package]] -name = "ntapi" -version = "0.3.7" +name = "nom8" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" dependencies = [ - "winapi", + "memchr", ] [[package]] @@ -411,12 +483,45 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +[[package]] +name = "ordered-stream" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360a24bdacdb7801a1a6af8500392864791c130ebe8bd9a063158cab00040c90" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "parking" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -443,6 +548,22 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.50" @@ -462,10 +583,80 @@ dependencies = [ ] [[package]] -name = "retain_mut" -version = "0.1.9" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] [[package]] name = "ryu" @@ -473,6 +664,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "serde" version = "1.0.152" @@ -505,12 +702,25 @@ dependencies = [ ] [[package]] -name = "signal-hook-registry" -version = "1.4.0" +name = "serde_repr" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" dependencies = [ - "libc", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", ] [[package]] @@ -522,6 +732,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "socket2" version = "0.4.7" @@ -532,6 +748,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "swayipc-async" version = "2.0.1" @@ -568,6 +790,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "thiserror" version = "1.0.38" @@ -590,19 +826,20 @@ dependencies = [ [[package]] name = "tokio" -version = "1.15.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ + "autocfg", "bytes", "libc", "memchr", "mio", - "once_cell", "pin-project-lite", - "signal-hook-registry", + "socket2", "tokio-macros", - "winapi", + "tracing", + "windows-sys", ] [[package]] @@ -616,6 +853,71 @@ dependencies = [ "syn", ] +[[package]] +name = "toml_datetime" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" + +[[package]] +name = "toml_edit" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" +dependencies = [ + "indexmap", + "nom8", + "toml_datetime", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] + [[package]] name = "unicode-ident" version = "1.0.6" @@ -727,3 +1029,93 @@ name = "windows_x86_64_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "zbus" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23eaeb1859a3cd5c5f780b101dfe626bf250a5f34873c3c0226d6d9f7a4d107c" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-recursion", + "async-task", + "async-trait", + "byteorder", + "derivative", + "dirs", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "lazy_static", + "nix", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tokio", + "tracing", + "uds_windows", + "winapi", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83c1c6d669caa4773ebe8cb2ebea2a8d0c6ea27fc6c5c8916c7308cbf1db3b1" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "zbus_names" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f34f314916bd89bdb9934154627fab152f4f28acdda03e7c4c68181b214fe7e3" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zvariant" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576cc41e65c7f283e5460f5818073e68fb1f1631502b969ef228c2e03c862efb" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd4aafc0dee96ae7242a24249ce9babf21e1562822f03df650d4e68c20e41ed" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] diff --git a/home/home-daemon/Cargo.toml b/home/home-daemon/Cargo.toml index e5ec1fe..0b1bc18 100644 --- a/home/home-daemon/Cargo.toml +++ b/home/home-daemon/Cargo.toml @@ -6,11 +6,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dbus-async = "2" -dbus-message-parser = "4" +zbus = { version = "3", features = ["tokio"] } futures-util = "0.3" swayipc-async = "2" [dependencies.tokio] version = "1" -features = ["rt"] +features = ["rt", "macros"] diff --git a/home/home-daemon/src/main.rs b/home/home-daemon/src/main.rs index 168410b..9fbf5e4 100644 --- a/home/home-daemon/src/main.rs +++ b/home/home-daemon/src/main.rs @@ -1,24 +1,16 @@ -use dbus_async::DBus; -use dbus_message_parser::{message::Message, value::Value}; use futures_util::stream::StreamExt; -use std::{collections::HashSet, sync::Arc}; +use std::collections::HashSet; use swayipc_async::{Connection, Event, EventType, WindowChange}; #[tokio::main(flavor = "current_thread")] async fn main() { - let (sys_dbus, _server_handle) = DBus::system(false, false) - .await - .expect("failed to get the DBus object"); - let (ses_dbus, _server_handle) = DBus::session(false, false) - .await - .expect("failed to get the DBus object"); - let sys_dbus = Arc::new(sys_dbus); - let _ses_dbus = Arc::new(ses_dbus); + let sys_dbus = Box::leak(Box::new(zbus::Connection::system().await.unwrap())); + let _ses_dbus = Box::leak(Box::new(zbus::Connection::session().await.unwrap())); let mut handlers = Vec::>::new(); for args in std::env::args().skip(1) { handlers.push(match args.as_str() { - "system76-scheduler" => Box::new(System76::new(sys_dbus.clone())), + "system76-scheduler" => Box::new(System76::new(sys_dbus).await), _ => panic!("handler not supported"), }) } @@ -31,20 +23,34 @@ async fn main() { handler.register(&mut subs); } let subs = subs.into_iter().collect::>(); + loop { + drop(start(&subs, &mut handlers).await); + tokio::time::sleep(std::time::Duration::from_secs(10)).await; + } +} +async fn start(subs: &[EventType], handlers: &mut [Box]) -> Result<(), swayipc_async::Error> { let mut events = Connection::new() - .await - .unwrap() + .await? .subscribe(&subs) - .await - .unwrap(); + .await?; while let Some(event) = events.next().await { - if let Ok(event) = event { - for handler in &mut handlers { - handler.handle(&event); + match event { + Ok(event) => { + for handler in &mut *handlers { + handler.handle(&event); + } + } + Err(err) => match err { + swayipc_async::Error::Io(_) + | swayipc_async::Error::InvalidMagic(_) + | swayipc_async::Error::SubscriptionFailed(_) + => return Err(err), + _ => {} } } } + Ok(()) } trait SwayIpcHandler { @@ -52,24 +58,28 @@ trait SwayIpcHandler { fn handle(&mut self, event: &Event); } -struct System76 { - dbus: Arc, - msg: Message, +#[zbus::dbus_proxy( + interface = "com.system76.Scheduler", + default_service = "com.system76.Scheduler", + default_path = "/com/system76/Scheduler" +)] +pub trait System76Scheduler { + /// This process will have its process group prioritized over background processes + fn set_foreground_process(&mut self, pid: u32) -> zbus::fdo::Result<()>; } -impl System76 { - pub fn new(dbus: Arc) -> Self { - let msg = Message::method_call( - "com.system76.Scheduler".try_into().unwrap(), - "/com/system76/Scheduler".try_into().unwrap(), - "com.system76.Scheduler".try_into().unwrap(), - "SetForegroundProcess".try_into().unwrap(), - ); - Self { dbus, msg } +struct System76<'a> { + proxy: System76SchedulerProxy<'a>, +} + +impl<'a> System76<'a> { + pub async fn new(dbus: &'a zbus::Connection) -> System76<'a> { + let proxy = System76SchedulerProxy::new(dbus).await.unwrap(); + Self { proxy } } } -impl SwayIpcHandler for System76 { +impl SwayIpcHandler for System76<'static> { fn register(&mut self, subs: &mut HashSet) { subs.insert(EventType::Window); } @@ -79,11 +89,9 @@ impl SwayIpcHandler for System76 { return; } if let Some(pid) = window.container.pid.and_then(|x| u32::try_from(x).ok()) { - let dbus = self.dbus.clone(); - let mut msg = self.msg.clone(); - msg.add_value(Value::Uint32(pid)); + let mut proxy = self.proxy.clone(); tokio::spawn(async move { - drop(dbus.call(msg).await); + drop(proxy.set_foreground_process(pid).await); }); } } diff --git a/home/hosts/nixmsi.nix b/home/hosts/nixmsi.nix index e50a767..eae580d 100644 --- a/home/hosts/nixmsi.nix +++ b/home/hosts/nixmsi.nix @@ -34,7 +34,7 @@ bottles gimp krita blender tdesktop - rustc rustfmt cargo + clang rustc rustfmt cargo clippy (import ../common/home-daemon.nix { inherit lib pkgs; }) # waiting until the PR gets merged (looking-glass-client.overrideAttrs (old: { diff --git a/home/overlays.nix b/home/overlays.nix index 18d7e66..68a482c 100644 --- a/home/overlays.nix +++ b/home/overlays.nix @@ -1 +1,2 @@ -[ (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz")) ] +# [ (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz")) ] +[ (import ) ] diff --git a/system/flake.nix b/system/flake.nix index 809d397..14a2a17 100644 --- a/system/flake.nix +++ b/system/flake.nix @@ -5,9 +5,15 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; utils.url = "github:gytis-ivaskevicius/flake-utils-plus"; nixos-hardware.url = "github:NixOS/nixos-hardware"; + impermanence.url = "github:nix-community/impermanence"; + # simply make rust-overlay available for the whole system + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs@{ self, nixpkgs, utils, nixos-hardware }: + outputs = inputs@{ self, nixpkgs, utils, nixos-hardware, rust-overlay, impermanence }: let hw = nixos-hardware.nixosModules; # IRL-related stuff I'd rather not put into git @@ -31,6 +37,7 @@ system = "x86_64-linux"; modules = [ ./hosts/nixmsi.nix + impermanence.nixosModule hw.common-pc-ssd # enables fstrim hw.common-cpu-amd # microcode hw.common-cpu-amd-pstate # amd-pstate diff --git a/system/hosts/nixmsi.nix b/system/hosts/nixmsi.nix index 34b0b9c..dcc1945 100644 --- a/system/hosts/nixmsi.nix +++ b/system/hosts/nixmsi.nix @@ -58,6 +58,14 @@ in { steam-hardware.enable = true; video.hidpi.enable = true; enableRedistributableFirmware = true; + opengl.driSupport32Bit = true; + }; + + services.tlp.settings = { + USB_DENYLIST = "0bda:8156"; + USB_EXCLUDE_PHONE = 1; + START_CHARGE_THRESH_BAT0 = 75; + STOP_CHARGE_THRESH_BAT0 = 80; }; # see common/vfio.nix @@ -72,21 +80,64 @@ in { # max compression! my cpu is pretty good anyway compress = "compress=zstd:15"; discard = "discard=async"; + neededForBoot = true; in { - "/" = { inherit device fsType; + # mount root on tmpfs + "/" = { device = "none"; fsType = "tmpfs"; inherit neededForBoot; + options = [ "defaults" "size=2G" "mode=755" ]; }; + "/persist" = + { inherit device fsType neededForBoot; options = [ discard compress "subvol=@" ]; }; - "/nix" = { inherit device fsType; + "/nix" = { inherit device fsType neededForBoot; options = [ discard compress "subvol=@nix" "noatime" ]; }; - "/swap" = { inherit device fsType; + "/swap" = { inherit device fsType neededForBoot; options = [ discard "subvol=@swap" "noatime" ]; }; "/home" = { inherit device fsType; options = [ discard compress "subvol=@home" ]; }; "/.snapshots" = { inherit device fsType; options = [ discard compress "subvol=@snapshots" ]; }; + "/boot" = { inherit device fsType neededForBoot; + options = [ discard compress "subvol=@boot" ]; }; "/boot/efi" = - { device = efiPart; - fsType = "vfat"; }; + { device = efiPart; fsType = "vfat"; inherit neededForBoot; }; + }; + + environment.persistence."/persist" = { + hideMounts = true; + directories = [ + # nixos files + "/etc/nixos" + "/var/lib/nixos" + + # mullvad vpn + "/etc/mullvad-vpn" + "/var/cache/mullvad-vpn" + + # as weird as it sounds, I won't use tmpfs for /tmp in case I'll have to put files over 2GB there + "/tmp" + + # qemu/libvirt + "/var/cache/libvirt" + "/var/lib/libvirt" + "/var/lib/swtpm-localca" + + # stored network info + "/var/lib/iwd" + "/var/db/dhcpcd" + + # persist this since everything here is cleaned up by systemd-tmpfiles over time anyway + # ...or so I'd like to believe + "/var/lib/systemd" + + "/var/db/sudo/lectured" + "/var/log" + ]; + files = [ + # hardware-related + "/etc/adjtime" + "/etc/machine-id" + ]; }; swapDevices = [ { device = "/swap/swapfile"; } ]; @@ -131,18 +182,33 @@ in { pulse.enable = true; jack.enable = true; }; + # zsh + environment.pathsToLink = [ "/share/zsh" ]; + + programs.fuse.userAllowOther = true; xdg.portal = { enable = true; extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ]; }; + users.mutableUsers = false; users.users.user = { isNormalUser = true; extraGroups = [ "networkmanager" "wheel" ]; + # initialHashedPassword = ...set in private.nix; }; + # users.users.root.initialHashedPassword = ...set in private.nix; nix = { - settings.allowed-users = [ "user" ]; + settings = { + allowed-users = [ "user" ]; + auto-optimise-store = true; + }; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; package = pkgs.nixFlakes; extraOptions = '' experimental-features = nix-command flakes @@ -151,10 +217,8 @@ in { ### RANDOM PATCHES ### - programs.fuse.userAllowOther = true; - - # zsh - environment.pathsToLink = [ "/share/zsh" ]; + # why is this not part of base NixOS? + systemd.tmpfiles.rules = [ "d /var/lib/systemd/pstore 0755 root root 14d" ]; # dedupe @@ -162,7 +226,7 @@ in { filesystems.cryptroot = { spec = "UUID=${cryptrootUuid}"; hashTableSizeMB = 128; - # extraOptions = [ ]; + extraOptions = [ "--loadavg-target" "8.0" ]; }; };