From 140da2c03c7604cf68b86b0bec91b2d4b7be59c9 Mon Sep 17 00:00:00 2001 From: Antoine Eiche Date: Tue, 12 Mar 2019 10:29:56 +0100 Subject: [PATCH 1/2] sources.nix: Use the fetcher instead of creating derivations The created derivations were not enough well created to be handled by Hydra as a package [1]. Basically, Hydra recurses on the provided attribute set to figure out which attribute is a derivation. If an attribute set contains an attribut `type="derivation"`, it is consider as a derivation. But Hydra requires also more attributes such as a `name`, `system`... Since we are now using fetchers from `nixpkgs`, we can directly use them since they return a derviation. [1] I add all Niv derivations as packages in Hydra in order to copy them to the binary cache since it is no done at evaluation time. --- Main.hs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Main.hs b/Main.hs index 5f36468..9e5df12 100644 --- a/Main.hs +++ b/Main.hs @@ -631,18 +631,9 @@ with rec "file" = pkgs.fetchurl; }; }; -# NOTE: spec must _not_ have an "outPath" attribute -mapAttrs (_: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec - then - spec // - { outPath = getFetcher spec { inherit (spec) url sha256; } ; } - else spec - ) sources +mapAttrs + (_: spec: getFetcher spec { inherit (spec) url sha256; }) + sources |] -- | @nix/default.nix@ From 7243969625851001f9cda05c3794507dc20f67ba Mon Sep 17 00:00:00 2001 From: Antoine Eiche Date: Wed, 13 Mar 2019 19:27:37 +0100 Subject: [PATCH 2/2] sources.nix: add `niv` attribute set in derivations This `niv` attribute set contains all JSON attributes. JSON attributes are exposed in the `niv` attribute set inside the derivation to avoid name collision on the `type` attribute for instance. Note this is a breaking change since JSON attributes were in the derivation attribute set directly. --- Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 9e5df12..e81bb0c 100644 --- a/Main.hs +++ b/Main.hs @@ -632,7 +632,7 @@ with rec }; }; mapAttrs - (_: spec: getFetcher spec { inherit (spec) url sha256; }) + (_: spec: getFetcher spec { inherit (spec) url sha256; } // { niv = spec; }) sources |]