nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.69k stars 1.76k forks source link

bug: programs.foot.server.enable = true; dosen't work #5739

Open sachinchaudhary1808 opened 1 month ago

sachinchaudhary1808 commented 1 month ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

so programs.foot.server.enable = true; dosen't really work i still have start foot server manually using foot --server, when i check the user service it's dead

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.6.44, NixOS, 24.05 (Uakari), 24.05.20240806.21cc704`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Lix, like Nix) 2.90.0`
 - channels(root): `""`
 - nixpkgs: `/nix/store/pi3i4rcxl8iadwxpyyx481ycnyxm856b-source`

     Loaded: loaded (/home/devu/.config/systemd/user/foot.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2024-08-16 20:49:50 IST; 5s ago
   Duration: 21ms
       Docs: man:foot(1)
    Process: 11646 ExecStart=/nix/store/bp50lnk62qyxlcglj61rxi3hl6kyjhf1-foot-1.17.2/bin/foot --server (code=exited, status=230/PERSONALITY)
   Main PID: 11646 (code=exited, status=230/PERSONALITY)
        CPU: 20ms

Aug 16 20:49:50 nixos systemd[1915]: foot.service: Scheduled restart job, restart counter is at 5.
Aug 16 20:49:50 nixos systemd[1915]: foot.service: Start request repeated too quickly.
Aug 16 20:49:50 nixos systemd[1915]: foot.service: Failed with result 'exit-code'.
Aug 16 20:49:50 nixos systemd[1915]: Failed to start Fast, lightweight and minimalistic Wayland terminal emulator..
~
~```
cgahr commented 2 weeks ago

I have the same issue. Do you, per chance, use foot together with dwl? I think this bug might happen since graphical-session.target is not run.

Based on this https://unix.stackexchange.com/questions/597990/enabled-systemd-user-service-doesnt-start-at-login it seems like desktop environments, and dwl in particular, often don't implement graphical-session.target.

sachinchaudhary1808 commented 2 weeks ago

I have the same issue. Do you, per chance, use foot together with dwl? I think this bug might happen since graphical-session.target is not run.

Based on this https://unix.stackexchange.com/questions/597990/enabled-systemd-user-service-doesnt-start-at-login it seems like desktop environments, and dwl in particular, often don't implement graphical-session.target.

I'm using sway

cgahr commented 2 weeks ago

Probably the same issue. I can confirm that adding the following snippet works:

config.systemd.user.services.foot = {
  Unit = {
    PartOf = [ "default.target" ];
    After = [ "default.target" ];
  };
  Install.WantedBy = [ "default.target" ];
};

The proper fix, however, would be to start graphical-session.target with sway or dwl...

cgahr commented 2 weeks ago

I investigated a bit further. First of all, this is not a bug, the issue lies with the window manager which does not start the graphical-session.service.

The previous snippet I send works in principle, the following approach is better however.

  1. add the following systemd service to your config

    systemd.user = {
    services.dwl-session = {
    enable = true;
    
    unitConfig = {
      Description = "dwl window manager session";
      PartOf = "dwl-session.target";
      Wants = "dwl-session.target";
    };
    
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = "yes";
      ExecStart = "${pkgs.coreutils}/bin/true";
      Restart = "on-failure";
    };
    };
    targets.dwl-session = {
    enable = true;
    
    unitConfig = {
      Description = "dwl window manager session";
      Requires = "basic.target";
      BindsTo = "graphical-session.target";
      Before = "graphical-session.target";
      Wants = "graphical-session-pre.target";
      After = "graphical-session-pre.target";
    
      DefaultDependencies = "no";
      RefuseManualStart = "yes";
      RefuseManualStop = "yes";
      StopWhenUnneeded = "yes";
    };
    };
    };
  2. start dwl via dwl -c 'systemctl start --user dwl-session.service'

This setup ensures that the graphical-session is started, which in turn starts foot --server.

Two caveats:

TLDR: The ticket can be closed, not a bug in home-manager