From 78a66fe898d8d4b4286e45e831dcd87f1e9b21ba Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Thu, 17 Mar 2022 16:54:20 +0100 Subject: [PATCH] flake-compat: use builtins.fetchTree if available --- flake.lock | 6 +++--- nix/flake-compat.nix | 17 +++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 1977e693049..f4f87eca5eb 100644 --- a/flake.lock +++ b/flake.lock @@ -496,11 +496,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1638445031, - "narHash": "sha256-dtIZLlf2tfYeLvpZa/jFxP5HvfoXAzr7X76yn6FQAdM=", + "lastModified": 1647532380, + "narHash": "sha256-wswAxyO8AJTH7d5oU8VK82yBCpqwA+p6kLgpb1f1PAY=", "owner": "input-output-hk", "repo": "flake-compat", - "rev": "20f79e3976b76a37090fbeec7b49dc08dac96b8e", + "rev": "7da118186435255a30b5ffeabba9629c344c0bec", "type": "github" }, "original": { diff --git a/nix/flake-compat.nix b/nix/flake-compat.nix index 47ec2b7ed71..e62cfa47e55 100644 --- a/nix/flake-compat.nix +++ b/nix/flake-compat.nix @@ -4,16 +4,13 @@ let lock = builtins.fromJSON (builtins.readFile (src + "/flake.lock")); flake-compate-input = lock.nodes.root.inputs.flake-compat; nixpkgs-input = lock.nodes.haskellNix.inputs.${builtins.elemAt lock.nodes.root.inputs.nixpkgs 1}; - flake-compat = import (builtins.fetchTarball { - url = "https://api.github.com/repos/input-output-hk/flake-compat/tarball/${lock.nodes.${flake-compate-input}.locked.rev}"; - sha256 = lock.nodes.${flake-compate-input}.locked.narHash; - }); - pkgs = import - (builtins.fetchTarball { - url = "https://api.github.com/repos/NixOS/nixpkgs/tarball/${lock.nodes.${nixpkgs-input}.locked.rev}"; - sha256 = lock.nodes.${nixpkgs-input}.locked.narHash; - }) - { }; + fetchTree = builtins.fetchTree or (info: + builtins.fetchTarball { + url = "https://api.github.com/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; + sha256 = info.narHash; + }); + flake-compat = import (fetchTree lock.nodes.${flake-compate-input}.locked); + pkgs = import (fetchTree lock.nodes.${nixpkgs-input}.locked) { }; in flake-compat { inherit src pkgs;