docs/development/nix-linux-setup.md
Nix flakes can be used to provide version controlled reproducible and cross-platform development environments. The key files are:
flake.nix: Defines the flake inputs and outputs, including development shells.shell.nix: This file defines the dependencies and additionally adds support for the Impure nix-shell method. This is used by the flake to create the dev environment.flake.lock: Locks the versions of inputs for reproducibility.You have two primary ways to enter the development shell with Nix:
nix develop (flake-native command)This is the recommended way if you have Nix with flakes support. Flake guarantee the versions of the dependencies and can be controlled through flake.nix and flake.lock.
nix develop
This will open a shell with all dependencies and environment configured as per the flake.nix for (x86_64-linux) systems only at this time.
nix-shell (that's why shell.nix is a separate file)If you want to use traditional nix-shell tooling which uses the nixpkgs version of your system:
nix-shell
This will drop you into the shell environment defined in shell.nix. Note that this is not flake-native method and does not use the locked nixpkgs in flake.lock so exact versions of the dependancies is not guaranteed.
shell.nix will be available.pkgs) used aligns with the versions locked in flake.lock to ensure reproducibility.# Navigate to the project root folder which contains the flake.nix, flake.lock and shell.nix files.
cd /home/user/dev/Libation
# Enter the flake development shell (Linux x86_64)
nix develop
# run VSCode or VSCodium from the current shell environment
code .
# Run or Debug using VSCode and VSCodium using the linux Launch configuration.
You can also Build and run your application inside the shell.
dotnet build ./Source/LibationAvalonia/LibationAvalonia.csproj -p:TargetFrameworks=net9.0 -p:TargetFramework=net9.0 -p:RuntimeIdentifier=linux-x64
exit inside the shell.nix.conf or global.json that might affect SDK versions or runtime identifiers.flake.lock file committed to ensure builds are reproducible for all collaborators.