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

Add support for installing flakes outside of nixpkgs #18

Open
seasonedfish opened this issue Jun 12, 2023 · 3 comments
Open

Add support for installing flakes outside of nixpkgs #18

seasonedfish opened this issue Jun 12, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@seasonedfish
Copy link
Owner

A nix flake can be installed with e.g. nix profile install github:peterldowns/nix-search-cli.

hdn should support installing a flake with a similar syntax: hdn add github:peterldowns/nix-search-cli.

@seasonedfish seasonedfish added the help wanted Extra attention is needed label Jun 12, 2023
@Thesola10
Copy link

Thesola10 commented Jun 13, 2023

Most likely this could be achieved using

(builtins.getFlake "...").outputs.packages.${builtins.currentSystem}

plus minimal parsing of the #... part

@Thesola10
Copy link

Thesola10 commented Jun 13, 2023

Proposed state machine for flake URI parsing, which mostly matches native Nix behavior. NB: getFlake accepts the URI before the fragment verbatim.

There is no fragment in the flake URI

  • flake.outputs.apps.${system}.default exists: use that
  • flake.outputs.packages.${system}.default exists: use that
  • flake.outputs.apps.${system} contains a single app: use it
  • flake.outputs.packages.${system} contains a single app: use it
  • fail

There is a fragment in the flake URI

  • of the form #apps.a.b: use flake.outputs.apps.a.b
  • of the form #packages.a.b: use flake.outputs.packages.a.b
  • of the form #name (or anything else): if flake.outputs.name exists, use that, else try flake.outputs.apps.${system}.name then flake.outputs.packages.${system}.name

If the home-manager config is itself a flake, we may need to manage locking ourselves as getFlake only supports locked refs in pure evaluation mode (i.e. flake evaluation mode)

PS: don't forget to try legacyPackages after packages to retain compatibility with Nixpkgs and overlay flakes

@seasonedfish
Copy link
Owner Author

@Thesola10 thanks! I'll give that shot when I get the chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants