Replacing module with unstable does not seem to work

Hi, I am a new user to NixOS. I have been trying to replace a module with an updated version from unstable, but it seems to be keeping the version from the stable packages. The services in particular are asusd and supergfxctl which should be version 5.1.2 and 5.0.2 from unstable but are instead 5.1.1 and 4.7.1 from stable. I am able to directly install unstable packages using overlays, as you can see with emacs at the bottom of the configuration.nix. Anyone have any idea what I am doing incorrectly with the modules?

flake.nix

{
  description = "Your new nix config";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager/release-23.11";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    hardware.url = "github:nixos/nixos-hardware";
  };

  outputs = {
    self,
    nixpkgs,  
    home-manager,
    ...
  } @ inputs: let
    inherit (self) outputs;
  in {
    overlays = import ./overlays {inherit inputs;};
    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem {
        specialArgs = {inherit inputs outputs;};
        modules = [
          # > Our main nixos configuration file <
          ./nixos/configuration.nix
        ];
      };
    };

  };
}

Relevant configuration.nix

{
  inputs,
  outputs,
  lib,
  config,
  pkgs,
  ...
}: {
  disabledModules =
    [
      "services/hardware/asusd.nix"
      "services/hardware/supergfxd.nix"
    ];
  imports = [
    inputs.hardware.nixosModules.asus-zephyrus-gu603h
    ./hardware-configuration.nix
    inputs.home-manager.nixosModules.home-manager
    "${inputs.nixpkgs-unstable}/nixos/modules/services/hardware/asusd.nix"
    "${inputs.nixpkgs-unstable}/nixos/modules/services/hardware/supergfxd.nix"
  ];

  nixpkgs = {
    # You can add overlays here
    overlays = [
      outputs.overlays.unstable-packages
    ];
    # Configure your nixpkgs instance
    config = {
      # Disable if you don't want unfree packages
      allowUnfree = true;
    };
  };  
  # Hardware
  services.supergfxd.enable = true;
  services.asusd.enable = true;
  services.asusd.enableUserService = true;

  environment.systemPackages = with pkgs; [
    vim
    git
    wget
    curl
    killall
    unstable.emacs
  ];
  ...

Looks right to me; when’s the last time you nix flake updated? Are you sure the module changes have made it to nixos-unstable?

I just ran nix flake update again. And nixos-unstable is at its latest version:

"nixpkgs": {
      "locked": {
        "lastModified": 1703200384,
        "narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "0b3d618173114c64ab666f557504d6982665d328",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-23.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-unstable": {
      "locked": {
        "lastModified": 1703255338,
        "narHash": "sha256-Z6wfYJQKmDN9xciTwU3cOiOk+NElxdZwy/FiHctCzjU=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "6df37dc6a77654682fe9f071c62b4242b5342e04",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },

I think the module changes have made it to nixos-unstable? The packages show as updated. The module files in the repo don’t look like they have been updated but I don’t see anything in them related to version.

I was able to solve the issue by modifying the module files from unstable and changing all references to pkgs.asusctl or pkgs.supergfxcl to pkgs.unstable.asusctl and pkgs.unstable.supergfxctl, utilizing my defined overlay. Still not sure why my original method does not work by itself, but this is an okay solution for now.

Ah, I see. That’s because you’re just substituting the module, injecting it into a nixpkgs with older packages. The package set stays the same.

Rather than hand-modifying the files, you could use an overlay to swap out the packages for newer ones:

nixpkgs.overlays = [(final: prev: {
  asusctl = pkgs.unstable.asusctl;
  supergfxctl = pkgs.unstable.supergfxctl;
})];

In that case maybe you don’t even need to substitute the modules if you don’t care for the changes to those.

1 Like