From 7853b4870f22b764029164454ea105e8d76c2c2d Mon Sep 17 00:00:00 2001 From: Frantisek Bohacek Date: Wed, 31 Jul 2024 11:33:05 +0200 Subject: [PATCH] feat: use desktopSessions options instead of custom .sessions folder --- home/modules/default.nix | 2 + home/modules/profiles/desktop/default.nix | 61 +------------------ home/modules/profiles/desktop/dwl/default.nix | 26 +++++++- nixos/hosts/laptop-phobos/home.nix | 22 ++++--- 4 files changed, 41 insertions(+), 70 deletions(-) diff --git a/home/modules/default.nix b/home/modules/default.nix index 6116e7f..ea5821c 100644 --- a/home/modules/default.nix +++ b/home/modules/default.nix @@ -4,5 +4,7 @@ ./profiles/default.nix ./programs/default.nix ./themes.nix + ./sessions + ./sessions/default-hm-impl.nix ]; } diff --git a/home/modules/profiles/desktop/default.nix b/home/modules/profiles/desktop/default.nix index 04c2d39..e554643 100644 --- a/home/modules/profiles/desktop/default.nix +++ b/home/modules/profiles/desktop/default.nix @@ -14,65 +14,6 @@ }; config = lib.mkIf config.profiles.desktop.enable { - home.file.".start-session".source = pkgs.writeShellScript "start-session" '' - sessions=($(ls ~/.sessions)) - session_indices=(''${!sessions[@]}) - - timeout=3 - selected="start-dwl" # default - - echo "Default session to start is $selected" - - echo "Available sessions:" - for i in ''${!sessions[@]}; do - echo " $((i+1))) ''${sessions[$i]}" - done - echo " q) Enter tty." - - echo -n "Choose session to start: " - read -t"$timeout" -n1 user_input - echo - - if [[ $user_input == "q" ]]; then - exit - elif [[ $user_input ]]; then - user_input=$((user_input-1)) - echo $user_input - echo ''${session_indices[@]} - if [[ " ''${session_indices[@]} " =~ " $user_input " ]]; then - selected="''${sessions[$user_input]}" - echo "Got $user_input. Going to start $selected" - else - echo "Got unknown option. Exiting." - exit - fi - else - echo "Got no input, starting $selected" - fi - - echo "Going to start $selected" - - exec "~/.sessions/$selected" - - ''; - - programs = { - bash = { - enable = true; - profileExtra = '' - if [[ "$(tty)" == "/dev/tty1" && "$(id -u)" != 0 ]]; then - ~/.start-session - fi - ''; - }; - zsh = { - enable = true; - profileExtra = '' - if [[ "$(tty)" == "/dev/tty1" && "$(id -u)" != 0 ]]; then - ~/.start-session - fi - ''; - }; - }; + desktopSessions.enable = true; }; } diff --git a/home/modules/profiles/desktop/dwl/default.nix b/home/modules/profiles/desktop/dwl/default.nix index c272185..a344b4d 100644 --- a/home/modules/profiles/desktop/dwl/default.nix +++ b/home/modules/profiles/desktop/dwl/default.nix @@ -19,6 +19,8 @@ let wlopmDisableScreens = wlopmScreens "off"; wlopmEnableScreens = wlopmScreens "on"; + dwl = inputs.self.packages.${pkgs.system}.dwl; + emacs-anywhere = pkgs.writeShellScriptBin "emacs-anywhere" '' emacs --batch --script "${./emacs-anywhere.el}" | wl-copy ''; @@ -35,6 +37,28 @@ in { }; config = lib.mkIf config.profiles.desktop.dwl.enable { + desktopSessions.instances.dwl = let + dwlInternal = pkgs.writeShellScript "dwl-s" '' + exec <&- + dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP DISPLAY + systemctl start --user wlr-session.target + ''; + in { + environment = { + XDG_CURRENT_DESKTOP = "wlroots"; + XDG_BACKEND = "wayland"; + QT_QPA_PLATFORM = "wayland"; + MOZ_ENABLE_WAYLAND = "1"; + _JAVA_AWT_WM_NONREPARENTING = "1"; + }; + + executable = lib.getExe dwl; + arguments = [ + "-s" + "${dwlInternal}" + ]; + }; + profiles.desktop.enable = true; systemd.user.targets.wlr-session = { Unit = { @@ -105,7 +129,7 @@ in { emacs-anywhere - inputs.self.packages.${pkgs.system}.dwl + dwl ]; programs = { diff --git a/nixos/hosts/laptop-phobos/home.nix b/nixos/hosts/laptop-phobos/home.nix index a66e66b..4933fc5 100644 --- a/nixos/hosts/laptop-phobos/home.nix +++ b/nixos/hosts/laptop-phobos/home.nix @@ -5,22 +5,26 @@ let # if etc-file.text != null then # etc-file.text else # (builtins.readFile etc-file.source); - readEtcFile = etc-file: lib.mkMerge [ - (lib.mkIf (etc-file.text != null) etc-file.text) - (lib.mkIf (etc-file.source != null) (builtins.readFile etc-file.source)) - ]; + # NO IFDs, future me!!!! + # readEtcFile = etc-file: lib.mkMerge [ + # (lib.mkIf (etc-file.text != null) etc-file.text) + # (lib.mkIf (etc-file.source != null) (builtins.readFile etc-file.source)) + # ]; in { profiles.development.enable = true; profiles.desktop.dwl.enable = true; profiles.matrix.enable = true; + desktopSessions.defaultSession = "dwl"; + # Don't Starve doesn't pick up /etc/alsa/conf.d. # ALSA lib conf.c:4136:(config_file_load) cannot stat file/directory /etc/alsa/conf.d # This is a workaround that puts the stuff from /etc/alsa/conf.d into ~/.asoundrc that # Don't starve is able to read. - home.file.".asoundrc".text = lib.mkMerge [ - (readEtcFile osConfig.environment.etc."alsa/conf.d/49-pipewire-modules.conf") - (readEtcFile osConfig.environment.etc."alsa/conf.d/50-pipewire.conf") - (readEtcFile osConfig.environment.etc."alsa/conf.d/99-pipewire-default.conf") - ]; + # home.file.".asoundrc".text = lib.mkMerge [ + # TODO: get rid of the ifd before commenting this out! + # (readEtcFile osConfig.environment.etc."alsa/conf.d/49-pipewire-modules.conf") + # (readEtcFile osConfig.environment.etc."alsa/conf.d/50-pipewire.conf") + # (readEtcFile osConfig.environment.etc."alsa/conf.d/99-pipewire-default.conf") + # ]; } -- 2.48.1