Direnv home-manager integration broken after 24.11 upgrade (was about terraform but only a symptom)

Hello everyone,

I used to have a simple shell.nix on a project that I only occasionally play with. I have done updates to this project using terraform from my nixos before ( last occurence 0ct 27 this year )

with import <nixpkgs> {config.allowUnfree=true;};

mkShell {
  name = "nix dev env";
  packages = [
      terraform
      kubernetes-helm
      msmtp
      bind.dnsutils
      k9s
    ];
}

So a vanilla terraform really. yestrday I wanted to push a small fix and I got

│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/null: failed to instantiate provider "registry.terraform.io/hashicorp/null" to obtain schema:
│ Unrecognized remote plugin message:
│ Failed to read any lines from plugin's stdout
│ This usually means
│   the plugin was not compiled for this architecture,
│   the plugin is missing dynamic-link libraries necessary to run,
│   the plugin is not executable by this process due to file permissions, or
│   the plugin failed to negotiate the initial go-plugin protocol handshake
│
│ Additional notes about plugin:
│   Path: .terraform/providers/registry.terraform.io/hashicorp/null/3.2.2/linux_amd
64/terraform-provider-null_v3.2.2_x5
│   Mode: -rwxr-xr-x
│   Owner: 1000 [jean] (current: 1000 [jean])
│   Group: 100 [users] (current: 100 [users])
│   ELF architecture: EM_X86_64 (current architecture: amd64)

I tried removing the .terraform directory and running init again but got another error this time :

╷
│ Error: Failed to install provider
│
│ Error while installing hashicorp/null v3.2.2: failed to open temporary file to download from https://releases.hashicorp.com/terraform-provider-null/3.2.2/terraform-provider-null_3.2.2_linux_amd64.zip: open
│ /tmp/nix-shell-123481-0/terraform-provider3862495864: no such file or directory

looking around, I notice that there are terraform-providers for all the plugins I use. I try to replace my naive terraform import and use terraform.withPlugins instead

with import <nixpkgs> {config.allowUnfree=true;};

mkShell {
  name = "nix dev env";
  packages = [
      (
        terraform.withPlugins(p:[
          p.null
        ])
      )
      kubernetes-helm
      msmtp
      bind.dnsutils
      k9s
    ];
}

I drop both .terraform and the .terraform.lock.hcl then run init again.
To no avail but with a different error this time.

│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/null: failed to instantiate provider "registry.terraform.io/hashicorp/null" to obtain schema:
│ Unrecognized remote plugin message:
│ Failed to read any lines from plugin's stdout
│ This usually means
│   the plugin was not compiled for this architecture,
│   the plugin is missing dynamic-link libraries necessary to run,
│   the plugin is not executable by this process due to file permissions, or
│   the plugin failed to negotiate the initial go-plugin protocol handshake
│
│ Additional notes about plugin:
│   Path: .terraform/providers/registry.terraform.io/hashicorp/null/3.2.3/linux_amd64/terraform-provider-null_3.2.3
│   Mode: -r-xr-xr-x
│   Owner: 0 [root] (current: 1000 [jean])
│   Group: 0 [root] (current: 100 [users])

running .terraform/providers/registry.terraform.io/hashicorp/null/3.2.3/linux_amd64/terraform-provider-null_3.2.3 directly yields

This binary is a plugin. These are not meant to be executed directly.
Please execute the program that consumes these plugins, which will
load any plugins automatically

which seems to point that it does and can run

I’m a bit at a loss as to how I can fix my install at this point. I don’t really care if the plugins versions have changed and introduced incompatibilities with my tf files. They are small and I don’t use fancy plugins so fixing the issues shouldn’t be a problem, but I can’t run anything for now :crying_cat_face:
the only “major” change I did recently is upgrading to 24.11

I further tried to use the terraform package from unstable but it fared no better.

What am I doing wrong ?

I’ve had this happen when I still was in an stale direnv shell without noticing. E.g. vscode tries to maintain terminal state across reboots.

Might help restarting your terminal?

This draft has been rewritten several times already as I tried further things

Out of desperation yesterday, I restarted the whole gnome-session then the whole laptop but still encountered the error.

today i tried a different approach and my conclusion is that the problem is not with terraform but somehow with my direnv setup as I can’t even run nix-shell properly it seems

~ ❯ z terraform
direnv: loading ~/dev/gmel/gmel/ops/terraform/.envrc
direnv: using nix
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_STORE +NM +OBJCOPY +OBJDUMP +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH ~XDG_DATA_DIRS
ops/terraform on  master [!?⇡] via 💠 default via ❄️  impure (nix-dev-env) ❯ nix-shell
error: creating directory '/tmp/nix-shell-197187-0/nix-shell-201944-0': No such file or directory
ops/terraform on  master [!?⇡] via 💠 default via ❄️  impure (nix-dev-env) ❯ nix-shell --pure
error: creating directory '/tmp/nix-shell-197187-0/nix-shell-202061-0': No such file or directory

if I comment out the use nix line in the .envrc

~ ❯ z terraform
direnv: loading ~/dev/gmel/gmel/ops/terraform/.envrc
ops/terraform on  master [!?⇡] via 💠 default ❯ nix-shell 
ops/terraform on  master [!?⇡] via 💠 default via ❄️  impure (nix-dev-env) ❯ nix-shell
ops/terraform on  master [!?⇡] via 💠 default via ❄️  impure (nix-dev-env) ❯ 

