Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixd (or nix) may request the inputs in some edge cases #322

Closed
hellodword opened this issue Jan 25, 2024 · 2 comments
Closed

nixd (or nix) may request the inputs in some edge cases #322

hellodword opened this issue Jan 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hellodword
Copy link
Contributor

hellodword commented Jan 25, 2024

The version I'm using is https://github.com/NixOS/nixpkgs/blob/06570e54184cb7f3aecb16c7c5ef82a871ce5873/pkgs/development/tools/language-servers/nixd/default.nix

Reproduce:

  1. prepare a local git+ssh server with docker
FROM ubuntu:latest

RUN apt-get update && \
    apt-get install git openssh-server -y && \
    git clone --bare https://codeberg.org/mhwombat/hello-flake.git && \
    passwd -d root && \
    printf '\nPasswordAuthentication yes\nPermitEmptyPasswords yes\nPermitRootLogin yes\n' | tee -a /etc/ssh/sshd_config && \
    service ssh start

EXPOSE 22

CMD ["/usr/sbin/sshd","-D"]
  1. run the git+ssh server and trust it
docker build -t nixd-issue .
docker run --rm -p 127.0.0.1:22222:22 nixd-issue
# trust
ssh root@127.0.0.1 -p 22222 uname
  1. commit the flake
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    flake-compat = {
      url = "github:inclyc/flake-compat/70e56389c58bbd300d11778913b255477ebbae22";
      flake = false;
    };

    disko = {
      url = "github:nix-community/disko/f0b9f374bb42fdcd57baa7d4448ac5d4788226bd";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    privates.url = "git+ssh://root@127.0.0.1:22222/hello-flake.git";
  };

  outputs = { self, nixpkgs, ... }@ inputs:
    let
      system = "x86_64-linux";

      minimal = {
        users.users = {
          admin = {
            isNormalUser = true;
            extraGroups = [ "wheel" ];
            password = "admin";
          };
        };

        virtualisation.vmVariant = {
          virtualisation = {
            memorySize = 1024;
            cores = 2;
            graphics = false;
          };
        };

        system.stateVersion = "23.05";
      };
    in
    {
      nixosConfigurations = {

        test-vm-nixd-issue = nixpkgs.lib.nixosSystem {
          inherit system;
          specialArgs = { inherit inputs; };
          modules = [
            (
              { config, lib, pkgs, inputs, ... }: (minimal // {

                boot.kernelPackages = pkgs.linuxPackages_latest;

                imports = [
                  inputs.disko.nixosModules.disko
                ];

                disko = {
                  enableConfig = false;
                  devices.disk = {
                    "${inputs.privates.apps.x86_64-linux.default.type}" = { };
                  };
                };

              })
            )
          ];
        };

      };
    };
}
nix flake update
# git add ...
# git commit ...
  1. lsp config
{
    "nix.enableLanguageServer": true,
    "nix.serverPath": "nixd",
    "nix.serverSettings": {
        "nixd": {
            "eval": {
                "target": {
                    "args": [
                        "-f",
                        "default.nix"
                    ],
                    "installable": "nixosConfigurations.test-vm-nixd-issue.config"
                },
                "workers": 5
            },
            "formatting": {
                "command": "nixpkgs-fmt"
            },
            "options": {
                "enable": true,
                "target": {
                    "args": [],
                    "installable": ".#nixosConfigurations.test-vm-nixd-issue.options"
                }
            }
        }
    }
}
  1. close all and reboot
  2. listen the 22222 port
nix-shell -p nmap --run 'ncat -v -k -l 22222'
  1. open the editor, you will catch the request
Ncat: Connection from 127.0.0.1:53768.
SSH-2.0-OpenSSH_9.6
@hellodword
Copy link
Contributor Author

@inclyc
Copy link
Member

inclyc commented Jan 25, 2024

With latest nixd-next: https://github.com/nix-community/nixd/tree/e7e26a16adb83d6c1b7a74615b6c77fe4c51bc82

image

This is not complete and your version may not even deal with lambdas. That's why you see these meaningless errors.

nixd-next is on a very early stage: #283

@hellodword hellodword changed the title nixd may request the inputs in some edge cases nixd (or nix) may request the inputs in some edge cases Jan 25, 2024
@inclyc inclyc added the bug Something isn't working label Jan 30, 2024
@inclyc inclyc closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants