Overlays in flakes on other things than nixpkgs

I’m trying to move my home manager config to a pure flake. Currently I still have a number of import (builtins.fetchGit {-statements at the top of the file to pin some specific packages.

I also have the Emacs Overlay and some additional overlays on that. I can’t figure out how to move these imports into the flake inputs and still keep the overlays. nixpkgs.overlays doesn’t seem to cover this case as I’m not overlaying the default pkgs variable (and want to keep that untouched) but rather a separate import of nixpkgs with its own version.


You can just set nixpkgs overlays. Details depend on the individual inputs you consume. Usually its something like nixpkgs.overlays = [ theInput.overlay.default ];.

How to get the inputs into the actual module is briefly described in a blogpost of mine. Even though it uses a package in the example, it is the same for overlays, just that you access a different output of the flake.


Without looking too closely at your exact config, something like this would do that:

# flake.nix
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
    nixpkgs-separate.url = "github:NixOS/nixpkgs/nixos-unstable"; # substitute whatever version you want
    emacs-overlay.url = "github:nix-community/emacs-overlay";

  outputs = { nixpkgs, nixpkgs-separate, emacs-overlay, ... } @ inputs: {
    nixosConfigurations.SKyeloftspc = let
      system = "x86_64-linux";
      pkgs-overlayed = import nixpkgs-separate {
        inherit system;
        overlays = [ emacs-overlay.overlays.default ];
    in nixpkgs.lib.nixosSystem {
      inherit system;
      # Use your favorite mechanism from @NobbZ' blog 
      specialArgs.flake-inputs = inputs // { inherit pkgs-overlayed; };
      # As an example
      modules = [{ flake-inputs, ... }: {
        services.emacs.package = flake-inputs.pkgs-overlayed.emacs;


That just leaves me with the existing allowUnfree = true; not working bug, but I can survive with --impure till that’s fixed