Stream: nix

Topic: Conditional internal option


view this post on Zulip Shivaraj B H (Mar 27 2024 at 07:34):

I don’t think it is possible with the current library, but I do have a case where it could be useful.

In a recent change to services-flake, I made the default value for socketDir option as ”” and when it is an empty-string, I don’t want the users to refer to this config, it doesn’t make sense. It only makes sense to refer to it when it is non-empty.

Is there a better way I can implement this? or is it a problem worth being solved upstream?

view this post on Zulip Srid (Mar 27 2024 at 12:47):

One way is types.nullOr types.string

view this post on Zulip Shivaraj B H (Mar 27 2024 at 14:34):

This is much better since it will throw a “cannot coerce null to string” error, when trying to use the option in any shell script.


Last updated: Nov 15 2024 at 12:33 UTC