Conversation
|
Not picked up automatically by ofborg, as expected. So, @GrahamcOfBorg build packageTests.fetchgit |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
probably needs documentation in |
|
can't get this to work diff --git a/pkgs/build-support/fetchfirefoxaddon/tests.nix b/pkgs/build-support/fetchfirefoxaddon/tests.nix
new file mode 100644
index 00000000000..05ee43aba29
--- /dev/null
+++ b/pkgs/build-support/fetchfirefoxaddon/tests.nix
@@ -0,0 +1,10 @@
+{ invalidateFetcherByDrvHash, fetchFirefoxAddon, ... }:
+
+{
+ simple = invalidateFetcherByDrvHash fetchFirefoxAddon {
+ name = "image-search-options";
+ # Chosen because its only 147KB
+ url = "https://addons.mozilla.org/firefox/downloads/file/3059971/image_search_options-3.0.12-fx.xpi";
+ sha256 = "1h768ljlh3pi23l27qp961v1hd0nbj2vasgy11bmcrlqp40zgvnr";
+ };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 161c48a3d48..d14a587eb11 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -516,7 +516,10 @@ with pkgs;
fetchhg = callPackage ../build-support/fetchhg { };
- fetchFirefoxAddon = callPackage ../build-support/fetchfirefoxaddon {};
+ fetchFirefoxAddon = callPackage ../build-support/fetchfirefoxaddon { }
+ // {
+ tests = callPackages ../build-support/fetchfirefoxaddon/tests.nix;
+ };
# `fetchurl' downloads a file from the network.
fetchurl = if stdenv.buildPlatform != stdenv.hostPlatformnix-repl> packageTests.fetchgit
{ recurseForDerivations = true; simple = «derivation /nix/store/5rl9by8nifg2k25rzp3yw5fdj303r6qn-nix-source-salted-v839ywjgprrp.drv»; }
nix-repl> packageTests.fetchFirefoxAddon
error: value is a function while a set was expected |
|
Diffception.
I also fall into this trap every now and then, fwiw.
yes. |
a9e5891 to
ac78ae8
Compare
roberth
left a comment
There was a problem hiding this comment.
I've cleaned up some minor docs issues while I was at it. I hope those will not hinder this pr.
|
|
||
| `fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time. | ||
|
|
||
| Other fetcher functions allow you to add source code directly from a VCS such as subversion or git. These are mostly straightforward nambes based on the name of the command used with the VCS system. Because they give you a working repository, they act most like `fetchzip`. |
There was a problem hiding this comment.
This was 90% stating the obvious. I've preserved the essence of the last sentence.
| When using Nix, you will frequently need to download source code and other files from the internet. Nixpkgs comes with a few helper functions that allow you to fetch fixed-output derivations in a structured way. | ||
| When using Nix, you will frequently need to download source code and other files from the internet. For this purpose, Nix provides the [_fixed output derivation_](https://nixos.org/manual/nix/stable/#fixed-output-drvs) feature and Nixpkgs provides various functions that implement the actual fetching from various protocols and services. | ||
|
|
||
| The two fetcher primitives are `fetchurl` and `fetchzip`. Both of these have two required arguments, a URL and a hash. The hash is typically `sha256`, although many more hash algorithms are supported. Nixpkgs contributors are currently recommended to use `sha256`. This hash will be used by Nix to identify your source. A typical usage of fetchurl is provided below. |
There was a problem hiding this comment.
The two fetcher primitives
There's no such thing.
The rest in the fetchurl section.
|
will having all the expressions in
nix-build doesn't work like that |
This adds about as much overhead as a package would. In most use cases it would go unnoticed like any other package. In cases where the whole of Nixpkgs is traversed, those traversals look for the |
|
@ofborg eval |
|
How would one run all the packageTests? |
|
@Artturin you generally wouldn't, if you mean literally all. @GrahamcOfBorg build packageTests.fetchgit |
This reverts commit 87b3740. packageTests wasn't inherently wrong, but I am not fully convinced that it is necessary. Specifically, it would only be used by: - `nix-build`, which is going to be a legacy command in the mid term - ofborg, perhaps, not even implemented whereas the following use cases do not need it: - `nix build` (experimental command with a future, unlike `nix-build`) - `release.nix` (Hydra), might use similar logic but not reuse this Further, considering that this is only necessary for tests of functions, I am hesitant to introduce it. Meanwhile, it should not hinder the rest of the PR.
|
I've removed packageTests wasn't inherently wrong, but I am not fully convinced
whereas the following use cases do not need it:
Further, considering that this is only necessary for tests of |
|
Not sure if I tested this or just assumed it still uses @GrahamcOfBorg build fetchgit.tests |
|
Confirmed. Ofborg tries to autocall the functor instead of using the attribute. I'll leave ofborg out of scope for now and merge this when ofborg is done. |
Motivation for this change
Make maintenance easier on the fetchers and avoid problems.
The
packageTestsattribute will serve two purposes:fetchgitCloses #133739
Refs #128749 #135881 or really all of topic: fetch
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)