When setting a prefix for a path-like environment variable, the
deduplication code in set_env_prefix reads past the NUL byte at the end
of the env val and into the next entry. This corrupts the resultant env
value with data from the next env var, or other data sitting after it.
On darwin, strings does not support -d. Regardless of darwin, the
generated extract script has `strings` without a full nix store path,
making it potentially impure.
The solution is to always pull `strings` from GNU toolchain, regardless
of the platform.
Note: this change should have no implications for darwin bootstrap
because `passthru.extractCmd` has very limited use in the tree,
basically only used when building Firefox, and is not evaluated
otherwise.
Note: previous attempt to resolve the issue was incorrect, effectively
doing nothing on Darwin, see #379014. (The
`targetPackages.gnuStdenv.cc.bintools.targetPrefix` was empty.)
This is mostly meant for `wrapQtApps`, which is why it's implemented only for `makeBinaryWrapper`.
Qt apps are often launched on top of each other, creating a problem: many of the paths in `XDG_DATA_PATHS`, `QT_PLUGIN_PATH` and `NIXPKGS_QT6_QML_IMPORT_PATH` become duplicated, and these envars are already massive by themselves without this problem.
Starting KDE Plasma, and most paths are seen twice. Open Konsole, and it becomes three times. If it was opened with CTRL+ALT+T, four times.
Why is this a problem?
- The more these paths are duplicated, the slower it becomes to copy the envars, and for the programs to parse them.
- Some programs are buggy and malfunction if the environment variable block is too big. For instance, the EA App (via Wine) is unable to launch games if there are more than 32768 characters in the block, a number easily surpassable due to this problem.
- It's ugly typing `env` and seeing this massive wall of duplicated paths.
Because there is no reason for the same path to appear multiple times, this change removes a path if it's already in the list, adding it back to the start or the end.
Only GNU supports the -d flag used. In a different environment, the
command fails as follows:
strings: error: unknown argument '-d'
Note: I believe it was not noticed because the command is used in
Firefox wrapper only where its failure is silently swallowed. The only
side effect then is that the wrapper won't work as expected when
wrapping a wrapper.
Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
We are migrating packages that meet below requirements:
1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration
The tool is here: https://github.com/Aleksanaa/by-name-migrate.