add dev-shell
This commit is contained in:
@@ -9,13 +9,16 @@
|
|||||||
},
|
},
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.defaultProfile.linux": "dev-shell"
|
||||||
|
},
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"formulahendry.dotnet-test-explorer",
|
"formulahendry.dotnet-test-explorer",
|
||||||
"jnoortheen.nix-ide",
|
"jnoortheen.nix-ide",
|
||||||
"eamodio.gitlens"
|
"eamodio.gitlens"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
// "features": {},
|
// "features": {},
|
||||||
@@ -29,7 +32,7 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
"postCreateCommand": "nix-env -i nixpkgs-fmt"
|
// "postCreateCommand": "nix-env -i nixpkgs-fmt"
|
||||||
|
|
||||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
// "remoteUser": "root"
|
// "remoteUser": "root"
|
||||||
|
|||||||
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@@ -1,3 +1,10 @@
|
|||||||
{
|
{
|
||||||
"dotnet-test-explorer.testProjectPath": "**/*Tests.csproj"
|
"dotnet-test-explorer.testProjectPath": "**/*Tests.csproj",
|
||||||
|
"terminal.integrated.profiles.linux": {
|
||||||
|
"dev-shell": {
|
||||||
|
"path": "bash",
|
||||||
|
"args": [ "-c", "nix --experimental-features \"nix-command flakes\" develop"],
|
||||||
|
"overrideName": true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
89
flake.nix
89
flake.nix
@@ -11,65 +11,65 @@
|
|||||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
scripts = forAllSystems (system: {
|
scripts = forAllSystems (system: {
|
||||||
updateFlakeLockFile = nixpkgsFor.${system}.writeScript "update_flake_lock.sh" ''
|
updateFlakeLockFile = nixpkgsFor.${system}.writeScript "update_flake_lock.sh" ''
|
||||||
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
|
||||||
nix --experimental-features 'nix-command flakes' build
|
nix --experimental-features 'nix-command flakes' build
|
||||||
'';
|
'';
|
||||||
|
|
||||||
updateNugetLockFile = nixpkgsFor.${system}.writeScript "update_nuget_lock.sh" ''
|
updateNugetLockFile = nixpkgsFor.${system}.writeScript "update_nuget_lock.sh" ''
|
||||||
temp_package_folder=$(mktemp -d)
|
temp_package_folder=$(mktemp -d)
|
||||||
dotnet restore ResourceString.Net --packages "$temp_package_folder"
|
dotnet restore ResourceString.Net --packages "$temp_package_folder"
|
||||||
${nixpkgsFor.${system}.nuget-to-nix}/bin/nuget-to-nix "$temp_package_folder" > ResourceString.Net/deps.nix
|
${nixpkgsFor.${system}.nuget-to-nix}/bin/nuget-to-nix "$temp_package_folder" > ResourceString.Net/deps.nix
|
||||||
rm -rf "$temp_package_folder"
|
rm -rf "$temp_package_folder"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
|
||||||
git tag --force v${version}
|
git tag --force v${version}
|
||||||
git push origin v${version}
|
git push origin v${version}
|
||||||
'';
|
'';
|
||||||
updateLogicResourceFile = nixpkgsFor.${system}.writeScript "update_logic_resource_file.sh" ''
|
updateLogicResourceFile = nixpkgsFor.${system}.writeScript "update_logic_resource_file.sh" ''
|
||||||
dotnet run --project ResourceString.Net.App.Console ResourceString.Net.Logic/Properties/Resources.resx ResourceString.Net.Logic.Properties > ResourceString.Net.Logic/Properties/Resources.cs.tmp
|
dotnet run --project ResourceString.Net.App.Console ResourceString.Net.Logic/Properties/Resources.resx ResourceString.Net.Logic.Properties > ResourceString.Net.Logic/Properties/Resources.cs.tmp
|
||||||
mv ResourceString.Net.Logic/Properties/Resources.cs.tmp ResourceString.Net.Logic/Properties/Resources.cs
|
mv ResourceString.Net.Logic/Properties/Resources.cs.tmp ResourceString.Net.Logic/Properties/Resources.cs
|
||||||
'';
|
'';
|
||||||
buildAllAssemblies = nixpkgsFor.${system}.writeScript "build_all_assemblies.sh" ''
|
buildAllAssemblies = nixpkgsFor.${system}.writeScript "build_all_assemblies.sh" ''
|
||||||
# Find all .csproj files below the current folder
|
# Find all .csproj files below the current folder
|
||||||
csproj_files=$(find . -name '*.csproj')
|
csproj_files=$(find . -name '*.csproj')
|
||||||
|
|
||||||
# Create a temporary file to store the number of dependencies for each project
|
# Create a temporary file to store the number of dependencies for each project
|
||||||
temp_file=$(mktemp)
|
temp_file=$(mktemp)
|
||||||
|
|
||||||
# Loop through each .csproj file and count its number of ResourceString dependencies
|
# Loop through each .csproj file and count its number of ResourceString dependencies
|
||||||
for file in $csproj_files
|
for file in $csproj_files
|
||||||
do
|
do
|
||||||
count=$(cat "$file" | grep -c "<ProjectReference.*ResourceString")
|
count=$(cat "$file" | grep -c "<ProjectReference.*ResourceString")
|
||||||
depth=$(echo "$file" | tr -cd '/' | wc -c)
|
depth=$(echo "$file" | tr -cd '/' | wc -c)
|
||||||
dot_count=$(echo "$file" | tr -cd '.' | wc -c)
|
dot_count=$(echo "$file" | tr -cd '.' | wc -c)
|
||||||
echo "$depth $count $dot_count $file" >> "$temp_file"
|
echo "$depth $count $dot_count $file" >> "$temp_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Sort the projects by their count of dependencies and path depth, in ascending order
|
# Sort the projects by their count of dependencies and path depth, in ascending order
|
||||||
sorted_projects=$(sort -nk1 -nk2 -nk3 -t' ' "$temp_file" | awk '{print $4}')
|
sorted_projects=$(sort -nk1 -nk2 -nk3 -t' ' "$temp_file" | awk '{print $4}')
|
||||||
|
|
||||||
# Loop through the sorted projects and build them
|
# Loop through the sorted projects and build them
|
||||||
while read -r file
|
while read -r file
|
||||||
do
|
do
|
||||||
echo "Building project: $file"
|
echo "Building project: $file"
|
||||||
dotnet build "$file"
|
dotnet build "$file"
|
||||||
done << EOF
|
done << EOF
|
||||||
$sorted_projects
|
$sorted_projects
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Remove the temporary file
|
# Remove the temporary file
|
||||||
rm "$temp_file"
|
rm "$temp_file"
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
cleanAllAssemblies = nixpkgsFor.${system}.writeScript "clean_all_assemblies.sh" ''
|
cleanAllAssemblies = nixpkgsFor.${system}.writeScript "clean_all_assemblies.sh" ''
|
||||||
csproj_files=$(find . -name '*.csproj')
|
csproj_files=$(find . -name '*.csproj')
|
||||||
for file in $csproj_files
|
for file in $csproj_files
|
||||||
do
|
do
|
||||||
dotnet clean "$file"
|
dotnet clean "$file"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
runDefaultApp = nixpkgsFor.${system}.writeScript "run_default_app.sh" ''
|
runDefaultApp = nixpkgsFor.${system}.writeScript "run_default_app.sh" ''
|
||||||
dotnet run --project ResourceString.Net.App.Console $@
|
dotnet run --project ResourceString.Net.App.Console $@
|
||||||
'';
|
'';
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
echo "# test package intregation"
|
echo "# test package intregation"
|
||||||
|
|
||||||
echo "## test example app"
|
echo "## test example app"
|
||||||
|
|
||||||
${scripts.${system}.runDotNet} restore example/Example.App/
|
${scripts.${system}.runDotNet} restore example/Example.App/
|
||||||
${scripts.${system}.runDotNet} build example/Example.App/
|
${scripts.${system}.runDotNet} build example/Example.App/
|
||||||
output=$(${scripts.${system}.runDotNet} run --project example/Example.App/ --no-build | tr '\n' ' ')
|
output=$(${scripts.${system}.runDotNet} run --project example/Example.App/ --no-build | tr '\n' ' ')
|
||||||
@@ -194,8 +194,7 @@
|
|||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
in
|
in rec {
|
||||||
rec {
|
|
||||||
packages = forAllSystems (system: {
|
packages = forAllSystems (system: {
|
||||||
default = nixpkgsFor.${system}.buildDotnetModule {
|
default = nixpkgsFor.${system}.buildDotnetModule {
|
||||||
pname = name;
|
pname = name;
|
||||||
|
|||||||
Reference in New Issue
Block a user