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

nixos/os-release: generate from attrset #162168

Merged
merged 1 commit into from
Mar 4, 2022
Merged

nixos/os-release: generate from attrset #162168

merged 1 commit into from
Mar 4, 2022

Conversation

peterhoeg
Copy link
Member

Motivation for this change

I've had this sitting around for ages - instead of interpolating a large string
in order to generate =/etc/os-release=, build it from an attribute set instead
which is less likely to be broken in case of changes.

Additionally, generate =/etc/lsb-release= for compatibility with older software.
The cost of doing this is a few hundred bytes, so it should be fairly
non-controversial.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Feb 28, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Feb 28, 2022
@peterhoeg peterhoeg requested review from prusnak and davidak and removed request for prusnak March 3, 2022 01:32
@peterhoeg
Copy link
Member Author

Kinda, sorta related to RFC42.

@peterhoeg peterhoeg requested a review from prusnak March 3, 2022 01:32
Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it 👍

@peterhoeg peterhoeg merged commit bae181d into master Mar 4, 2022
@peterhoeg peterhoeg deleted the m/lsb branch March 4, 2022 01:39
@andrevmatos
Copy link
Member

I have /etc/NIXOS as a symlink (currently to /dev/null, tmpfs root, since this may be just be an empty file), and it seems that the check for "This is not a NixOS installation!" in switch-to-configuration checks that either /etc/NIXOS is an actual file (couldn't it just check that the path exists?) or that os-release has exactly the string ID=nixos, which broke with this PR, since this now renders to ID="nixos"

@peterhoeg
Copy link
Member Author

peterhoeg commented Mar 8, 2022 via email

@andrevmatos
Copy link
Member

I was actually using environment.etc."NIXOS".source = "/dev/null";, but tmpfiles is a good approach as well, thanks!

@peterhoeg
Copy link
Member Author

peterhoeg commented Mar 8, 2022 via email

@andrevmatos
Copy link
Member

Yes, that should also work. It'll still create it as a symlink, but being symlinked to an actual file would allow the -f test to pass. Either way, the os-release check may still require fixing. Thanks

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/veloren-airshipper-libegl-so-not-found/18225/8

ben0x539 added a commit to ben0x539/rust that referenced this pull request Mar 23, 2022
Per https://www.freedesktop.org/software/systemd/man/os-release.html,

> Variable assignment values must be enclosed in double or single quotes
> if they include spaces, semicolons or other special characters outside
> of A–Z, a–z, 0–9. (Assignments that do not include these special
> characters may be enclosed in quotes too, but this is optional.)

So, past `ID=nixos`, let's also check for `ID='nixos'` and `ID="nixos"`.

One of these is necessary between NixOS/nixpkgs#162168 and
NixOS/nixpkgs#164068, but this seems more correct either way.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 5, 2022
bootstrap.py: nixos check in /etc/os-release with quotes

Per https://www.freedesktop.org/software/systemd/man/os-release.html,

> Variable assignment values must be enclosed in double or single quotes
> if they include spaces, semicolons or other special characters outside
> of A–Z, a–z, 0–9. (Assignments that do not include these special
> characters may be enclosed in quotes too, but this is optional.)

So, past `ID=nixos`, let's also check for `ID='nixos'` and `ID="nixos"`.

One of these is necessary between NixOS/nixpkgs#162168 and
NixOS/nixpkgs#164068, but this seems more correct either way.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 5, 2022
bootstrap.py: nixos check in /etc/os-release with quotes

Per https://www.freedesktop.org/software/systemd/man/os-release.html,

> Variable assignment values must be enclosed in double or single quotes
> if they include spaces, semicolons or other special characters outside
> of A–Z, a–z, 0–9. (Assignments that do not include these special
> characters may be enclosed in quotes too, but this is optional.)

So, past `ID=nixos`, let's also check for `ID='nixos'` and `ID="nixos"`.

One of these is necessary between NixOS/nixpkgs#162168 and
NixOS/nixpkgs#164068, but this seems more correct either way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants