Modernise flake (#68)

This commit is contained in:
Patrick Stevens
2024-07-12 20:13:12 +01:00
committed by GitHub
parent ca1b564f4e
commit 10ecc21a9c
6 changed files with 122 additions and 84 deletions

View File

@@ -7,7 +7,6 @@
};
outputs = {
self,
nixpkgs,
flake-utils,
...
@@ -17,10 +16,10 @@
projectFile = "./AdventOfCode2022.App/AdventOfCode2022.App.fsproj";
testProjectFile = "./AdventOfCode2022.Test/AdventOfCode2022.Test.fsproj";
pname = "AdventOfCode2022";
dotnet-sdk = pkgs.dotnet-sdk_7;
dotnet-runtime = pkgs.dotnetCorePackages.runtime_7_0;
dotnet-sdk = pkgs.dotnet-sdk_8;
dotnet-runtime = pkgs.dotnetCorePackages.runtime_8_0;
version = "0.0.1";
dotnetTool = toolName: toolVersion: sha256:
dotnetTool = toolName: toolVersion: hash:
pkgs.stdenvNoCC.mkDerivation rec {
name = toolName;
version = toolVersion;
@@ -28,7 +27,7 @@
src = pkgs.fetchNuGet {
pname = name;
version = version;
sha256 = sha256;
hash = hash;
installPhase = ''mkdir -p $out/bin && cp -r tools/net6.0/any/* $out/bin'';
};
installPhase = ''
@@ -41,31 +40,14 @@
};
in {
packages = {
fantomas = dotnetTool "fantomas" "5.2.0-alpha-008" "sha256-1egphbWXTjs2I5aFaWibFDKgu3llP1o32o1X5vab6v4=";
fetchDeps = let
flags = [];
runtimeIds = map (system: pkgs.dotnetCorePackages.systemToDotnetRid system) dotnet-sdk.meta.platforms;
in
pkgs.writeShellScript "fetch-${pname}-deps" (builtins.readFile (pkgs.substituteAll {
src = ./nix/fetchDeps.sh;
pname = pname;
binPath = pkgs.lib.makeBinPath [pkgs.coreutils dotnet-sdk (pkgs.nuget-to-nix.override {inherit dotnet-sdk;})];
projectFiles = toString (pkgs.lib.toList projectFile);
testProjectFiles = toString (pkgs.lib.toList testProjectFile);
rids = pkgs.lib.concatStringsSep "\" \"" runtimeIds;
packages = dotnet-sdk.packages;
storeSrc = pkgs.srcOnly {
src = ./.;
pname = pname;
version = version;
};
}));
fantomas = dotnetTool "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version (builtins.head (builtins.filter (elem: elem.pname == "fantomas") ((import ./nix/deps.nix) {fetchNuGet = x: x;}))).hash;
default = pkgs.buildDotnetModule {
pname = pname;
version = version;
src = ./.;
projectFile = projectFile;
nugetDeps = ./nix/deps.nix;
testProjectFile = testProjectFile;
nugetDeps = ./nix/deps.nix; # `nix build .#default.passthru.fetch-deps && ./result` and put the result here
doCheck = true;
dotnet-sdk = dotnet-sdk;
dotnet-runtime = dotnet-runtime;
@@ -75,7 +57,7 @@
buildInputs = with pkgs; [
(with dotnetCorePackages;
combinePackages [
dotnet-sdk_7
dotnet-sdk_8
dotnetPackages.Nuget
])
];