Skip to content

Commit

Permalink
Remove dirname hack from nix_path concatenation
Browse files Browse the repository at this point in the history
Previously we applied `dirname` to each path, which meant we could
only use nix files named `default.nix` (because of nix’s defaulting to
that file). Now we can name files directly (see the `WORKSPACE` file
for an example that calls `nixpksgs-pin.nix`).
  • Loading branch information
Profpatsch authored and mboes committed Oct 23, 2018
1 parent 1b52674 commit 083c1ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,38 @@ nixpkgs_package(

nixpkgs_package(
name = "hello",
repositories = { "nixpkgs": "//:nix/default.nix" }
repositories = { "nixpkgs": "//:nixpkgs.nix" }
)

nixpkgs_package(
name = "expr-test",
nix_file_content = "let pkgs = import <nixpkgs> {}; in pkgs.hello",
repositories = { "nixpkgs": "//:nix/default.nix" }
repositories = { "nixpkgs": "//:nixpkgs.nix" }
)

nixpkgs_package(
name = "attribute-test",
attribute_path = "hello",
repositories = { "nixpkgs": "//:nix/default.nix" }
repositories = { "nixpkgs": "//:nixpkgs.nix" }
)

nixpkgs_package(
name = "expr-attribute-test",
nix_file_content = "import <nixpkgs> {}",
attribute_path = "hello",
repositories = { "nixpkgs": "//:nix/default.nix" },
repositories = { "nixpkgs": "//:nixpkgs.nix" },
)

nixpkgs_package(
name = "nix-file-test",
nix_file = "//tests:nixpkgs.nix",
attribute_path = "hello",
repositories = { "nixpkgs": "//:nix/default.nix" },
repositories = { "nixpkgs": "//:nixpkgs.nix" },
)

nixpkgs_package(
name = "nix-file-deps-test",
nix_file = "//tests:hello.nix",
nix_file_deps = ["//tests:pkgname.nix"],
repositories = { "nixpkgs": "//:nix/default.nix" },
repositories = { "nixpkgs": "//:nixpkgs.nix" },
)
File renamed without changes.
7 changes: 2 additions & 5 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,9 @@ def _nixpkgs_package_impl(ctx):
# unless a pinned nixpkgs is set in the `nix_file` attribute.
nix_path = ""
if repositories:
# XXX Another hack: the repository label typically resolves to
# some top-level package in the external workspace. So we use
# dirname to get the actual workspace path.
nix_path = ":".join(
[(path_name + "=" + str(ctx.path(path).dirname))
for (path, path_name) in repositories.items()])
[(path_name + "=" + str(ctx.path(target)))
for (target, path_name) in repositories.items()])
elif not (ctx.attr.nix_file or ctx.attr.nix_file_content):
fail(strFailureImplicitNixpkgs)

Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs ? import ./nix/default.nix {} }:
{ pkgs ? import ./nixpkgs.nix {} }:

with pkgs;

Expand Down

0 comments on commit 083c1ce

Please sign in to comment.