diff --git a/home/modules/hyprland/hyprland.nix b/home/modules/hyprland/hyprland.nix index c3374f2..bac4bb9 100644 --- a/home/modules/hyprland/hyprland.nix +++ b/home/modules/hyprland/hyprland.nix @@ -201,9 +201,6 @@ in exec-once=pasystray source=${config.home.homeDirectory}/.cache/wallust/hyprland.conf - - exec-once=bash -c "sleep 10; until ping -c 1 google.com; do sleep 1; done; slack" - exec-once=bash -c "sleep 10; until ping -c 1 nextcloud.tigor.web.id; do sleep 1; done; nextcloud --background" ''; }; }; diff --git a/home/programs/slack.nix b/home/programs/slack.nix index ce8bca5..3b815ea 100644 --- a/home/programs/slack.nix +++ b/home/programs/slack.nix @@ -1,56 +1,19 @@ { pkgs, lib, config, ... }: let cfg = config.profile.slack; + script = pkgs.writeShellScriptBin "slack.sh" '' + sleep 10; until ${pkgs.unixtools.ping}/bin/ping -c 1 1.1.1.1; do sleep 1; done; slack + ''; + scriptFile = lib.meta.getExe script; in { config = lib.mkIf cfg.enable { home.packages = with pkgs; [ slack ]; - systemd.user = lib.mkIf cfg.autostart { - # Unlike Discord, Slack is only used on office hours, - # so we will use a timer to start it on office hours only. - timers.slack = { - Unit = { - Description = "Start Slack Desktop Client on Weekdays on Login"; - }; - Timer = { - OnCalendar = "Mon..Fri 09..18:*:*"; - }; - Install = { - WantedBy = [ "timers.target" ]; - }; - }; - services.slack = { - Unit = { - Description = "Slack Desktop Client"; - Wants = [ "graphical.target" ]; - StartLimitIntervalSec = 300; - StartLimitBurst = 10; - }; - Service = - let - bash = "${pkgs.bash}/bin/bash"; - ping = "${pkgs.unixtools.ping}/bin/ping"; - host = "google.com"; # slack.com does not respond to ping - sleep = "${pkgs.coreutils}/bin/sleep"; - slack = "${pkgs.slack}/bin/slack"; - exec = ''${bash} -c "until ${ping} -c 1 ${host}; do ${sleep} 1; done; ${slack}"''; - in - { - Type = "simple"; - ExecStartPre = "${sleep} 5"; - ExecStart = exec; - Restart = "on-failure"; - # Prevent Slack from auto-restarting when user closes it. - # The timer setup above will trigger this service - # if RemaiAfterExit is not set to "yes". - # - # This will mark the service as still "Active" by systemd - # hence the timer will not trigger the service again. - RemainAfterExit = "yes"; - Environment = [ "NIXOS_OZONE_WL=1" ]; - }; - }; - }; + wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.autostart [ + scriptFile + ]; + + home.file.".config/autostart/slack.sh".source = lib.mkIf cfg.autostart scriptFile; }; } diff --git a/home/programs/zsh.nix b/home/programs/zsh.nix index 19b542f..5c45de2 100644 --- a/home/programs/zsh.nix +++ b/home/programs/zsh.nix @@ -86,7 +86,7 @@ in /*bash*/ '' packfiles() { - find $(nix build "nixpkgs#$1" --no-link --print-out-paths) + find $(NIXPKGS_ALLOW_UNFREE=1 nix build "nixpkgs#$1" --impure --no-link --print-out-paths) } build() { diff --git a/profiles/castle.nix b/profiles/castle.nix index 1350c35..95c3c1a 100644 --- a/profiles/castle.nix +++ b/profiles/castle.nix @@ -52,7 +52,10 @@ in enable = true; autostart = true; }; - slack.enable = true; + slack = { + enable = true; + autostart = true; + }; whatsapp = { enable = true; autostart = true;