Skip to content

add flake.nix example to how to install tabs#963

Open
BridgerB wants to merge 1 commit intoNixOS:mainfrom
BridgerB:main
Open

add flake.nix example to how to install tabs#963
BridgerB wants to merge 1 commit intoNixOS:mainfrom
BridgerB:main

Conversation

@BridgerB
Copy link
Copy Markdown

@BridgerB BridgerB commented Jun 28, 2025

See screenshot for a new "flake.nix" tab in the "How to install xyz?" section:
image

It works with their currently selected channel (example 24.11 selected):
image

@raboof
Copy link
Copy Markdown
Member

raboof commented Jun 28, 2025

I think having flake-based suggestions in there makes sense.

I'm not sure these specific suggestions make sense - how/when would you use it like this? Wouldn't you rather just nix run nixpkgs#hello?

@BridgerB
Copy link
Copy Markdown
Author

Wouldn't you rather just nix run nixpkgs#hello

You could. But then you wouldn't have a flake.nix

@BridgerB
Copy link
Copy Markdown
Author

BridgerB commented Jul 4, 2025

@raboof what specific suggestions do you think would make more sense?

@dwt
Copy link
Copy Markdown

dwt commented Jul 19, 2025

@BridgerB I like the approach, but I was actually expecting this to show me how to configure this in a flake based nixos config.

Thinking about this it would actually be really nice to show all the alternatives for the more modern syntax. That would mean

  • nix profile instead of nix-env
  • flake based NixOS configuration (not sure there is actually a meaningful difference? Showing how add the input and perhaps how to instantiate unstable in a flake based config that only has stable would have been really helpful to me when I was starting out though)
  • nix shell instead of nix-shell
  • I would also like to see an example of how to use nix-shell as a shebang and provide this as a dependency for a script.

I would actually like to have examples for a shell.nix and flake.nix example that adds this package to a shell. (That is what this pull request adds)

Not quite sure what a great UI would be, but ideally I could specify or at least distinguish which commands / examples I want shown. For my use-case, I like to not use the old commands where possible, especially nix-env as it's incompatible with a flake based system setup.

Perhaps the easiest way would be to start out with just adding pull requests to slowly add all the tabs, and then worry about making it easier to use by having a separation between the two worlds?

I would like to help with this, but since I haven't contributed to nixos-search before I am still a bit lost.

@dwt
Copy link
Copy Markdown

dwt commented Jul 19, 2025

Thinking about this further, perhaps this would be much better, if the tabs where:

  • 'Run Directly'
  • 'Try out in shell'
  • 'Install in development shell'
  • 'Install on NixOS / nix-darwin / home-manager'
  • 'Install from the shell'
  • 'Use in shell script'

That would map much more cleanly to the actual use cases (that I have) and would allow grouping the old and new, or just multiple ways of doing things inside those tabs much more cleanly.

@maintainers sorry, this should perhaps become it's own discussion / issue at this point?

Edit: Moved this discussion out to it's own ticket in #978

Comment on lines +767 to +773
[ text "Then run "
, code [] [ text "nix build" ]
, text " to build the package, "
, code [] [ text "nix run" ]
, text " to run it directly, or "
, code [] [ text "nix develop" ]
, text " to enter a shell with the package available."
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this text actually is correct. To my understanding you only provide a devShell with the package, so it cannot be built with nix build or directly run with nix run. Only nix develop will work.

@miniBill
Copy link
Copy Markdown
Collaborator

LGTM for the Elm part of this, no comment on the merits of the content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants