Cant update NVIDIA driver on stable branch

Flakes are amazing for pinning like this.

I use it often for neovim plugins especially.

Btw if you use neovim, I made this :slight_smile:

You can do it with fetch functions as well but its more verbose

https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#examples

This is where I got info of how to format URLs for flake inputs

1 Like

Thanks for the examples link. Neovim looks great. I am currently using VSCodium. If I feel brave enough for more new things, I might consider a switch. As a NixOS noob, still trying to get my system up and running, there is tons of information to figure out. I still have far more questions than answers.

1 Like

I started 3.5 months ago. I JUST figured out disko and installer isos lol

1 Like

Well done! It seems like you have learned a lot in that short period of time. My NixOS birthday was on January 29th, one week ago. Flakes and Overlays feels Greek to me. Have been stuck for a while now due to this NVIDIA issue. Had never heard about Disko before you mentioned it. Sounds smart as well. Ideally, I will manage to use NixOS to easily set up three different computers, so “script installers” (if that is an expression) is something I have to look into as well.

Well, I guess I should not clutter up this thread. I see a Discourse message telling me to consider writing DMs instead.

Anyhow, my system is still building. Hopefully, it will work when it is done. As well, maybe the PR / code change will be deployed soon. Then, I guess another build is needed.

1 Like

Overlays just cause a new pkgs object to be returned and used instead which contains whichever things the overlay adds to it.

(self: super: { jq = super.jq; })

This overlay, for example, would replace jq with itself lol

You would then either put it in a list and pass it to overlays when creating a new pkgs, or when using the nixpkgs.overlays module option used in the nvidia fix posted above (careful with the module option, it can lead to infinite recursion as it needs to be sequenced to happen before anything needs the pkgs, adding it when creating the pkgs option is preferred).

the two arguments for overlays are either called self: super: or final: prev: by convention and are the new and old pkgs sets before and after the overlay is called.

And flakes are just an agreed upon set of outputs (i.e. packages.${system} or nixosConfigurations), and a way to explicitly say where you are importing your nix channel from, as well as defining a way of importing things slightly nicer than fetch functions while still making sure everything is locked appropriately and still updatable either atomically or all at once.

They have inputs and outputs, (outputs is a function that recieves the things in inputs and a self variable and returns outputs of the agreed upon format) and a description.

The format is what allows the nicer command line syntax, because the cli has targets it can now look for.

The inputs are what allows for the lockfile, as now it knows what to put in the lockfile

The fetch functions are already locked because you need to put the hash. So those are locked by default, and not being in inputs is not an issue. anything fetched from the channel is locked to the version of the channel in the lockfile because thats the version of the channel you imported.

This makes importing from multiple channels very easy, and makes synchronizing your channels between machines, as well as between nixos and home manager, much easier, as now they are in the lock file and do not need to be configured via external commands.

As far as script installers go, I havent figured out remote provisioning yet, but my system flake I linked outputs an iso installer that you can generate, burn to usb, and then install via 1 command (or 2 commands if the target disk isnt /dev/sda), with an ease of use alias defined within the iso so that the 1 or 2 commands are shorter and easier to type. So maybe that will be a good example for you.

mine is x86_64-linux only so no vms yet but Im pretty sure you could just change the system variable to “i686-linux” and it would work in a vm? Figuring out that part soon. You would also probably have to regenerate hardware config within the vm first and then delete the nvidia stuff from the system config you chose because you dont have the same computer and stuff so it might be a couple more than 1 command depending on circumstances XD but for the hardware its designed for, its 1 command XD I will be making a separate vm config for it soon that should just work rather than needing to do all that.

Once again, thanks for your reply. To keep things tidy I created a new post:

And, I created this for Flakes:

As far as script installers go …

Thanks! I have saved the link.

By the way, the build process, using your mentioned solution, worked well!

I dont know how to on my end, but this can be closed now as Hydra has built the fix and it works.

https://nixpk.gs/pr-tracker.html?pr=286058

Its only in nixpkgs-unstable its not in nixos-unstable yet

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