From a3bb1463ff1628c013fd7c68766310b190c05bfc Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Mon, 22 Jan 2024 23:43:36 +0000 Subject: [PATCH] Flake --- .github/dependabot.yml | 15 ++ .github/workflows/dotnet.yaml | 168 +++++++++++++ .gitignore | 2 + Directory.Build.props | 28 +++ PrattParser.Test/TestLexer.fs | 2 +- README.md | 3 + flake.lock | 60 +++++ flake.nix | 94 +++++++ nix/deps.nix | 444 ++++++++++++++++++++++++++++++++++ nix/fetchDeps.sh | 73 ++++++ 10 files changed, 888 insertions(+), 1 deletion(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dotnet.yaml create mode 100644 Directory.Build.props create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/deps.nix create mode 100644 nix/fetchDeps.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4a479ff --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + + - package-ecosystem: "nuget" + directory: "/" + schedule: + interval: "weekly" + ignore: + # Target the lowest version of FSharp.Core, for max compat + - dependency-name: "FSharp.Core" diff --git a/.github/workflows/dotnet.yaml b/.github/workflows/dotnet.yaml new file mode 100644 index 0000000..f9051f6 --- /dev/null +++ b/.github/workflows/dotnet.yaml @@ -0,0 +1,168 @@ +name: .NET + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + NUGET_XMLDOC_MODE: '' + DOTNET_MULTILEVEL_LOOKUP: 0 + +jobs: + build: + strategy: + matrix: + config: + - Release + - Debug + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # so that NerdBank.GitVersioning has access to history + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Restore dependencies + run: nix develop --command dotnet restore + - name: Build + run: nix develop --command dotnet build --no-restore --configuration ${{matrix.config}} + - name: Test + run: nix develop --command dotnet test --no-build --verbosity normal --configuration ${{matrix.config}} + + analyzers: + runs-on: ubuntu-latest + permissions: + security-events: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # so that NerdBank.GitVersioning has access to history + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Prepare analyzers + run: nix develop --command dotnet restore analyzers/analyzers.fsproj + - name: Build project + run: nix develop --command dotnet build + - name: Run analyzers + run: nix run .#fsharp-analyzers -- --project ./PrattParser/PrattParser.fsproj --analyzers-path ./.analyzerpackages/g-research.fsharp.analyzers/0.6.0/ --verbosity detailed --report ./analysis.sarif --treat-as-error GRA-STRING-001 GRA-STRING-002 GRA-STRING-003 GRA-UNIONCASE-001 GRA-INTERPOLATED-001 GRA-TYPE-ANNOTATE-001 GRA-VIRTUALCALL-001 GRA-IMMUTABLECOLLECTIONEQUALITY-001 GRA-JSONOPTS-001 GRA-LOGARGFUNCFULLAPP-001 + + build-nix: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Build + run: nix build + + check-dotnet-format: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Run Fantomas + run: nix run .#fantomas -- --check . + + check-nix-format: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Run Alejandra + run: nix develop --command alejandra --check . + + linkcheck: + name: Check links + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Run link checker + run: nix develop --command markdown-link-check README.md + + flake-check: + name: Check flake + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Flake check + run: nix flake check + + nuget-pack: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # so that NerdBank.GitVersioning has access to history + - name: Install Nix + uses: cachix/install-nix-action@v25 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Restore dependencies + run: nix develop --command dotnet restore + - name: Build + run: nix develop --command dotnet build --no-restore --configuration Release + - name: Pack + run: nix develop --command dotnet pack --configuration Release + - name: Upload NuGet artifact + uses: actions/upload-artifact@v4 + with: + name: nuget-package + path: PrattParser/bin/Release/PrattParser.*.nupkg + + expected-pack: + needs: [nuget-pack] + runs-on: ubuntu-latest + steps: + - name: Download NuGet artifact + uses: actions/download-artifact@v4 + with: + name: nuget-package + - name: Check NuGet contents + # Verify that there is exactly one nupkg in the artifact that would be NuGet published + run: if [[ $(find . -maxdepth 1 -name 'PrattParser.*.nupkg' -printf c | wc -c) -ne "1" ]]; then exit 1; fi + + all-required-checks-complete: + needs: [check-dotnet-format, check-nix-format, build, build-nix, linkcheck, flake-check, analyzers, nuget-pack, expected-pack] + runs-on: ubuntu-latest + steps: + - run: echo "All required checks complete." + diff --git a/.gitignore b/.gitignore index 775ff7c..bb4f691 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ riderModule.iml /_ReSharper.Caches/ .idea/ *.DotSettings.* + +result diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..2bc68d8 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,28 @@ + + + embedded + true + [UNDEFINED] + true + true + true + embedded + FS3388,FS3559 + + + + + + + + + + + Z:\CheckoutRoot\WoofWare.Myriad\ + + + + diff --git a/PrattParser.Test/TestLexer.fs b/PrattParser.Test/TestLexer.fs index edf3ed8..52678c7 100644 --- a/PrattParser.Test/TestLexer.fs +++ b/PrattParser.Test/TestLexer.fs @@ -67,4 +67,4 @@ module TestLexer = } ] - Lexer.lex input |> shouldEqual expected + Lexer.lex input |> Seq.toList |> shouldEqual expected diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ae05e0 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# PrattParser + +A Pratt parser, based on https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html . diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..109c548 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1703134684, + "narHash": "sha256-SQmng1EnBFLzS7WSRyPM9HgmZP2kLJcPAz+Ug/nug6o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d6863cbcbbb80e71cecfc03356db1cda38919523", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6ee0b40 --- /dev/null +++ b/flake.nix @@ -0,0 +1,94 @@ +{ + description = "A Pratt parser"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + pname = "PrattParser"; + dotnet-sdk = pkgs.dotnet-sdk_8; + dotnet-runtime = pkgs.dotnetCorePackages.runtime_8_0; + version = "0.1"; + dotnetTool = dllOverride: 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 = let + dll = + if isNull dllOverride + then name + else dllOverride; + in '' + runHook preInstall + mkdir -p "$out/lib" + cp -r ./bin/* "$out/lib" + makeWrapper "${dotnet-runtime}/bin/dotnet" "$out/bin/${name}" --add-flags "$out/lib/${dll}.dll" + runHook postInstall + ''; + }; + in { + packages = { + fantomas = dotnetTool null "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version "sha256-Jmo7s8JMdQ8SxvNvPnryfE7n24mIgKi5cbgNwcQw3yU="; + fsharp-analyzers = dotnetTool "FSharp.Analyzers.Cli" "fsharp-analyzers" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fsharp-analyzers.version "sha256-CWMW06ncSs8QkQvxNPNrgn3TAzMU6qCT1k2A3pnGrYQ="; + fetchDeps = let + flags = []; + runtimeIds = ["win-x64"] ++ map (system: pkgs.dotnetCorePackages.systemToDotnetRid system) dotnet-sdk.meta.platforms; + in + pkgs.writeShellScriptBin "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 ["./PrattParser/PrattParser.fsproj"]; + testProjectFiles = ["./PrattParser.Test/PrattParser.Test.fsproj"]; + rids = pkgs.lib.concatStringsSep "\" \"" runtimeIds; + packages = dotnet-sdk.packages; + storeSrc = pkgs.srcOnly { + src = ./.; + pname = pname; + version = version; + }; + })); + default = pkgs.buildDotnetModule { + pname = pname; + name = "PrattParser"; + version = version; + src = ./.; + projectFile = "./PrattParser/PrattParser.fsproj"; + nugetDeps = ./nix/deps.nix; + doCheck = true; + dotnet-sdk = dotnet-sdk; + dotnet-runtime = dotnet-runtime; + }; + }; + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + (with dotnetCorePackages; + combinePackages [ + dotnet-sdk_8 + dotnetPackages.Nuget + ]) + ]; + packages = [ + pkgs.alejandra + pkgs.nodePackages.markdown-link-check + pkgs.shellcheck + ]; + }; + }); +} diff --git a/nix/deps.nix b/nix/deps.nix new file mode 100644 index 0000000..ee2964d --- /dev/null +++ b/nix/deps.nix @@ -0,0 +1,444 @@ +# This file was automatically generated by passthru.fetch-deps. +# Please don't edit it manually, your changes might get overwritten! +{fetchNuGet}: [ + (fetchNuGet { + pname = "fsharp-analyzers"; + version = "0.23.0"; + sha256 = "sha256-CWMW06ncSs8QkQvxNPNrgn3TAzMU6qCT1k2A3pnGrYQ="; + }) + (fetchNuGet { + pname = "fantomas"; + version = "6.3.0-alpha-005"; + sha256 = "sha256-Jmo7s8JMdQ8SxvNvPnryfE7n24mIgKi5cbgNwcQw3yU="; + }) + (fetchNuGet { + pname = "ApiSurface"; + version = "4.0.25"; + sha256 = "0zjq8an9cr0l7wxdmm9n9s3iyq5m0zl4x0h0wmy5cz7am8y15qc4"; + }) + (fetchNuGet { + pname = "coverlet.collector"; + version = "6.0.0"; + sha256 = "12j34vrkmph8lspbafnqmfnj2qvysz1jcrks2khw798s6dwv0j90"; + }) + (fetchNuGet { + pname = "Fantomas.Core"; + version = "6.1.1"; + sha256 = "1h2wsiy4fzwsg9vrlpk6w7zsvx6bc4wg4x25zqc48akg04fwpi0m"; + }) + (fetchNuGet { + pname = "Fantomas.FCS"; + version = "6.1.1"; + sha256 = "0733dm5zjdp8w5wwalqlv1q52pghfr04863i9wy807f4qfd7rrin"; + }) + (fetchNuGet { + pname = "FsCheck"; + version = "2.16.6"; + sha256 = "176rwky6b5rk8dzldiz4068p7m9c5y9ygzbhadrs14jkl94pc56n"; + }) + (fetchNuGet { + pname = "FSharp.Core"; + version = "6.0.1"; + sha256 = "0qks2aadkhsffg9a6xq954ll9xacnph852avd7ljh9n2g6vj06qj"; + }) + (fetchNuGet { + pname = "FSharp.Core"; + version = "8.0.100"; + sha256 = "06z3vg8yj7i83x6gmnzl2lka1bp4hzc07h6mrydpilxswnmy2a0l"; + }) + (fetchNuGet { + pname = "FsUnit"; + version = "6.0.0"; + sha256 = "18q3p0z155znwj1l0qq3vq9nh9wl2i4mlfx4pmrnia4czr0xdkmb"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Ref"; + version = "6.0.25"; + sha256 = "1vrmqn5j6ibwkqasbf7x7n4w5jdclnz3giymiwvym2wa0y5zc59q"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Ref"; + version = "8.0.0"; + sha256 = "0k304yhpm92c46a1fscbzlgvdbhrm9vlbpyfgwp3cafz4f7z7a5y"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64"; + version = "6.0.25"; + sha256 = "0mgcs4si7mwd0f555s1vg17pf4nqfaijd1pci359l1pgrmv70rrg"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64"; + version = "8.0.0"; + sha256 = "05y1xb5fw8lzvb4si77a5qwfwfz1855crqbphrwky6x9llivbhkx"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; + version = "6.0.25"; + sha256 = "0wvzhqhlmlbnpa18qp8m3wcrlcgj3ckvp3iv2n7g8vb60c3238aq"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; + version = "8.0.0"; + sha256 = "18zdbcb2bn7wy1dp14z5jyqiiwr9rkad1lcb158r5ikjfq1rg5iw"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64"; + version = "6.0.25"; + sha256 = "1pywgvb8ck1d5aadmijd5s3z6yclchd9pa6dsahijmm55ibplx36"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64"; + version = "8.0.0"; + sha256 = "1nbxzmj6cnccylxis67c54c0ik38ma4rwdvgg6sxd6r04219maqm"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.osx-x64"; + version = "6.0.25"; + sha256 = "1zlf0w7i6r02719dv3nw4jy14sa0rs53i89an5alz5qmywdy3f1d"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.osx-x64"; + version = "8.0.0"; + sha256 = "1wqkbjd1ywv9w397l7rsb89mijc5n0hv7jq9h09xfz6wn9qsp152"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.win-x64"; + version = "6.0.25"; + sha256 = "1fbsnm4056cpd4avgpi5sq05m1yd9k4x229ckxpr4q7yc94sncwy"; + }) + (fetchNuGet { + pname = "Microsoft.AspNetCore.App.Runtime.win-x64"; + version = "8.0.0"; + sha256 = "08vlmswmiyp2nxlr9d77716hk7kz7h9x5bl8wh76xzbj5id1xlb2"; + }) + (fetchNuGet { + pname = "Microsoft.Build.Tasks.Git"; + version = "8.0.0"; + sha256 = "0055f69q3hbagqp8gl3nk0vfn4qyqyxsxyy7pd0g7wm3z28byzmx"; + }) + (fetchNuGet { + pname = "Microsoft.CodeCoverage"; + version = "17.8.0"; + sha256 = "173wjadp3gan4x2jfjchngnc4ca4mb95h1sbb28jydfkfw0z1zvj"; + }) + (fetchNuGet { + pname = "Microsoft.NET.Test.Sdk"; + version = "17.8.0"; + sha256 = "1syvl3g0hbrcgfi9rq6pld8s8hqqww4dflf1lxn59ccddyyx0gmv"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.linux-arm64"; + version = "6.0.25"; + sha256 = "052388yjivzkfllkss0nljbzmjx787jqdjsbb6ls855sp6wh9xfd"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.linux-arm64"; + version = "8.0.0"; + sha256 = "0bpg3v9dnalz7yh7lsgriw9rnm9jx37mqhhvf7snznb3sfk7rgwb"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.linux-x64"; + version = "6.0.25"; + sha256 = "103xy6kncjwbbchfnpqvsjpjy92x3dralcg9pw939jp0dwggwarz"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.linux-x64"; + version = "8.0.0"; + sha256 = "1c7l68bm05d94x5wk1y33mnd4v8m196vyprgrzqnh94yrqy6fkf7"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.osx-arm64"; + version = "6.0.25"; + sha256 = "13m14pdx5xfxky07xgxf6hjd7g9l4k6k40wvp9znhvn27pa0wdxv"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.osx-arm64"; + version = "8.0.0"; + sha256 = "1hdv825s964vfcgnk94pzhgxnj948f1vdj423jjxpkppcy30fl0m"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.osx-x64"; + version = "6.0.25"; + sha256 = "132pgjhv42mqzx4007sd59bkds0fwsv5xaz07y2yffbn3lzr228k"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.osx-x64"; + version = "8.0.0"; + sha256 = "0jmzf58vv45j0hqlxq8yalpjwi328vp2mjr3h0pdg0qr143iivnr"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.win-x64"; + version = "6.0.25"; + sha256 = "039433rm4w37h9qri11v3lrpddpz7zcly9kq8vmk6w1ixzlqwf01"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Host.win-x64"; + version = "8.0.0"; + sha256 = "1n8yr13df2f6jhxpfazs6rxahfqm18fhjvfm16g5d60c3za1hwnk"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Ref"; + version = "6.0.25"; + sha256 = "0jfhmfxpx1h4f3axgf60gc8d4cnlvbb853400kag6nk0875hr0x1"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Ref"; + version = "8.0.0"; + sha256 = "0hyvbh86433764qqqhw9i7ga0ax7bbdmzh77jw58pq0ggm41cff9"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.linux-arm64"; + version = "6.0.25"; + sha256 = "0jpcmva1l8z36r4phz055l7fz9s6z8pv8pqc4ia69mhhgvr0ks7y"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.linux-arm64"; + version = "8.0.0"; + sha256 = "0gwqmkmr7jy3sjh9gha82amlry41gp8nwswy2iqfw54f28db63n7"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.linux-x64"; + version = "6.0.25"; + sha256 = "012jml0bqxbspahf1j4bvvd91pz85hsbcyhq00gxczcazhxpkhz4"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.linux-x64"; + version = "8.0.0"; + sha256 = "042cjvnwrrjs3mw5q8q5kinh0cwkks33i3n1vyifaid2jbr3wlc0"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.osx-arm64"; + version = "6.0.25"; + sha256 = "0wgwxpyy1n550sw7npjg69zpxknwn0ay30m2qybvqb5mj857qzxi"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.osx-arm64"; + version = "8.0.0"; + sha256 = "06ndp4wh1cap01dql3nixka4g56bf6ipmqys7xaxvg4xisf79x8d"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.osx-x64"; + version = "6.0.25"; + sha256 = "08vr7c5bg5x3w35l54z1azif7ysfc2yiyz50ip1dl0mpqywvlswr"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.osx-x64"; + version = "8.0.0"; + sha256 = "1kh5bnaf6h9mr4swcalrp304625frjiw6mlz1052rxwzsdq98a96"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.win-x64"; + version = "6.0.25"; + sha256 = "03snpmx204xvc9668riisvvdjjgdqhwj7yjp85w5lh8j8ygrqkif"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.App.Runtime.win-x64"; + version = "8.0.0"; + sha256 = "054icf5jjnwnswrnv1r05x3pfjvacbz6g3dj8caar1zp53k49rkk"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.Platforms"; + version = "1.1.1"; + sha256 = "164wycgng4mi9zqi2pnsf1pq6gccbqvw6ib916mqizgjmd8f44pj"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.Platforms"; + version = "2.0.0"; + sha256 = "1fk2fk2639i7nzy58m9dvpdnzql4vb8yl8vr19r2fp8lmj9w2jr0"; + }) + (fetchNuGet { + pname = "Microsoft.NETCore.Targets"; + version = "1.1.3"; + sha256 = "05smkcyxir59rgrmp7d6327vvrlacdgldfxhmyr1azclvga1zfsq"; + }) + (fetchNuGet { + pname = "Microsoft.SourceLink.Common"; + version = "8.0.0"; + sha256 = "0xrr8yd34ij7dqnyddkp2awfmf9qn3c89xmw2f3npaa4wnajmx81"; + }) + (fetchNuGet { + pname = "Microsoft.SourceLink.GitHub"; + version = "8.0.0"; + sha256 = "1gdx7n45wwia3yvang3ls92sk3wrymqcx9p349j8wba2lyjf9m44"; + }) + (fetchNuGet { + pname = "Microsoft.TestPlatform.ObjectModel"; + version = "17.8.0"; + sha256 = "0b0i7lmkrcfvim8i3l93gwqvkhhhfzd53fqfnygdqvkg6np0cg7m"; + }) + (fetchNuGet { + pname = "Microsoft.TestPlatform.TestHost"; + version = "17.8.0"; + sha256 = "0f5jah93kjkvxwmhwb78lw11m9pkkq9fvf135hpymmmpxqbdh97q"; + }) + (fetchNuGet { + pname = "Myriad.Core"; + version = "0.8.3"; + sha256 = "0s5pdckjw4x0qrbd4i3cz9iili5cppg5qnjbr7zjbbhhmxzb24xw"; + }) + (fetchNuGet { + pname = "Myriad.Sdk"; + version = "0.8.3"; + sha256 = "0qv78c5s5m04xb8h17nnn2ig26zcyya91k2dpj745cm1cbnzvvgc"; + }) + (fetchNuGet { + pname = "Nerdbank.GitVersioning"; + version = "3.6.133"; + sha256 = "1cdw8krvsnx0n34f7fm5hiiy7bs6h3asvncqcikc0g46l50w2j80"; + }) + (fetchNuGet { + pname = "Newtonsoft.Json"; + version = "13.0.1"; + sha256 = "0fijg0w6iwap8gvzyjnndds0q4b8anwxxvik7y8vgq97dram4srb"; + }) + (fetchNuGet { + pname = "Newtonsoft.Json"; + version = "13.0.3"; + sha256 = "0xrwysmrn4midrjal8g2hr1bbg38iyisl0svamb11arqws4w2bw7"; + }) + (fetchNuGet { + pname = "NuGet.Common"; + version = "6.8.0"; + sha256 = "0l3ij8iwy7wj6s7f93lzi9168r4wz8zyin6a08iwgk7hvq44cia1"; + }) + (fetchNuGet { + pname = "NuGet.Configuration"; + version = "6.8.0"; + sha256 = "0x03p408smkmv1gv7pmvsia4lkn0xaj4wfrkl58pjf8bbv51y0yw"; + }) + (fetchNuGet { + pname = "NuGet.Frameworks"; + version = "6.5.0"; + sha256 = "0s37d1p4md0k6d4cy6sq36f2dgkd9qfbzapxhkvi8awwh0vrynhj"; + }) + (fetchNuGet { + pname = "NuGet.Frameworks"; + version = "6.8.0"; + sha256 = "0i2xvhgkjkjr496i3pg8hamwv6505fia45qhn7jg5m01wb3cvsjl"; + }) + (fetchNuGet { + pname = "NuGet.Packaging"; + version = "6.8.0"; + sha256 = "031z4s905bxi94h3f0qy4j1b6jxdxgqgpkzqvvpfxch07szxcbim"; + }) + (fetchNuGet { + pname = "NuGet.Protocol"; + version = "6.7.0"; + sha256 = "1v5ibnq2mp801vw68zyj169hkj3xm7h55824i33n1jxxj2vs3vbk"; + }) + (fetchNuGet { + pname = "NuGet.Versioning"; + version = "6.8.0"; + sha256 = "1sd25h46fd12ng780r02q4ijcx1imkb53kj1y2y7cwg5myh537ks"; + }) + (fetchNuGet { + pname = "NUnit"; + version = "4.0.1"; + sha256 = "0jgiq3dbwli5r70j0bw7021d69r7bhr58s8kphlpjmf7k47l5pcd"; + }) + (fetchNuGet { + pname = "NUnit.Analyzers"; + version = "3.10.0"; + sha256 = "1zc6s7lmzw5avrnbbjwyzla9d6bafbpxgv62m4zlqxv14p85md0d"; + }) + (fetchNuGet { + pname = "NUnit3TestAdapter"; + version = "4.5.0"; + sha256 = "1srx1629s0k1kmf02nmz251q07vj6pv58mdafcr5dr0bbn1fh78i"; + }) + (fetchNuGet { + pname = "RestEase"; + version = "1.6.4"; + sha256 = "1mvi3nbrr450g3fgd1y4wg3bwl9k1agyjfd9wdkqk12714bsln8l"; + }) + (fetchNuGet { + pname = "runtime.any.System.Runtime"; + version = "4.3.0"; + sha256 = "1cqh1sv3h5j7ixyb7axxbdkqx6cxy00p4np4j91kpm492rf4s25b"; + }) + (fetchNuGet { + pname = "runtime.native.System"; + version = "4.3.0"; + sha256 = "15hgf6zaq9b8br2wi1i3x0zvmk410nlmsmva9p0bbg73v6hml5k4"; + }) + (fetchNuGet { + pname = "runtime.unix.System.Private.Uri"; + version = "4.3.0"; + sha256 = "1jx02q6kiwlvfksq1q9qr17fj78y5v6mwsszav4qcz9z25d5g6vk"; + }) + (fetchNuGet { + pname = "System.Diagnostics.DiagnosticSource"; + version = "7.0.0"; + sha256 = "1jxhvsh5mzdf0sgb4dfmbys1b12ylyr5pcfyj1map354fiq3qsgm"; + }) + (fetchNuGet { + pname = "System.Formats.Asn1"; + version = "6.0.0"; + sha256 = "1vvr7hs4qzjqb37r0w1mxq7xql2b17la63jwvmgv65s1hj00g8r9"; + }) + (fetchNuGet { + pname = "System.IO.Abstractions"; + version = "4.2.13"; + sha256 = "0s784iphsmj4vhkrzq9q3w39vsn76w44zclx3hsygsw458zbyh4y"; + }) + (fetchNuGet { + pname = "System.IO.FileSystem.AccessControl"; + version = "4.5.0"; + sha256 = "1gq4s8w7ds1sp8f9wqzf8nrzal40q5cd2w4pkf4fscrl2ih3hkkj"; + }) + (fetchNuGet { + pname = "System.Memory"; + version = "4.5.5"; + sha256 = "08jsfwimcarfzrhlyvjjid61j02irx6xsklf32rv57x2aaikvx0h"; + }) + (fetchNuGet { + pname = "System.Private.Uri"; + version = "4.3.0"; + sha256 = "04r1lkdnsznin0fj4ya1zikxiqr0h6r6a1ww2dsm60gqhdrf0mvx"; + }) + (fetchNuGet { + pname = "System.Reflection.Metadata"; + version = "1.6.0"; + sha256 = "1wdbavrrkajy7qbdblpbpbalbdl48q3h34cchz24gvdgyrlf15r4"; + }) + (fetchNuGet { + pname = "System.Runtime"; + version = "4.3.1"; + sha256 = "03ch4d2acf6q037a4njxpll2kkx3dwzlg07yxr4z5m6j1kqgmm27"; + }) + (fetchNuGet { + pname = "System.Runtime.CompilerServices.Unsafe"; + version = "6.0.0"; + sha256 = "0qm741kh4rh57wky16sq4m0v05fxmkjjr87krycf5vp9f0zbahbc"; + }) + (fetchNuGet { + pname = "System.Security.AccessControl"; + version = "4.5.0"; + sha256 = "1wvwanz33fzzbnd2jalar0p0z3x0ba53vzx1kazlskp7pwyhlnq0"; + }) + (fetchNuGet { + pname = "System.Security.Cryptography.Pkcs"; + version = "6.0.4"; + sha256 = "0hh5h38pnxmlrnvs72f2hzzpz4b2caiiv6xf8y7fzdg84r3imvfr"; + }) + (fetchNuGet { + pname = "System.Security.Cryptography.ProtectedData"; + version = "4.4.0"; + sha256 = "1q8ljvqhasyynp94a1d7jknk946m20lkwy2c3wa8zw2pc517fbj6"; + }) + (fetchNuGet { + pname = "System.Security.Principal.Windows"; + version = "4.5.0"; + sha256 = "0rmj89wsl5yzwh0kqjgx45vzf694v9p92r4x4q6yxldk1cv1hi86"; + }) + (fetchNuGet { + pname = "System.Text.Encodings.Web"; + version = "6.0.0"; + sha256 = "06n9ql3fmhpjl32g3492sj181zjml5dlcc5l76xq2h38c4f87sai"; + }) + (fetchNuGet { + pname = "System.Text.Json"; + version = "6.0.0"; + sha256 = "1si2my1g0q0qv1hiqnji4xh9wd05qavxnzj9dwgs23iqvgjky0gl"; + }) +] diff --git a/nix/fetchDeps.sh b/nix/fetchDeps.sh new file mode 100644 index 0000000..e15b822 --- /dev/null +++ b/nix/fetchDeps.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +# This file was adapted from +# https://github.com/NixOS/nixpkgs/blob/b981d811453ab84fb3ea593a9b33b960f1ab9147/pkgs/build-support/dotnet/build-dotnet-module/default.nix#L173 +set -euo pipefail +export PATH="@binPath@" +for arg in "$@"; do + case "$arg" in + --keep-sources|-k) + keepSources=1 + shift + ;; + --help|-h) + echo "usage: $0 [--keep-sources] [--help] " + echo " The path to write the lockfile to. A temporary file is used if this is not set" + echo " --keep-sources Don't remove temporary directories upon exit, useful for debugging" + echo " --help Show this help message" + exit + ;; + esac +done +tmp=$(mktemp -td "@pname@-tmp-XXXXXX") +export tmp +HOME=$tmp/home +exitTrap() { + test -n "${ranTrap-}" && return + ranTrap=1 + if test -n "${keepSources-}"; then + echo -e "Path to the source: $tmp/src\nPath to the fake home: $tmp/home" + else + rm -rf "$tmp" + fi + # Since mktemp is used this will be empty if the script didnt succesfully complete + if ! test -s "$depsFile"; then + rm -rf "$depsFile" + fi +} +trap exitTrap EXIT INT TERM +dotnetRestore() { + local -r project="${1-}" + local -r rid="$2" + dotnet restore "${project-}" \ + -p:ContinuousIntegrationBuild=true \ + -p:Deterministic=true \ + --packages "$tmp/nuget_pkgs" \ + --runtime "$rid" \ + --no-cache \ + --force +} +declare -a projectFiles=( @projectFiles@ ) +declare -a testProjectFiles=( @testProjectFiles@ ) +export DOTNET_NOLOGO=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +depsFile=$(realpath "${1:-$(mktemp -t "@pname@-deps-XXXXXX.nix")}") +mkdir -p "$tmp/nuget_pkgs" +storeSrc="@storeSrc@" +src="$tmp/src" +cp -rT "$storeSrc" "$src" +chmod -R +w "$src" +cd "$src" +echo "Restoring project..." +rids=("@rids@") +for rid in "${rids[@]}"; do + (( ${#projectFiles[@]} == 0 )) && dotnetRestore "" "$rid" + for project in "${projectFiles[@]-}" "${testProjectFiles[@]-}"; do + dotnetRestore "$project" "$rid" + done +done +echo "Successfully restored project" +echo "Writing lockfile..." +echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please don't edit it manually, your changes might get overwritten!\n" > "$depsFile" +nuget-to-nix "$tmp/nuget_pkgs" "@packages@" >> "$depsFile" +echo "Successfully wrote lockfile to $depsFile"