From 083c1ced089049d927aaa791196116b725074314 Mon Sep 17 00:00:00 2001 From: Philip Patsch Date: Tue, 23 Oct 2018 18:54:10 +0200 Subject: [PATCH] Remove `dirname` hack from nix_path concatenation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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`). --- WORKSPACE | 12 ++++++------ nix/default.nix => nixpkgs.nix | 0 nixpkgs/nixpkgs.bzl | 7 ++----- shell.nix | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) rename nix/default.nix => nixpkgs.nix (100%) diff --git a/WORKSPACE b/WORKSPACE index 731c028ee..a87418d10 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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 {}; 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 {}", 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" }, ) diff --git a/nix/default.nix b/nixpkgs.nix similarity index 100% rename from nix/default.nix rename to nixpkgs.nix diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl index f1e73b2a6..f63730886 100644 --- a/nixpkgs/nixpkgs.bzl +++ b/nixpkgs/nixpkgs.bzl @@ -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) diff --git a/shell.nix b/shell.nix index 19d33dff5..23b3e10da 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -{ pkgs ? import ./nix/default.nix {} }: +{ pkgs ? import ./nixpkgs.nix {} }: with pkgs;