Conversation
infinisil
left a comment
There was a problem hiding this comment.
I wonder, could types.str (and all types on top of it) use check = isStringLike and coerce using toString?
Also, are there more than just the linked use-case?
I'd expect a string interpolation instead. Path values are generally turned into store paths first. EDIT: in the context of |
As @roberth said, it might be a bit unintuitive whether
I can see |
infinisil
left a comment
There was a problem hiding this comment.
I think we should have more descriptive types than this, "string-like" is too arbitrary, mainly just based on what Nix builtins consider strings. This doesn't really have a coherent meaning in e.g. a NixOS system.
For the issue you linked, it seems like a path type specifically for runtime paths would be better, e.g. types.runtimePath. You might also want to allow relative paths, types.relativePath or types.subpath (see also lib.path.subpath.normalise and lib.path.subpath.isValid). If you need to accept both, this could be either runtimePath relativePath. These are just some quick ideas, and other use cases might have other types that would be more fitting. It would be great to spend some time to think about this.
And in any case, there should be docs and tests for any new types.
c6a64d1 to
4beddb9
Compare
|
force pushed to add docs and tests |
|
-1 on "runtime" because it not defined in a purely Nix context, and even in a Nixpkgs context, a
I don't believe having |
|
I guess more concretely, Imo we have too many pathy types with unclear semantics already:
This is just a mess, and Instead we should work towards a more clear set of types that have clearer semantics, including how path values get handled, what the intended use case is, ensuring the return value is always the same type, with the same semantics no matter the input type. |
|
Doesn't seem messier than the fairly extensive problem domain we model with these types, but if you have concrete suggestions or plans to improve it, feel free. |
|
Concretely I just have one idea: More generally I'd like a design document for why we need this many string/path-like types, comparing them and specifying their use cases. And if we can't find a good justification for them, rename/document the types more properly or introduce new types with better semantics. |
|
I see that the motivating issue was better solved with Plan sgtm @infinisil. I'll add that the As for the design part (ie making changes) we might want to gather requirements in the form of simple use cases first so we can more easily test designs we come up with. |
Description of changes
Motivation: microvm-nix/microvm.nix#138
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)