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

How to add overlays such as emacs-overlay to primary nixpkgs #55

Open
ParetoOptimalDev opened this issue Nov 14, 2023 · 1 comment
Open

Comments

@ParetoOptimalDev
Copy link

This is partially covered in #48, however that's for if you want to add to the unstable-packages overlay.

I've instead:

  • switched my primary nixpkgs to unstable
  • created a stable overlay

I added it to my inputs:

      emacs-overlay.url  = "github:nix-community/emacs-overlay";

This makes available pkgs.inputs.emacs-overlay.emacs-pgtk for example, which partially works.

However for some reason, it doesn't seem to also include pkgs.inputs.emacs-overlay.emacsWithPackagesFromUsePackage for some reason.

Maybe this is some sort of merging error?

Also, if I wanted to include the override so that I could just use pkgs.emacs-pgtk throughout my configuration, how would I do that in this config?

Thanks!

@schwanberger
Copy link

schwanberger commented Dec 6, 2023

I also had some issues with using the emacs overlay properly.

In the hopes of helping someone in the future, I have achieved the following

  • opt-in of the emacs overlay, following nixpkgs-unstable per nixos config
  • setting up nix-community cachix for downloading the emacs versions already compiled (until then I always compiled emacs from source which was sad)

Assuming the standard template, I made these changes:
(overlays/default.nix)

  unstable-packages-emacs-overlay = final: _prev: {
    unstable-emacs-overlay = import inputs.nixpkgs-unstable {
      system = final.system;
      config.allowUnfree = true;
      overlays = [ (import inputs.emacs-overlay) ];
    };
  };

(flake.nix)

...
  nixConfig = {
    extra-substituters = [
      # Nix community's cache server
      "https://nix-community.cachix.org"
      # Devenv cachix - doing some testing
      "https://devenv.cachix.org"
    ];
    extra-trusted-public-keys = [
      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
    ];
  };
...
inputs = {
...
    emacs-overlay = {
      url = "github:nix-community/emacs-overlay";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
    };
...
}

In NixOS module (nixos/configuration.nix)

{ inputs, outputs, lib, config, pkgs, ... }:
let
  emacs-pgtk-unstable = with pkgs.unstable-emacs-overlay;
    [
      ((emacsPackagesFor emacs-unstable-pgtk).emacsWithPackages
        (epkgs: with epkgs; [ vterm sqlite ]))
    ];
in {
...
  nixpkgs = {
    # You can add overlays here
    overlays = [
      # Add overlays your own flake exports (from overlays and pkgs dir):
      outputs.overlays.additions
      outputs.overlays.modifications
      outputs.overlays.unstable-packages
      outputs.overlays.unstable-packages-emacs-overlay
...
  nix = {
    settings = {
      # Enable flakes and new 'nix' command
      experimental-features = "nix-command flakes";
      # Deduplicate and optimize nix store
      auto-optimise-store = true;
      substituters =
        [ "https://nix-community.cachix.org" "https://devenv.cachix.org" ];
      trusted-public-keys = [
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
        "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
      ];
      trusted-users = [ "root" "@wheel" ];
    };
  };
...

I can then get the emacs version I want from the overlay (controlled via flake.lock) like so:

  environment.systemPackages = with pkgs.unstable; [ ... ] ++ emacs-pgtk-unstable;

In case you're interested, I made my nix config publicly available here: https://github.com/schwanberger/nix

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

2 participants