nix-community / nixos-vscode-server

Visual Studio Code Server support in NixOS
MIT License
419 stars 76 forks source link

Unit file auto-fix-vscode-server.service does not exist. #62

Closed ce-dot closed 1 year ago

ce-dot commented 1 year ago

This flake does not seem to produce a systemd service for me.

My flake.nix reads (shortened version)

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
    vscode-server.url = "github:nix-community/nixos-vscode-server";
  };

  outputs = {self, nixpkgs, vscode-server}:
    {
      nixosConfigurations = {
        "myhost" = nixpkgs.lib.nixosSystem {
          system = "x86_64-linux";
          modules = [
            ./myhost.nix
            vscode-server.nixosModules.default
             ({ config, pkgs, ... }: {
               services.vscode-server.enable = true;
             })
          ];
        };
      };
    };
}

But when I try to enable the service with systemctl --user enable auto-fix-vscode-server.service (or disable, start) it says the unit file does not exist.

What am I doing wrong?

msteen commented 1 year ago

I just tried it in a VM and cannot reproduce your problem. Can you give me more context about where you are installing this? Is just a regular NixOS installation?

jmatsushita commented 1 year ago

Had the same problem, and these instructions on the README solved it for me:

Enabling the user service creates a symlink to the Nix store, but the linked store path could be garbage collected at some point. One workaround to this particular issue is creating the following symlink:

ln -sfT /run/current-system/etc/systemd/user/auto-fix-vscode-server.service ~/.config/systemd/user/auto-fix-vscode-server.service
ce-dot commented 1 year ago

That worked, thanks (and ouch)! Sorry for the hassle!

ce@nuc-nixos ~ % systemctl --user enable auto-fix-vscode-server.service
Failed to enable unit: Unit file auto-fix-vscode-server.service does not exist.
1 ce@nuc-nixos ~ % ln -sfT /run/current-system/etc/systemd/user/auto-fix-vscode-server.service ~/.config/systemd/user/auto-fix-vscode-server.service
ce@nuc-nixos ~ % systemctl --user start auto-fix-vscode-server.service
ce@nuc-nixos ~ % systemctl --user status auto-fix-vscode-server.service
● auto-fix-vscode-server.service - Automatically fix the VS Code server used by the remote SSH extension
     Loaded: loaded (/etc/systemd/user/auto-fix-vscode-server.service; enabled; preset: enabled)
     Active: active (running) since Fri 2023-06-16 21:39:41 CEST; 4s ago
   Main PID: 15774 (auto-fix-vscode)
      Tasks: 2 (limit: 18673)
     Memory: 1.7M
        CPU: 32ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/auto-fix-vscode-server.service
             ├─15774 /nix/store/7q1b1bsmxi91zci6g8714rcljl620y7f-bash-5.2-p15/bin/bash /nix/store/ndrrfpa8qm9rq3ikhqmygzd05nvicqrp-auto-fix-vscode-server/bin/auto-fix-vscode-server
             └─15780 inotifywait -q -m -e CREATE,ISDIR -e DELETE_SELF --format %f:%e /home/ce/.vscode-server/bin

Jun 16 21:39:41 nuc-nixos systemd[1360]: Started Automatically fix the VS Code server used by the remote SSH extension.
Jun 16 21:39:41 nuc-nixos auto-fix-vscode-server[15774]: Patching Node.js of VS Code server installation in /home/ce/.vscode-server/bin/b380da4ef1ee00e224a15c1d4d9793e27c2b6302...

P.S. Good job on this unit btw!