home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

bug: Darkman module doesn't run scripts properly

Open TWB0109 opened this issue 1 year ago • 2 comments

Are you following the right branch?

  • [X] My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • [X] I have searched the existing issues

Issue description

The module tries to run the scripts as bash scripts, but they fail to run. Even though they can be run manually ("./.local/share/light-mode.d/gtk-theme"). I've changed my shell from nushell to bash to see if that helped, but it didn't. I also tried to add the script as a writeScript and add the shebang below, but that didn't help either.

#!/usr/bin/env nix-shell
#! nix-shell -i bash -p bash dconf

Here's my config in the relevant areas:

/etc/nixos/configuration.nix

{ config, pkgs ... }:

{
  ...
  users.users.myusername = {
    ...
    shell = pkgs.nushell;
    ...
  };
  
  home-manager.users.myusername = { pkgs, ...}: {
    ...
    services.darkman = {
      enable = true;
      darkModeScripts = {
        gtk-theme = ''
          ${pkgs.dconf}/bin/dconf write\
          /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
        '';
      };
      lightModeScripts = {
        gtk-theme = ''
          ${pkgs.dconf}/bin/dconf write\
          /org/gnome/desktop/interface/color-scheme "'prefer-light'"
        '';
      };
      settings = {
        usegeoclue = true;
      };
    };
    ...
  };
  ...
  environment.systemPackages = with pkgs; [
    vim
    kitty
    gnome.gnome-tweaks
    git
    polkit_gnome
    gnome-text-editor
    bash
  ];
}

Systemctl shows that darkman was unable to run the script because it couldn't find bash in path, but bash is, in fact, included in $PATH.

● darkman.service - Darkman system service
     Loaded: loaded (/home/myusername/.config/systemd/user/darkman.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-01-24 16:25:11 CST; 37min ago
       Docs: man:darkman(1)
   Main PID: 4499 (darkman)
      Tasks: 9 (limit: 18989)
     Memory: 2.2M
        CPU: 12ms
     CGroup: /user.slice/user-1000.slice/[email protected]/background.slice/darkman.service
             └─4499 /nix/store/dgrsjlads5j8c5hmwdp54jxgfb7vy434-darkman-1.5.4/bin/darkman run

Jan 24 16:25:22 nixos darkman[4499]: scripts.go:49: Running /home/myusername/.local/share/dark-mode.d/gtk-theme...
Jan 24 16:25:22 nixos darkman[4499]: scripts.go:56: Failed to run: exec: "bash": executable file not found in $PATH.
Jan 24 16:25:23 nixos darkman[4499]: main.go:44: Mode should now be: light mode.
Jan 24 16:25:23 nixos darkman[4499]: scripts.go:39: Found /home/myusername/.local/share/light-mode.d/gtk-theme.
Jan 24 16:25:23 nixos darkman[4499]: scripts.go:49: Running /home/myusername/.local/share/light-mode.d/gtk-theme...
Jan 24 16:25:23 nixos darkman[4499]: scripts.go:56: Failed to run: exec: "bash": executable file not found in $PATH.
Jan 24 16:36:04 nixos darkman[4499]: main.go:44: Mode should now be: dark mode.
Jan 24 16:36:04 nixos darkman[4499]: scripts.go:39: Found /home/myusername/.local/share/dark-mode.d/gtk-theme.
Jan 24 16:36:04 nixos darkman[4499]: scripts.go:49: Running /home/myusername/.local/share/dark-mode.d/gtk-theme...
Jan 24 16:36:04 nixos darkman[4499]: scripts.go:56: Failed to run: exec: "bash": executable file not found in $PATH.

I think this is all of the information I can provide, but let me know if more is needed.

Is there any way we can fix this?

Maintainer CC

@xlambein

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.1.74, NixOS, 24.05 (Uakari), 24.05pre574351.612f97239e2c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"home-manager, nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

TWB0109 avatar Jan 24 '24 23:01 TWB0109

Experiencing the same issue.

I tracked it down in the darkman source to this line , which is present as of version 1.5.4 (what's in nixpkgs).

The unnecessary call to bash was removed later. Now there is a 2.0.0 version mentioned in their changelog but there isn't the corresponding tag yet. As far as I can tell this will be resolved the moment there's a 2.0.0 package available.

hyblm avatar Feb 10 '24 08:02 hyblm

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar May 11 '24 22:05 stale[bot]

v2.0.0 is out

WhyNotHugo avatar May 27 '24 15:05 WhyNotHugo