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

Add support for NixOS #7528

Open
malaow3 opened this issue May 3, 2024 · 6 comments
Open

Add support for NixOS #7528

malaow3 opened this issue May 3, 2024 · 6 comments

Comments

@malaow3
Copy link

malaow3 commented May 3, 2024

When trying to invoke sourcekit-lsp on Nix, I get an error:

2024-05-03 14:47:53.510 sourcekit-lsp[25781:4ffff6c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension

Is adding NixOS support a possibility / planned for the future?

@ahoppen
Copy link
Contributor

ahoppen commented May 3, 2024

Looks like we are not detecting NixOS as a Linux OS here:

switch try? Process.checkNonZeroExit(args: "uname")
.trimmingCharacters(in: .whitespacesAndNewlines)
.lowercased()
{
case "darwin"?:
return .darwin
case "linux"?:
return Platform.findCurrentPlatformLinux(localFileSystem)
default:
return nil
}
.

What does uname output on NixOS?

@malaow3
Copy link
Author

malaow3 commented May 3, 2024

Here are the results:

uname
Linux

uname -a
Linux nixos 5.15.146.1-microsoft-standard-WSL2 apple/sourcekit-lsp#1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 GNU/Linux

@ahoppen
Copy link
Contributor

ahoppen commented May 3, 2024

Synced to Apple’s issue tracker as rdar://127491941

@ahoppen
Copy link
Contributor

ahoppen commented May 3, 2024

Interesting, that definitely is what we are expecting uname to return. In practice, the log message probably shouldn’t cause any issues because we’re falling back to using .so, which is correct for Linux.

Which version of SourceKit-LSP are you using? Ie. which Swift toolchain do you have installed? If it’s some Swift 5 version, could you try if the issue still reproduces with a Swift 6 development snapshot from https://www.swift.org/download/#swift-60-development? I’ve made a lot of improvements to SourceKit-LSP during the Swift 6 development cycle and I vaguely remember seeing that log message before but can’t remember when or if I fixed it.

@malaow3
Copy link
Author

malaow3 commented May 3, 2024

I can definitely give that a try, might take me a little bit to figure out how to get everything all set up though

@ahoppen
Copy link
Contributor

ahoppen commented May 3, 2024

Ah, I remember now: I was seeing a similar issue at some point because for some reasons (I can’t remember the details) uname was not in PATH. But that must have been a few years ago and fixed now, even though I don’t remember the fix.

The problem here is that we only detect debian and fedora as Linux distributions here

private static func findCurrentPlatformLinux(_ fileSystem: FileSystem) -> Platform? {
do {
if try fileSystem.isFile(AbsolutePath(validating: "/etc/debian_version")) {
return .linux(.debian)
}
if try fileSystem.isFile(AbsolutePath(validating: "/system/bin/toolbox")) ||
fileSystem.isFile(AbsolutePath(validating: "/system/bin/toybox"))
{
return .android
}
if try fileSystem.isFile(AbsolutePath(validating: "/etc/redhat-release")) ||
fileSystem.isFile(AbsolutePath(validating: "/etc/centos-release")) ||
fileSystem.isFile(AbsolutePath(validating: "/etc/fedora-release")) ||
Platform.isAmazonLinux2(fileSystem)
{
return .linux(.fedora)
}
} catch {}
return nil
}

With that information, it’s not necessary for you to test the Swift 6 snapshot since it also won’t have support for NixOS. I’ll move the issue over to SwiftPM because that’s where the platform detection logic lives.

@ahoppen ahoppen transferred this issue from apple/sourcekit-lsp May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants