Skip to content

Commit

Permalink
Merge pull request tweag#94 from tweag/repository-file-deps
Browse files Browse the repository at this point in the history
Fix nix_file_deps on nixpkgs_local_repository
  • Loading branch information
mboes authored Oct 28, 2019
2 parents 2980a2f + cbedf6d commit a169f54
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ nixpkgs_git_repository(
nixpkgs_local_repository(
name = "nixpkgs",
nix_file = "//:nixpkgs.nix",
nix_file_deps = ["//:nixpkgs.json"],
)

nixpkgs_package(
Expand All @@ -39,6 +40,7 @@ nixpkgs_package(
nix_file_content = "let pkgs = import <nixpkgs> { 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(
Expand Down Expand Up @@ -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",
],
Expand Down
8 changes: 8 additions & 0 deletions nixpkgs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "NixOS",
"repo": "nixpkgs-channels",
"branch": "nixpkgs-unstable",
"rev": "0620e0fdbf4d79df771afd28f741b2159f381d2b",
"sha256": "046l2c83s568c306hnm8nfdpdhmgnbzgid354hr7p0khq3jx3lhf"
}

7 changes: 3 additions & 4 deletions nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a169f54

Please sign in to comment.