Conversation
In NixOS/nix#14584 mkString was changed to require an `EvalMemory`, part of a larger effort to centralize memory allocation.
|
A minimal flake to reproduce (which inlines the patch) is attached. You can test it with {
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { nixpkgs, ... }:
let
forAllSystems = f: nixpkgs.lib.genAttrs
[ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]
(system: f nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (pkgs:
let
nix = pkgs.nixVersions.nix_2_33;
nixComponents = pkgs.nixVersions.nixComponents_2_33;
nix-plugins-broken = pkgs.nix-plugins.override { inherit nixComponents; };
nix-plugins-fixed = nix-plugins-broken.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [
(pkgs.writeText "nix-2.33.patch" ''
--- a/extra-builtins.cc
+++ b/extra-builtins.cc
@@ -72,9 +72,9 @@ static void cflags(EvalState & state, const PosIdx _pos,
Value ** _args, Value & v)
{
auto attrs = state.buildBindings(3);
- attrs.alloc("NIX_INCLUDE_DIRS").mkString(NIX_INCLUDE_DIRS);
- attrs.alloc("NIX_CFLAGS_OTHER").mkString(NIX_CFLAGS_OTHER);
- attrs.alloc("BOOST_INCLUDE_DIR").mkString(BOOST_INCLUDE_DIR);
+ attrs.alloc("NIX_INCLUDE_DIRS").mkString(NIX_INCLUDE_DIRS, state.mem);
+ attrs.alloc("NIX_CFLAGS_OTHER").mkString(NIX_CFLAGS_OTHER, state.mem);
+ attrs.alloc("BOOST_INCLUDE_DIR").mkString(BOOST_INCLUDE_DIR, state.mem);
v.mkAttrs(attrs);
}
'')
];
});
extra-builtins = pkgs.writeText "extra-builtins.nix" ''
{ ... }: { hello = "nix-plugins works!"; }
'';
mkShell = nix-plugins: pkgs.mkShell {
packages = [ nix ];
NIX_CONFIG = ''
plugin-files = ${nix-plugins}/lib/nix/plugins
extra-builtins-file = ${extra-builtins}
'';
};
in
{
broken = mkShell nix-plugins-broken;
fixed = mkShell nix-plugins-fixed;
default = mkShell nix-plugins-fixed;
}
);
};
} |
|
For folks that don't want to manually patch but instead pin their devshell to nix 2.32 (latest version that nix-plugins will build in), you can do something like this: And as long as you do your work that needs the extra-builtins from your devshell, it'll work. The outer nix may be 2.33, but in the devshell it'll be 2.32. If you're using this for things like oddlama/nix-config where you have an |
|
Thanks! That work perfectly with the latest determinate(d) nix {inputs, ...}: {
imports = [
inputs.devshell.flakeModule
];
perSystem = {
pkgs,
system,
...
}: let
# inputs.determinate-nix.url = "https://flakehub.com/f/DeterminateSystems/nix-src/3.15.2.tar.gz";
determinate-nix = inputs.determinate-nix.packages."${system}".default;
nix-plugins-fixed = pkgs.nix-plugins.overrideAttrs (old: {
buildInputs = [determinate-nix pkgs.boost];
patches =
(old.patches or [])
++ [
(pkgs.writeText "nix-2.33.patch" ''
--- a/extra-builtins.cc
+++ b/extra-builtins.cc
@@ -72,9 +72,9 @@ static void cflags(EvalState & state, const PosIdx _pos,
Value ** _args, Value & v)
{
auto attrs = state.buildBindings(3);
- attrs.alloc("NIX_INCLUDE_DIRS").mkString(NIX_INCLUDE_DIRS);
- attrs.alloc("NIX_CFLAGS_OTHER").mkString(NIX_CFLAGS_OTHER);
- attrs.alloc("BOOST_INCLUDE_DIR").mkString(BOOST_INCLUDE_DIR);
+ attrs.alloc("NIX_INCLUDE_DIRS").mkString(NIX_INCLUDE_DIRS, state.mem);
+ attrs.alloc("NIX_CFLAGS_OTHER").mkString(NIX_CFLAGS_OTHER, state.mem);
+ attrs.alloc("BOOST_INCLUDE_DIR").mkString(BOOST_INCLUDE_DIR, state.mem);
v.mkAttrs(attrs);
}
'')
];
});
in {
devshells.default = {
packages = with pkgs; [
determinate-nix
];
env = [
{
name = "NIX_CONFIG";
value = ''
plugin-files = ${nix-plugins-fixed}/lib/nix/plugins
extra-builtins-file = ${./.}/extra-builtins.nix
'';
}
];
};
};
} |
|
Thanks all. However, |
As usual, NixOS 26.05 brings Nix 2.34, and Nix 2.34 brings broken changes. This patch will fix compile errors for Nix 2.34. BTW: This PR include shlevy#25 for it is required and still not be merged..
In NixOS/nix#14584 mkString was changed to require an
EvalMemory, part of a larger effort to centralize memory allocation.Disclaimer: Claude wrote this patch. While I am a software developer I'm not a C++ developer, nor do I have a lot of experience with Nix (yet). I just wanted to contribute back the fix.