Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget-to-nix: sort output not the input #162187

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

asmundo
Copy link
Contributor

@asmundo asmundo commented Feb 28, 2022

It is the package list output that should be sorted. The file input
sorting do not produce stable output lists.

Motivation for this change

Sorting of input files do not produce stable output list across machines with version changes for some reason.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Feb 28, 2022
@06kellyjac
Copy link
Member

Idea sounds good but I'm not familiar with nuget2nix.sh
cc @IvarWithoutBones are you?

@asmundo
Copy link
Contributor Author

asmundo commented Mar 9, 2022

I am dyslexic and it could be that below commit message would be better:

nuget-to-nix: deterministic sorting of output list

It is the package list output that should be sorted. The current output
sequence is not logical because '.' is sorted in front of '/' with
input sorting and is not deterministic for different language 
environments. 

To get a deterministic and logical sorting in environments with
different language configured, env "LC_ALL=C" is set and the produced
strings is that is sorted. To get alphabetic sorting and not a pure ASCII
value sort "--ignore-case" is added.

@asmundo
Copy link
Contributor Author

asmundo commented Mar 9, 2022

commit message updated.

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one suggestion, otherwise the code looks good!

done < <(find $1 -name '*.nuspec')

LC_ALL=C sort --ignore-case ${tmpfile}
rm ${tmpfile}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rm ${tmpfile}

Not needed anymore with the trap

@IvarWithoutBones
Copy link
Member

Thank you, this fixes a pretty big issue with #162548 I never noticed :)

It is the package list output that should be sorted. The current
output sequence is not logical because '.' is sorted in front of '/'
with input sorting and is not deterministic for different language
environments.

To get a deterministic and logical sorting in environments with
different language configured, env "LC_ALL=C" is set and the produced
strings is that is sorted. To get alphabetic sorting and not a pure
ASCII value sort "--ignore-case" is added.
@zimbatm zimbatm merged commit d8012c5 into NixOS:master Mar 10, 2022
@asmundo asmundo deleted the nugetToNixSortOutput branch March 10, 2022 09:04
@@ -8,6 +8,8 @@ if [ $# -eq 0 ]; then
fi

pkgs=$1
tmpfile=$(mktemp /tmp/nuget-to-nix.XXXXXX)
trap 'rm -f "$tmpfile" EXIT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a quote was missed here, breaking the program: nuget-to-nix: line 25: unexpected EOF while looking for matching ''

Suggested change
trap 'rm -f "$tmpfile" EXIT
trap 'rm -f "$tmpfile"' EXIT

@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 10.rebuild-linux: 1 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants