Cant update NVIDIA driver on stable branch

And all you do is choose a comment to mark as having the solution and it will put a little checkmark in the box in the main message board

Hello,

Not so quick disclaimer : I am off this week and wanting to use the time to learn nix, so I installed it and aim for some objective to discover things : using flakes, using home manager, installing and configuring hyprland, but since I am using an nvidia graphic card it seems I need the proprietary driver.

From my understanding, the fix should be available soon, but I take this as an opportunity to learn and tried to apply the patch directly in my conf with what was gave in this thread but i got some errors, and i can’t understand why :

[root@nixos:/etc/nixos]# nix flake update
warning: Git tree '/etc/nixos' is dirty
warning: updating lock file '/etc/nixos/flake.lock':
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/25e3d4c0d3591c99929b1ec07883177f6ea70c9d' (2024-02-01)
  → 'github:NixOS/nixpkgs/9f2ee8c91ac42da3ae6c6a1d21555f283458247e' (2024-02-05)
warning: Git tree '/etc/nixos' is dirty

[root@nixos:/etc/nixos]# nixos-rebuild switch --flake .
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error:
       … while calling the 'head' builtin

         at /nix/store/ws5098bfhd2kzvg3yxwb2ggvl05h7gfd-source/lib/attrsets.nix:922:11:

          921|         || pred here (elemAt values 1) (head values) then
          922|           head values
             |           ^
          923|         else

       … while evaluating the attribute 'value'

         at /nix/store/ws5098bfhd2kzvg3yxwb2ggvl05h7gfd-source/lib/modules.nix:807:9:

          806|     in warnDeprecation opt //
          807|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          808|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'inputs' missing

       at /nix/store/ws5098bfhd2kzvg3yxwb2ggvl05h7gfd-source/lib/modules.nix:506:28:

          505|         builtins.addErrorContext (context name)
          506|           (args.${name} or config._module.args.${name})
             |                            ^
          507|       ) (lib.functionArgs f);

With --show-trace :

[root@nixos:/etc/nixos]# sudo nixos-rebuild switch --flake  /etc/nixos#nixos --show-trace
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: cached failure of attribute 'nixosConfigurations.nixos.config.system.build.toplevel'

My flake.nix :

[root@nixos:/etc/nixos]# cat flake.nix 
{
  description = "NixOS Flake";

  # This is the standard format for flake.nix.
  # `inputs` are the dependencies of the flake,
  # and `outputs` function will return all the build results of the flake.
  # Each item in `inputs` will be passed as a parameter to
  # the `outputs` function after being pulled and built.
  inputs = {
    # There are many ways to reference flake inputs.
    # The most widely used is `github:owner/name/reference`,
    # which represents the GitHub repository URL + branch/commit-id/tag.

    # Official NixOS package source, using nixos-23.11 branch here
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
    nixpkgs_patched.url = "github:nixos/nixpkgs/468a37e6ba01c45c91460580f345d48ecdb5a4db";

  };

  # `outputs` are all the build result of the flake.
  #
  # A flake can have many use cases and different types of outputs.
  # 
  # parameters in function `outputs` are defined in `inputs` and
  # can be referenced by their names. However, `self` is an exception,
  # this special parameter points to the `outputs` itself(self-reference)
  # 
  # The `@` syntax here is used to alias the attribute set of the
  # inputs's parameter, making it convenient to use inside the function.
  outputs = { self, nixpkgs, ... }@inputs: {
    nixosConfigurations = {
      # By default, NixOS will try to refer the nixosConfiguration with
      # its hostname, so the system named `nixos-test` will use this one.
      # However, the configuration name can also be specified using:
      #   sudo nixos-rebuild switch --flake /path/to/flakes/directory#<name>
      #
      # The `nixpkgs.lib.nixosSystem` function is used to build this
      # configuration, the following attribute set is its parameter.
      #
      # Run the following command in the flake's directory to
      # deploy this configuration on any NixOS system:
      #   sudo nixos-rebuild switch --flake .#nixos
      "nixos" = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";

        # The Nix module system can modularize configuration,
        # improving the maintainability of configuration.
        #
        # Each parameter in the `modules` is a Nixpkgs Module, and
        # there is a partial introduction to it in the nixpkgs manual:
        #    <https://nixos.org/manual/nixpkgs/unstable/#module-system-introduction>
        # It is said to be partial because the documentation is not
        # complete, only some simple introductions.
        # such is the current state of Nix documentation...
        #
        # A Nixpkgs Module can be an attribute set, or a function that
        # returns an attribute set. By default, if a Nixpkgs Module is a
        # function, this function has the following default parameters:
        #
        #  lib:     the nixpkgs function library, which provides many
        #             useful functions for operating Nix expressions:
        #             https://nixos.org/manual/nixpkgs/stable/#id-1.4
        #  config:  all config options of the current flake, very useful
        #  options: all options defined in all NixOS Modules
        #             in the current flake
        #  pkgs:   a collection of all packages defined in nixpkgs,
        #            plus a set of functions related to packaging.
        #            you can assume its default value is
        #            `nixpkgs.legacyPackages."${system}"` for now.
        #            can be customed by `nixpkgs.pkgs` option
        #  modulesPath: the default path of nixpkgs's modules folder,
        #               used to import some extra modules from nixpkgs.
        #               this parameter is rarely used,
        #               you can ignore it for now.
        #
        # The default parameters mentioned above are automatically
        # generated by Nixpkgs. 
        # However, if you need to pass other non-default parameters
        # to the submodules, 
        # you'll have to manually configure these parameters using
        # `specialArgs`. 
        # you must use `specialArgs` by uncommenting the following line:
        #
        # specialArgs = {...};  # pass custom arguments into all submodules.
        specialArgs = inputs;
        modules = [
          # Import the configuration.nix here, so that the
          # old configuration file can still take effect.
          # Note: configuration.nix itself is also a Nixpkgs Module,
          ./configuration.nix
        ];
      };
    };
  };
}

My configuration.nix

[root@nixos:/etc/nixos]# head -n30 configuration.nix 
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, inputs, ... }:

{
  nixpkgs.overlays = [ (self: super: (let
    patched_pkgs = import inputs.nixpkgs_patched {
      inherit (self) system;
      config.allowUnfree = true;
    };
  in {
    linuxPackages = patched_pkgs.linuxPackages;
  })) ];
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
  boot.kernelPackages = pkgs.linuxPackages;

  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix

      # Nvidia config
      # ./nvidia.nix
    ];


  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

[...]
}

Regards

You would need to pass inputs to your configuration.nix via specialArgs

    nixosConfigurations = {
      "nestOS" = nixpkgs.lib.nixosSystem {
        specialArgs = {
          hostname = "nestOS";
          inherit stateVersion self inputs users system-modules;
        };
        inherit system;
        modules = [
          disko.nixosModules.disko
          ./disko/PCs/sda_swap.nix
          ./systems/PCs/aSUS
        ];
      };
    };

This is one of my nixosConfigurations output by my flake. See how I pass things into specialArgs? Those will be accessible in the arguments set of every module loaded in that nixosConfiguration. That is how I access my flake inputs in configuration.nix

its on nixos-unstable now :slight_smile:

Thanks a lot, i switch

        specialArgs = inputs;

to

 specialArgs = {
     inputs = inputs;
};

and it work ! I need to get more familiarized with the nix language :slight_smile:

1 Like

so now a completely different problem with 6.7.4


using nvidia beta driver works though so yeah coool
it works with linux kernel stable and rc kernels so cool as well