Skip to content

Commit

Permalink
dissolve the Learning Journey section
Browse files Browse the repository at this point in the history
This does not yet follow NixOS#701, because the change to get there would be
too big. The goal is to keep the table of contents meaningful at all
times and the diff of each pull request manageable.

The packaging tutorial is quite important, so it's not wrong to have it
visible on the front page until we have enough material for a packaging
section.

The sharing dependencies article should really be a very brief guide, but
because that would be quite a big change, it's only moved to the Guides
section for now.
  • Loading branch information
fricklerhandwerk committed Nov 1, 2023
1 parent 8186923 commit 8afee98
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 50 deletions.
2 changes: 2 additions & 0 deletions _redirects
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
/recipes/faq /guides/faq 301
/recipes/python-environment /guides/recipes/python-environment 301
/recipes/direnv /guides/recipes/direnv 301
/tutorials/learning-journey/sharing-dependencies /guides/recipes/sharing-dependencies 301
/tutorials/learning-journey/packaging-existing-software /tutorials/packaging-existing-software 301
2 changes: 1 addition & 1 deletion source/guides/recipes/direnv.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(automatic-direnv)=
(direnv)=
# Automatic environment activation with `direnv`

Instead of manually activating the environment for each project, you can reload a [declarative shell](declarative-reproducible-envs) every time you enter the project's directory or change the `shell.nix` inside it.
Expand Down
3 changes: 2 additions & 1 deletion source/guides/recipes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
```{toctree}
:maxdepth: 1
Automatic environments <./direnv.md>
sharing-dependencies.md
Automatic environments <direnv>
Python development environment <./python-environment.md>
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Sharing dependencies between `default.nix` and `shell.nix`
(sharing-dependencies)=
# Dependencies in the development shell

<!-- Include any foreward you want here -->

Expand Down
2 changes: 1 addition & 1 deletion source/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ These sections contains series of lessons to get started.
first-steps/index.md
nix-language.md
learning-journey/index.md
Packaging existing software <packaging-existing-software.md>
nixos/index.md
cross-compilation.md
```
12 changes: 0 additions & 12 deletions source/tutorials/learning-journey/index.md

This file was deleted.

29 changes: 0 additions & 29 deletions source/tutorials/learning-journey/template.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ myst:
"keywords": "Nix, packaging"
---


(packaging-existing-software)=


# Packaging Existing Software With Nix

One of Nix's primary use-cases is in addressing common difficulties encountered while packaging software, like managing dependencies.

In the long term, Nix helps tremendously in alleviating that stress, but when *first* packaging existing software with Nix, it's common to encounter missing dependencies preventing builds from succeeding.

In this tutorial, you'll create your first Nix derivations to package C/C++ software, taking advantage of the [`nixpkgs stdenv`](https://nixos.org/manual/nixpkgs/stable/#chap-stdenv) which automates much of the work of building self-contained C/C++ packages.
In this tutorial, you'll create your first Nix derivations to package C/C++ software, taking advantage of the [Nixpkgs Standard Environment](https://nixos.org/manual/nixpkgs/stable/#part-stdenv) (`stdenv`) which automates much of the work of building self-contained C/C++ packages.

The tutorial begins by considering `hello`, an implementation of "hello world" which only requires dependencies provided by `stdenv`.

Expand Down Expand Up @@ -118,7 +115,7 @@ in
This allows you to use `nix-build -A hello` to realize the derivation in `hello.nix`, similar to the current convention used in `nixpkgs`.

:::{note}
`callPackage` automatically passes attributes from `nixpkgs` to the given function, if they match attributes required by that function's argument attrset.
[`callPackage`] automatically passes attributes from `pkgs` to the given function, if they match attributes required by that function's argument attrset.

In this case, `callPackage` will supply `lib`, and `stdenv` to the function defined in `hello.nix`.
:::
Expand Down Expand Up @@ -517,3 +514,16 @@ default.nix hello.nix icat.nix result
```

`result/bin/icat` is the executable built previously. Success!

## References

- [Nixpkgs Manual - Standard Environment](https://nixos.org/manual/nixpkgs/unstable/#part-stdenv)
- [Nix Pills - `callPackage` Design Pattern][`callPackage`]

[`callPackage`]: https://nixos.org/guides/nix-pills/callpackage-design-pattern.html

## Next steps

- [](sharing-dependencies)
- [](direnv)
- [](python-dev-environment)

0 comments on commit 8afee98

Please sign in to comment.