mirror of
https://github.com/Smaug123/PulumiConfig
synced 2025-10-07 09:38:40 +00:00
Improve flake (#32)
This commit is contained in:
29
flake.nix
29
flake.nix
@@ -5,7 +5,6 @@
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
@@ -40,34 +39,12 @@
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
fantomas = dotnetTool "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version "sha256-Jmo7s8JMdQ8SxvNvPnryfE7n24mIgKi5cbgNwcQw3yU=";
|
||||
fetchDeps = let
|
||||
flags = [];
|
||||
runtimeIds = 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 (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;}))).sha256;
|
||||
default = pkgs.buildDotnetModule {
|
||||
pname = pname;
|
||||
version = version;
|
||||
inherit pname version projectFile testProjectFile dotnet-sdk dotnet-runtime;
|
||||
src = ./.;
|
||||
projectFile = projectFile;
|
||||
nugetDeps = ./nix/deps.nix;
|
||||
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;
|
||||
};
|
||||
};
|
||||
devShells = let
|
||||
|
59
nix/deps.nix
59
nix/deps.nix
@@ -1,11 +1,16 @@
|
||||
# This file was automatically generated by passthru.fetch-deps.
|
||||
# Please don't edit it manually, your changes might get overwritten!
|
||||
# Please dont edit it manually, your changes might get overwritten!
|
||||
{fetchNuGet}: [
|
||||
(fetchNuGet {
|
||||
pname = "Ben.Demystifier";
|
||||
version = "0.4.1";
|
||||
sha256 = "1szlrhvwpwkjhpgvjlrpjg714bz1yhyljs72pxni3li4mgnklk1f";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "fantomas";
|
||||
version = "6.3.0-alpha-005";
|
||||
sha256 = "09fz632c23dqf6wsi048i7dyfkkwy9x3wvzkqq90yxacqarknsi6";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "FsCheck";
|
||||
version = "2.16.5";
|
||||
@@ -13,19 +18,29 @@
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "FSharp.Core";
|
||||
version = "7.0.0";
|
||||
sha256 = "1pgk3qk9p1s53wvja17744x4bf7zs3a3wf0dmxi66w1w06z7i85x";
|
||||
version = "8.0.101";
|
||||
sha256 = "0prgcnki6s0rlrfbarrcv50w1bbhaalsyhhw5gsnjs2is7qrjbii";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "FsUnit";
|
||||
version = "5.0.0";
|
||||
sha256 = "0r535cw9ikm8xmyla6ah7qx3hb7nvz5m9fi0dqgbkd3wsrc8jlpl";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Google.Protobuf";
|
||||
version = "3.15.5";
|
||||
sha256 = "1pjg4f99y5k80nx76bjzlgvzd6zpwm80vfxhhi13wcxc69pnr2gf";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.AspNetCore.Server";
|
||||
version = "2.37.0";
|
||||
sha256 = "1wkdkfawdm5znhzwp21jwhs1hml08ks3308ak7zbf1f902jb9cad";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.AspNetCore.Server.Reflection";
|
||||
version = "2.37.0";
|
||||
sha256 = "1zpsnn4fwg9z5n91sc7vqbiamq562bkdbz9v8af1ykdnafxy2f7j";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.Core.Api";
|
||||
version = "2.37.0";
|
||||
@@ -33,13 +48,13 @@
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.Core.Api";
|
||||
version = "2.43.0";
|
||||
sha256 = "0aywd270inzfy3nizdvz7z1c083m11xfd76016q0c9sbmwrhv20j";
|
||||
version = "2.52.0";
|
||||
sha256 = "1mrc8zkcgvklrc0xalky9xxy9dkq5yk92idj1wm5zgdh6pghsa11";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.Net.Client";
|
||||
version = "2.43.0";
|
||||
sha256 = "1yxm894lpn5sg6xg7i5ldd9bh7xg2s2c6xsx0yf7zrachy1bqbar";
|
||||
version = "2.52.0";
|
||||
sha256 = "0f8m8nmx30bb5wk61i7aqxnwz00rflyc7l8pl9i60mr8ybq5n671";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.Net.Common";
|
||||
@@ -48,8 +63,13 @@
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.Net.Common";
|
||||
version = "2.43.0";
|
||||
sha256 = "17gn73ccqq5aap7r8i6nir1260f5ndav2yc67wk2gnp94nsavbm2";
|
||||
version = "2.52.0";
|
||||
sha256 = "1dhf98h89xbcpx4v6lmr3gq51br9r8jm38zhrs9dw8l9vy73x1jy";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Grpc.Reflection";
|
||||
version = "2.37.0";
|
||||
sha256 = "1gxdc4la8m9jkig87fa5r0zr1swiyfcpwqyn7n4yc3yv7zm9k53d";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Microsoft.CodeCoverage";
|
||||
@@ -188,23 +208,23 @@
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Pulumi";
|
||||
version = "3.53.0";
|
||||
sha256 = "0lalidv5kbn668h4517pgzv6di6x9i9ki1xi9fabbq2p9middwpj";
|
||||
version = "3.59.0";
|
||||
sha256 = "1692934sjzkjsn8j81yx69xin6f2mvnw561g8chac1n611an2p2c";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Pulumi.Cloudflare";
|
||||
version = "4.15.0";
|
||||
sha256 = "12wyz0slxgwwfk9ns322xgzqnix5mpx9nrmhs6rw2ssysf3jviv6";
|
||||
version = "5.16.0";
|
||||
sha256 = "06nnl6smcv8fqqb3gqhr63nqw5d8b9n8p28a96vcagq9l4a2h357";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Pulumi.Command";
|
||||
version = "4.5.0";
|
||||
sha256 = "01m3ap6prkkq8kaqdhjcs7m5ww7jb50vybadgx26381njgf24pk0";
|
||||
version = "0.5.2";
|
||||
sha256 = "1gas4raqr1fz58xqqhi3gdy85f8vy74a4s96ha8brp24l9z0568i";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Pulumi.DigitalOcean";
|
||||
version = "4.16.0";
|
||||
sha256 = "16xid3lv884csv1n4w3k0s9cqaikcbrpfavrp59c9aqc4l13a9v8";
|
||||
version = "4.24.0";
|
||||
sha256 = "1dv8vm2715nakb7z561pb5mwm928qkmvxvjrm0q9966r5jvm4rdl";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "Pulumi.Protobuf";
|
||||
@@ -616,6 +636,11 @@
|
||||
version = "4.4.0";
|
||||
sha256 = "0a6ahgi5b148sl5qyfpyw383p3cb4yrkm802k29fsi4mxkiwir29";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "System.Runtime.CompilerServices.Unsafe";
|
||||
version = "4.5.2";
|
||||
sha256 = "1vz4275fjij8inf31np78hw50al8nqkngk04p3xv5n4fcmf1grgi";
|
||||
})
|
||||
(fetchNuGet {
|
||||
pname = "System.Runtime.Extensions";
|
||||
version = "4.1.0";
|
||||
|
@@ -1,73 +0,0 @@
|
||||
#!/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] <output path>"
|
||||
echo " <output path> 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"
|
Reference in New Issue
Block a user