An example dotnet project using a nix flake for specifying it's development environment.
- Install Nix
- Install direnv & nix-direnv
- Install VSCode
- Install the recommended VSCode extensions
TODO: Quickstart option to install these via Nix.
-
Clone the repository
git clone https://github.com/squirmy/nix-flake-example-dotnet
-
Change directory
cd nix-flake-example-dotnet
If the dependencies are installed correctly you should see an error:
direnv: error /Users/squirmy/code/nix-flake-example-dotnet/.envrc is blocked. Run `direnv allow` to approve its content
-
Allow direnv to install the dependencies in the nix flake
direnv allow
-
Run a build to test it out
dotnet build
-
Launch VSCode from this directory for the best experience See Known Issues.
code .
VSCode extensions do not have an order in which they are loaded on startup. Sometimes the dotnet extension will try to load before the direnv extension has had a chance to set the DOTNET_BIN
environment variable causing this error.
This error can be safely ignored as the direnv extension is configured to restart extensions after the environment changes.
"direnv.restart.automatic": true
Changing directory into this project and then launching VSCode from the command line will avoid this error completely as VSCode will inherit the environment from the shell.