Skip to content

Merge "master-with-treewide-nixfmt" into haskell-updates#395864

Merged
sternenseemann merged 2033 commits intoNixOS:haskell-updatesfrom
wolfgangwalther:haskell-updates-merge-nixfmt
Apr 6, 2025
Merged

Merge "master-with-treewide-nixfmt" into haskell-updates#395864
sternenseemann merged 2033 commits intoNixOS:haskell-updatesfrom
wolfgangwalther:haskell-updates-merge-nixfmt

Conversation

@wolfgangwalther
Copy link
Contributor

#371032 currently has quite some merge conflicts after the treewide nixfmt run in #380990.

I tried to merge the current merge base of master and staging back into haskell-updates, but this isn't easy. The approaches in #395247 are targeting smaller branches and rebases, but not a merge of this size:

  • The auto-rebase script doesn't apply here.
  • The "mergetool" approach is currently buggy in terms of correctness (Mergetool fixes nixfmt#291), but with the number of conflicts in this case, it just hangs and never finishes, anyway.

Thus, I used a better approach: I wrote a custom git merge driver. This kicks in before the conflicts arise, runs nixfmt on all sides, then merges the files. The result is applied here.

The merge-driver consists of:

  • Addition to .git/config:
    [merge "nixfmt"]
    	driver = ./merge-driver.sh %A %O %B -L %X -L %S -L %Y
    
  • Addition to .gitattributes:
    *.nix merge=nixfmt
    
  • merge-driver.sh:
    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p bash moreutils nixfmt-rfc-style
    set -euxo pipefail
    
    cat $1 | nixfmt | sponge $1
    cat $2 | nixfmt | sponge $2
    cat $3 | nixfmt | sponge $3
    
    git merge-file "$@"

This gave me zero merge conflicts, except for a true conflict in the release notes. I am quite confident in the result, but a second pair of eyes would be good.


Additionally, there is the question of how to deal with the auto-generated hackage-packages.nix file. I'm not sure whether that was explicitly discussed as part of the treewide formatting effort or just happened to be formatted, too.

Here, I took the pragmatic approach and added a nixfmt call to the script generating this file. (Can't currently test this, because the regeneration script has broken haskell dependencies on the branch currently.)

@wolfgangwalther wolfgangwalther requested review from a team, maralorn and sternenseemann April 3, 2025 21:42
@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: kernel The Linux kernel 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: printing Drivers, CUPS & Co. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: vim Advanced text editor 6.topic: erlang General-purpose, concurrent, functional high-level programming language 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: xfce The Xfce Desktop Environment 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: stdenv Standard environment 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 6.topic: hardware Drivers, Firmware and Kernels 6.topic: coq A formal proof management system 6.topic: nixos-container Imperative and declarative systemd-nspawn containers 6.topic: pantheon The Pantheon desktop environment 6.topic: TeX Issues regarding texlive and TeX in general 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: testing Tooling for automated testing of packages and modules labels Apr 3, 2025
@sternenseemann
Copy link
Member

Thanks for looking into this. This looks like an adequate solution. The one alternative I see would be to independently reformat all files the haskell-updates branch has changed compared to master/staging in an actual commit and then merge. This could have the upside that the merge commit is smaller. As things stand, it is quite an arduous task reviewing the merge commit 2248aee58984c3378eaa093cfce29fed2f349b9e. From a technical perspective, I'd agree that the merge driver is the better solution.

@wolfgangwalther
Copy link
Contributor Author

The one alternative I see would be to independently reformat all files the haskell-updates branch has changed compared to master/staging in an actual commit and then merge.

I actually tried that, but still got plenty of merge conflicts to resolve. Not sure whether I made a mistake there or the approach won't work in principle.

@wolfgangwalther
Copy link
Contributor Author

As things stand, it is quite an arduous task reviewing the merge commit 2248aee.

The only way to "review" the merge commit is by reproducing it and then looking at the diff (aka the manually resolved conflicts). This only confirms that I didn't sneak anything into that commit, though - not whether the merge-driver did alright.

This looks like an adequate solution. [...] From a technical perspective, I'd agree that the merge driver is the better solution.

We have a merge conflict now, so I'll need to redo this.

How would you like to proceed? Should I push it directly to haskell-updates or would you like to reproduce it on this branch first?

@sternenseemann
Copy link
Member

If it's okay with you, I'd say update this PR and I'll reproduce the merge commit and merge then?

@sternenseemann
Copy link
Member

(Alternatively, solve the merge conflict by merging haskell-updates into this PR.)

This commit has been generated by maintainers/scripts/haskell/regenerate-hackage-packages.sh
@wolfgangwalther wolfgangwalther force-pushed the haskell-updates-merge-nixfmt branch from a1355c8 to ccdcdd5 Compare April 5, 2025 12:23
@wolfgangwalther
Copy link
Contributor Author

If it's okay with you, I'd say update this PR and I'll reproduce the merge commit and merge then?

Did that. The latest merge-base was 3b48b2e.

Since you fixed regenerate-hackage-packages.sh, I also ran it and confirmed it works with the added nixfmt. There were a few pending changes from haskell-updates, applied.

@github-actions github-actions bot added 6.topic: php PHP is a general-purpose scripting language geared towards web development. backport release-24.11 labels Apr 5, 2025
@nix-owners
Copy link

nix-owners bot commented Apr 5, 2025

The PR's base branch is set to haskell-updates, but 2030 commits from the master branch are included. Make sure you know the right base branch for your changes, then:

  • If the changes should go to the master branch, change the base branch to master
  • If the changes should go to the haskell-updates branch, rebase your PR onto the merge base with the haskell-updates branch:
    # git rebase --onto $(git merge-base upstream/haskell-updates HEAD) $(git merge-base upstream/master HEAD)
    git rebase --onto 646c26ebd028cf8a50d25d7c54f3f548708d4de2 3b48b2eb41f0bcd2c0551cd1c2457fdae806c7a3
    git push --force-with-lease

@RossComputerGuy RossComputerGuy removed this from Stdenv Apr 6, 2025
Copy link
Member

@sternenseemann sternenseemann left a comment

Choose a reason for hiding this comment

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

I'm able to create the exact same tree object (f749a0cb63afebb64b9057b4b0b39ba9b89723d3) using the approach outlined in this PR.

@sternenseemann sternenseemann merged commit b8b7f30 into NixOS:haskell-updates Apr 6, 2025
24 of 25 checks passed
@sternenseemann
Copy link
Member

Thanks for figuring this out!

@wolfgangwalther wolfgangwalther deleted the haskell-updates-merge-nixfmt branch April 6, 2025 09:15
This was referenced Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cinnamon Desktop environment 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: coq A formal proof management system 6.topic: crystal Programming language - https://crystal-lang.org/ 6.topic: docker tools Open-source software for deploying and running of containerized applications 6.topic: dotnet Language: .NET 6.topic: emacs Text editor 6.topic: erlang General-purpose, concurrent, functional high-level programming language 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: flakes The experimental Nix feature 6.topic: flutter Open-source UI software development kit for cross-platform applications 6.topic: games Gaming on NixOS 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 6.topic: hardware Drivers, Firmware and Kernels 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: julia Julia is a high-level, high-performance dynamic language for technical computing. 6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: kernel The Linux kernel 6.topic: lib The Nixpkgs function library 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: LXQt The Lightweight Qt Desktop Environment 6.topic: module system About "NixOS" module system internals 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: nixos-container Imperative and declarative systemd-nspawn containers 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 6.topic: nvidia Nvidia-specific issues and fixes 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: pantheon The Pantheon desktop environment 6.topic: php PHP is a general-purpose scripting language geared towards web development. 6.topic: policy discussion Discuss policies to work in and around Nixpkgs 6.topic: printing Drivers, CUPS & Co. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: R R is a programming language for statistical computing and data visualization. 6.topic: rocm ROCm is an Advanced Micro Devices software stack for graphics processing unit programming. 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 6.topic: stdenv Standard environment 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 6.topic: tcl Dynamic, multi-paradigm programming language 6.topic: teams Relating to team creation, updates, other management actions 6.topic: testing Tooling for automated testing of packages and modules 6.topic: TeX Issues regarding texlive and TeX in general 6.topic: vim Advanced text editor 6.topic: vscode A free and versatile code editor that supports almost every major programming language. 6.topic: xen-project Issues and PRs related to the Xen Project Hypervisor. 6.topic: xfce The Xfce Desktop Environment 6.topic: zig Zig is an imperative, general-purpose, statically typed, compiled system programming language. 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 2501-5000 This PR causes many rebuilds on Darwin and should target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.