diff options
| author | Franck Cuny <franck@fcuny.net> | 2024-12-06 17:37:28 -0800 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2024-12-06 17:37:41 -0800 |
| commit | 0a350777002ba638bcd44eb23db323b12f7c5d9e (patch) | |
| tree | f512c7c320e34d301c4f3715f16a098552c2b530 /content/working-with-nix.md | |
| parent | some style changes for the default template (diff) | |
| download | fcuny.net-0a350777002ba638bcd44eb23db323b12f7c5d9e.tar.gz | |
get rid of sections
I use tags to organize things.
Diffstat (limited to 'content/working-with-nix.md')
| -rw-r--r-- | content/working-with-nix.md | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/content/working-with-nix.md b/content/working-with-nix.md new file mode 100644 index 0000000..1269963 --- /dev/null +++ b/content/working-with-nix.md @@ -0,0 +1,45 @@ ++++ +title = "working with nix" +date = 2022-05-10 +[taxonomies] +tags = ["nix"] ++++ + +## the `nix develop` command + +The `nix develop` command is for working on a repository. If our +repository contains a `Makefile`, it will be used by the various +sub-commands. + +`nix develop` supports multiple +[phases](https://nixos.org/manual/nixpkgs/stable/#sec-stdenv-phases) and +they map as follow: + +| phase | default to | command | note | +| -------------- | -------------- | ------------------------- | ---- | +| configurePhase | `./configure` | `nix develop --configure` | | +| buildPhase | `make` | `nix develop --build` | | +| checkPhase | `make check` | `nix develop --check` | | +| installPhase | `make install` | `nix develop --install` | | + +In the repository, running `nix develop --build` will build the binary +**using the Makefile**. This is different from running `nix build`. + +## the `nix build` and `nix run` commands + +### for Go + +For Go, there's the `buildGoModule`. Looking at the +[source](https://github.com/NixOS/nixpkgs/blob/fb7287e6d2d2684520f756639846ee07f6287caa/pkgs/development/go-modules/generic/default.nix) +we can see there's a definition of what will be done for each phases. As +a result, we don't have to define them ourselves. + +If we run `nix build` in the repository, it will run the default [build +phase](https://github.com/NixOS/nixpkgs/blob/fb7287e6d2d2684520f756639846ee07f6287caa/pkgs/development/go-modules/generic/default.nix#L171). + +## `buildInputs` or `nativeBuildInputs` + +- `nativeBuildInputs` is intended for architecture-dependent + build-time-only dependencies +- `buildInputs` is intended for architecture-independent + build-time-only dependencies |
