Skip to content

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 on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Feb 28, 2022
@peterhoeg peterhoeg requested review from davidak and prusnak 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.
raboof added a commit to raboof/trafficserver that referenced this pull request Sep 4, 2025
Ubuntu is not the only distribution that has a `/etc/lsb-release`,
NixOS has it as well since NixOS/nixpkgs#162168
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 on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants