lix/src/nix/develop.md
raito b8cb7abcf0 chore: rebrand Nix to Lix when it makes sense
Here's my guide so far:

$ rg '((?!(recursive).*) Nix
(?!(daemon|store|expression|Rocks!|Packages|language|derivation|archive|account|user|sandbox|flake).*))'
-g '!doc/' --pcre2

All items from this query have been tackled. For the documentation side:
that's for lix-project/lix#162.

Additionally, all remaining references to github.com/NixOS/nix which
were not relevant were also replaced.

Fixes: lix-project/lix#148.
Fixes: lix-project/lix#162.
Change-Id: Ib3451fae5cb8ab8cd9ac9e4e4551284ee6794545
Signed-off-by: Raito Bezarius <raito@lix.systems>
2024-06-01 20:31:24 +02:00

2.8 KiB

R""(

Note: this command's interface is based heavily around installables, which you may want to read about first (nix --help).

Examples

  • Start a shell with the build environment of the default package of the flake in the current directory:

    # nix develop
    

    Typical commands to run inside this shell are:

    # configurePhase
    # buildPhase
    # installPhase
    

    Alternatively, you can run whatever build tools your project uses directly, e.g. for a typical Unix project:

    # ./configure --prefix=$out
    # make
    # make install
    
  • Run a particular build phase directly:

    # nix develop --unpack
    # nix develop --configure
    # nix develop --build
    # nix develop --check
    # nix develop --install
    # nix develop --installcheck
    
  • Start a shell with the build environment of GNU Hello:

    # nix develop nixpkgs#hello
    
  • Record a build environment in a profile:

    # nix develop --profile /tmp/my-build-env nixpkgs#hello
    
  • Use a build environment previously recorded in a profile:

    # nix develop /tmp/my-build-env
    
  • Replace all occurrences of the store path corresponding to glibc.dev with a writable directory:

    # nix develop --redirect nixpkgs#glibc.dev ~/my-glibc/outputs/dev
    

    Note that this is useful if you're running a nix develop shell for nixpkgs#glibc in ~/my-glibc and want to compile another package against it.

  • Run a series of script commands:

    # nix develop --command bash -c "mkdir build && cmake .. && make"
    

Description

nix develop starts a bash shell that provides an interactive build environment nearly identical to what Lix would use to build installable. Inside this shell, environment variables and shell functions are set up so that you can interactively and incrementally build your package.

Nix determines the build environment by building a modified version of the derivation installable that just records the environment initialised by stdenv and exits. This build environment can be recorded into a profile using --profile.

The prompt used by the bash shell can be customised by setting the bash-prompt, bash-prompt-prefix, and bash-prompt-suffix settings in nix.conf or in the flake's nixConfig attribute.

Flake output attributes

If no flake output attribute is given, nix develop tries the following flake output attributes:

  • devShells.<system>.default

  • packages.<system>.default

If a flake output name is given, nix develop tries the following flake output attributes:

  • devShells.<system>.<name>

  • packages.<system>.<name>

  • legacyPackages.<system>.<name>

)""