diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bed90d0..4817ed0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,13 +9,16 @@ }, "customizations": { "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "dev-shell" + }, "extensions": [ "formulahendry.dotnet-test-explorer", "jnoortheen.nix-ide", "eamodio.gitlens" ] } - }, + } // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, @@ -29,7 +32,7 @@ // } // 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. // "remoteUser": "root" diff --git a/.vscode/settings.json b/.vscode/settings.json index 40df522..d977c0d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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 + } + } } \ No newline at end of file diff --git a/flake.nix b/flake.nix index 8f9cea5..592105c 100644 --- a/flake.nix +++ b/flake.nix @@ -11,65 +11,65 @@ nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); scripts = forAllSystems (system: { 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' build - ''; + nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs + nix --experimental-features 'nix-command flakes' build + ''; updateNugetLockFile = nixpkgsFor.${system}.writeScript "update_nuget_lock.sh" '' - temp_package_folder=$(mktemp -d) - dotnet restore ResourceString.Net --packages "$temp_package_folder" - ${nixpkgsFor.${system}.nuget-to-nix}/bin/nuget-to-nix "$temp_package_folder" > ResourceString.Net/deps.nix - rm -rf "$temp_package_folder" - ''; + temp_package_folder=$(mktemp -d) + dotnet restore ResourceString.Net --packages "$temp_package_folder" + ${nixpkgsFor.${system}.nuget-to-nix}/bin/nuget-to-nix "$temp_package_folder" > ResourceString.Net/deps.nix + rm -rf "$temp_package_folder" + ''; autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" '' git tag --force v${version} git push origin v${version} ''; 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 - mv ResourceString.Net.Logic/Properties/Resources.cs.tmp ResourceString.Net.Logic/Properties/Resources.cs - ''; + 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 + ''; buildAllAssemblies = nixpkgsFor.${system}.writeScript "build_all_assemblies.sh" '' - # Find all .csproj files below the current folder - csproj_files=$(find . -name '*.csproj') + # Find all .csproj files below the current folder + csproj_files=$(find . -name '*.csproj') - # Create a temporary file to store the number of dependencies for each project - temp_file=$(mktemp) + # Create a temporary file to store the number of dependencies for each project + temp_file=$(mktemp) - # Loop through each .csproj file and count its number of ResourceString dependencies - for file in $csproj_files - do - count=$(cat "$file" | grep -c "> "$temp_file" - done + # Loop through each .csproj file and count its number of ResourceString dependencies + for file in $csproj_files + do + count=$(cat "$file" | grep -c "> "$temp_file" + done - # 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}') + # 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}') - # Loop through the sorted projects and build them - while read -r file - do - echo "Building project: $file" - dotnet build "$file" - done << EOF - $sorted_projects - EOF + # Loop through the sorted projects and build them + while read -r file + do + echo "Building project: $file" + dotnet build "$file" + done << EOF + $sorted_projects + EOF - # Remove the temporary file - rm "$temp_file" + # Remove the temporary file + rm "$temp_file" - ''; + ''; cleanAllAssemblies = nixpkgsFor.${system}.writeScript "clean_all_assemblies.sh" '' - csproj_files=$(find . -name '*.csproj') - for file in $csproj_files - do - dotnet clean "$file" - done - ''; + csproj_files=$(find . -name '*.csproj') + for file in $csproj_files + do + dotnet clean "$file" + done + ''; runDefaultApp = nixpkgsFor.${system}.writeScript "run_default_app.sh" '' dotnet run --project ResourceString.Net.App.Console $@ ''; @@ -97,7 +97,7 @@ echo "# test package intregation" echo "## test example app" - + ${scripts.${system}.runDotNet} restore example/Example.App/ ${scripts.${system}.runDotNet} build example/Example.App/ output=$(${scripts.${system}.runDotNet} run --project example/Example.App/ --no-build | tr '\n' ' ') @@ -194,8 +194,7 @@ ''; }); - in - rec { + in rec { packages = forAllSystems (system: { default = nixpkgsFor.${system}.buildDotnetModule { pname = name;