How to build a package for home-manager


I have been using home-manager to set my dotfiles and dev environment dependencies, so far it’s been a great experience albeit somewhat challenging.

Right now I am stuck with attempting to build a package instead of using the channel one, since the channel package is not up to date.

My home.nix looks like this:

{ config, pkgs, lib,  ... }:

  extraNodePackages = import ./node/default.nix {};
  helix = (pkgs.callPackage ./helix.nix { });
  home.stateVersion = "23.05";

  programs.helix = {
    enable = true;
    package = helix;

For the derivation I downloaded the one from nix packages for the time being nixpkgs/default.nix at f9f47e8032817023bf9d1cb570515cf439bedeb4 · NixOS/nixpkgs · GitHub

Still, when I build my flake I get this error:

error: getting status of '/nix/store/1g64l335shnjzbd50wkv1h3x7i6xm7h3-source/helix.nix': No such file or directory

does your helix.nix live in the same folder as the home.nix and did you git add( -N) it?

Thanks @NobbZ git add did the trick! what is the rationale about having to add it? the error message is not descriptive, there is only a warning about the directory being dirty, which I tend to ignore while I am testing things.

Flakes want to be self contained. So things either need to be declared as inputs or part of the flake.

If your flake is a git-flake, then nix will not see things not part of the git tree.

The error is currently indeed unfortunate, but there is actively being worked on as part of the “lazy tree” feature.

If you were using a path-flake, then your problem wouldn’t have occured.

1 Like