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

pkgs.formats.json alters integers in options due to use of jq #148824

Open
anna328p opened this issue Dec 6, 2021 · 1 comment
Open

pkgs.formats.json alters integers in options due to use of jq #148824

anna328p opened this issue Dec 6, 2021 · 1 comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@anna328p
Copy link
Member

anna328p commented Dec 6, 2021

Describe the bug

$ nix-build -E '((import <nixpkgs> {}).formats.json {}).generate "file.json" 165998239273844736'
/nix/store/c4qchpr6bi0yk168gaj1k1fv9lkqx3p6-file.json

$ cat /nix/store/c4qchpr6bi0yk168gaj1k1fv9lkqx3p6-file.json
165998239273844740

Expected behavior

I expected the file to contain the integer given as input.

Additional context

https://github.com/NixOS/nixpkgs/blob/master/pkgs/pkgs-lib/formats.nix#L46

$ jq . <<< "165998239273844736"
165998239273844740

jqlang/jq#369

Notify maintainers

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.14.21, NixOS, 22.05 (Quokka)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: formats.json
# a list of nixos modules affected by the problem
module:
@anna328p anna328p added the 0.kind: bug Something is broken label Dec 6, 2021
@anna328p
Copy link
Member Author

anna328p commented Dec 6, 2021

as an interim solution, i'm using configFile = pkgs.writeText "config.json" (builtins.toJSON cfg.config);

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

1 participant