diff --git a/flake.lock b/flake.lock index fee1f90..ae36e2d 100644 --- a/flake.lock +++ b/flake.lock @@ -3,9 +3,15 @@ "agenix": { "inputs": { "darwin": "darwin", - "home-manager": "home-manager", - "nixpkgs": "nixpkgs", - "systems": "systems" + "home-manager": [ + "home-manager" + ], + "nixpkgs": [ + "nixpkgs" + ], + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1723293904, @@ -130,22 +136,6 @@ "type": "github" } }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -164,24 +154,6 @@ "type": "github" } }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib_2" - }, - "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "flake-utils": { "locked": { "lastModified": 1629284811, @@ -199,14 +171,16 @@ }, "flake-utils_2": { "inputs": { - "systems": "systems_2" + "systems": [ + "systems" + ] }, "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -217,7 +191,7 @@ }, "flake-utils_3": { "inputs": { - "systems": "systems_4" + "systems": "systems_2" }, "locked": { "lastModified": 1731533236, @@ -233,60 +207,6 @@ "type": "github" } }, - "flake-utils_4": { - "inputs": { - "systems": "systems_7" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "ghostty": { - "inputs": { - "flake-compat": "flake-compat", - "nixpkgs-stable": "nixpkgs-stable", - "nixpkgs-unstable": "nixpkgs-unstable", - "zig": "zig" - }, - "locked": { - "lastModified": 1736115260, - "narHash": "sha256-9VrUz+JNq90Z1QOBojSxKDdUHr0I5XsK/OHjZSyvXwU=", - "owner": "ghostty-org", - "repo": "ghostty", - "rev": "2485482aecc02c6c377a30c36a34c647cc521ddf", - "type": "github" - }, - "original": { - "owner": "ghostty-org", - "repo": "ghostty", - "type": "github" - } - }, - "ghostty-hm": { - "locked": { - "lastModified": 1702368251, - "narHash": "sha256-hafrDmzGplzm+vdIo+LkOjRfA4qRcy5JmpGGksnht5c=", - "owner": "clo4", - "repo": "ghostty-hm-module", - "rev": "887e13a6e7acf5ffaab0119d96e476d84db90904", - "type": "github" - }, - "original": { - "owner": "clo4", - "repo": "ghostty-hm-module", - "type": "github" - } - }, "gitignore": { "inputs": { "nixpkgs": [ @@ -310,27 +230,6 @@ } }, "home-manager": { - "inputs": { - "nixpkgs": [ - "agenix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1703113217, - "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "home-manager_2": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -509,9 +408,11 @@ "hyprlang": "hyprlang", "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks", - "systems": "systems_3", + "systems": [ + "systems" + ], "xdph": "xdph" }, "locked": { @@ -917,11 +818,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1703013332, - "narHash": "sha256-+tFNwMvlXLbJZXiMHqYq77z/RfmpfpiI3yjL6o/Zo9M=", + "lastModified": 1735291276, + "narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "54aac082a4d9bb5bbc5c4e899603abfb76a3f6d6", + "rev": "634fd46801442d760e09493a794c4f15db2d0cbb", "type": "github" }, "original": { @@ -943,35 +844,7 @@ "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" } }, - "nixpkgs-lib_2": { - "locked": { - "lastModified": 1733096140, - "narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" - } - }, "nixpkgs-stable": { - "locked": { - "lastModified": 1733423277, - "narHash": "sha256-TxabjxEgkNbCGFRHgM/b9yZWlBj60gUOUnRT/wbVQR8=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "e36963a147267afc055f7cf65225958633e536bf", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "release-24.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-stable_2": { "locked": { "lastModified": 1730741070, "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", @@ -987,39 +860,7 @@ "type": "github" } }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1733229606, - "narHash": "sha256-FLYY5M0rpa5C2QAE3CKLYAM6TwbKicdRK6qNrSHlNrE=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "566e53c2ad750c84f6d31f9ccb9d00f823165550", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { - "locked": { - "lastModified": 1735291276, - "narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "634fd46801442d760e09493a794c4f15db2d0cbb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1735834308, "narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=", @@ -1035,7 +876,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { "lastModified": 1656753965, "narHash": "sha256-BCrB3l0qpJokOnIVc3g2lHiGhnjUi0MoXiw6t1o8H1E=", @@ -1051,22 +892,6 @@ "type": "github" } }, - "nixpkgs_5": { - "locked": { - "lastModified": 1734435836, - "narHash": "sha256-kMBQ5PRiFLagltK0sH+08aiNt3zGERC2297iB6vrvlU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4989a246d7a390a859852baddb1013f825435cee", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nmd": { "flake": false, "locked": { @@ -1085,8 +910,12 @@ }, "nvf": { "inputs": { - "flake-parts": "flake-parts_2", - "flake-utils": "flake-utils_3", + "flake-parts": [ + "flake-parts" + ], + "flake-utils": [ + "flake-utils" + ], "mnw": "mnw", "nil": "nil", "nixpkgs": [ @@ -1213,7 +1042,9 @@ "plugin-vim-startify": "plugin-vim-startify", "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", - "systems": "systems_5" + "systems": [ + "systems" + ] }, "locked": { "lastModified": 1736124878, @@ -1229,26 +1060,6 @@ "type": "github" } }, - "ooks-scripts": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1718496814, - "narHash": "sha256-q9OaUOdA0+bmlJ8nK11aiEjHxlJ6a9sqAdvG8CwsH8M=", - "ref": "refs/heads/main", - "rev": "53ef8a8bc986f6a3a80aa0336eb6ea8ccd6e3ae7", - "revCount": 39, - "type": "git", - "url": "ssh://git@github.com/ooks-io/scripts" - }, - "original": { - "type": "git", - "url": "ssh://git@github.com/ooks-io/scripts" - } - }, "plugin-alpha-nvim": { "flake": false, "locked": { @@ -3157,13 +2968,13 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "gitignore": "gitignore", "nixpkgs": [ "hyprland", "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs-stable": "nixpkgs-stable" }, "locked": { "lastModified": 1734797603, @@ -3182,7 +2993,7 @@ "rnix-lsp": { "inputs": { "naersk": "naersk", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_3", "utils": "utils" }, "locked": { @@ -3204,9 +3015,8 @@ "agenix": "agenix", "firefox-addons": "firefox-addons", "flake-parts": "flake-parts", - "ghostty": "ghostty", - "ghostty-hm": "ghostty-hm", - "home-manager": "home-manager_2", + "flake-utils": "flake-utils_2", + "home-manager": "home-manager", "hypridle": "hypridle", "hyprland": "hyprland", "hyprland-contrib": "hyprland-contrib", @@ -3214,12 +3024,10 @@ "hyprlock": "hyprlock", "hyprpaper": "hyprpaper", "nix-index-db": "nix-index-db", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "nvf": "nvf", - "ooks-scripts": "ooks-scripts", "secrets": "secrets", - "systems": "systems_6", - "vpn-confinement": "vpn-confinement", + "systems": "systems", "zjstatus": "zjstatus" } }, @@ -3294,16 +3102,16 @@ }, "systems": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default", + "repo": "default-linux", "type": "github" } }, @@ -3322,81 +3130,6 @@ "type": "github" } }, - "systems_3": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_4": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_6": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_7": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "utils": { "locked": { "lastModified": 1656928814, @@ -3412,21 +3145,6 @@ "type": "github" } }, - "vpn-confinement": { - "locked": { - "lastModified": 1731209328, - "narHash": "sha256-b3jggBHZh20jUfBxoaIvew23czsw82zBc0aKxtkF3g8=", - "owner": "Maroka-chan", - "repo": "VPN-Confinement", - "rev": "74e6fd47804b5ca69187200efbb14cf1ecb9ea07", - "type": "github" - }, - "original": { - "owner": "Maroka-chan", - "repo": "VPN-Confinement", - "type": "github" - } - }, "xdph": { "inputs": { "hyprland-protocols": [ @@ -3468,36 +3186,13 @@ "type": "github" } }, - "zig": { - "inputs": { - "flake-compat": [ - "ghostty" - ], - "flake-utils": "flake-utils_2", - "nixpkgs": [ - "ghostty", - "nixpkgs-stable" - ] - }, - "locked": { - "lastModified": 1717848532, - "narHash": "sha256-d+xIUvSTreHl8pAmU1fnmkfDTGQYCn2Rb/zOwByxS2M=", - "owner": "mitchellh", - "repo": "zig-overlay", - "rev": "02fc5cc555fc14fda40c42d7c3250efa43812b43", - "type": "github" - }, - "original": { - "owner": "mitchellh", - "repo": "zig-overlay", - "type": "github" - } - }, "zjstatus": { "inputs": { "crane": "crane", - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_5", + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "nixpkgs" + ], "rust-overlay": "rust-overlay_2" }, "locked": { diff --git a/flake.nix b/flake.nix index 47c66b1..313e272 100644 --- a/flake.nix +++ b/flake.nix @@ -9,27 +9,48 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-parts.url = "github:hercules-ci/flake-parts"; + + systems.url = "github:nix-systems/default-linux"; + + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.systems.follows = "systems"; + }; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - agenix.url = "github:ryantm/agenix"; + + agenix = { + url = "github:ryantm/agenix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + systems.follows = "systems"; + home-manager.follows = "home-manager"; + }; + }; + nix-index-db = { url = "github:nix-community/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; }; - zjstatus.url = "github:dj95/zjstatus"; - systems.url = "github:nix-systems/default-linux"; + + zjstatus = { + url = "github:dj95/zjstatus"; + inputs.nixpkgs.follows = "nixpkgs"; + }; firefox-addons = { url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; inputs.nixpkgs.follows = "nixpkgs"; }; - ooks-scripts = { - url = "git+ssh://git@github.com/ooks-io/scripts"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + secrets = { url = "git+ssh://git@github.com/ooks-io/kunzen"; inputs = { @@ -41,17 +62,20 @@ nvf = { url = "github:notashelf/nvf"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + systems.follows = "systems"; + + nixpkgs.follows = "nixpkgs"; + flake-parts.follows = "flake-parts"; + flake-utils.follows = "flake-utils"; + }; }; - # confine vpns to specific systemd services - vpn-confinement.url = "github:Maroka-chan/VPN-Confinement"; - - ghostty-hm.url = "github:clo4/ghostty-hm-module"; - ghostty.url = "github:ghostty-org/ghostty"; - # hypr* ecosystem - hyprland.url = "github:hyprwm/hyprland"; + hyprland = { + url = "github:hyprwm/hyprland"; + inputs.systems.follows = "systems"; + }; hypridle = { url = "github:hyprwm/hypridle"; diff --git a/modules/home/workstation/tools/ookpower.nix b/modules/home/workstation/tools/ookpower.nix index 23903ab..b8d4850 100644 --- a/modules/home/workstation/tools/ookpower.nix +++ b/modules/home/workstation/tools/ookpower.nix @@ -1,14 +1,177 @@ { lib, config, - inputs', + pkgs, ... }: let inherit (lib) mkIf; inherit (config.programs) rofi; + + powermenu = pkgs.writeShellApplication { + name = "powermenu"; + runtimeInputs = [pkgs.rofi-wayland]; + text = + # bash + '' + + pid_file="/tmp/my_countdown.pid" + + DRY= + COUNTDOWN= + + while [ $# -gt 0 ]; do + key="$1" + case $key in + -c | --countdown) + COUNTDOWN=true + shift + ;; + -d | --dry) + DRY=true + shift + ;; + *) + break + ;; + esac + done + + notify() { + notify-send -u critical -a system-notify -t 1000 -h string:x-canonical-private-synchronous:anything "$@" + } + + # Used for development, instead of running command, notifies if command was successful and exits. + dry_success() { + if [ "$DRY" == "true" ]; then + TITLE="Action Successful:" + notify "$TITLE" "$1" + exit 0 + fi + } + + cancel() { + if [ -f "$pid_file" ]; then + # Read the process ID from the file and kill the process + kill "$(cat "$pid_file")" &>/dev/null + notify-send "Action canceled" + rm -f "$pid_file" + else + echo "No countdown to cancel." + fi + } + + countdown() { + if [ "$COUNTDOWN" == "true" ]; then + msg="''${1:-doing something}" + echo $$ >"$pid_file" + for i in {5..1}; do + notify-send "$msg in $i" -h string:x-canonical-private-synchronous:anything + sleep 1 + done + echo "Countdown done" + rm -f "$pid_file" + fi + } + + action_logout() { + countdown "Logging out" + dry_success "Logged out" + PROCESS="Hyprland|\.Hyprland-wrapp" + if pgrep -x $PROCESS >/dev/null; then + hyprctl dispatch exit 0 + sleep 2 + if pgrep -x $PROCESS; then + pkill -9 $PROCESS + fi + fi + + } + + action_poweroff() { + countdown "Shutting down" + dry_success "Shutdown" + poweroff + } + + action_lock() { + dry_success "Screen Locked" + hyprlock + } + + action_reboot() { + countdown "Rebooting" + dry_success "Reboot" + reboot + } + + action_suspend() { + countdown "Suspending" + dry_success "Suspend" + suspend + } + + action_dmenu() { + selection=$(echo -e " Reboot\n Lock\n󰍃 Logout\n󰐥 Shutdown\n󰒲 Suspend" | rofi -dmenu -i) + + case "$selection" in + "󰐥 Shutdown") action_poweroff ;; + " Reboot") action_reboot ;; + " Lock") action_lock ;; + "󰍃 Logout") action_logout ;; + "󰒲 Suspend") action_suspend ;; + *) + echo "ERROR" "Invalid option" + exit 1 + ;; + esac + } + # Check if the script is already running and decide to cancel or start countdown + if [ -f "$pid_file" ]; then + cancel + else + ACTION=''${1:-usage} + case "$ACTION" in + logout) + action_logout + ;; + poweroff) + action_poweroff + ;; + reboot) + action_reboot + ;; + lock) + action_lock + ;; + usage) + echo " Usage: powermenu [OPTION]... [ACTION usage|dmenu|logout|poweroff|reboot|lock]" + echo "" + echo "Options:" + echo " -c, --countdown Enable 5 seconds countdown before action is performed" + echo " -d, --dry Print instead of perform action debug/development" + echo "" + echo "Actions:" + echo " usage Print help information" + echo " dmenu Open menu with rofi for selecting action" + echo " logout Kills current active Hyprland session" + echo " poweroff Shut down current host" + echo " reboot Restart current host" + echo " lock Locks current session with hyprlock" + echo "" + ;; + dmenu) + action_dmenu + ;; + *) + echo "Invalid action: $ACTION (expecting: usage|logout|poweroff|reboot|lock)" + ;; + esac + fi + ''; + }; in { config = mkIf rofi.enable { - home.packages = [inputs'.ooks-scripts.packages.powermenu]; + home.packages = [powermenu]; ooknet.binds.powerMenu = "powermenu -c dmenu"; }; }