about summary refs log tree commit diff
path: root/nixos/lib/nixpkgs.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/lib/nixpkgs.nix')
-rw-r--r--nixos/lib/nixpkgs.nix8
1 files changed, 8 insertions, 0 deletions
diff --git a/nixos/lib/nixpkgs.nix b/nixos/lib/nixpkgs.nix
new file mode 100644
index 000000000000..10096f58c79a
--- /dev/null
+++ b/nixos/lib/nixpkgs.nix
@@ -0,0 +1,8 @@
+/* Terrible backward compatibility hack to get the path to Nixpkgs
+   from here.  Usually, that's the relative path ‘../..’.  However,
+   when using the NixOS channel, <nixos> resolves to a symlink to
+   nixpkgs/nixos, so ‘../..’ doesn't resolve to the top-level Nixpkgs
+   directory but one above it.  So check for that situation. */
+if builtins.pathExists ../../.version then import ../..
+else if builtins.pathExists ../../nixpkgs then import ../../nixpkgs
+else abort "Can't find Nixpkgs, please set ‘NIX_PATH=nixpkgs=/path/to/nixpkgs’."