Open davidak opened 4 years ago
If it's no longer a single file, the fixed-output hash of the result changes by definition, so we can't simply change the default there.
It could e.g. be a parameter that you'd pass to the fetchurl
call in case you wanted. Perhaps it would be useful to even allow specifying a longer chain of directories (say, share/fonts/opentype
in this case).
There is a relevant stripHash
bash function provided by stdenv.
I marked this as stale due to inactivity. → More info
I get bitten by this frequently. Except for backward compatibility arguments is there really any reason to change file names in the first place?
Simplicity, I'd say.
Not creating a "useless" directory. You can't have completely custom name directly under /nix/store/
.
Also, if you put it into a directory, you can no longer use the plain hash you got e.g. from upstream website. At least unless you split it into two derivations: keep the fixed-output download as is and add another wrapper that just copies the file into the desired location, but that's even more complication and expenses.
I marked this as stale due to inactivity. → More info
In the workaround, to avoid repeating the filename for postFetch
, one can use:
pkgs.fetchurl rec {
url = "https://github.com/path/to/your/single-file.ttf";
hash = "sha256-YOURHASH";
downloadToTemp = true;
postFetch = "install -D $downloadedFile $out/" + builtins.baseNameOf url;
recursiveHash = true;
}
Alternatively the same, but with builtins.fetchurl
, which has the advantage that the provided hash is identical to the one you would get with sha256sum
on the actual file, that you download:
pkgs.stdenv.mkDerivation rec {
name = "YOURNAME";
fetchurl = "https://github.com/path/to/your/single-file.ttf";
src = builtins.fetchurl {
url = fetchurl;
name = "fetchurl";
sha256 = "YOURHASH";
};
dontUnpack = true;
installPhase = "install -D $src $out/" + builtins.baseNameOf fetchurl;
};
Describe the bug When fetchurl get's a single file, it adds it to the nix store with a hash. That makes it hard to work with that file.
When installing it, it will have this messed up name.
To Reproduce Steps to reproduce the behavior:
Expected behavior It would help if fetchurl creates a folder, even for a single file.
Workaround