diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..30a66d0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + + + + + + { + "name": "Python Debugger: Current File with Arguments", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "args": "${command:pickArgs}" + } + ] +} \ No newline at end of file diff --git a/configuration.nix b/configuration.nix index dab72b2..1532cab 100644 --- a/configuration.nix +++ b/configuration.nix @@ -10,6 +10,7 @@ in ./system-modules/sound.nix ./system-modules/grub.nix ./system-modules/dm.nix + ./system-modules/networking.nix ./system-modules/hsmw.nix ./system-modules/docker.nix @@ -18,11 +19,6 @@ in ./system-modules/ollama.nix ]; - networking.hostName = "NxXPS"; - - networking.networkmanager = { - enable = true; - }; @@ -84,6 +80,7 @@ in dmidecode ]; + fonts.packages = with pkgs; [ noto-fonts noto-fonts-cjk diff --git a/flake.lock b/flake.lock index 90fa6c7..65d54a9 100644 --- a/flake.lock +++ b/flake.lock @@ -13,11 +13,11 @@ ] }, "locked": { - "lastModified": 1712850504, - "narHash": "sha256-s1cUVFgoukNsAfU7bpLP3G0qL0Q2un/AimUxnQ+u6ig=", + "lastModified": 1713240951, + "narHash": "sha256-Nvbn1baUNN7AQOA1hHunUHuFziF0dErqaTlfxr9NNwo=", "owner": "KZDKM", "repo": "Hyprspace", - "rev": "18e4b1d6a35acbcea2cef05a4a8eece83f1da5ae", + "rev": "954eda50aca5ef986c557f3b515c4321fd3c7fd8", "type": "github" }, "original": { @@ -63,11 +63,11 @@ ] }, "locked": { - "lastModified": 1712434681, - "narHash": "sha256-qwmR2p1oc48Bj7gUDvb1oGL19Rjs2PmEmk4ChV01A5o=", + "lastModified": 1713214463, + "narHash": "sha256-zAOOjqHAbccCRgJSuvTCA0FNLqKswN63LgVo43R7pxw=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "818d8c4b69e0997483d60b75f701fe14b561a7a3", + "rev": "0a53b9957f0b17f1a0036b25198f569969ad43a0", "type": "github" }, "original": { @@ -87,11 +87,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1712797985, - "narHash": "sha256-2WS5zErQC7DuGUoVIiWUqQPXsIpdYBqFJip5XSpCVrU=", + "lastModified": 1713283263, + "narHash": "sha256-Urb/njWiHYUudXpmK8EKl9Z58esTIG0PxXw5LuM2r5g=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "ac0f3411c18497a39498b756b711e092512de9e0", + "rev": "fe7b748eb668136dd0558b7c8279bfcd7ab4d759", "type": "github" }, "original": { @@ -112,11 +112,11 @@ ] }, "locked": { - "lastModified": 1712420644, - "narHash": "sha256-h2X8qhN5RKYQXzT1kxKgUz1u1QthqOrP9xk800mTM6E=", + "lastModified": 1713283897, + "narHash": "sha256-/0OPK/bDr8/Lf7r8kzDD/yP1kySbJ8gPmV3CdUbVTFM=", "owner": "hyprwm", "repo": "hyprland-plugins", - "rev": "5ec0140d4aeca42b8a33e7f335f979e376d1b549", + "rev": "00d147d7f6ad2ecfbf75efe4a8402723c72edd98", "type": "github" }, "original": { @@ -189,11 +189,11 @@ ] }, "locked": { - "lastModified": 1711671891, - "narHash": "sha256-C/Wwsy/RLxHP1axFFl+AnwJRWfd8gxDKKoa8nt8Qk3c=", + "lastModified": 1713121246, + "narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "c1402612146ba06606ebf64963a02bc1efe11e74", + "rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", "type": "github" }, "original": { @@ -204,11 +204,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712439257, - "narHash": "sha256-aSpiNepFOMk9932HOax0XwNxbA38GOUVOiXfUVPOrck=", + "lastModified": 1712963716, + "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ff0dbd94265ac470dda06a657d5fe49de93b4599", + "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", "type": "github" }, "original": { @@ -220,11 +220,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1712608508, - "narHash": "sha256-vMZ5603yU0wxgyQeHJryOI+O61yrX2AHwY6LOFyV1gM=", + "lastModified": 1712963716, + "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4cba8b53da471aea2ab2b0c1f30a81e7c451f4b6", + "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", "type": "github" }, "original": { @@ -235,11 +235,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1712588820, - "narHash": "sha256-y31s5idk3jMJMAVE4Ud9AdI7HT3CgTAeMTJ0StqKN7Y=", + "lastModified": 1713145326, + "narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d272ca50d1f7424fbfcd1e6f1c9e01d92f6da167", + "rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e", "type": "github" }, "original": { @@ -276,20 +276,18 @@ "wlroots": { "flake": false, "locked": { - "host": "gitlab.freedesktop.org", - "lastModified": 1709983277, - "narHash": "sha256-wXWIJLd4F2JZeMaihWVDW/yYXCLEC8OpeNJZg9a9ly8=", - "owner": "wlroots", - "repo": "wlroots", - "rev": "50eae512d9cecbf0b3b1898bb1f0b40fa05fe19b", - "type": "gitlab" + "lastModified": 1713124002, + "narHash": "sha256-vPeZCY+sdiGsz4fl3AVVujfyZyQBz6+vZdkUE4hQ+HI=", + "owner": "hyprwm", + "repo": "wlroots-hyprland", + "rev": "611a4f24cd2384378f6e500253983107c6656c64", + "type": "github" }, "original": { - "host": "gitlab.freedesktop.org", - "owner": "wlroots", - "repo": "wlroots", - "rev": "50eae512d9cecbf0b3b1898bb1f0b40fa05fe19b", - "type": "gitlab" + "owner": "hyprwm", + "repo": "wlroots-hyprland", + "rev": "611a4f24cd2384378f6e500253983107c6656c64", + "type": "github" } }, "xdph": { @@ -312,11 +310,11 @@ ] }, "locked": { - "lastModified": 1709299639, - "narHash": "sha256-jYqJM5khksLIbqSxCLUUcqEgI+O2LdlSlcMEBs39CAU=", + "lastModified": 1713214484, + "narHash": "sha256-h1bSIsDuPk1FGgvTuSHJyiU2Glu7oAyoPMJutKZmLQ8=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "2d2fb547178ec025da643db57d40a971507b82fe", + "rev": "bb44921534a9cee9635304fdb876c1b3ec3a8f61", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0ef5ed8..458f3ca 100644 --- a/flake.nix +++ b/flake.nix @@ -17,30 +17,22 @@ url = "github:hyprwm/hyprland-plugins"; inputs.hyprland.follows = "hyprland"; }; - - # hyprfocus = { - # url = "github:VortexCoyote/hyprfocus"; - # inputs.hyprland.follows = "hyprland"; - # }; - Hyprspace = { url = "github:KZDKM/Hyprspace"; inputs.hyprland.follows = "hyprland"; }; - # hycov = { - # url = "github:DreamMaoMao/hycov"; - # inputs.hyprland.follows = "hyprland"; - # }; }; outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }@inputs: - # outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, hyprland, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; + + overlays = [ inputs.nix-rice.overlays.default ]; + user = "nx2"; nvidia = rec { @@ -74,34 +66,39 @@ }; secrets = import ./secrets/passwords-and-certificates.nix; - - rice = { - transparency = "0.9"; + + rice = rec { + lib = import ./nxlib/ricelib.nix { lib = nixpkgs.lib; }; + transparency = 0.9; + rounding = 5; color = rec { - background = "000000"; # #000000 - foreground = "dddddd"; # #dddddd - black = "282B35"; # #282B35 - bright-black = "686A71"; # #686A71 - blue = "9d00ff"; # #9d00ff - bright-blue = "c76eff"; # #c76eff - cyan = "00ddff"; # #00ddff - bright-cyan = "33f9ff"; # #33f9ff - green = "0048ff"; # #0048ff - bright-green = "1166ff"; # #1166ff - magenta = "B21889"; # #B21889 - bright-magenta = "ff75f6"; # #ff75f6 - red = "ff0044"; # #ff0044 - bright-red = "ff4576"; # #ff4576 - white = "939599"; # #939599 - bright-white = "ffffff"; # #ffffff - yellow = "ff4000"; # #ff4000 - bright-yellow = "ff8454"; # #ff8454 + background = "#000000"; + foreground = "#dddddd"; + black = "#282B35"; + bright-black = "#686A71"; + blue = "#9d00ff"; + bright-blue = "#c76eff"; + cyan = "#00ddff"; + bright-cyan = "#33f9ff"; + green = "#0048ff"; + bright-green = "#1166ff"; + magenta = "#B21889"; + bright-magenta = "#ff75f6"; + red = "#ff0044"; + bright-red = "#ff4576"; + white = "#939599"; + bright-white = "#ffffff"; + yellow = "#ff4000"; + bright-yellow = "#ff8454"; border = red; }; font = { code = { - name = "CascadiaCove-NF"; - package = (pkgs.nerdfonts.override { fonts = [ "CascadiaCode" ]; }); + name = "JetBrainsMono-NF"; + name2 = "JetBrainsMono Nerd Font"; + package = (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }); + # name = "CascadiaCove-NF"; + # package = (pkgs.nerdfonts.override { fonts = [ "CascadiaCode" ]; }); }; base = { name = "Atkinson Hyperlegible"; @@ -125,12 +122,12 @@ }; homeConfigurations = { - NxXPS = let host = "NxXPS"; in home-manager.lib.homeManagerConfiguration { + "${user}@NxXPS" = let host = "NxXPS"; in home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ ./home.nix ]; extraSpecialArgs = { inherit inputs system user host allowed secrets pkgs-unstable rice nvidia; }; }; - NxNORTH = let host = "NxNORTH"; in home-manager.lib.homeManagerConfiguration { + "${user}@NxNORTH" = let host = "NxNORTH"; in home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ ./home.nix ]; extraSpecialArgs = { inherit inputs system user host allowed secrets pkgs-unstable rice nvidia; }; diff --git a/home-modules/bitwarden.nix b/home-modules/bitwarden.nix new file mode 100644 index 0000000..51a64df --- /dev/null +++ b/home-modules/bitwarden.nix @@ -0,0 +1,32 @@ +{ config, pkgs, secrets, ... }: +{ + home.packages = with pkgs; [ + bitwarden + bitwarden-cli + ]; + + home.file.".config/Bitwarden CLI/data.json".text = '' + { + "stateVersion": 9, + "global": { + "theme": "system", + "window": {}, + "environmentUrls": { + "base": "https://pw.nx2.site", + "api": null, + "identity": null, + "webVault": null, + "icons": null, + "notifications": null, + "events": null, + "keyConnector": null + }, + "region": "Self-hosted", + "installedVersion": "2023.12.0" + } + } + ''; + + home.sessionVariables.BW_SESSION = secrets.bitwarden.env.bw-session; + +} \ No newline at end of file diff --git a/home-modules/email.nix b/home-modules/email.nix index 9318cc2..bc61f25 100644 --- a/home-modules/email.nix +++ b/home-modules/email.nix @@ -1,17 +1,93 @@ -{ config, pkgs, lib, system, user, allowed, secrets, ... }: - +{ config, pkgs, secrets, ... }: { home.packages = with pkgs; [ thunderbird ]; - - + + programs.thunderbird = { + enable = true; + profiles = { + default = { + isDefault = true; + settings = { + "calendar.alarms.showmissed" = false; + "calendar.alarms.playsound" = false; + "calendar.alarms.show" = false; + }; + }; + }; + }; - # home.file.".config/meli.config" = { + accounts.email.accounts = { + "gamil-online" = { + address = secrets.email.gmail-online.mail; + realName = "Lennart J. Kurzweg"; + flavor = "gmail.com"; + primary = true; + signature = { + text = '' + -- + About Me: https://nx2.site/about-me + Contact: https://nx2.site/contact + GPG: https://nx2.site/gpg + ''; + showSignature = "append"; + }; + thunderbird = { + enable = true; + profiles = [ "default" ]; + }; + }; - # }; + "gamil-business" = { + address = secrets.email.gmail-business.mail; + realName = "Lennart J. Kurzweg"; + flavor = "gmail.com"; + signature = { + text = '' + -- + About Me: https://nx2.site/about-me + Contact: https://nx2.site/contact + GPG: https://nx2.site/gpg + ''; + showSignature = "append"; + }; + thunderbird = { + enable = true; + profiles = [ "default" ]; + }; + }; + + # "hsmw" = { + # address = secrets.email.hsmw.mail; + # realName = "Lennart J. Kurzweg"; + # imap = { + # port = 993; + # host = "mail.hs-mittweida.de"; + # }; + # smtp = { + # port = 465; + # host = "mail.hs-mittweida.de"; + # }; + # signature = { + # text = '' + # -- + # MatNr: ${secrets.email.hsmw.mnr} + # SemGr: ${secrets.email.hsmw.semgr} + # About Me: https://nx2.site/about-me + # Contact: https://nx2.site/contact + # GPG: https://nx2.site/gpg + # ''; + # showSignature = "append"; + # }; + # thunderbird = { + # enable = true; + # profiles = [ "default" ]; + # }; + # }; + }; } diff --git a/home-modules/hyprland/hyprland-autoname-workspaces.nix b/home-modules/hyprland-autoname-workspaces.nix similarity index 90% rename from home-modules/hyprland/hyprland-autoname-workspaces.nix rename to home-modules/hyprland-autoname-workspaces.nix index a597821..395b98b 100644 --- a/home-modules/hyprland/hyprland-autoname-workspaces.nix +++ b/home-modules/hyprland-autoname-workspaces.nix @@ -63,17 +63,6 @@ [initial_class_active] [workspaces_name] - 10 = "ten" - 4 = "four" - 8 = "eight" - 9 = "nine" - 6 = "six" - 1 = "one" - 3 = "three" - 2 = "two" - 0 = "zero" - 7 = "seven" - 5 = "five" [title_in_class] [title_in_class_active] @@ -87,7 +76,6 @@ [exclude] "(?i)fcitx" = ".*" aProgram = "^$" - "ueberzug.*" = "" "" = "^$" "[Ss]team" = "^(Friends List.*)?$" "explorer.exe" = ".*" @@ -97,7 +85,7 @@ dedup = false dedup_inactive_fullscreen = false delim = " " - workspace = "{id}: {clients}" + workspace = "{id}:{clients}" workspace_empty = "{id}" client = "{icon}" client_fullscreen = "{icon}" diff --git a/home-modules/hyprland/hyprland.nix b/home-modules/hyprland.nix similarity index 94% rename from home-modules/hyprland/hyprland.nix rename to home-modules/hyprland.nix index 9449c28..675a386 100644 --- a/home-modules/hyprland/hyprland.nix +++ b/home-modules/hyprland.nix @@ -1,9 +1,9 @@ { config, pkgs, pkgs-unstable, inputs, host, nvidia, rice, lib, ... }: let animation-speed = "2"; - transparency = rice.transparency; + transparency = builtins.toString rice.transparency; gap-size = 10; - rounding = 3; + rounding = rice.rounding; border-width = 3; monitors = { xps = { @@ -50,42 +50,6 @@ in pkgs-unstable.hyprlock pkgs-unstable.hypridle - (pkgs.writeShellScriptBin "waybar_mode" '' - #!/bin/bash - - # Function to print help message - print_help() { - echo "Usage: waybar_mode {set |unset}" - } - if [ $# -lt 1 ]; then - print_help; exit 1; - fi - - case "$1" in - set) - # Check if there is a second argument for the 'set' operation - if [ $# -eq 2 ]; then - echo "$2" > /tmp/waybar-mode - pkill -RTMIN+8 waybar - else - echo "Error: 'set' operation requires exactly one string argument." - print_help - exit 1 - fi - ;; - unset) - echo "" > /tmp/waybar-mode - pkill -RTMIN+8 waybar - ;; - *) - echo "Error: Unknown command '$1'" - print_help - exit 1 - ;; - esac - - exit 0 - '') ]; wayland.windowManager.hyprland = { @@ -179,8 +143,8 @@ in gaps_in = builtins.div gap-size 2; gaps_out = gap-size; border_size = border-width; - "col.active_border" = "rgba(${rice.color.red}ff) rgba(${rice.color.bright-cyan}ff) 45deg"; - "col.inactive_border" = "rgba(${rice.color.black}ff)"; + "col.active_border" = "rgba(${rice.lib.nohash rice.color.red}ff) rgba(${rice.lib.nohash rice.color.blue}ff) 90deg"; + "col.inactive_border" = "rgba(${rice.lib.nohash rice.color.black}ff)"; cursor_inactive_timeout = 10; @@ -195,8 +159,8 @@ in shadow_range = "20"; shadow_offset = "0 0"; shadow_render_power = "4"; - "col.shadow" = "rgba(${rice.color.red}ff)"; - "col.shadow_inactive" = "rgba(${rice.color.black}ff)"; + "col.shadow" = "rgba(${rice.lib.nohash rice.color.red}ff)"; + "col.shadow_inactive" = "rgba(${rice.lib.nohash rice.color.black}ff)"; active_opacity = "1.0"; inactive_opacity = "1.0"; @@ -239,7 +203,6 @@ in workspace_swipe_direction_lock = false; workspace_swipe_direction_lock_threshold = "10"; workspace_swipe_forever = true; - workspace_swipe_numbered = false; workspace_swipe_use_r = false; }; @@ -276,7 +239,7 @@ in windowrulev2 = [ "opacity ${transparency},class:^(com.chatterino.*)$" "opacity ${transparency},class:^(chatterino)$" - "bordercolor rgba(${rice.color.bright-magenta}ff), pinned:1" + "bordercolor rgba(${rice.lib.nohash rice.color.bright-magenta}ff), pinned:1" ]; windowrule = [ @@ -287,8 +250,8 @@ in "opacity ${transparency}, neovide" "opacity ${transparency}, obsidian" "opacity ${transparency}, zathura" - "bordercolor rgba(${rice.color.foreground}ff) rgba(${rice.color.background}b2), Alacritty" - "bordercolor rgba(${rice.color.foreground}ff) rgba(${rice.color.background}b2), Kitty" + "bordercolor rgba(${rice.lib.nohash rice.color.foreground}ff) rgba(${rice.lib.nohash rice.color.background}${rice.lib.float-to-drune rice.transparency}), Alacritty" + "bordercolor rgba(${rice.lib.nohash rice.color.foreground}ff) rgba(${rice.lib.nohash rice.color.background}${rice.lib.float-to-drune rice.transparency}), Kitty" "opacity ${transparency}, discord" "opacity ${transparency}, vesktop" "opacity ${transparency}, Element" @@ -342,16 +305,16 @@ in # "SUPER, F2," "SUPER, F3, toggleopaque" # "SUPER, F4," - "SUPER, F5, exec, /home/nx2/scripts/NxGCalEvent/force-new-lookup.sh" - "SUPER SHIFT, F5, exec, /home/nx2/scripts/NxGCalEvent/force-reauthentication.sh" + "SUPER, F5, exec, nx_gcal_event force-lookup" + "SUPER SHIFT, F5, exec, nx_gcal_event reauthenticate" # "SUPER, F6," "SUPER, F8, exec, /home/nx2/scripts/swww-randomize.sh" # "SUPER, F9, hyprload,reload" # "SUPER, F10, hyprload,update" "SUPER, F11, exec, waybar" "SUPER SHIFT, F11, exec, pkill waybar " - "SUPER, F12, exec, hyprland-autoname-workspaces --migrate-config &" - "SUPER SHIFT, F12, exec, pkill hyprland-autoname-workspaces " + "SUPER, F12, exec, hyprland-autoname-workspaces" + "SUPER SHIFT, F12, exec, pkill -9 hyprland-autoname-workspaces " ########################################################################### ## ROW 1: @@ -815,7 +778,7 @@ in hyprexpo { columns = 5 gap_size = ${builtins.toString gap-size} - bg_col = rgb(${rice.color.background}) + bg_col = rgb(${rice.lib.nohash rice.color.background}) workspace_method = first 10 # [center/first] [workspace] e.g. first 1 or center m+1 enable_gesture = false # laptop touchpad, 4 fingers diff --git a/home-modules/kitty.nix b/home-modules/kitty.nix index 41c544c..d95eefe 100644 --- a/home-modules/kitty.nix +++ b/home-modules/kitty.nix @@ -9,28 +9,31 @@ in programs.kitty = { enable = true; - font = rice.font.code; + font = { + name = rice.font.code.name2; + package = rice.font.code.package; + }; settings = { - background = "#${rice.color.background}"; - foreground = "#${rice.color.foreground}"; - cursor = "#${rice.color.foreground}"; - color0 = "#${rice.color.black}"; - color8 = "#${rice.color.bright-black}"; - color1 = "#${rice.color.red}"; - color9 = "#${rice.color.bright-red}"; - color2 = "#${rice.color.green}"; - color10 = "#${rice.color.bright-green}"; - color3 = "#${rice.color.yellow}"; - color11 = "#${rice.color.bright-yellow}"; - color4 = "#${rice.color.blue}"; - color12 = "#${rice.color.bright-blue}"; - color5 = "#${rice.color.magenta}"; - color13 = "#${rice.color.bright-magenta}"; - color6 = "#${rice.color.cyan}"; - color14 = "#${rice.color.bright-cyan}"; - color7 = "#${rice.color.white}"; - color15 = "#${rice.color.bright-white}"; - background_opacity = rice.transparency; + background = rice.color.background; + foreground = rice.color.foreground; + cursor = rice.color.foreground; + color0 = rice.color.black; + color8 = rice.color.bright-black; + color1 = rice.color.red; + color9 = rice.color.bright-red; + color2 = rice.color.green; + color10 = rice.color.bright-green; + color3 = rice.color.yellow; + color11 = rice.color.bright-yellow; + color4 = rice.color.blue; + color12 = rice.color.bright-blue; + color5 = rice.color.magenta; + color13 = rice.color.bright-magenta; + color6 = rice.color.cyan; + color14 = rice.color.bright-cyan; + color7 = rice.color.white; + color15 = rice.color.bright-white; + background_opacity = builtins.toString rice.transparency; transparency = true; scroll_multiplier = 9; window_padding_width = 5; diff --git a/home-modules/mako.nix b/home-modules/mako.nix index e5d5f3f..af16d73 100644 --- a/home-modules/mako.nix +++ b/home-modules/mako.nix @@ -7,10 +7,10 @@ ]; services.mako = { enable = true; - defaultTimeout = 5; + defaultTimeout = 10000; # in ms backgroundColor = "#${rice.color.background}"; textColor = "#${rice.color.foreground}"; borderColor = "#${rice.color.border}"; - font = "#${rice.font.code.name}"; + font = rice.font.code.name2; }; } \ No newline at end of file diff --git a/home-modules/nx-gcal-event.nix b/home-modules/nx-gcal-event.nix new file mode 100644 index 0000000..6a7effe --- /dev/null +++ b/home-modules/nx-gcal-event.nix @@ -0,0 +1,222 @@ +{ config, pkgs, secrets, ... }: +let in +{ + home = { + file."${config.xdg.dataHome}/nx-gcal-event-credentials.json".text = '' + { + "installed": { + "client_id": "${secrets.nx-gcal-event.client-client-id}", + "project_id": "my-own-cal", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_secret": "${secrets.nx-gcal-event.client-secret}", + "redirect_uris": [ + "http://localhost" + ] + } + } + ''; + + packages = with pkgs; [ + # TODO: make into real package, currently dependencies are in home.nix + # (pkgs.python311.withPackages (python-pkgs: [ + # python-pkgs.google + # ])) + (writeScriptBin "nx_gcal_event" '' + #!${pkgs.python3}/bin/python3 + import datetime + import os + import pickle + import sys + + from google.auth.transport.requests import Request + from google.oauth2.credentials import Credentials + from google_auth_oauthlib.flow import InstalledAppFlow + from googleapiclient.discovery import build + from googleapiclient.errors import HttpError + from html import escape + + + + CREDENTIALS_PATH = f"{os.environ['XDG_DATA_HOME']}/nx-gcal-event-credentials.json" + TOKEN_PATH = f"{os.environ['XDG_CACHE_HOME']}/nx-gcal-event-token.json" + PICKLE_PATH = "/tmp/nx-gcal-event.pickle" + + + def sec_to_nice_string(seconds: int): + (hours, rsec) = divmod(seconds, 3600) + minutes = rsec // 60 + sep = " " + if hours == 0: + s_hours = f"" + sep = "" + elif hours == 1: s_hours = f"{hours} hour" + else: s_hours = f"{hours} hours" + if minutes == 0: + s_minutes = f"" + sep = "" + elif minutes == 1: s_minutes = f"{minutes} minute" + else: s_minutes = f"{minutes} minutes" + if hours + minutes == 0: + s_minutes = "~ No time" + os.remove(PICKLE_PATH) + + return f"{s_hours}{sep}{s_minutes}" + + def get_event_from_api(): + creds = None + SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"] + + if os.path.exists(TOKEN_PATH): + creds = Credentials.from_authorized_user_file(TOKEN_PATH, SCOPES) + + if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow = InstalledAppFlow.from_client_secrets_file(CREDENTIALS_PATH, SCOPES) + creds = flow.run_local_server(port=0) + # Save the credentials for the next run + with open(TOKEN_PATH, "w") as token: + token.write(creds.to_json()) + + try: + service = build("calendar", "v3", credentials=creds) + now = datetime.datetime.utcnow().isoformat() + "Z" # 'Z' indicates UTC time + in_24_h = (datetime.datetime.utcnow() + datetime.timedelta(days=1)).isoformat() + "Z" + calendar_list = service.calendarList().list().execute() + calendars = calendar_list.get("items", []) + + # List events from all calendars + all_events = [] + for calendar in calendars: + calendar_id = calendar["id"] + events_result = service.events().list( + calendarId=calendar_id, + timeMin=now, + timeMax=in_24_h, + singleEvents=True, + orderBy="startTime", + ).execute() + events = events_result.get("items", []) + + all_events.extend(events) + + # Filter out all-day events + all_events = [event for event in all_events if "dateTime" in event["start"]] + + # Find the earliest event + earliest_event = None + for event in all_events: + event_start = event["start"]["dateTime"] + if not earliest_event or event_start < earliest_event["start"]["dateTime"]: + earliest_event = event + + # Now earliest_event contains the event that starts earliest + return earliest_event + + except HttpError as error: + print("An error occurred: %s" % error) + exit(1) + + def dump_dict_to_file(event, now): + if not event: + event = {} + event['nxWriteTime'] = now + with open(PICKLE_PATH, 'wb') as f: + pickle.dump(event, f) + + def load_dict_from_file(now): + with open(PICKLE_PATH, 'rb') as f: + event = pickle.load(f) + # recheck all 15 minutes + if (now - event['nxWriteTime']).seconds > 900: + event = get_event_from_api() + os.remove(PICKLE_PATH) + return event + + def lookup(): + # set now (timezone CEST) + now = datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=2))) + + no_event_string = "~ Zen ~" + + if os.path.exists(PICKLE_PATH): + event = load_dict_from_file(now) + else: + event = get_event_from_api() + if not event: + print(no_event_string) + dump_dict_to_file(event, now) + exit(0) + dump_dict_to_file(event, now) + + try: # when the saved even was empty (there was no event) + end = datetime.datetime.strptime(event["end"]["dateTime"], "%Y-%m-%dT%H:%M:%S%z") + start = datetime.datetime.strptime(event["start"]["dateTime"], "%Y-%m-%dT%H:%M:%S%z") + except: + if (now - event['nxWriteTime']).seconds > 900: + event = get_event_from_api() + os.remove(PICKLE_PATH) + else: + print(no_event_string) + exit(0) + + # set mode, remaining + if start.day != now.day: # event start tomorrow + print(no_event_string) + exit(0) + elif (start - now).days < 0: # today, started alredy + remaining = end - now + mode = " remaining in " + else: # today, not started yet + remaining = start - now + mode = " until the start of " + + name = escape(event['summary']) + + print(f"󱙬 {sec_to_nice_string(remaining.seconds)}{mode}\'{name}\'") + exit(0) + + def print_help(): + print("Usage: nx_gcal_event [lookup|force-lookup|reauthenicate|help]") + + def forece_lookup(): + try: + os.remove(PICKLE_PATH) + os.system('notify-send --app-name="nx_gcal_event" "Saved event deleted!"') + except: + os.system('notify-send --app-name="nx_gcal_event" "No saved event found!"') + finally: + lookup() + + def reauthenicate(): + os.remove(PICKLE_PATH) + os.remove(TOKEN_PATH) + os.system('notify-send --app-name="nx_gcal_event" "Deleted Token"') + lookup() + + def print_help(): + print("Usage: nx_gcal_event [lookup|force-lookup|reauthenicate|help]") + + if __name__ == "__main__": + if len(sys.argv) != 2: + print("Incorrect number of arguments.") + print_help() + else: + arg = sys.argv[1] + if arg == "lookup": + lookup() + elif arg == "force-lookup": + forece_lookup() + elif arg == "reauthenticate": + reauthenicate() + elif arg == "help": + print_help() + else: + print_help() + '') + ]; + }; +} diff --git a/home-modules/python.nix b/home-modules/python.nix new file mode 100644 index 0000000..4d53a84 --- /dev/null +++ b/home-modules/python.nix @@ -0,0 +1,18 @@ +{ config, pkgs, ... }: +let + python-with-packages = pkgs.python3.withPackages (pp: with pp; [ + ipython + pipdeptree + requests + google google-api-python-client google-auth-httplib2 google-auth-oauthlib + ]); +in +{ + home.packages = [ + python-with-packages + ]; + + home.sessionVariables = { + PYTHONPATH = "${python-with-packages}/${python-with-packages.sitePackages}"; + }; +} \ No newline at end of file diff --git a/home-modules/shell/nh.nix b/home-modules/shell/nh.nix new file mode 100644 index 0000000..3aea2ac --- /dev/null +++ b/home-modules/shell/nh.nix @@ -0,0 +1,13 @@ +{ config, pkgs-unstable, ... }: +{ + home = { + packages = with pkgs-unstable; [ + nh + nix-output-monitor + nvd + ]; + sessionVariables = { + FLAKE = "${config.home.homeDirectory}/nix-dots"; + }; + }; +} \ No newline at end of file diff --git a/home-modules/vscode.nix b/home-modules/vscode.nix index 36eb0ae..deb7c1c 100644 --- a/home-modules/vscode.nix +++ b/home-modules/vscode.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, system, user, allowed, secrets, ... }: +{ config, pkgs, lib, user, rice, allowed, ... }: { home.packages = [ @@ -41,6 +41,7 @@ donjayamanne.githistory mads-hartmann.bash-ide-vscode bungcip.better-toml + arrterian.nix-env-selector # ms-vscode-remote.remote-ssh ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ @@ -77,7 +78,7 @@ ]; userSettings = { workbench.colorTheme = "Just Black"; - editor.fontFamily = "'CaskaydiaCove Nerd Font', 'monospace', monospace"; + editor.fontFamily = "'${rice.font.code.name2}', 'monospace', monospace"; emote.SSH.useLocalServer = false; }; enableUpdateCheck = false; diff --git a/home-modules/hyprland/waybar.nix b/home-modules/waybar.nix similarity index 52% rename from home-modules/hyprland/waybar.nix rename to home-modules/waybar.nix index fab7142..dba86d9 100644 --- a/home-modules/hyprland/waybar.nix +++ b/home-modules/waybar.nix @@ -1,9 +1,57 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, rice, ... }: let in { + imports = [ + ./nx-gcal-event.nix + ]; + home.packages = with pkgs; [ waybar + + (pkgs.writeShellScriptBin "waybar_mode" '' + #!/usr/bin/env bash + print_help() { + echo "Usage: waybar_mode {set |unset}" + } + if [ $# -lt 1 ]; then + print_help; exit 1; + fi + case "$1" in + set) + # Check if there is a second argument for the 'set' operation + if [ $# -eq 2 ]; then + echo "$2" > /tmp/waybar-mode + pkill -RTMIN+8 waybar + else + echo "Error: 'set' operation requires exactly one string argument." + print_help + exit 1 + fi + ;; + unset) + echo "" > /tmp/waybar-mode + pkill -RTMIN+8 waybar + ;; + *) + echo "Error: Unknown command '$1'" + print_help + exit 1 + ;; + esac + exit 0 + '') + (pkgs.writeShellScriptBin "cclock" '' + #!/bin/bash + #ord=$(date +"%e" | awk '{printf("%d%s\n", $1, substr("thstndrd", ($1%100-20)%10*2+1, 2))}') + ord=$(date +"%e" | awk '{printf("%d%s\n", $1, ($1==11||$1==12||$1==13)?"th":((($1%10)==1)?"st":((($1%10)==2)?"nd":((($1%10)==3)?"rd":"th"))))}') + if [ $# -eq 0 ]; then + echo "󰃮 $(date +'%A the')" "$ord" "of" "$(date +'%B')" "  " "$(date +'%R')" + elif [ "$1" = "--no-icons" ]; then + echo "$(date +'%A the')" "$ord" "of" "$(date +'%B')" "$(date +'%R')" + fi + '') + ]; programs.waybar = { @@ -12,6 +60,7 @@ in bar = { height = 20; layer = "top"; + # position = "top"; position = "bottom"; margin-top = 0; margin-left = 0; @@ -48,11 +97,11 @@ in separate-outputs = true; }; "custom/cclock" = { - exec = "/home/nx2/scripts/cclock.sh"; + exec = "cclock"; restart-interval = 60; }; "custom/ctimeremaining" = { - exec = "python /home/nx2/scripts/NxGCalEvent/get-remaining-time.py"; + exec = "nx_gcal_event lookup"; restart-interval = 60; }; "custom/mode" = { @@ -105,30 +154,29 @@ in ]; }; network = { - format-wifi = "直 {essid}"; - format-ethernet = " Wired"; - format-disconnected = "睊 Disconnected"; + format-wifi = " {essid}"; + format-ethernet = "󰈀 Wired"; + format-disconnected = "󰌙 Disconnected"; }; wireplumber = { format = "󰕾 {volume}%"; - format-muted = "婢 Muted"; + format-muted = " Muted"; }; }; }; style = '' * { - font-family: Atkinson Hyperlegible, Caskaydia Cove NF, Noto Sans; - font-weight: bold; - font-size: 1.01em; + font-family: ${rice.font.code.name2}; + font-size: 1em; min-height: 0; } window#waybar { - background-color: rgba(0, 0, 0, 0.85); + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.background},${builtins.toString rice.transparency}); transition-duration: 0.5s; padding: 0.1em 1em; padding-top: 0.1em; - border: 0px solid transparent; + border: None; } #clock, @@ -147,40 +195,34 @@ in #workspaces { padding: 0px 3px; margin-top: 0.3em; - border-radius: 0.8em; - color: white; - } - - #window { - font-weight: normal; + border-radius: ${builtins.toString rice.rounding}px; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.foreground}); } #workspaces button { - color: grey; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.bright-black}); padding: 0px 10px; margin: 1px; - border-radius: 0.2em; - border: 0px solid transparent; - } - - #workspaces button.focused { - background-color: darkred; + border-radius: ${builtins.toString rice.rounding}px; + border: None; } #workspaces button:hover { - background-color: green; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.background}); + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.foreground},${builtins.toString rice.transparency}); } #workspaces button.active { - color: white; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.foreground}); + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.background},${builtins.toString rice.transparency}); } #workspaces button.urgent { - background-color: darkorchid; + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.magenta},${builtins.toString rice.transparency}); } #custom-mode { - color: crimson; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.red}); } #cpu { diff --git a/home-modules/wlogout.nix b/home-modules/wlogout.nix index 9ea6402..e0473be 100644 --- a/home-modules/wlogout.nix +++ b/home-modules/wlogout.nix @@ -12,7 +12,7 @@ font-family: ${rice.font.code.name}, monospace; font-size: 12pt; color: ${rice.color.foreground}; - background-color: rgba(0, 0, 0, ${rice.transparency}); + background-color: rgba(0, 0, 0, ${builtins.toString rice.transparency}); } button { diff --git a/home.nix b/home.nix index e5e682e..a988788 100644 --- a/home.nix +++ b/home.nix @@ -6,6 +6,7 @@ ./home-modules/chatterino.nix # ./home-modules/meli/meli.nix ./home-modules/email.nix + ./home-modules/bitwarden.nix # ./home-modules/mutt/neomutt.nix ./home-modules/gestures.nix @@ -13,9 +14,9 @@ ./home-modules/pnx/pnx.nix # ./home-modules/hsmw.nix - ./home-modules/hyprland/hyprland.nix - ./home-modules/hyprland/hyprland-autoname-workspaces.nix - ./home-modules/hyprland/waybar.nix + ./home-modules/hyprland.nix + ./home-modules/hyprland-autoname-workspaces.nix + ./home-modules/waybar.nix ./home-modules/wlogout.nix ./home-modules/kitty.nix @@ -23,6 +24,7 @@ ./home-modules/shell/starship.nix ./home-modules/shell/yazi.nix ./home-modules/shell/zoxide.nix + ./home-modules/shell/nh.nix ./home-modules/ssh.nix ./home-modules/git.nix @@ -30,6 +32,8 @@ ./home-modules/theme/gtk.nix ./home-modules/theme/qt.nix + + ./home-modules/python.nix ]; home.username = "nx2"; home.homeDirectory = "/home/nx2"; @@ -50,7 +54,7 @@ obsidian spotify spicetify-cli - obs-studio bitwarden + obs-studio waybar swww rofi @@ -59,23 +63,12 @@ lynx bat du-dust eza neofetch tldr fzf figlet ripgrep lolcat jq glow brightnessctl wev element sssnake pipes + dig nodejs gnumake speedtest-go - - (pkgs.python3.withPackages (python-pkgs: [ - python-pkgs.ipython - python-pkgs.pipdeptree - python-pkgs.requests - ])) - # (writeShellScriptBin "nxrbs-nix" '' - # set -e - # pushd ~/.nix-dots/ - # git diff - # '') - ]; xdg = { diff --git a/nxlib/ricelib.nix b/nxlib/ricelib.nix new file mode 100644 index 0000000..65d5753 --- /dev/null +++ b/nxlib/ricelib.nix @@ -0,0 +1,64 @@ +{ lib, ... }: +rec +{ + nohash = s: builtins.substring 1 7 s; + + slice-hex = hex: { r = builtins.substring 0 2 hex; g = builtins.substring 2 2 hex; b = builtins.substring 4 5 hex; }; + + # https://github.com/bertof/nix-rice + rune-to-num = c: + let + k = lib.strings.toUpper c; + dict = { + "0" = 0; + "1" = 1; + "2" = 2; + "3" = 3; + "4" = 4; + "5" = 5; + "6" = 6; + "7" = 7; + "8" = 8; + "9" = 9; + "A" = 10; + "B" = 11; + "C" = 12; + "D" = 13; + "E" = 14; + "F" = 15; + }; + in + assert(builtins.hasAttr k dict); + builtins.getAttr k dict; + + drune-to-255 = hex: (rune-to-num (builtins.substring 0 1 hex)) * 15 + (rune-to-num (builtins.substring 1 2 hex)); + + hex-to-rgb-comma-string = hex: let color = (slice-hex (nohash hex)); in "${builtins.toString (drune-to-255 color.r)},${builtins.toString (drune-to-255 color.g)},${builtins.toString (drune-to-255 color.b)}"; + + num-to-rune = n: + let + ns = builtins.toString n; + dict = { + "0" = "0"; + "1" = "1"; + "2" = "2"; + "3" = "3"; + "4" = "4"; + "5" = "5"; + "6" = "6"; + "7" = "7"; + "8" = "8"; + "9" = "9"; + "10" = "A"; + "11" = "B"; + "12" = "C"; + "13" = "D"; + "14" = "E"; + "15" = "F"; + }; + in + assert(builtins.hasAttr ns dict); + builtins.getAttr ns dict; + + float-to-drune = f: "${num-to-rune (builtins.floor((255*f) / 16))}${num-to-rune (builtins.floor(255*f) - (builtins.floor((255 * f) / 16) * 16))}"; +} \ No newline at end of file diff --git a/system-modules/grub.nix b/system-modules/grub.nix index 78f10e0..5c30456 100644 --- a/system-modules/grub.nix +++ b/system-modules/grub.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, host, ... }: let grub-theme-ascii-diana = (pkgs.fetchFromGitea { domain = "git.nx2.site"; @@ -23,13 +23,22 @@ fontSize = 50; splashImage = null; - extraEntries = '' + extraEntries = if host == "NxXPS" then '' menuentry 'Windows 11' --class windows --class os $menuentry_id_option 'osprober-efi-0A97-7A2D' { insmod part_gpt insmod fat search --no-floppy --fs-uuid --set=root 0A97-7A2D chainloader /EFI/Microsoft/Boot/bootmgfw.efi } + '' else '' + menuentry 'Windows 11' --class windows --class os $menuentry_id_option 'osprober-efi-8932-4A3D' { + insmod part_gpt + insmod fat + search --no-floppy --label --set=root EFI + chainloader /EFI/Microsoft/Boot/bootmgfw.efi + } ''; }; } + + diff --git a/system-modules/hsmw.nix b/system-modules/hsmw.nix index 00449d2..a629b6e 100644 --- a/system-modules/hsmw.nix +++ b/system-modules/hsmw.nix @@ -2,7 +2,7 @@ { environment.systemPackages = [ - pkgs.strongswan + pkgs.strongswanNM ]; environment.etc = { @@ -20,6 +20,8 @@ "ipsec.d/USERTrust-ECC.pem".source = ../secrets/vpn-hsmw/USERTrust-ECC-Certification-Authority.pem; "ipsec.d/USERTrust-RSA.pem".source = ../secrets/vpn-hsmw/USERTrust-RSA-Certification-Authority.pem; }; + + networking.networkmanager.enableStrongSwan = true; services.strongswan = { enable = true; diff --git a/system-modules/networking.nix b/system-modules/networking.nix new file mode 100644 index 0000000..7a8e558 --- /dev/null +++ b/system-modules/networking.nix @@ -0,0 +1,14 @@ + +{ config, pkgs, host, ... }: +let +in +{ + + networking.hostName = host; + + networking.networkmanager = { + enable = true; + }; + + networking.enableIPv6 = true; +}