Skip to content

Commit

Permalink
fix formatting and links
Browse files Browse the repository at this point in the history
  • Loading branch information
fricklerhandwerk committed Mar 8, 2024
1 parent 86a5de3 commit 522f33b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
6 changes: 3 additions & 3 deletions source/guides/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ See <https://github.com/nix-community/home-manager>

### What's the recommended process for building custom packages?

Please read [](packaging-existing-software).
Please read [](packaging-tutorial).

### How to use a clone of the Nixpkgs repository to update or write new packages?

Please read [](packaging-existing-software) and the [Nixpkgs contributing guide](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
Please read [](packaging-tutorial) and the [Nixpkgs contributing guide](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).

## NixOS

Expand All @@ -69,7 +69,7 @@ There are a few ways to resolve this mismatch in environment expectations:
- Build from source.

Many open-source programs are highly flexible at compile time in terms of where their files go.
For an introduction to this, see [](../tutorials/packaging-existing-software).
For an introduction to this, see [](packaging-tutorial).
- Modify the program's [ELF header](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) to include paths to libraries using [`autoPatchelfHook`](https://nixos.org/manual/nixpkgs/stable/#setup-hook-autopatchelfhook).

Do this if building from source isn't feasible.
Expand Down
2 changes: 1 addition & 1 deletion source/guides/recipes/python-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Others can now use the same shell environment as long as they have [Nix installe

## Next steps

- [](packaging-existing-software)
- [](packaging-tutorial)
- [](file-sets-tutorial)
- [](automatic-direnv)
- [](./dependency-management.md)
4 changes: 2 additions & 2 deletions source/guides/recipes/sharing-dependencies.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(sharing-dependencies)=
# Dependencies in the development shell

When [packaging software in `default.nix`](packaging-existing-software), you'll want a [development environment in `shell.nix`](declarative-reproducible-envs) to enter it conveniently with `nix-shell` or [automatically with `direnv`](./direnv).
When [packaging software in `default.nix`](packaging-tutorial), you'll want a [development environment in `shell.nix`](declarative-reproducible-envs) to enter it conveniently with `nix-shell` or [automatically with `direnv`](./direnv).

How to share the package's dependencies in `default.nix` with the development environment in `shell.nix`?

Expand Down Expand Up @@ -109,4 +109,4 @@ $ nix-shell --pure
- [](pinning-nixpkgs)
- [](./direnv)
- [](python-dev-environment)
- [](packaging-existing-software)
- [](packaging-tutorial)
2 changes: 1 addition & 1 deletion source/tutorials/callpackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This tutorial shows how to use it and why it's beneficial.
### What do you need?

- Familiarity with the [Nix language](reading-nix-language)
- First experience with [packaging existing software](packaging-existing-software)
- First experience with [packaging existing software](packaging-tutorial)

### How long does it take?

Expand Down
22 changes: 11 additions & 11 deletions source/tutorials/module-system/module-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Start by changing the first line in `default.nix`:

```{code-block} diff
:caption: default.nix
- { ... }:
+ { lib, ... }:
{
-{ ... }:
+{ lib, ... }:
{
}
}
```

Now the module is a function which takes *at least* one argument, called `lib`, and may accept other arguments (expressed by the ellipsis `...`).
Expand All @@ -97,7 +97,7 @@ Change `default.nix` to include the following declaration:
```{code-block} diff
:caption: default.nix
{ lib, ... }: {
+
+ options = {
+ scripts.output = lib.mkOption {
+ type = lib.types.lines;
Expand Down Expand Up @@ -204,12 +204,12 @@ Update `default.nix` by changing the value of `scripts.output` to the following

```{code-block} diff
:caption: default.nix
config = {
- scripts.output = 42;
+ scripts.output = ''
+ ./map size=640x640 scale=2 | feh -
+ '';
};
config = {
- scripts.output = 42;
+ scripts.output = ''
+ ./map size=640x640 scale=2 | feh -
+ '';
};
```

## Interlude: reproducible scripts
Expand Down
9 changes: 4 additions & 5 deletions source/tutorials/packaging-existing-software.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ myst:
"keywords": "Nix, packaging"
---

(packaging-existing-software)=
(packaging-tutorial)=
# Packaging existing software with Nix

One of Nix's primary use-cases is in addressing common difficulties encountered with packaging software, such as specifying and obtaining dependencies.
Expand Down Expand Up @@ -141,7 +141,7 @@ in
This allows you to run `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 `pkgs` 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 attribute set.

In this case, `callPackage` will supply `lib`, `stdenv`, and `fetchzip` to the function defined in `hello.nix`.
:::
Expand Down Expand Up @@ -643,6 +643,7 @@ Adjust your `installPhase` to call the appropriate hooks:
# ...
```

## A successful build

Running the `nix-build` command once more will finally do what you want, repeatably.
Expand All @@ -658,15 +659,13 @@ default.nix hello.nix icat.nix result
## 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

- [Add your own new packages to Nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md)
- [](../contributing/how-to-contribute.md)
- [](../contributing/how-to-get-help.md)
- [](callpackage-tutorial)
- [](sharing-dependencies)
- [](automatic-direnv)
- [](python-dev-environment)

0 comments on commit 522f33b

Please sign in to comment.