Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make overlays working #48

Open
xxxcrow opened this issue Oct 7, 2023 · 2 comments
Open

Can't make overlays working #48

xxxcrow opened this issue Oct 7, 2023 · 2 comments

Comments

@xxxcrow
Copy link

xxxcrow commented Oct 7, 2023

Hi, thank you for your well made config 😁
But it's taking me time to comprehend how your config works 😅
Currently i'm struggling with the overlays (i'm not really familiar with them)
My overlays look like:

# This file defines overlays
{ inputs, ... }: {
  # This one brings our custom packages from the 'pkgs' directory
  additions = final: _prev: import ../pkgs { pkgs = final; };

  # This one contains whatever you want to overlay
  # You can change versions, add patches, set compilation flags, anything really.
  # https://nixos.wiki/wiki/Overlays
  modifications = final: prev: {
    # example = prev.example.overrideAttrs (oldAttrs: rec {
    # ...
    # });
    wp4nix = import ./wp4nix.nix;
  };

  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
  # be accessible through 'pkgs.unstable'
  unstable-packages = final: _prev: {
    unstable = import inputs.nixpkgs-unstable {
      system = final.system;
#      config.allowUnfree = true;
    };
  };
}

and some of my uses are:

      package = "pkgs.unstable.syncthing";

and:

{pkgs, libs, inputs, outputs, ...}:
{
    nixpkgs.overlays = [
    (final: super: {
      nginxStable = super.nginxStable.override { openssl = super.pkgs.libressl; };
    })
    (self: super: {
      wordpressPackages = pkgs.unstable.callPackage inputs.wp4nix { };
    }
    )
  ];
}

and in all the cases overlays don't seem to work
so the syncthing is using 23.05, and wp4nix is not overlayed

there's probably something else i need to show here, but i'm not sure how the logic of your config works 😥

@Misterio77
Copy link
Owner

Misterio77 commented Nov 12, 2023

Hey!

There's no secret sauce to it, actually! Just plain ol' overlays in a separate file, which you can export to other people and/or use on your own config.

The included overlays are just examples, really. But, to actually use pkgs.unstable, you gotta apply that unstable overlay (which you are not doing). This is probably the issue.

Second, using pkgs inside an overlay is a no-no. This will almost def cause a infinite loop or something. You should only use the two arguments (super/prev or self/final). This should work:

{pkgs, libs, inputs, outputs, ...}:
{
    nixpkgs.overlays = [
      outputs.overlays.unstable-packages
      (final: prev: {
        nginxStable = prev.nginxStable.override { openssl = final.pkgs.libressl; };
      })
      (final: prev: {
        wordpressPackages = final.unstable.callPackage inputs.wp4nix { };
      })
  ];
}

Notice that overlays is an list, the order matters. Overlays are basically applied one after the other.

Also, It's not the easiest concept to grasp, but the first argument (in this example, final) is pkgs after that overlay is applied, and the second one (prev) is pkgs before the overlay is applied.

You usually always use final, unless you're accessing something that overlay modified (for example, nginxStable). In this case using final or prev does not matter much, but it's good practice.

@juangiordana
Copy link
Contributor

This is what I'm doing to apply my own Neovim flake to my overlays in nixpkgs-unstable.

I'm new to Nix so I'm sticking with stable and had problems adding the flake to it, since it follows unstable.

Can this be considered a good practice?

overlays/default.nix:

# This file defines overlays
{inputs, ...}: {
  # This one brings our custom packages from the 'pkgs' directory
  additions = final: _prev: import ../pkgs {pkgs = final;};

  # This one contains whatever you want to overlay
  # You can change versions, add patches, set compilation flags, anything really.
  # https://nixos.wiki/wiki/Overlays
  modifications = final: prev: {
    # example = prev.example.overrideAttrs (oldAttrs: rec {
    # ...
    # });
  };

  # When applied, the unstable nixpkgs set (declared in the flake inputs) will
  # be accessible through 'pkgs.unstable'
  unstable-packages = final: _prev: {
    unstable = import inputs.nixpkgs-unstable {
      system = final.system;
      config.allowUnfree = true;
      overlays = [
        inputs.neovim-flake.overlays.default
      ];
    };
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants