Skip to content

Add better NixOS detection#1714

Open
Pandapip1 wants to merge 1 commit intoCISOfy:masterfrom
Pandapip1:nixowos
Open

Add better NixOS detection#1714
Pandapip1 wants to merge 1 commit intoCISOfy:masterfrom
Pandapip1:nixowos

Conversation

@Pandapip1
Copy link

@Pandapip1 Pandapip1 commented Jan 21, 2026

Because it's funny, I have my /etc/os-release customized to use a NAME that's not NixOS. This is something that's easy to do by simply setting the options that control the stuff in os-release:

https://github.com/NixOS/nixpkgs/blob/527be1432109cfaf305987865bc17cc908e8e77a/nixos/modules/misc/version.nix#L121-L161

In fact, there's an entire library dedicated to making silly customizations like this: https://github.com/yunfachi/denix

This changes the NixOS detection code to look for /run/current-system, which is present on all NixOS systems regardless of configuration, and is importantly not present when using Nix on non-NixOS.

Because it's funny, I have my /etc/os-release customized to use a `NAME` that's not `NixOS`. This is something that's easy to do by simply setting the options that control the stuff in os-release:

https://github.com/NixOS/nixpkgs/blob/527be1432109cfaf305987865bc17cc908e8e77a/nixos/modules/misc/version.nix#L121-L161

In fact, there's an entire library dedicated to making silly customizatoins like this: https://github.com/yunfachi/denix

This changes the nixos detection code to look for /run/current-system, which is present on all NixOS systems regardless of configuration, and is importantly _not_ present when using Nix on non-NixOS.
@Pandapip1
Copy link
Author

Also added NixOS EOL data and vulnix support (#1509)

@mboelen
Copy link
Member

mboelen commented Jan 27, 2026

Thanks for your work.

Kind request: please don't add all changes to one pull request, otherwise it becomes very hard to merge them upon reviewing.

@Pandapip1
Copy link
Author

Kind request: please don't add all changes to one pull request, otherwise it becomes very hard to merge them upon reviewing.

Sounds good; I'll cherry-pick each of the commits into their own branches.

@Pandapip1
Copy link
Author

Pandapip1 commented Jan 27, 2026

This has been tested on my own system and it correctly identifies it as NixOS despite the customized /etc/os-release.

  - Detecting OS...                                           [ DONE ]
  - Checking profiles...                                      [ DONE ]

  ---------------------------------------------------
  Program version:           3.1.6
  Operating system:          Linux
  Operating system name:     NixOS
  Operating system version:  26.05
❯ cat /etc/os-release
ANSI_COLOR=""
BUG_REPORT_URL=""
BUILD_ID="26.05.20251221.a653104"
CPE_NAME="cpe:/o:nixowos:nixowos:26.05"
DEFAULT_HOSTNAME=nixowos
DOCUMENTATION_URL=""
HOME_URL=""
ID=nixowos
ID_LIKE=nixos
IMAGE_ID=""
IMAGE_VERSION=""
LOGO="nix-snowflake"
NAME=NixOwOS
PRETTY_NAME="NixOwOS 26.05 (Yarara)"
SUPPORT_URL=""
VARIANT=""
VARIANT_ID=""
VENDOR_NAME=NixOwOS
VENDOR_URL=""
VERSION="26.05 (Yarara)"
VERSION_CODENAME=yarara
VERSION_ID="26.05"

@Pandapip1
Copy link
Author

Bump!

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 this pull request may close these issues.

2 participants