Override package attributes using flakes

Dear all, I am trying to overide the extraPkgs attribute of the steam package in my config using flakes. This is where I am at right now:

  outputs =
    { self, nixos, nixos-unstable, emacs-overlay, home-manager, agenix }:
    let
      system = "x86_64-linux";
      pkgs = mkPkgs (import nixos) [
        (_: super: { steam = super.steam // { extraPkgs = pkgs: [ pkgs.libpng ]; }; })
      ];
      pkgs-unstable = mkPkgs (import nixos-unstable) [ ];
      mkPkgs = pkgs: overlays:
        pkgs {
          inherit system;
          overlays = [ emacs-overlay.overlay ] ++ overlays;
          config.allowUnfree = true;
        };
    in {
      nixosConfigurations.nixosLaptop = nixos.lib.nixosSystem {
        inherit pkgs system;
        specialArgs = { inherit pkgs pkgs-unstable; };
        modules = [
          ./laptop.nix
          nixos.nixosModules.notDetected
          home-manager.nixosModules.home-manager
          {
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              users.tim = import ./common/commonHome.nix;
            };
          }
        ];
      };

I then set programs.steam.enable = true; but unfortunately it seems like libpng is still missing within steam. I am trying to run the game Dead Cells, without flakes I just had this in my config:

nixpkgs.config = {
    # Enable unfree packages (chrome)
    allowUnfree = true;
    packageOverrides = pkgs: {
      steam = pkgs.steam.override {
        extraPkgs = pkgs:
          with pkgs;
          [
            libpng # for dead cells
          ];
      };
    };
  };

I have found this question but unfortunately it is not quite what I need. Can anybody help me with this issue? Many Thanks!! Also please let me know if you need more information.

I found the solution by reading the overlay wiki article which explains that it should be:

      pkgs = mkPkgs (import nixos) [
        (_: super: {
          steam = super.steam.override { extraPkgs = pkgs: [ pkgs.libpng ]; };
        })
      ];

my only issue so far is actually finding the documentation that I need :stuck_out_tongue:

1 Like