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 12846fc commit ace0578
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 48 deletions.
2 changes: 2 additions & 0 deletions _redirects
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
1 change: 1 addition & 0 deletions source/guides/recipes/index.md
Expand Up @@ -4,6 +4,7 @@
```{toctree}
:maxdepth: 1
sharing-dependencies.md
Automatic environments <./direnv.md>
Python development environment <./python-environment.md>
```
@@ -1,4 +1,5 @@
# Sharing dependencies between `default.nix` and `shell.nix`
(sharing-dependencies-shell)=
# Dependencies in the development shell

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

Expand Down
2 changes: 1 addition & 1 deletion source/tutorials/index.md
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.

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-shell)
- [](direnv)
- [](python-dev-environment)

0 comments on commit ace0578

Please sign in to comment.