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 outline for "sharing deps" tutorial #622

Merged
merged 3 commits into from
Jul 13, 2023

Conversation

zmitchell
Copy link
Contributor

This PR contains the outline for #600.

Copy link
Contributor

@henrik-ch henrik-ch left a comment

Choose a reason for hiding this comment

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

just a short snippet/idea.


<!-- What is the reader supposed to gain from reading this? -->
- Show the reader how to set up a development environment.
- Show the reader how not to repeat themselves.
Copy link
Contributor

Choose a reason for hiding this comment

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

Show the reader how to repeat themselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

(this is intended as a step before showing the readers how not to repeat themselves)

Copy link
Collaborator

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

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

Discussed in LJWG meeting, comments are collaborative.


## Assumptions
- The reader has seen a derivation before.
- The reader understands that builders come from `nixpkgs`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI: There is a Nixpkgs PR discussing to rename "builder" to "build helper"

# Sharing dependencies between `default.nix` and `shell.nix`

## Assumptions
- The reader has seen a derivation before.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may want to specify which tutorials or explanations should have been read first. Is it "packaging existing software"?

- Demonstrate that in order to bring those tools into our environment with the current `default.nix` those packages would also be included in the build even though they aren't necessary to build our application.
- (Optional) Add the packages to `propagatedBuildInputs` and show that they're included in the closure.
- Create a `shell.nix` to separate build dependencies from development dependencies.
- Duplicate dependencies from `default.nix` so that you can still perform the build in `shell.nix`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Skip the duplication step, go directly to the viable solution.

Comment on lines +44 to +63
# default.nix
let
myPackage = python3Packages.buildPythonApplication {
propagatedBuildInputs = [
python3Packages.flask
];
};
in myPackage // {
shell = mkShell {
inputsFrom = [
myPackage
];
buildInputs = [
curl
];
};
}

# shell.nix
(import ./default.nix).shell
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be also a recipe that assumes you know the skills and concepts involved.

## Assumptions
- The reader has seen a derivation before.
- The reader understands that builders come from `nixpkgs`.
- The reader knows what a shell environment is.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- The reader knows what a shell environment is.
- The reader knows what a declarative shell environment is.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-06-29-learning-journey-working-group-meeting-notes-15/29799/1

@zmitchell zmitchell merged commit db95609 into NixOS:master Jul 13, 2023
1 check passed
fricklerhandwerk pushed a commit to fricklerhandwerk/nix.dev that referenced this pull request Jul 13, 2023
* Add outline for sharing deps tutorial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants