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

Binary is not being patched on NixOS in the latest nightly #11695

Closed
cab404 opened this issue Mar 12, 2022 · 7 comments · Fixed by #11696
Closed

Binary is not being patched on NixOS in the latest nightly #11695

cab404 opened this issue Mar 12, 2022 · 7 comments · Fixed by #11696
Assignees

Comments

@cab404
Copy link
Contributor

cab404 commented Mar 12, 2022

@lnicola This is cursed, and should never have been accepted:
https://github.com/rust-analyzer/rust-analyzer/blob/0182f7451600e1700873549c324f7d13585547f4/editors/code/src/main.ts#L272

cat /etc/os-release
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
BUILD_ID="22.05.20220305.062a0c5"
DOCUMENTATION_URL="https://nixos.org/learn.html"
HOME_URL="https://nixos.org/"
ID="nixos"
LOGO="nix-snowflake"
NAME="NixOS"
PRETTY_NAME="NixOS 22.05 (Quokka)"
SUPPORT_URL="https://nixos.org/community.html"
VERSION="22.05 (Quokka)"
VERSION_CODENAME="quokka"

This is a serious regression in nightly and it's important to fix it before the next release.
@matklad, please take a look.

@lnicola
Copy link
Member

lnicola commented Mar 12, 2022

What do you mean by regression? That code has been like this for almost two one and a half years.

@cab404
Copy link
Contributor Author

cab404 commented Mar 12, 2022

IIRC NixOS detection were at first detecting /etc/nixos folder (which is cursed as well)

@lnicola
Copy link
Member

lnicola commented Mar 12, 2022

Yeah, but that was 15 months ago. Maybe you updated your distro (is that a thing on Nix?) and they added this quotes recently.

@cab404
Copy link
Contributor Author

cab404 commented Mar 12, 2022

That's probable

const idString = contents.split('\n').find((a) => a.startsWith("ID="))
return idString?.toLowerCase()?.indexOf("nixos") !== -1;

should probably work?
At least I think that bash do not support any whitespaces after and inside assignments

@lnicola
Copy link
Member

lnicola commented Mar 12, 2022

We could also look for the three ways of spelling it. Is that file even a shell script?

@cab404
Copy link
Contributor Author

cab404 commented Mar 12, 2022

It looks like it's a bit simpler than that https://www.linux.org/docs/man5/os-release.html

@cab404
Copy link
Contributor Author

cab404 commented Mar 12, 2022

I've tested it with the patch I suggested above — detection works correctly with it.

bors bot added a commit that referenced this issue Mar 13, 2022
11696: editors/code: fix nixos detection r=lnicola a=cab404

Problem: NixOS started using quotes around it's id field in /etc/os-release
Solution: Parially parsing os-release, and detecting, whether `nixos` appears anywhere in "ID=" field\
See #11695

Closes #11695

Co-authored-by: Vladimir Serov <me@cab404.ru>
@bors bors bot closed this as completed in ce4b610 Mar 13, 2022
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

Successfully merging a pull request may close this issue.

3 participants