so now I need to figure out how I broke direnv…

I booted back to before I upgraded both nixos and homemanager to 24.11 and it everything works fine again.

unfortunately i upgraded both releases at the same time (same commit same switch)

I did try to downgrade home manager to 24.05 and test this with sudo nixos-rebuild test --flake ~/etc/nixos but I get the same error.

even accounting for all the changes I did since my first switch to 24.11,
the diff in my config is really small :

  • fixes a nix warning about sound.enable being deprecated
  • fixes an alacritty warning about a configuration schema change
  • enable fractional scaling for gnome
  • fix the gnome keyring ssh-agent exclusion because the gnome packages namespace has changed
  • fixes more gnome package namespace changes.
index fb5c83e..173ac85 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -94,8 +94,6 @@
   # Enable CUPS to print documents.
   services.printing.enable = true;
 
-  # Enable sound.
-  sound.enable = true;
   # hardware.pulseaudio.enable = true;
 
   # Enable touchpad support (enabled default in most desktopManager).
diff --git a/flake.nix b/flake.nix
index c3380d2..2f81e68 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,6 +1,6 @@
 {
   inputs = {
-    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
+    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
     
     nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable";
     
@@ -22,7 +22,7 @@
     };
 
     home-manager = {
-      url = "github:nix-community/home-manager/release-24.05";
+      url = "github:nix-community/home-manager/release-24.11";
       # The `follows` keyword in inputs is used for inheritance.
       # Here, `inputs.nixpkgs` of home-manager is kept consistent with
       # the `inputs.nixpkgs` of the current flake,
diff --git a/home/alacritty.nix b/home/alacritty.nix
index 9ca277f..ca0e2cc 100644
--- a/home/alacritty.nix
+++ b/home/alacritty.nix
@@ -6,13 +6,15 @@
     enable = true;
     # custom settings
     settings = {
-      shell = {
-        program = "tmux";
-        args = [
-          "new-session"
-          "-A"
-          "-s main"
-        ];
+      terminal = {
+        shell = {
+          program = "tmux";
+          args = [
+            "new-session"
+            "-A"
+            "-s main"
+          ];
+        };
       };
       env.TERM = "xterm-256color";
       font = {
diff --git a/home/gnome.nix b/home/gnome.nix
index 92dd205..85b987b 100644
--- a/home/gnome.nix
+++ b/home/gnome.nix
@@ -1,6 +1,9 @@
 {config, pkgs, ...}:
 {
   dconf.settings = {
+    "org/gnome/mutter" = {
+      experimental-features = [ "scale-monitor-framebuffer" ];
+    };
     "org/gnome/shell" = {
       favorite-apps = [
         "firefox.desktop"
diff --git a/system/gnome.nix b/system/gnome.nix
index 0e6f8a5..7b1692f 100644
--- a/system/gnome.nix
+++ b/system/gnome.nix
@@ -2,12 +2,10 @@
 {
   nixpkgs.overlays = [
     (final: prev: {
-       gnome = prev.gnome.overrideScope (gfinal: gprev: {
-         gnome-keyring = gprev.gnome-keyring.overrideAttrs ( oldAttrs: {
-           configureFlags = oldAttrs.configureFlags or [ ] ++ [
-             "--disable-ssh-agent"
-           ];
-         });
+       gnome-keyring = prev.gnome-keyring.overrideAttrs ( oldAttrs: {
+         configureFlags = (builtins.filter (flag: flag != "--enable-ssh-agent") oldAttrs.configureFlags) ++ [
+           "--disable-ssh-agent"
+         ];
        });
     })
   ];
@@ -15,13 +13,12 @@
     gnome-photos
     gnome-tour
   ]) ++ (with pkgs.gnome; [
-    gnome-music
-    epiphany # gnome web browser -> firefox
-    geary # email reader (to revisit ?)
-    tali #poker game
+#    epiphany # gnome web browser -> firefox
+#    geary # email reader (to revisit ?)
+    #tali #poker game
   ]);
   programs.dconf.enable = true;
   environment.systemPackages = with pkgs; [
-    gnome.gnome-tweaks
+    gnome-tweaks
   ];
 }

A friend told me they upgraded to 24.11 without any issue. I know they don’t use flakes and I’m almost sure they don’t use home-manager. on a hunch I disabled the home-manager direnv integration and enabled the nixos direnv integration.

sudo nixos-rebuild test --flake ~/etc/nixos was not enough to fix the problem but after a switchand a reboot everything is working again …

diff --git a/configuration.nix b/configuration.nix
index 173ac85..34ad099 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -163,6 +163,9 @@
       dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
       localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
     };
+    direnv = {
+      enable = true;
+    };
   };
   # List services that you want to enable:
   services.fprintd = {
diff --git a/home/direnv.nix b/home/direnv.nix
index 1f4dbc0..8a37c94 100644
--- a/home/direnv.nix
+++ b/home/direnv.nix
@@ -1,5 +1,5 @@
 { config, pkgs, ... }:

 {
-  programs.direnv.enable = true;
+#  programs.direnv.enable = true;
 }