Skip to content

Commit f4d32e0

Browse files
committed
nixForLinking: init
Overlays for CppNix nightly, Lix, or Tvix want to change the default Nix implementation in Nixpkgs by overriding `pkgs.nix`. However, some packages link against the internal/unstable CppNix APIs directly, and these packages will break if built with different versions or implementations of Nix. If you want to swap out the Nix implementation in your package set, you don't want these packages to break. Therefore, some packages will refer to `nixForLinking` explicitly, at least until these dependencies can be sorted out. The addition of an explicit `nixForLinking` attribute decoupled from `nix`, which is just "a Nix implementation", will help Nix implementation maintainers test Nix implementations in Nixpkgs with minimal hassle.
1 parent 63d0ef6 commit f4d32e0

File tree

7 files changed

+40
-17
lines changed

7 files changed

+40
-17
lines changed

pkgs/build-support/node/fetch-yarn-deps/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
makeSetupHook,
1818
cacert,
1919
callPackage,
20-
nix,
20+
nixForLinking,
2121
}:
2222

2323
let
@@ -54,7 +54,7 @@ in
5454
lib.makeBinPath [
5555
coreutils
5656
nix-prefetch-git
57-
nix
57+
nixForLinking
5858
]
5959
}
6060

pkgs/by-name/at/attic-client/package.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
lib,
33
rustPlatform,
44
fetchFromGitHub,
5-
nix,
5+
nixForLinking,
66
nixosTests,
77
boost,
88
pkg-config,
@@ -29,7 +29,7 @@ rustPlatform.buildRustPackage {
2929

3030
buildInputs =
3131
[
32-
nix
32+
nixForLinking
3333
boost
3434
]
3535
++ lib.optionals stdenv.hostPlatform.isDarwin (
@@ -44,7 +44,7 @@ rustPlatform.buildRustPackage {
4444
useFetchCargoVendor = true;
4545

4646
ATTIC_DISTRIBUTOR = "nixpkgs";
47-
NIX_INCLUDE_PATH = "${lib.getDev nix}/include";
47+
NIX_INCLUDE_PATH = "${lib.getDev nixForLinking}/include";
4848

4949
# Attic interacts with Nix directly and its tests require trusted-user access
5050
# to nix-daemon to import NARs, which is not possible in the build sandbox.

pkgs/by-name/nu/nurl/package.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
darwin,
99
gitMinimal,
1010
mercurial,
11-
nix,
11+
nixForLinking,
1212
}:
1313

1414
rustPlatform.buildRustPackage rec {
@@ -47,7 +47,7 @@ rustPlatform.buildRustPackage rec {
4747
lib.makeBinPath [
4848
gitMinimal
4949
mercurial
50-
nix
50+
nixForLinking
5151
]
5252
}
5353
installManPage artifacts/nurl.1

pkgs/development/tools/language-servers/nixd/default.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
llvmPackages,
99
meson,
1010
ninja,
11-
nix,
11+
nixForLinking,
1212
nix-update-script,
1313
nixd,
1414
nixf,
@@ -101,12 +101,12 @@ in
101101
];
102102

103103
buildInputs = [
104-
nix
104+
nixForLinking
105105
gtest
106106
boost
107107
];
108108

109-
env.CXXFLAGS = "-include ${nix.dev}/include/nix/config.h";
109+
env.CXXFLAGS = "-include ${nixForLinking.dev}/include/nix/config.h";
110110

111111
passthru.tests.pkg-config = testers.hasPkgConfigModules {
112112
package = nixt;
@@ -127,7 +127,7 @@ in
127127
sourceRoot = "${common.src.name}/nixd";
128128

129129
buildInputs = [
130-
nix
130+
nixForLinking
131131
nixf
132132
nixt
133133
llvmPackages.llvm
@@ -137,7 +137,7 @@ in
137137

138138
nativeBuildInputs = common.nativeBuildInputs ++ [ cmake ];
139139

140-
env.CXXFLAGS = "-include ${nix.dev}/include/nix/config.h";
140+
env.CXXFLAGS = "-include ${nixForLinking.dev}/include/nix/config.h";
141141

142142
# See https://github.com/nix-community/nixd/issues/519
143143
doCheck = false;

pkgs/tools/package-management/nix-du/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
stdenv,
44
fetchFromGitHub,
55
rustPlatform,
6-
nix,
6+
nixForLinking,
77
nlohmann_json,
88
boost,
99
graphviz,
@@ -27,13 +27,13 @@ rustPlatform.buildRustPackage rec {
2727

2828
doCheck = true;
2929
nativeCheckInputs = [
30-
nix
30+
nixForLinking
3131
graphviz
3232
];
3333

3434
buildInputs = [
3535
boost
36-
nix
36+
nixForLinking
3737
nlohmann_json
3838
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security ];
3939

pkgs/tools/package-management/nix-prefetch-scripts/default.nix

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{ lib, stdenv, makeWrapper, buildEnv
2-
, bash, breezy, coreutils, cvs, findutils, gawk, git, git-lfs, gnused, mercurial, nix, subversion
2+
, bash, breezy, coreutils, cvs, findutils, gawk, git, git-lfs, gnused, mercurial
3+
, # FIXME: These scripts should not depend on Nix, they should depend on a
4+
# `.nar` hasher compatible with Nix.
5+
#
6+
# The fact that these scripts depend on Nix means that e.g. Chromium depends
7+
# on Nix.
8+
#
9+
# Also should be fixed:
10+
# - prefetch-yarn-deps
11+
# - nurl, nix-init
12+
#
13+
# Gridlock is one such candidate: https://github.com/lf-/gridlock
14+
nixForLinking
15+
, subversion
316
}:
417

518
let mkPrefetchScript = tool: src: deps:
@@ -15,7 +28,7 @@ let mkPrefetchScript = tool: src: deps:
1528
installPhase = ''
1629
install -vD ${src} $out/bin/$name;
1730
wrapProgram $out/bin/$name \
18-
--prefix PATH : ${lib.makeBinPath (deps ++ [ coreutils gnused nix ])} \
31+
--prefix PATH : ${lib.makeBinPath (deps ++ [ coreutils gnused nixForLinking ])} \
1932
--set HOME /homeless-shelter
2033
'';
2134

pkgs/top-level/all-packages.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17562,6 +17562,16 @@ with pkgs;
1756217562

1756317563
nix = nixVersions.stable;
1756417564

17565+
# Overlays for CppNix nightly, Lix, or Tvix want to change the default Nix
17566+
# implementation in Nixpkgs by overriding `pkgs.nix`. However, some packages
17567+
# link against the internal/unstable CppNix APIs directly, and these packages
17568+
# will break if built with different versions or implementations of Nix.
17569+
#
17570+
# If you want to swap out the Nix implementation in your package set, you
17571+
# don't want these packages to break. Therefore, some packages will refer to
17572+
# `nixForLinking` explicitly, at least until these dependencies can be sorted out.
17573+
nixForLinking = nixVersions.stable;
17574+
1756517575
nixStatic = pkgsStatic.nix;
1756617576

1756717577
lixVersions = recurseIntoAttrs (callPackage ../tools/package-management/lix {

0 commit comments

Comments
 (0)