Hi, I’m trying to emit integer keys with pkgs.formats.yaml. Does anyone know how to do it?
I’m trying to turn my LACT configuration to nix with services.lact.settings .
I attempted to directly translate my current config file into a nix struct:
...
curve:
50: 0.0
63: 0.25
71: 0.50
77: 0.75
82: 1.0
...
gpu_vf_curve:
2:
voltage: 945
clockspeed: 1905
...
My LACT config file has integer keys which I can’t directly express in nix (attribute set keys can’t be numbers)
I tried turning the integer keys into strings:
curve = {
"50" = 0.0;
"63" = 0.25;
"71" = 0.5;
"77" = 0.75;
"82" = 1.0;
};
But it generated an invalid config file:
curve:
'50': 0.0
'63': 0.25
'71': 0.5
'77': 0.75
'82': 1.0
which prevented lactd from starting:
Error: Could not deserialize config
Caused by:
profiles.Steam.gpus.{...}.fan_control_settings.curve: invalid type: string "50", expected i32 at line 16 column 13
lactd.service: Main process exited, code=exited, status=1/FAILURE
1 Like
Can’t be done. The formatter uses JSON as an intermediate format, and JSON only has string keys, so the final json2yaml invocation always ensures that the output keys are strings too.
gaelj
December 27, 2025, 4:06pm
3
One solution is to add to lact a configFile option, similar to this PR
master ← ralichkov:glance-configfile-option
opened 08:23PM - 24 Dec 25 UTC
Closes #426790
Introduces a `configFile` option to the Glance service that al… lows the use of an existing YAML config file instead of the one generated by the `settings` option.
Thanks to @/zimbatm's [blog post](https://zimbatm.com/notes/the-nixos-settings-option-when-and-how-to-use-it) for pointing me in the right direction!
## Things done
- Built on platform:
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- Tested, as applicable:
- [ ] [NixOS tests] in [nixos/tests].
- [ ] [Package tests] at `passthru.tests`.
- [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
- [x] Ran `nixpkgs-review` on this PR. See [nixpkgs-review usage].
- [x] Tested basic functionality of all binary files, usually in `./result/bin/`.
- Nixpkgs Release Notes
- [ ] Package update: when the change is major or breaking.
- NixOS Release Notes
- [ ] Module addition: when adding a new NixOS module.
- [ ] Module update: when the change is significant.
- [x] Fits [CONTRIBUTING.md], [pkgs/README.md], [maintainers/README.md] and other READMEs.
[NixOS tests]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
[Package tests]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
[nixpkgs-review usage]: https://github.com/Mic92/nixpkgs-review#usage
[CONTRIBUTING.md]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
[lib/tests]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
[maintainers/README.md]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
[nixos/tests]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
[pkgs/README.md]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
[pkgs/test]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
gaelj
December 30, 2025, 10:37am
4
In case there is a misunderstanding:
The above PR is for a different package (glance). You’ll need to make your own modifications to lact (in a fork of nixpkgs), in a similar fashion to the glance modification, to achieve the desired functionality in lact.
If you want I can do it for you, just give me a shout.