Skip to content

Properly deprecate types.string#66346

Merged
rycee merged 2 commits intoNixOS:masterfrom
infinisil:remove-types.string
Aug 31, 2019
Merged

Properly deprecate types.string#66346
rycee merged 2 commits intoNixOS:masterfrom
infinisil:remove-types.string

Conversation

@infinisil
Copy link
Member

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:

  • Remove all usages of types.string in nixpkgs and replace them with a more appropriate type
  • Make types.string emit a warning upon use

The 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 be listOf 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 work

Ping @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.

  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)

@infinisil infinisil requested review from edolstra and nbp as code owners August 8, 2019 21:26
@infinisil infinisil changed the title Remove types.string Properly deprecate types.string Aug 8, 2019
@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 8, 2019
@rycee
Copy link
Member

rycee commented Aug 8, 2019

Wonderful! I've recently been thinking about doing this exact thing since I see people accidentally using types.string in new modules all the time. It's a waste of energy to always have to look for and point this out when reviewing.

I'll make a proper review on the 12th 🙂

github-actions bot pushed a commit to nix-community/nixpkgs.lib that referenced this pull request Dec 4, 2022
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.
@infinisil infinisil added the 1.severity: significant Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc. label Apr 19, 2023
@infinisil infinisil removed the 1.severity: significant Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc. label Aug 8, 2023
@jian-lin jian-lin mentioned this pull request Aug 8, 2023
12 tasks
jalil-salame added a commit to jalil-salame/NixNeovim that referenced this pull request Aug 27, 2023
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.
@wkordalski
Copy link
Contributor

wkordalski commented Dec 14, 2023

Even now https://nixos.wiki/wiki/Declaration informs that types.string is the right thing to use.
I don't know if this site is yours or not, but for sure a significant number of NixOS beginners learns there how to use mkOption.
Putting correct information there might help with the repeating types.string.

@Mic92
Copy link
Member

Mic92 commented Dec 14, 2023

https://nixos.wiki/wiki/Declaration

Everyone can edit their, including you. I fixed it now.

slotThe added a commit to xmonad/xmonad that referenced this pull request Feb 8, 2024
gwarf added a commit to gwarf/dotfiles that referenced this pull request Mar 12, 2024
shivaraj-bh added a commit to juspay/services-flake that referenced this pull request Mar 29, 2024
ackttic pushed a commit to gwarf/dotfiles that referenced this pull request Oct 19, 2024
alexnguyennn added a commit to alexnguyennn/nix-keyboard-shortcut-apps that referenced this pull request Nov 10, 2024
jules-sommer pushed a commit to jules-sommer/nix_config_minimal that referenced this pull request Nov 30, 2024
- as per NixOS/nixpkgs#66346
- also disabled gnome-keyring to use keepassxc secret agent instead
thefossguy added a commit to thefossguy/prathams-nixos that referenced this pull request Mar 12, 2025
There is a deprecation warning, so act on it.
```
evaluation warning: The type `types.string` is deprecated. See NixOS/nixpkgs#66346 for better alternative types.
```
@DaniD3v
Copy link
Contributor

DaniD3v commented May 23, 2025

types.separatedString " " if its an option representing command line arguments (ideally it should be listOf str for new modules)

Can you explain why listOf str should be used?

Should it be manually merged with " " in the config = {} section? Should we use apply in mkOptions?
Why is seperatedString even bad in the first place?

@infinisil
Copy link
Member Author

@DaniD3v separatedString " " breaks passing of arguments with spaces, because concatStringsSep " " [ "foo bar" ] == concatStringsSep " " [ "foo" "bar" ]. It should be listOf str so that you can use lib.escapeShellArgs to turn it into a string that bash properly interprets :)

cl0vrfi3ld pushed a commit to cl0vrfi3ld/selfprivacy-nixos-config that referenced this pull request Jun 11, 2025
tzeman77 added a commit to tzeman77/nur-packages that referenced this pull request Jul 7, 2025
types.string is deprecated
Viz. NixOS/nixpkgs#66346
osnyx added a commit to flyingcircusio/fc-nixos that referenced this pull request Jul 10, 2025
- evaluation warning: In test `sensuclient': The `machine' attribute in
NixOS tests (pkgs.nixosTest / make-test-python.nix / testing-python.nix
/ makeTest) is deprecated. Please set the equivalent `nodes.machine'.

- evaluation warning: The type `types.string` is deprecated. See
NixOS/nixpkgs#66346 for better alternative
types.

- evaluation warning: Module argument `nodes.host1.config` is
deprecated. Use `nodes.host1` instead.
platform-pr-manager bot pushed a commit to flyingcircusio/fc-nixos that referenced this pull request Jul 21, 2025
- evaluation warning: In test `sensuclient': The `machine' attribute in
NixOS tests (pkgs.nixosTest / make-test-python.nix / testing-python.nix
/ makeTest) is deprecated. Please set the equivalent `nodes.machine'.

- evaluation warning: The type `types.string` is deprecated. See
NixOS/nixpkgs#66346 for better alternative
types.

- evaluation warning: Module argument `nodes.host1.config` is
deprecated. Use `nodes.host1` instead.

(cherry picked from commit 9267841)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: module system About "NixOS" module system internals 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants