-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Properly deprecate types.string #66346
Conversation
Wonderful! I've recently been thinking about doing this exact thing since I see people accidentally using I'll make a proper review on the 12th 🙂 |
This fixes the warning being emitted by nixos-rebuild switch: building Nix... building the system configuration... trace: warning: types.string is deprecated because it quietly concatenates strings It started emitting a warning in NixOS#66346. (cherry picked from commit 5a03f90)
As per NixOS/nixpkgs#66346 suggestion I'm going for 'str' since it's a list of arguments and is only further processed by Python
Previously if `_file` was specified by a module: trace: warning: The type `types.string' of option `foo' defined in `/nix/store/yxhm2il5yrb92fldgriw0wyqh2kk9qyc-bug.nix' is deprecated. See NixOS#66346 for better alternative types. With this change: trace: warning: The type `types.string' of option `foo' defined in `/home/infinisil/src/nixpkgs/bug.nix' is deprecated. See NixOS#66346 for better alternative types.
Previously if `_file` was specified by a module: trace: warning: The type `types.string' of option `foo' defined in `/nix/store/yxhm2il5yrb92fldgriw0wyqh2kk9qyc-bug.nix' is deprecated. See NixOS/nixpkgs#66346 for better alternative types. With this change: trace: warning: The type `types.string' of option `foo' defined in `/home/infinisil/src/nixpkgs/bug.nix' is deprecated. See NixOS/nixpkgs#66346 for better alternative types.
see: NixOS/nixpkgs#66346 Use `types.str` when merging makes no sense (ie. "Hello" "World" shouln't become "HelloWorld"), `types.separatedString "${sep}"` when merging should be done (prefer `listOf str` though), and `types.lines` for line based configuration.
Even now https://nixos.wiki/wiki/Declaration informs that |
Everyone can edit their, including you. I fixed it now. |
types.string is deprecated. Related: NixOS/nixpkgs#66346
- as per NixOS/nixpkgs#66346 - also disabled gnome-keyring to use keepassxc secret agent instead
Motivation for this change
For almost 6 (!) years now,
types.string
has been marked as deprecated in the comment above its definition. People keep using this type regardless, and it's getting annoying while reviewing PRs to constantly have to remind people to not use it.This PR does following things:
types.string
in nixpkgs and replace them with a more appropriate typetypes.string
emit a warning upon useThe mass replacement was done all manually, because I needed to decide what the replacement type should be. This was either
types.str
when merging doesn't make sense (e.g.user
options)types.separatedString " "
if its an option representing command line arguments (ideally it should belistOf str
for new modules)types.lines
if it's a line-based configuration format (where joining with newlines makes sense)types.str
if it's a different configuration format where concatenation doesn't workPing @Profpatsch @rycee @aanderse @danbst
Things done
I have not tested any of the modules. While there's a very low chance of any of these changes breaking anything, I might have made a mistake somewhere. A double-check would therefore be good.