Skip to content

Commit 083c1ce

Browse files
Profpatschmboes
authored andcommitted
Remove dirname hack from nix_path concatenation
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`).
1 parent 1b52674 commit 083c1ce

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

WORKSPACE

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,38 @@ nixpkgs_package(
1919

2020
nixpkgs_package(
2121
name = "hello",
22-
repositories = { "nixpkgs": "//:nix/default.nix" }
22+
repositories = { "nixpkgs": "//:nixpkgs.nix" }
2323
)
2424

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

3131
nixpkgs_package(
3232
name = "attribute-test",
3333
attribute_path = "hello",
34-
repositories = { "nixpkgs": "//:nix/default.nix" }
34+
repositories = { "nixpkgs": "//:nixpkgs.nix" }
3535
)
3636

3737
nixpkgs_package(
3838
name = "expr-attribute-test",
3939
nix_file_content = "import <nixpkgs> {}",
4040
attribute_path = "hello",
41-
repositories = { "nixpkgs": "//:nix/default.nix" },
41+
repositories = { "nixpkgs": "//:nixpkgs.nix" },
4242
)
4343

4444
nixpkgs_package(
4545
name = "nix-file-test",
4646
nix_file = "//tests:nixpkgs.nix",
4747
attribute_path = "hello",
48-
repositories = { "nixpkgs": "//:nix/default.nix" },
48+
repositories = { "nixpkgs": "//:nixpkgs.nix" },
4949
)
5050

5151
nixpkgs_package(
5252
name = "nix-file-deps-test",
5353
nix_file = "//tests:hello.nix",
5454
nix_file_deps = ["//tests:pkgname.nix"],
55-
repositories = { "nixpkgs": "//:nix/default.nix" },
55+
repositories = { "nixpkgs": "//:nixpkgs.nix" },
5656
)

nix/default.nix nixpkgs.nix

File renamed without changes.

nixpkgs/nixpkgs.bzl

+2-5
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@ def _nixpkgs_package_impl(ctx):
7979
# unless a pinned nixpkgs is set in the `nix_file` attribute.
8080
nix_path = ""
8181
if repositories:
82-
# XXX Another hack: the repository label typically resolves to
83-
# some top-level package in the external workspace. So we use
84-
# dirname to get the actual workspace path.
8582
nix_path = ":".join(
86-
[(path_name + "=" + str(ctx.path(path).dirname))
87-
for (path, path_name) in repositories.items()])
83+
[(path_name + "=" + str(ctx.path(target)))
84+
for (target, path_name) in repositories.items()])
8885
elif not (ctx.attr.nix_file or ctx.attr.nix_file_content):
8986
fail(strFailureImplicitNixpkgs)
9087

shell.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs ? import ./nix/default.nix {} }:
1+
{ pkgs ? import ./nixpkgs.nix {} }:
22

33
with pkgs;
44

0 commit comments

Comments
 (0)