Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Northwind.DataContext.Sqlite/NorthwindContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -39,9 +39,9 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
string dir = Environment.CurrentDirectory;
string path = string.Empty;

if (dir.EndsWith("net8.0"))
if (dir.EndsWith("net9.0"))
{
// In the <project>/bin/<Debug|Release>/net8.0 directory.
// In the <project>/bin/<Debug|Release>/net9.0 directory.
path = Path.Combine("..", "..", "..", "..", database);
}
else
Expand Down
20 changes: 20 additions & 0 deletions Northwind.DataContext.Sqlite/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
pkgs,
dotnet-sdk,
dotnet-runtime,
}:
pkgs.buildDotnetModule {
name = "northwind-data-context";
src = ./.;
nugetDeps = ../deps.json;
buildType = "Release";
packNupkg = true;
inherit dotnet-sdk dotnet-runtime;
projectReferences = [
import
../northwind.entitymodels.sqlite
{
inherit pkgs dotnet-sdk dotnet-runtime;
}
];
}
13 changes: 13 additions & 0 deletions Northwind.EntityModels.Sqlite/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
pkgs,
dotnet-sdk,
dotnet-runtime,
}:
pkgs.buildDotnetModule {
name = "northwind-entity-models";
src = ./.;
nugetDeps = ../deps.json;
inherit dotnet-sdk dotnet-runtime;
buildType = "Release";
packNupkg = true;
}
21 changes: 21 additions & 0 deletions Northwind.Mvc/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
pkgs,
dotnet-sdk,
dotnet-runtime,
}:
pkgs.buildDotnetModule {
name = "northwind-mvc";
src = ./.;
nugetDeps = ../deps.json;
buildType = "Release";
executables = [ "Northwind.Mvc" ];
inherit dotnet-sdk dotnet-runtime;
projectReferences = [
import
../northwind.data-context.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
import
../northwind.entitymodels.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
];
}
21 changes: 21 additions & 0 deletions Northwind.UnitTests/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
pkgs,
dotnet-sdk,
dotnet-runtime,
}:
pkgs.buildDotnetModule {
name = "northwind-unittests";
src = ./.;
nugetDeps = ../deps.json;
buildType = "Release";
doCheck = true;
inherit dotnet-sdk dotnet-runtime;
projectReferences = [
import
../northwind.data-context.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
import
../northwind.entitymodels.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
];
}
21 changes: 21 additions & 0 deletions Northwind.Web/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
pkgs,
dotnet-sdk,
dotnet-runtime,
}:
pkgs.buildDotnetModule {
name = "northwind-web";
src = ./.;
nugetDeps = ../deps.json;
buildType = "Release";
executables = [ "Northwind.Web" ];
inherit dotnet-sdk dotnet-runtime;
projectReferences = [
import
../northwind.data-context.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
import
../northwind.entitymodels.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
];
}
21 changes: 21 additions & 0 deletions Northwind.WebApi/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
pkgs,
dotnet-sdk,
dotnet-runtime,
}:
pkgs.buildDotnetModule {
name = "northwind-webapi";
src = ./.;
nugetDeps = ../deps.json;
buildType = "Release";
executables = [ "Northwind.WebApi" ];
inherit dotnet-sdk dotnet-runtime;
projectReferences = [
import
../northwind.data-context.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
import
../northwind.entitymodels.sqlite
{ inherit pkgs dotnet-sdk dotnet-runtime; }
];
}
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Tools used:
- [Nix](https://srid.ca/haskell-nix) + [Flakes](https://serokell.io/blog/practical-nix-flakes)
- [devenv](https://devenv.sh/) and [direnv](https://direnv.net/) for development shell
- [just](https://just.systems/) as a task runner; run `just` in devshell
- [nuget-packageslock2nix](https://github.com/mdarocha/nuget-packageslock2nix) for generating `nuget` dependency lock files for nix
- [csharpier](https://github.com/belav/csharpier) for opinionated code formatting of C#
- [treefmt](https://github.com/numtide/treefmt-nix) for formatting of all code on the pipeline (C# and nix)

Expand All @@ -37,11 +36,11 @@ Simply run the following command from the root of the project:
$ nix develop --impure
```

This will install a .NET SDK in version 8 and all other required dependencies in a completely isolated way (they will not interfere
This will install a .NET SDK in version 9 and all other required dependencies in a completely isolated way (they will not interfere
with any system installations of .NET SDK or any other software).

For even better ergonomics, install [direnv](https://direnv.net/) using your favourite package manager. After that, just `cd` into the directory.
(Note that you might have to run `direnv allow` inside the directory once.)
For even better ergonomics, install [direnv](https://direnv.net/) using your favourite package manager. After that, just `cd` into the directory
and run `direnv allow` to enable the automatic shell hook.

When using `vscode` or `emacs`, use the corresponding `direnv` extension:
- [direnv for VSCode](https://marketplace.visualstudio.com/items?itemName=mkhl.direnv)
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 25 additions & 97 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,106 +35,45 @@
system:
let
pkgs = import nixpkgs { inherit system; };
dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

in

rec {
devenv-up = self.devShells.${system}.default.config.procfileScript;

entity-models = pkgs.buildDotnetModule {
name = "northwind-entity-models";
src = ./northwind.entitymodels.sqlite;

nugetDeps = ./deps.json;

dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

packNupkg = true;
web = import ./northwind.web/package.nix {
inherit pkgs dotnet-sdk dotnet-runtime;
};

data-context = pkgs.buildDotnetModule {
name = "northwind-data-context";
src = ./northwind.datacontext.sqlite;

nugetDeps = ./deps.json;

projectReferences = [ entity-models ];

dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

packNupkg = true;
webapi = import ./northwind.webapi/package.nix {
inherit pkgs dotnet-sdk dotnet-runtime;
};

web = pkgs.buildDotnetModule {
name = "northwind-web";
src = ./northwind.web;

nugetDeps = ./deps.json;

projectReferences = [
data-context
entity-models
];

dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

buildType = "Release";

executables = [ "Northwind.Web" ];
mvc = import ./northwind.mvc/package.nix {
inherit pkgs dotnet-sdk dotnet-runtime;
};

webapi = pkgs.buildDotnetModule {
name = "northwind-webapi";
src = ./northwind.webapi;

nugetDeps = ./deps.json;

projectReferences = [
data-context
entity-models
];

dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

buildType = "Release";

executables = [ "Northwind.WebApi" ];
};

mvc = pkgs.buildDotnetModule {
name = "northwind-mvc";
src = ./northwind.mvc;

nugetDeps = ./deps.json;

projectReferences = [
data-context
entity-models
];

dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

buildType = "Release";

executables = [ "Northwind.Mvc" ];
};
}
);

apps = forEachSystem (system: {
web = mkApp (self.packages.${system}.web) "Northwind.Web";
webapi = mkApp (self.packages.${system}.webapi) "Northwind.WebApi";
mvc = mkApp (self.packages.${system}.mvc) "Northwind.Mvc";
web = mkApp self.packages.${system}.web "Northwind.Web";
webapi = mkApp self.packages.${system}.webapi "Northwind.WebApi";
mvc = mkApp self.packages.${system}.mvc "Northwind.Mvc";
});

devShells = forEachSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
dotnet-sdk =
with pkgs.dotnetCorePackages;
combinePackages [
sdk_9_0-bin
sdk_8_0-bin
];

in
{
Expand All @@ -150,7 +89,7 @@

just # task runner
sqlite # sqlite3 db for now
dotnet-sdk_9 # .NET SDK version 9
dotnet-sdk

nuget-to-json
];
Expand All @@ -163,7 +102,7 @@
'';

enterShell = ''
export DOTNET_ROOT=${pkgs.dotnet-sdk_9}/share/dotnet
export DOTNET_ROOT=${dotnet-sdk}/share/dotnet
cowsay "Welcome to .NET dev shell" | lolcat
'';
}
Expand All @@ -178,25 +117,14 @@
system:
let
pkgs = import nixpkgs { inherit system; };
dotnet-sdk = pkgs.dotnet-sdk_9;
dotnet-runtime = pkgs.dotnet-runtime_9;

in
{
formatting = treefmtEval.${system}.config.build.check self;
unit-tests = pkgs.stdenv.mkDerivation {
name = "northwind-unittests";
src = ./.;
nativeBuildInputs = with pkgs; [ dotnet-sdk_9 ];
buildInputs = with pkgs; [ dotnet-sdk_9 ];
doCheck = true;
checkPhase = ''
dotnet test
'';

buildPhase = ''
# make compile
'';
installPhase = ''
mkdir -p $out/bin
'';
unittests = import ./northwind.unittests/package.nix {
inherit pkgs dotnet-sdk dotnet-runtime;
};
}
);
Expand Down
Loading