Skip to content

lib.lists: add uniqueByString#459228

Open
roberth wants to merge 1 commit intoNixOS:masterfrom
roberth:dedup-by-string
Open

lib.lists: add uniqueByString#459228
roberth wants to merge 1 commit intoNixOS:masterfrom
roberth:dedup-by-string

Conversation

@roberth
Copy link
Member

@roberth roberth commented Nov 6, 2025

Adds a new function to remove duplicates based on a string key function. This provides stable deduplication that preserves input order, unlike uniqueStrings, which doesn't preserve order, and allows custom key extraction unlike unique which compares elements directly.

Also adds docs cross-references between unique, uniqueStrings, and uniqueByString to help users discover the appropriate function for their use case.

Context

  • First written for Infer devShell deps, provide smaller one nix#14489
    • deduplicating a large number of build inputs gathered from multiple derivations, so that the resulting devShell is reviewable, and doesn't waste the finite env+args space in processes.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot requested review from hsjobeki and infinisil November 6, 2025 19:17
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 6.topic: lib The Nixpkgs function library labels Nov 6, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 14, 2025
Adds a new function to remove duplicates based on a string key function.
This provides stable deduplication that preserves input order, unlike
uniqueStrings which doesn't preserve order, and allows custom key extraction
unlike unique which compares elements directly.

Also adds cross-references between unique, uniqueStrings, and uniqueByString
to help users discover the appropriate function for their use case.
@nixpkgs-ci nixpkgs-ci bot added 2.status: merge conflict This PR has merge conflicts with the target branch and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Nov 26, 2025
@hsjobeki
Copy link
Contributor

hsjobeki commented Dec 19, 2025

Motivation for #452088
Linked lists would allow to cut down time complexity from O(n^2) to O(n log n).
Without linked lists this has the same behavior and time complexity as unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants