lib/types: init defaultComposedFunctor for types.{attrsWith,listOf}#366015
Merged
infinisil merged 3 commits intoNixOS:masterfrom Jan 6, 2025
Merged
lib/types: init defaultComposedFunctor for types.{attrsWith,listOf}#366015infinisil merged 3 commits intoNixOS:masterfrom
infinisil merged 3 commits intoNixOS:masterfrom
Conversation
infinisil
requested changes
Dec 18, 2024
Member
infinisil
left a comment
There was a problem hiding this comment.
Discussed this together in a meeting with @hsjobeki:
- This should only be an internal refactoring, no new function should be exposed
- The function can be specific to an
elemTypepayload, e.g.elemTypeFunctor, which can then also implement the merge forelemTypespecifically - The deprecation message makes sense to have for types that currently use
wrapped
In the future we could also imagine an interface like this for creating types with appropriate functors more easily:
submoduleWith = createAttrType {
# Doesn't need to stay in sync with `submoduleWith` anymore
# because the name is decoupled from the `lib.types` identifier
name = "submodule";
payloadSpec = {
modules = {
# No default, required argument
binOp = a: b: a ++ b;
};
specialArgs = {
default = {};
binOp = unionOfDisjoint;
}
# ...
};
# Gets a functor/typeMerge based on the above spec
create = { modules, specialArgs }: mkOptionType {
description = "...";
merge = "...";
# ...
};
};204bd60 to
3f80731
Compare
7679fed to
66be74f
Compare
66be74f to
5978559
Compare
5978559 to
557e4fa
Compare
557e4fa to
327883c
Compare
327883c to
5782ef8
Compare
13 tasks
hsjobeki
pushed a commit
to infinisil/nixpkgs
that referenced
this pull request
Feb 19, 2025
Otherwise nested types such as `attrsOf (attrsOf int)` won't have a backwards compatible `type.nestedTypes.elemType.functor.wrapped`. Follow-up work to NixOS#366015
github-actions bot
pushed a commit
to nix-community/nixpkgs.lib
that referenced
this pull request
Feb 23, 2025
Otherwise nested types such as `attrsOf (attrsOf int)` won't have a backwards compatible `type.nestedTypes.elemType.functor.wrapped`. Follow-up work to NixOS/nixpkgs#366015
arcnmx
pushed a commit
to arcnmx/nixpkgs-lib
that referenced
this pull request
Aug 29, 2025
Otherwise nested types such as `attrsOf (attrsOf int)` won't have a backwards compatible `type.nestedTypes.elemType.functor.wrapped`. Follow-up work to NixOS/nixpkgs#366015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overall i think all types.functor should deprecate
functor.wrappedThis PR introduces a new
defaultFunctorfor composed types that makes the migration easy.Additional thoughts:
types should be constructible via
type payloadmaybe we want to spread the{type}With payloadpattern ?This design thought also went into the default functor:
Compare:
attrsWithlistWith(doesnt exist)submoduleWithdeferredModuleWithstringWith(doesnt exist)This only internally changes the following for now.
listOfrequires overriding thetypebecause there is nolistWithyet.attrsWithdoesn't require any additional attribute overrides. (Only the custom binOp for merging)Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.