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

Nix language primer with shell.nix #516

Open
2 of 5 tasks
zmitchell opened this issue Apr 13, 2023 · 13 comments
Open
2 of 5 tasks

Nix language primer with shell.nix #516

zmitchell opened this issue Apr 13, 2023 · 13 comments
Assignees
Labels
tracking A stopgap for issue dependencies tutorial Topics for new tutorials

Comments

@zmitchell
Copy link
Contributor

zmitchell commented Apr 13, 2023

The Learning Journey WG identified that the second tutorial in the learning journey should be a tutorial walking the user through creating a shell.nix. This is the tracking issue for discussion on this tutorial and related work.

  • Compile a survey of shell.nix tutorials (@khaled)
  • Consider if there are elements of existing tutorials that we should include
  • Prepare an outline of the tutorial
  • Prepare a draft of the tutorial
  • Submit the draft as a PR

Tutorial contents

  • Provide the reader with a small, functioning shell.nix installing Python
  • Explain that once you've experimented with packages via nix-shell -p you can enter the same environment repeatedly by declaring it in a shell.nix file.
  • You can also use shell.nix to configure other aspects of the environment:
    • Environment variables
    • Shell hooks
    • Shell prompts
  • Illustrate how to add packages to the shell, explaining the basic differences between buildInputs and packages
  • This shell.nix will just grab nixpkgs from <nixpkgs>, leaving pinning, channels, etc to later tutorials

How

@zmitchell zmitchell added the tracking A stopgap for issue dependencies label Apr 13, 2023
@zmitchell zmitchell changed the title First step tutorial 2 First steps tutorial - shell.nix Apr 13, 2023
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-04-13-learning-journey-working-group-meeting-notes-4/27255/1

@khaled
Copy link

khaled commented Apr 20, 2023

A collection of existing tutorials with notes about what they cover:

Posts

Videos


From existing doc survey:

Tutorials

Ad hoc Shell Environments
* Finding packages given a program name
* Nesting shells
* Pinning within adhoc shell
Declarative and reproducible developer environments
* Why
* Pinning
* Direnv
Developing with nix-shell
* From first principles
* Custom builder for nix-shell

References

Comand Reference -> Main Commands -> nix-shell
Nix-shell shebang

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-04-20-learning-journey-working-group-meeting-notes-5/27460/1

@alper
Copy link
Contributor

alper commented May 2, 2023

I have a flake.nix with a mkShell in it. Is that equivalent?

The tutorial also does not mention whether shell.nix is a hard convention or something.

@fricklerhandwerk
Copy link
Collaborator

fricklerhandwerk commented May 2, 2023

The agreed-upon tenet at the moment is to only teach using the stable interface, and Flakes are an experimental feature. Other than that, yes, it's equivalent.

shell.nix is the default filename taken by nix-shell (see the Nix manual).

@alper
Copy link
Contributor

alper commented May 2, 2023

OK. In his tutorial here Amos focuses heavily on flake:
https://fasterthanli.me/series/building-a-rust-service-with-nix/part-9

@zmitchell
Copy link
Contributor Author

@roberth assigned to you for feedback

@bew
Copy link
Contributor

bew commented Jun 19, 2023

  • This shell.nix will just grab nixpkgs from <nixpkgs>, leaving pinning, channels, etc to later tutorials

I think the guide should still mention this in a warning / note, or at least the kind of issues that comes from not pinning

@roberth
Copy link
Member

roberth commented Jun 29, 2023

Regarding not using flakes, it would be beneficial to make clear in the tutorial which parts of the file are about bring things into scope, and which part is the actual shell expression. As this is "First steps" they're not too familiar with the language yet, so some extra guidance as to what's what will help them transfer this knowledge to a flake context.

Furthermore some of these points apply; some context to keep in mind while writing this tutorial

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-13-learning-journey-working-group-meeting-notes-17/30393/1

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-17-tutorial-series-call-for-feedback/30616/1

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-27-learning-journey-working-group-meeting-notes-19/31151/1

@zmitchell zmitchell changed the title First steps tutorial - shell.nix Learning Journey tutorial - shell.nix Sep 19, 2023
@fricklerhandwerk fricklerhandwerk changed the title Learning Journey tutorial - shell.nix Nix language primer with shell.nix Feb 7, 2024
@fricklerhandwerk
Copy link
Collaborator

Cleaning out issues and compiling a refreshed overview, I think what we're still missing is a smooth transition between a very superficial look at Nix expressions (e.g. in the context of shell.nix) and the hefty Nix language basics tutorial. I renamed the issue accordingly to make it fit into the new overview.

@fricklerhandwerk fricklerhandwerk added tutorial Topics for new tutorials and removed learning journey labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracking A stopgap for issue dependencies tutorial Topics for new tutorials
Projects
Status: No status
Development

No branches or pull requests

7 participants