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

Example of adding a local package to be recognised by home-manager build is missing #62

Open
dietmarw-se opened this issue Jan 17, 2024 · 3 comments
Labels
question Further information is requested

Comments

@dietmarw-se
Copy link

I was following this nice starter config and was especially interested in the ability to define local packages under pkgs/. However I can't get home-manager build succeed because it always complains about my local package being unknown.

Example:

I have my package defined under:

├── pkgs
│   ├── mypkg
│   │   └── default.nix
│   └── default.nix

with all the other configuration taken from the standard example simply adding
home.packages = with pkgs; [ mypkg ]; as suggested in

# home.packages = with pkgs; [ steam ];

is not enough since home-manger build will complain with
error: undefined variable 'mypkg'

Doing a nix build .#mypkg works fine though.

So how should one add the mypkg in order that it will be found by home-manager build?

@rykugur
Copy link

rykugur commented Feb 24, 2024

I was having this same problem and found a post from @Misterio77 in another issue. TLDR: in my configuration/home files, I added nixpkgs.overlays. = [ outputs.overlays.additions ]; and was then able to import my custom packages.

Relevant files in my config:

https://github.com/rykugur/dotfiles/blob/master/overlays/default.nix#L4
https://github.com/rykugur/dotfiles/blob/master/home/dusty/taln/home.nix#L30
https://github.com/rykugur/dotfiles/blob/master/home/dusty/taln/home.nix#L80 (importing my custom derivation)

@dietmarw-se
Copy link
Author

@rykugur Thanks, this is interesting. I did have that line https://github.com/Misterio77/nix-starter-configs/blob/main/standard/home-manager/home.nix#L27 ( and the following two) commented out since I though I did not use overlays. I got it work with some help from the forum by addressing the usage of the package with

 # local packages
    inputs.self.packages.${system}.mypkg

instead of simply:

mypkg

Doing it like you did in your config as suggested in the three places will lead to the error message error: attribute 'outputs' missing in my case. Which I think lead me into the rabbit hole to get this working in the first place.
Anyway despite me having gotten it to work it would still be nice to have a working example demonstrated here in the nix-starter-config.
I think this is the challenge of nix that there are always multiple ways to get something done and for beginners this can cause some (nix) anxiety ;-)

@Misterio77
Copy link
Owner

Hey! You probably figured this out, but inputs.self == outputs, and the error is probably fixable by:

@Misterio77 Misterio77 added the question Further information is requested label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants