nix config show --json outputs experimental-features as integer bitmap #738

Closed
opened 2025-03-14 18:52:28 +00:00 by niklaskorz · 7 comments

Describe the bug

Running nix config show --json renders the value field of experimental-features as an integer bitmap, likely because of 007211e7a2.

Thank to Vaskel for finding this (I don't think she's registered here).

Steps To Reproduce

Execute nix config show --json | jq '."experimental-features"'

{
  "aliases": [],
  "defaultValue": 0,
  "description": "Experimental features that are enabled.\n\nExample:\n\n```\nexperimental-features = nix-command flakes\n```\n\nThe following experimental features are available:\n\n{{#include @generated@/../../../lix/libutil/experimental-features-shortlist.md}}\n\nExperimental features are [further documented in the manual](@docroot@/contributing/experimental-features.md).\n",
  "documentDefault": true,
  "experimentalFeature": null,
  "value": 576
}

Expected behavior

Get the same output as in Lix 2.91, which is a list of strings with the names of the active experimental features:

{
  "aliases": [],
  "defaultValue": [],
  "description": "\nExperimental features that are enabled.\n\nExample:\n\n```\nexperimental-features = nix-command flakes\n```\n\nThe following experimental features are available:\n\n{{#include @generated@/command-ref/experimental-features-shortlist.md}}\n\nExperimental features are [further documented in the manual](@docroot@/contributing/experimental-features.md).\n\n",
  "documentDefault": true,
  "experimentalFeature": null,
  "value": [
    "flakes",
    "nix-command"
  ]
}

nix --version output

nix (Lix, like Nix) 2.93.0-devpre20250314_af15a44

Additional context

Running nix config show without --json still correctly serializes the experimental-features to their string representations:

experimental-features = flakes nix-command
## Describe the bug Running `nix config show --json` renders the `value` field of `experimental-features` as an integer bitmap, likely because of https://git.lix.systems/lix-project/lix/commit/007211e7a27a512cb343060e8b363c9f66ef67af. Thank to Vaskel for finding this (I don't think she's registered here). ## Steps To Reproduce Execute `nix config show --json | jq '."experimental-features"'` ```json { "aliases": [], "defaultValue": 0, "description": "Experimental features that are enabled.\n\nExample:\n\n```\nexperimental-features = nix-command flakes\n```\n\nThe following experimental features are available:\n\n{{#include @generated@/../../../lix/libutil/experimental-features-shortlist.md}}\n\nExperimental features are [further documented in the manual](@docroot@/contributing/experimental-features.md).\n", "documentDefault": true, "experimentalFeature": null, "value": 576 } ``` ## Expected behavior Get the same output as in Lix 2.91, which is a list of strings with the names of the active experimental features: ```json { "aliases": [], "defaultValue": [], "description": "\nExperimental features that are enabled.\n\nExample:\n\n```\nexperimental-features = nix-command flakes\n```\n\nThe following experimental features are available:\n\n{{#include @generated@/command-ref/experimental-features-shortlist.md}}\n\nExperimental features are [further documented in the manual](@docroot@/contributing/experimental-features.md).\n\n", "documentDefault": true, "experimentalFeature": null, "value": [ "flakes", "nix-command" ] } ``` ## `nix --version` output nix (Lix, like Nix) 2.93.0-devpre20250314_af15a44 ## Additional context Running `nix config show` without `--json` still correctly serializes the `experimental-features` to their string representations: ``` experimental-features = flakes nix-command ```
Owner

wait, what. nlohmann json automatically casts scoped enum to ints. that's some cursed nonsense right there

wait, what. nlohmann json automatically casts scoped enum to ints. that's some cursed nonsense right there
Owner

is this a screw up involving experimental-features-json.hh that would otherwise set up the necessary specialization to not screw this up? i might have a CL deleting that file that's languishing for some reason; there's a ticket for it.

is this a screw up involving experimental-features-json.hh that would otherwise set up the necessary specialization to not screw this up? i might have a CL deleting that file that's languishing for some reason; there's a ticket for it.
Owner

it doesn't look like it. that header implement json hooks for ExperimentalFeature, not ExperimentalFeatures, which is the bitmap type of ExperimentalFeature :/

it doesn't look like it. that header implement json hooks for `ExperimentalFeature`, not `ExperimentalFeatures`, which is the bitmap type of `ExperimentalFeature` :/
piegames was assigned by pennae 2025-03-16 17:37:36 +00:00
pennae added this to the 2.93 milestone 2025-03-19 00:27:46 +00:00
Owner

looked at this for a bit and concluded that we need to abandon using straight nlohmann:json objects and define our own basic_json specialization instead; one that doesn't use the default adl_serializer but a variant that simply rejects enum types

looked at this for a bit and concluded that we need to abandon using straight `nlohmann:json` objects and define our own `basic_json` specialization instead; one that doesn't use the default adl_serializer but a variant that simply rejects enum types
pennae self-assigned this 2025-03-21 13:38:59 +00:00
piegames was unassigned by pennae 2025-03-21 13:39:00 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/2882 ("libutil: disallow enum serialization by default")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/2882", "number": 2882, "kind": "commit message"}], "cl_meta": {"2882": {"change_title": "libutil: disallow enum serialization by default"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/2882](https://gerrit.lix.systems/c/lix/+/2882) ("libutil: disallow enum serialization by default")
Owner

this seems to have affected 2.92 as well

this seems to have affected 2.92 as well
Author

@pennae wrote in #738 (comment):

this seems to have affected 2.92 as well

Yes, 007211e7a2 was already shipped in 2.92

@pennae wrote in https://git.lix.systems/lix-project/lix/issues/738#issuecomment-9768: > this seems to have affected 2.92 as well Yes, 007211e7a27a512cb343060e8b363c9f66ef67af was already shipped in 2.92
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#738
No description provided.