From 06fc8321370afb1aaf227196669893df35bfccea Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Mon, 28 Oct 2019 17:40:26 +0100 Subject: [PATCH 1/2] nixpkgs_local_repository: copy nix_file_deps And preserve the relative path to the repository root. --- nixpkgs/nixpkgs.bzl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl index a3d23d3bf..4bac218c3 100644 --- a/nixpkgs/nixpkgs.bzl +++ b/nixpkgs/nixpkgs.bzl @@ -38,12 +38,14 @@ def _nixpkgs_local_repository_impl(repository_ctx): ) target = repository_ctx.path("default.nix") else: - target = repository_ctx.path(repository_ctx.attr.nix_file) - _cp(repository_ctx, target, target.basename) + target = _cp(repository_ctx, repository_ctx.attr.nix_file) + + for dep in repository_ctx.attr.nix_file_deps: + _cp(repository_ctx, dep) # Make "@nixpkgs" (syntactic sugar for "@nixpkgs//:nixpkgs") a valid # label for the target Nix file. - repository_ctx.symlink(target.basename, repository_ctx.name) + repository_ctx.symlink(target, repository_ctx.name) nixpkgs_local_repository = repository_rule( implementation = _nixpkgs_local_repository_impl, From cbedf6d09b9f56d12515e69da7720f3b648d9b65 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Mon, 28 Oct 2019 17:59:19 +0100 Subject: [PATCH 2/2] Regression test: local_repository nix_file_deps --- WORKSPACE | 3 +++ nixpkgs.json | 8 ++++++++ nixpkgs.nix | 7 +++---- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 nixpkgs.json diff --git a/WORKSPACE b/WORKSPACE index 0470bc042..9a3a1c138 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,6 +20,7 @@ nixpkgs_git_repository( nixpkgs_local_repository( name = "nixpkgs", nix_file = "//:nixpkgs.nix", + nix_file_deps = ["//:nixpkgs.json"], ) nixpkgs_package( @@ -39,6 +40,7 @@ nixpkgs_package( nix_file_content = "let pkgs = import { config = {}; overlays = []; }; in pkgs.hello", # Deliberately not @nixpkgs, to test whether explict file works. repositories = {"nixpkgs": "//:nixpkgs.nix"}, + nix_file_deps = ["//:nixpkgs.json"], ) nixpkgs_package( @@ -101,6 +103,7 @@ nixpkgs_package( attribute_path = "hello", nix_file = "//tests:relative_imports.nix", nix_file_deps = [ + "//:nixpkgs.json", "//:nixpkgs.nix", "//tests:relative_imports/nixpkgs.nix", ], diff --git a/nixpkgs.json b/nixpkgs.json new file mode 100644 index 000000000..8716771ac --- /dev/null +++ b/nixpkgs.json @@ -0,0 +1,8 @@ +{ + "owner": "NixOS", + "repo": "nixpkgs-channels", + "branch": "nixpkgs-unstable", + "rev": "0620e0fdbf4d79df771afd28f741b2159f381d2b", + "sha256": "046l2c83s568c306hnm8nfdpdhmgnbzgid354hr7p0khq3jx3lhf" +} + diff --git a/nixpkgs.nix b/nixpkgs.nix index 2b7d682d5..3425ec91b 100644 --- a/nixpkgs.nix +++ b/nixpkgs.nix @@ -1,10 +1,9 @@ let # nixpkgs-unstable as of 2019-04-25 - nixpkgsRev = "0620e0fdbf4"; - nixpkgsSha256 = "046l2c83s568c306hnm8nfdpdhmgnbzgid354hr7p0khq3jx3lhf"; + spec = builtins.fromJSON (builtins.readFile ./nixpkgs.json); nixpkgs = fetchTarball { - url = "https://github.com/nixos/nixpkgs/archive/${nixpkgsRev}.tar.gz"; - sha256 = nixpkgsSha256; + url = "https://github.com/${spec.owner}/${spec.repo}/archive/${spec.rev}.tar.gz"; + sha256 = spec.sha256; }; in import nixpkgs