From 967137ce526cc3c6501b7cca19a6d88fa9c53d17 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Tue, 10 May 2022 08:11:31 -0700 Subject: nix: start documenting what I'm learning --- .../fcuny/notes/content/notes/working-with-nix.org | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 users/fcuny/notes/content/notes/working-with-nix.org diff --git a/users/fcuny/notes/content/notes/working-with-nix.org b/users/fcuny/notes/content/notes/working-with-nix.org new file mode 100644 index 0000000..05e6720 --- /dev/null +++ b/users/fcuny/notes/content/notes/working-with-nix.org @@ -0,0 +1,21 @@ +#+TITLE: Working with 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 [[https://nixos.org/manual/nixpkgs/stable/#sec-stdenv-phases][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 [[https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/go-modules/generic/default.nix][source]] 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 [[https://github.com/NixOS/nixpkgs/blob/fb7287e6d2d2684520f756639846ee07f6287caa/pkgs/development/go-modules/generic/default.nix#L171][build phase]]. -- cgit 1.4.1