https://github.com/cor/flake-template-dotnet
Reproducibly build a dotnet project with Nix
https://github.com/cor/flake-template-dotnet
Last synced: 8 months ago
JSON representation
Reproducibly build a dotnet project with Nix
- Host: GitHub
- URL: https://github.com/cor/flake-template-dotnet
- Owner: cor
- Created: 2025-02-09T15:07:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-09T15:07:32.000Z (over 1 year ago)
- Last Synced: 2025-06-11T11:12:17.186Z (12 months ago)
- Language: Nix
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# .NET/Nix Project Template
A template for building .NET applications with Nix (+Refit HTTP client as a nuget dependency example)
## How to reproducibly build and run
```bash
nix build
./result/bin/MyApp
# Or run directly
nix run
```
## Adding New NuGet Dependencies
Follow these steps to add a new NuGet package:
1. **Add package reference** to `MyApp.csproj`:
```xml
```
2. **Update `deps.nix`** with a new entry (use placeholder hash first):
```nix
(fetchNuGet {
pname = "New.Package";
version = "X.Y.Z";
sha256 = lib.fakeHash; # Temporary placeholder
})
```
3. **Get real SHA256 hash** by building and extracting the sha-256 from the output:
```bash
nix build -L
# observe what the sha-256 should be
```
4. **Replace** `lib.fakeHash` with the actual hash output by the nix build error
## Development Environment
```bash
# Enter development shell with all tools
nix develop
# Normal .NET commands work inside the shell:
dotnet build
dotnet run
```
### Editor Setup
The dev shell includes:
- Omnisharp (C# language server)
- .NET SDK 8.0
- NuGet dependency tools
Ensure your editor uses the `./.nuget-packages` directory for packages.