file: patch to fix misclassification of some zip files#402318
file: patch to fix misclassification of some zip files#402318doronbehar wants to merge 1 commit intoNixOS:stagingfrom
Conversation
wolfgangwalther
left a comment
There was a problem hiding this comment.
IIRC, I had some zip files not identified as such a while ago. I also tried this patch, but somehow it didn't fix my issue. I will try again tomorrow, but there might be more wrong upstream.
|
Thanks for reviewing @wolfgangwalther . If you could confirm that this patch fixes an issue you've experienced before it'd be great. If not, I guess we'll merge this in a day or two. |
|
I tested and the zip files that I have are still problematic with this. They are returned as mimetype So while this is not an issue with this PR, the question is whether the patch here will be enough - or you'd eventually run into the same problem that I have, @txkyel. Not sure whether downgrading would be an option, either. |
|
It seems the problem that I am hitting has been reported upstream already: https://bugs.astron.com/view.php?id=622 TLDR: It depends on how you call file / libmagic, whether zip files are detected correctly. Simple example on this branch: This one returns "data": while this one works and returns zip file info: @txkyel you wrote the following in the other PR:
Did you only take this info from the PR or did you test I'm not sure whether we should proceed with this rather incomplete fix at this time. |
I haven't tested |
|
A bit hacky of a work around but I was able to get nixpkgs.overlays = [
(self: super: {
file-patched = super.file.overrideAttrs (old: {
patches = old.patches or [ ] ++ [
(super.fetchpatch {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/ae7f8403e0552fababb2110bea2e436283230282/pkgs/tools/misc/file/PR-571-jschleus-Some-zip-files-are-misclassified-as-data.patch";
hash = "sha256-RVrL7P0Riu3hiLsVvGoGNsJctDplxaF7t+wW/zezdUg=";
})
];
});
})
];
environment.systemPackages = [ pkgs.file-patched ];
environment.sessionVariables = {
YAZI_FILE_ONE = "${lib.getExe pkgs.file-patched}";
};
|
Thanks @wolfgangwalther for finding that issue. In light of that, I am marking this PR as a draft, and perhaps in the near future we'll see a fix for the rest of the issue at upstream soon, which will can be added to this PR as well. You see it'll take time for the staging -> staging-next -> master cycle anyway, meaning you'll have to live with your local overlays a long time anyway. |
|
I wonder if it makes sense to revert file to 5.45. Misclassifying zip files is a major regression, so it might be worth it. |
|
I suppose it's better to revert than to try to monkeypatch it out temporarily, with the fix not even being as reliable. A little earlier this thread:
Especially with the new release coming up, I think it's better to go back to the more predictable $ cat OneDrive_1_3-7-2025.zip | file -
/dev/stdin: data
$ file OneDrive_1_3-7-2025.zip
OneDrive_1_3-7-2025.zip: data
$ file --version
file-5.46
magic file from /nix/store/2lnhqdy9zqbzg525hwab9cwfx9kz1cgh-file-5.46/share/misc/magic
$ nix shell github:nixos/nixpkgs/882842d2a908700540d206baa79efb922ac1c33d#file # https://lazamar.co.uk/nix-versions/?package=file&channel=nixpkgs-unstable
$ file OneDrive_1_3-7-2025.zip
OneDrive_1_3-7-2025.zip: Zip archive data, at least v2.0 to extract, compression method=store
$ cat OneDrive_1_3-7-2025.zip | file -
/dev/stdin: Zip archive data, at least v2.0 to extract, compression method=store
$ gh pr checkout 402318
$ nom-build -E '(import ./. {}).file.override { inherit (import <nixpkgs> {}) stdenv zlib updateAutotoolsGnuConfigScriptsHook; }' # cheat a little bit
$ ./result/bin/file ~/Downloads/OneDrive_1_3-7-2025.zip
/home/tomvd/Downloads/OneDrive_1_3-7-2025.zip: Zip archive data, at least v2.0 to extract, compression method=store
$ cat ~/Downloads/OneDrive_1_3-7-2025.zip | ./result/bin/file -
/dev/stdin: data |
|
You convinced me @dtomvan : I'll update this PR accordingly after the above will be merged. |
This reverts commit 75d2d3c, after multiple complains best summarized here: NixOS#402318 (comment)
This reverts commit 75d2d3c, after multiple complains best summarized here: #402318 (comment) (cherry picked from commit 7377f9e)
Description of changes
Things done
nix.conf? (See Nix manual)nix-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.