From 8a6311b89654a4f0b7344a76e12e783d301a45d1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 19:14:42 +0200 Subject: [PATCH 1/6] rye: update & use globally --- .../terminal/coding/python/default.nix | 1 - .../terminal/coding/python/python.nix | 14 ---------- home/programs/terminal/coding/python/rye.nix | 26 ++++++++++++++++++- hosts/voyager/default.nix | 1 + 4 files changed, 26 insertions(+), 16 deletions(-) delete mode 100644 home/programs/terminal/coding/python/python.nix diff --git a/home/programs/terminal/coding/python/default.nix b/home/programs/terminal/coding/python/default.nix index 1bf124b..0241592 100644 --- a/home/programs/terminal/coding/python/default.nix +++ b/home/programs/terminal/coding/python/default.nix @@ -1,6 +1,5 @@ { imports = [ - ./python.nix ./ipython.nix ./poetry.nix ./rye.nix diff --git a/home/programs/terminal/coding/python/python.nix b/home/programs/terminal/coding/python/python.nix deleted file mode 100644 index f4628e2..0000000 --- a/home/programs/terminal/coding/python/python.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - lib, - pkgs, - osConfig, - ... -}: let - inherit (lib) mkIf; - - cfg = osConfig.myOptions.home-manager.programs.coding.python; -in { - config = mkIf cfg.enable { - home.packages = with pkgs; [ python312 ]; - }; -} diff --git a/home/programs/terminal/coding/python/rye.nix b/home/programs/terminal/coding/python/rye.nix index 5e06e4c..3ac8e9a 100644 --- a/home/programs/terminal/coding/python/rye.nix +++ b/home/programs/terminal/coding/python/rye.nix @@ -1,14 +1,38 @@ { lib, pkgs, + config, osConfig, ... }: let inherit (lib) mkIf; cfg = osConfig.myOptions.home-manager.programs.coding.python; + + toTOML = name: (pkgs.formats.toml {}).generate "${name}"; in { config = mkIf cfg.enable { - home.packages = with pkgs; [ rye ]; + home = { + packages = with pkgs; [ rye ]; + + sessionVariables = { + RYE_HOME = "${config.xdg.configHome}/rye"; + }; + + # Add rye python shims to path. + # Rye provides python executables that will automatically pick up on the python + # from a virtual environment, if we're in a directory (project) with one. If not, + # rye will fall back to system python. That is, if behavior.global-python=false, + # otherwise, we can actually use a python version from rye as our global python. + sessionPath = [ + "${config.xdg.configHome}/rye/shims" + ]; + }; + + # see: + xdg.configFile."rye/config.toml".source = toTOML "config.toml" { + default.license = "GPL-3.0-or-later"; + behavior.global-python=true; + }; }; } diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 68be7f9..65f1f3b 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -79,6 +79,7 @@ # Language package managers ".local/share/cargo" ".local/share/go" + ".config/rye" ]; extraFiles = [ ".config/gtk-3.0/bookmarks" From 46f5fa83e8e1fcfd19211f8d7e2224a867ced2f4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 19:17:44 +0200 Subject: [PATCH 2/6] python: fix history location & persist history --- home/programs/xdg/config-files.nix | 48 +++++++++++++++--------------- hosts/voyager/default.nix | 1 + 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/home/programs/xdg/config-files.nix b/home/programs/xdg/config-files.nix index b16ce44..18c1abf 100644 --- a/home/programs/xdg/config-files.nix +++ b/home/programs/xdg/config-files.nix @@ -57,34 +57,34 @@ in { ''; "python/pythonrc.py".text = '' - import atexit - import os - import readline - from functools import partial - from pathlib import Path - from types import ModuleType - - cache_xdg_dir = Path( - os.environ.get("XDG_CACHE_HOME", str(Path("~/.cache").expanduser())) - ) - cache_xdg_dir.mkdir(exist_ok=True, parents=True) - - history_file = cache_xdg_dir.joinpath("python_history") - history_file.touch() - - readline.read_history_file(history_file) + def is_vanilla() -> bool: + import sys + return not hasattr(__builtins__, '__IPYTHON__') and 'bpython' not in sys.argv[0] - def write_history(readline: ModuleType, history_file: Path) -> None: - """ - We need to get ``readline`` and ``history_file`` as arguments, as it - seems they get garbage collected when the function is registered and - the program ends, even though we refer to them here. - """ - readline.write_history_file(history_file) + def setup_history(): + import os + import atexit + import readline + from pathlib import Path + + if state_home := os.environ.get('XDG_STATE_HOME'): + state_home = Path(state_home) + else: + state_home = Path.home() / '.local' / 'state' + + history: Path = state_home / 'python_history' + + # https://github.com/python/cpython/issues/105694 + if not history.is_file(): + readline.write_history_file(str(history)) # breaks on macos + python3 without this. + + readline.read_history_file(str(history)) + atexit.register(readline.write_history_file, str(history)) - atexit.register(partial(write_history, readline, history_file)) + if is_vanilla(): + setup_history() ''; }; diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 65f1f3b..be7a456 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -87,6 +87,7 @@ ".cache/walker/history.gob" ".config/pcmanfm-qt/default/recent-files.conf" ".config/qalculate/qalculate-gtk.cfg" + ".local/state/python_history" ]; persistentDataMountPoint = "/data/Data"; From 842b009f840a8dfecc15a8a8ba2156485d1c690b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 20:20:06 +0200 Subject: [PATCH 3/6] Persist ssh config --- hosts/voyager/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index be7a456..02ffe20 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -66,6 +66,7 @@ ".config/obs-studio" # Tools + ".ssh" ".local/share/gnupg" ".local/share/zoxide" ".local/share/wakatime" From 73c7b503ad7057043e3eac19abdde1f98c234766 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 22:00:11 +0200 Subject: [PATCH 4/6] Add hyprpaper --- home/services/default.nix | 1 + home/services/hyprpaper.nix | 34 ++++++++++++++++++++++++++++++++++ hosts/voyager/default.nix | 6 ++++++ options/home/services.nix | 8 ++++++++ 4 files changed, 49 insertions(+) create mode 100644 home/services/hyprpaper.nix diff --git a/home/services/default.nix b/home/services/default.nix index 9799edc..fa9f89a 100644 --- a/home/services/default.nix +++ b/home/services/default.nix @@ -1,5 +1,6 @@ _: { imports = [ ./dunst.nix + ./hyprpaper.nix ]; } diff --git a/home/services/hyprpaper.nix b/home/services/hyprpaper.nix new file mode 100644 index 0000000..aad3a6a --- /dev/null +++ b/home/services/hyprpaper.nix @@ -0,0 +1,34 @@ +{ + lib, + pkgs, + osConfig, + config, + ... +}: let + inherit (lib) mkIf getExe; + + cfg = osConfig.myOptions.home-manager.services.hyprpaper; + cfgIsWayland = osConfig.myOptions.home-manager.wms.isWayland; +in { + config = mkIf (cfg.enable && cfgIsWayland) { + systemd.user.services.hyprpaper = { + Install.WantedBy = [ "hyprland-session.target" ]; + Unit = { + Description = "Hyprpaper (Hyprland wallpaper daemon)"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${getExe pkgs.hyprpaper}"; + Restart = "on-failure"; + }; + }; + xdg.configFile."hypr/hyprpaper.conf".text = '' + preload=${cfg.wallpaperPath} + wallpaper=,${cfg.wallpaperPath} # same wallpaper on all monitors + ipc=off + ''; + }; +} + diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 02ffe20..891e996 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -217,6 +217,12 @@ services = { dunst.enable = true; + hyprpaper = { + enable = true; + # This file intentionally lacks a file extension, it should be a symlink + # to whatever file you wish to actually be your wallpaper + wallpaperPath = "/data/Data/Media/Pictures/Wallpapers/active"; + }; }; }; }; diff --git a/options/home/services.nix b/options/home/services.nix index 7586b0a..bd2ec2c 100644 --- a/options/home/services.nix +++ b/options/home/services.nix @@ -4,6 +4,14 @@ in { options.myOptions.home-manager.services = { dunst.enable = mkEnableOption "Dunst (lightweight notification daemon)"; + hyprpaper = { + enable = mkEnableOption "Hyprpaper (Hyprland wallpaper daemon)"; + wallpaperPath = mkOption { + type = types.path; + default = null; + description = "Path to the wallpaper of your choosing"; + }; + }; }; } From ee9c647cb31e8d4c98ef4a5856988b7d0ff82ee1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 22:12:27 +0200 Subject: [PATCH 5/6] ssh: update paths to some identity files --- home/programs/terminal/tools/ssh.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/programs/terminal/tools/ssh.nix b/home/programs/terminal/tools/ssh.nix index 2946298..149c0fb 100644 --- a/home/programs/terminal/tools/ssh.nix +++ b/home/programs/terminal/tools/ssh.nix @@ -13,12 +13,12 @@ "gitlab" = { user = "git"; hostname = "gitlab.com"; - identityFile = "~/.ssh/git/gitlab"; + identityFile = "~/.ssh/git/gitlab-itsdrike"; }; "github" = { user = "git"; hostname = "gitlab.com"; - identityFile = "~/.ssh/git/github"; + identityFile = "~/.ssh/git/github-itsdrike"; }; # TODO: Figure out how to add protected/encrypted blocks here # I don't like the idea of expising IPs/hostnames in the config From 86383c69dd6b29dff8e78b45391e727c739ff8dc Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 22:29:50 +0200 Subject: [PATCH 6/6] hyprland: Disable inactive opacity --- home/programs/graphical/wms/hyprland/config/style.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/programs/graphical/wms/hyprland/config/style.nix b/home/programs/graphical/wms/hyprland/config/style.nix index 12f25ee..d3cdedf 100644 --- a/home/programs/graphical/wms/hyprland/config/style.nix +++ b/home/programs/graphical/wms/hyprland/config/style.nix @@ -101,7 +101,7 @@ dim_inactive = false; # disabled for now dim_strength = 0.02; dim_special = 0.2; - inactive_opacity = 0.9; + #inactive_opacity = 0.9; }; #