From f091534c05ef53cfb2a0942c6d48da340e1f3b3d Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Wed, 28 Dec 2022 11:03:19 +0000 Subject: [PATCH] Fantomas from flake (#49) --- .config/dotnet-tools.json | 2 +- .github/workflows/dotnet.yaml | 15 +++++++-------- AdventOfCode2022.sln | 2 +- flake.nix | 27 +++++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 219ac8b..2f2cb78 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "fantomas": { - "version": "5.1.0", + "version": "5.2.0-alpha-008", "commands": [ "fantomas" ] diff --git a/.github/workflows/dotnet.yaml b/.github/workflows/dotnet.yaml index 57bc34e..9325ddd 100644 --- a/.github/workflows/dotnet.yaml +++ b/.github/workflows/dotnet.yaml @@ -53,14 +53,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup .NET SDK v7.0.x - uses: actions/setup-dotnet@v3 + - name: Install Nix + uses: cachix/install-nix-action@v17 with: - dotnet-version: 7.0.x - - name: Prepare .NET tools - run: dotnet tool restore + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Run Fantomas - run: ./hooks/pre-push + run: nix run .#fantomas -- -r --check . check-nix-format: runs-on: ubuntu-latest @@ -87,7 +86,7 @@ jobs: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Run ShellCheck - run: nix shell 'nixpkgs#shellcheck' --command bash -c "find . -type f -name '*.sh' | xargs shellcheck" + run: nix develop --command bash -c "find . -type f -name '*.sh' | xargs shellcheck" linkcheck: name: Check links @@ -100,7 +99,7 @@ jobs: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Run link checker - run: nix shell 'nixpkgs#nodePackages.markdown-link-check' --command markdown-link-check README.md + run: nix develop --command markdown-link-check README.md all-required-checks-complete: needs: [check-dotnet-format, check-nix-format, build, shellcheck, linkcheck, run-app] diff --git a/AdventOfCode2022.sln b/AdventOfCode2022.sln index 0439762..c981d00 100644 --- a/AdventOfCode2022.sln +++ b/AdventOfCode2022.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AdventOfCode2022", "AdventOfCode2022\AdventOfCode2022.fsproj", "{6C4FDE18-389F-4AE6-AE9A-B4BD5BA19773}" EndProject diff --git a/flake.nix b/flake.nix index 9f3ab59..d029332 100644 --- a/flake.nix +++ b/flake.nix @@ -20,9 +20,30 @@ outputFiles = [""]; arrayToShell = a: toString (map (pkgs.lib.escape (pkgs.lib.stringToCharacters "\\ ';$`()|<>\t")) a); dotnet-sdk = pkgs.dotnet-sdk_7; + dotnet-runtime = pkgs.dotnetCorePackages.runtime_7_0; version = "0.0.1"; + dotnetTool = toolName: toolVersion: sha256: + pkgs.stdenvNoCC.mkDerivation rec { + name = toolName; + version = toolVersion; + nativeBuildInputs = [pkgs.makeWrapper]; + src = pkgs.fetchNuGet { + pname = name; + version = version; + sha256 = sha256; + installPhase = ''mkdir -p $out/bin && cp -r tools/net6.0/any/* $out/bin''; + }; + installPhase = '' + runHook preInstall + mkdir -p "$out/lib" + cp -r ./bin/* "$out/lib" + makeWrapper "${dotnet-runtime}/bin/dotnet" "$out/bin/${name}" --add-flags "$out/lib/${name}.dll" + runHook postInstall + ''; + }; 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; @@ -48,8 +69,8 @@ projectFile = projectFile; nugetDeps = ./deps.nix; doCheck = true; - dotnet-sdk = pkgs.dotnet-sdk_7; - dotnet-runtime = pkgs.dotnetCorePackages.runtime_7_0; + dotnet-sdk = dotnet-sdk; + dotnet-runtime = dotnet-runtime; }; }; devShell = pkgs.mkShell { @@ -62,6 +83,8 @@ ]; packages = [ pkgs.alejandra + pkgs.nodePackages.markdown-link-check + pkgs.shellcheck ]; }; });