Applying an overlay in flake for custom package

I made a custom package then I spent a few hours trying to add a custom package in a flake in my main nixOS flake.

As per Xe’s guide, I added an overlay in the custom package’s flake:

  outputs = { self, nixpkgs }: {
    overlay = final: prev: { muttdown = prev.pkgs.callPackage ./derivation.nix { }; };

    packages.x86_64-linux.muttdown = nixpkgs.legacyPackages.x86_64-linux.callPackage ./derivation.nix {};

    packages.x86_64-linux.default = self.packages.x86_64-linux.muttdown;


Then added the overlay

  description = "Jevin's Humi Home Manager configuration";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs
    home-manager.url                    = "github:nix-community/home-manager/release-22.11";
    nixpkgs.url                         = "github:NixOS/nixpkgs/nixos-22.11";
    nixos-hardware.url                  = "github:NixOS/nixos-hardware";
    nixpkgs-unstable.url                = "github:NixOS/nixpkgs/nixos-unstable";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    muttdown.url                        = "path:./custom_packages/muttdown/";
    stylix.url                          = "github:danth/stylix";
  outputs = { home-manager, stylix, nixpkgs, nixpkgs-unstable, nixos-hardware, muttdown, ... }@inputs:

    # Modeling it after:
      system = "x86_64-linux";
      overlay-unstable = final: prev: {
        unstable = import nixpkgs-unstable {
          inherit system;
          config.allowUnfree = true;
    in {
    nixosConfigurations = {
     # <... Extra hosts removed for clarity... >

      framework = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        specialArgs = { inherit inputs; }; # Pass flake inputs to our config
        overlays = [ overlay-unstable muttdown.overlay];
        modules = [
          stylix.nixosModules.stylix ./theme-personal.nix
            home-manager = {
              useGlobalPkgs = true;
              useUserPackages = true;
              extraSpecialArgs = { inherit stylix; };
              users = {
                jevin     = import ./jevin-linux.nix;
                jevinhumi = import ./work-linux.nix;




When rebuilding, I get the error:

warning: Git tree '/home/jevin/.config/nixpkgs' is dirty
error: anonymous function at /nix/store/0ww6l2a68jv8pq99scbmjqinwrh941x0-source/nixos/lib/eval-config.nix:11:1 called with unexpected argument 'overlays'

       at /nix/store/0ww6l2a68jv8pq99scbmjqinwrh941x0-source/flake.nix:22:11:

           21|         nixosSystem = args:
           22|           import ./nixos/lib/eval-config.nix (
             |           ^
           23|             args // {

I’m stuck.

Full code tree: GitHub - jevy/home-manager-nix-config at muttdown

nixosSystem does not have an overlays argument. You need to set the nixpkgs.overlays option in your configuration.

That makes sense and I updated my config! Now, nix-rebuild doesn’t complain, but the binary doesn’t appear in my path. To help my debugging skills, how do I somehow see how the overlay is evaluated and applied to the derivation?

I can see that the package seems to be part of the derivation:

❯ nix show-derivation | grep muttdown
  "/nix/store/2yf6n8wfg04c6pzb08s6l6w7qpxqbnaz-muttdown-0.3.5.drv": {
        "path": "/nix/store/31jdsakpm8879fbh5qwjk6gs4xcvncjd-muttdown-0.3.5-dist"
        "path": "/nix/store/r8psqy0yzl9ph1051xr0l05hg6mgy4y9-muttdown-0.3.5"
      "/nix/store/wzfn296709by58gp876ww50jcagxwgkr-muttdown-0.3.5.tar.gz.drv": [
      "dist": "/nix/store/31jdsakpm8879fbh5qwjk6gs4xcvncjd-muttdown-0.3.5-dist",
      "name": "muttdown-0.3.5",
      "out": "/nix/store/r8psqy0yzl9ph1051xr0l05hg6mgy4y9-muttdown-0.3.5",
      "pname": "muttdown",
      "src": "/nix/store/ll1kgyz3k2ahikg91wdcqjrpq7j8rc6f-muttdown-0.3.5.tar.gz",

And the binary is there:

❯ ls -l /nix/store/r8psqy0yzl9ph1051xr0l05hg6mgy4y9-muttdown-0.3.5/bin/muttdown
.r-xr-xr-x root root 1.4 KB Wed Dec 31 19:00:01 1969  /nix/store/r8psqy0yzl9ph1051xr0l05hg6mgy4y9-muttdown-0.3.5/bin/muttdown

But muttdown isn’t in my path. How come?

Reference for how I included it

Input defined here:

Overlay defined here:

Where do you add it to your environment?

Is this what you mean?
flake.nix → configuration.nix (where nixpkgs.overlays is defined) → muttdown.overlay

No, I mean, where are you actually installing muttdown? Or whatever you want to install from the overlay?

In your current code I only see that you are adding that overlay, but not that you was using anything from it.

After a few hours beating my head against the wall…

… I didn’t actually add the package to be installed …

Nobbz you saved me and now I’m going to hide under my desk.

Thank you so much for working through this with me.

1 Like