Skip to content

Commit 3ce11a7

Browse files
authored
Merge pull request #68230 from dehnert/nix
Report major&minor version for NixOS
2 parents b8327e0 + c6abecf commit 3ce11a7

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

changelog/68230.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Made osfinger report major&minor version for NixOS

salt/grains/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2547,7 +2547,7 @@ def _osrelease_data(os, osfullname, osrelease):
25472547
os_name = osfullname
25482548
grains["osfinger"] = "{}-{}".format(
25492549
os_name,
2550-
osrelease if os in ("Ubuntu", "Pop") else grains["osrelease_info"][0],
2550+
osrelease if os in ("Ubuntu", "Pop", "NixOS") else grains["osrelease_info"][0],
25512551
)
25522552

25532553
return grains

tests/pytests/unit/grains/test_core.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,50 @@ def test_openeuler_os_grains():
16491649
_run_os_grains_tests(_os_release_data, {}, expectation)
16501650

16511651

1652+
@pytest.mark.skip_unless_on_linux
1653+
def test_nixos_os_grains():
1654+
"""
1655+
Test that OS grains are parsed correctly for NixOS
1656+
"""
1657+
# /etc/os-release data taken from NixOS 25.05
1658+
_os_release_data = {
1659+
"ANSI_COLOR": "0;38;2;126;186;228",
1660+
"BUG_REPORT_URL": "https://github.com/NixOS/nixpkgs/issues",
1661+
"BUILD_ID": "25.05.807313.59e69648d345",
1662+
"CPE_NAME": "cpe:/o:nixos:nixos:25.05",
1663+
"DEFAULT_HOSTNAME": "nixos",
1664+
"DOCUMENTATION_URL": "https://nixos.org/learn.html",
1665+
"HOME_URL": "https://nixos.org/",
1666+
"ID": "nixos",
1667+
"ID_LIKE": "",
1668+
"IMAGE_ID": "",
1669+
"IMAGE_VERSION": "",
1670+
"LOGO": "nix-snowflake",
1671+
"NAME": "NixOS",
1672+
"PRETTY_NAME": "NixOS 25.05 (Warbler)",
1673+
"SUPPORT_END": "2025-12-31",
1674+
"SUPPORT_URL": "https://nixos.org/community.html",
1675+
"VARIANT": "",
1676+
"VARIANT_ID": "",
1677+
"VENDOR_NAME": "NixOS",
1678+
"VENDOR_URL": "https://nixos.org/",
1679+
"VERSION": "25.05 (Warbler)",
1680+
"VERSION_CODENAME": "warbler",
1681+
"VERSION_ID": "25.05",
1682+
}
1683+
expectation = {
1684+
"os": "NixOS",
1685+
"os_family": "NixOS",
1686+
"oscodename": "warbler",
1687+
"osfullname": "NixOS",
1688+
"osrelease": "25.05",
1689+
"osrelease_info": (25, 5),
1690+
"osmajorrelease": 25,
1691+
"osfinger": "NixOS-25.05",
1692+
}
1693+
_run_os_grains_tests(_os_release_data, {}, expectation)
1694+
1695+
16521696
@pytest.mark.skip_unless_on_windows
16531697
def test_windows_platform_data():
16541698
"""

0 commit comments

Comments
 (0)