Jump to content

Godot-Mono: Difference between revisions

From Official NixOS Wiki
Klinger (talk | contribs)
Fix incorrect code (wrong sdk path, missing userSettings, missing }, ...), improve code formatting, remove unused vscode settings, add smaller example, explicitly mention that home manager is needed, make section on configuring vscode as editor for godot more consistent and correct
 
Line 14: Line 14:
As Godot editor has poor support for C#, VSCode editor is recommended.
As Godot editor has poor support for C#, VSCode editor is recommended.


You can install and configure VSCode as such:
You can install and configure VSCode using [[Home Manager]] as such:
programs.vscode = {
  enable = true;
  # `pkgs.vscodium` is unsupported by "C# Dev Kit" VSCode extension which demands [https://marketplace.visualstudio.com/items/ms-dotnettools.csdevkit/license Microsoft license] compliance.
  package = pkgs.vscode;
  profiles.default = {
    "csharp.toolsDotnetPath" = "${pkgs.dotnet-sdk_9}/bin/dotnet";
    "dotnetAcquisitionExtension.sharedExistingDotnetPath" = "${pkgs.dotnet-sdk_9}/bin/dotnet";
    "dotnetAcquisitionExtension.existingDotnetPath" = [
      {
         "extensionId" = "ms-dotnettools.csharp";
         "path" = "${pkgs.dotnet-sdk_9}/bin/dotnet";
       }
       {
         "extensionId" = "ms-dotnettools.csdevkit";
         "path" = "${pkgs.dotnet-sdk_9}/bin/dotnet";
       }
      {
        "extensionId" = "woberg.godot-dotnet-tools";
        "path" = "${pkgs.dotnet-sdk_8}/bin/dotnet"; # Godot-Mono uses DotNet8 version.
      }
     ];
    "godotTools.lsp.serverPort" = 6005; # port should match your Godot configuration
    "omnisharp" = { # OminiSharp is a custom [[wikipedia:Language_Server_Protocol|LSP]] for C#
      "path" = "${pkgs.omnisharp-roslyn}/bin/OmniSharp";
      "sdkPath" = "${pkgs.dotnet-sdk_9}";
      "dotnetPath" = "${pkgs.dotnet-sdk_9}/bin/dotnet";
    };
  extensions = with pkgs.vscode-extensions; [
    geequlim.godot-tools # For Godot GDScript support
    woberg.godot-dotnet-tools # For Godot C# support
    ms-dotnettools.csdevkit
    ms-dotnettools.csharp
    ms-dotnettools.vscode-dotnet-runtime
  ];
};
home.packages = [
  dotnetCorePackages.dotnet_9.sdk # For Godot-Mono VSCode-Extension CSharp
];
# The proposed solution above requires .Net SDK to be broadly available in the host.
# Code is ugly but works. Ideally we should find a better solution to this.
# If you wonder why solution got so complex, test VSCode extensions as immutable,
# using flag "programs.vscode.mutableExtensionsDir = false". (No external downloads.)
Configure Godot's '''Editor → Editor Settings''' menu:


* Set '''Dotnet''' -> '''Editor''' -> '''External Editor''' to '''Visual Studio Code'''.
=== Minimal/Small Example ===
{{code|lang=nix|line=no|1=
programs.vscode = {
enable = true;
package = pkgs.vscodium;
profiles.default = {
userSettings = {
"dotnetAcquisitionExtension.sharedExistingDotnetPath" = "${pkgs.dotnet-sdk_9}/bin";
"godotTools.lsp.serverPort" = 6005; # port should match your Godot configuration
};
extensions = with pkgs.vscode-extensions; [
geequlim.godot-tools # For Godot GDScript support
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
];
};
};


====== Configure VSCode as External Editor in Godot 4 ======
home.packages = [
Click '''Editor''' [top menu] -> '''Editor Settings''' [menu item] -> '''General''' [Tab] -> '''Text Editor''' [Category] -> '''External''' [Sub-Category]:
dotnetCorePackages.dotnet_9.sdk # For Godot-Mono VSCode-Extension CSharp
];
 
# The proposed solution above requires .Net SDK to be broadly available in the host.
# Code is ugly but works. Ideally we should find a better solution to this.
# If you wonder why solution got so complex, test VSCode extensions as immutable,
# using flag "programs.vscode.mutableExtensionsDir = false". (No external downloads.)
}}
 
 
=== More elaborate Example ===
{{code|lang=nix|line=no|1=
programs.vscode = {
enable = true;
package = pkgs.vscode; # `pkgs.vscodium` is unsupported by "C# Dev Kit" VSCode extension.
profiles.default = {
userSettings = {
"dotnetAcquisitionExtension.existingDotnetPath" = [
{
"extensionId" = "ms-dotnettools.csharp";
"path" = "${pkgs.dotnet-sdk_9}/bin";
}
{
"extensionId" = "ms-dotnettools.csdevkit";
"path" = "${pkgs.dotnet-sdk_9}/bin";
}
{
"extensionId" = "woberg.godot-dotnet-tools";
"path" = "${pkgs.dotnet-sdk_8}/bin"; # Godot-Mono uses DotNet8 version.
}
];
"godotTools.lsp.serverPort" = 6005; # port should match your Godot configuration
};
extensions = with pkgs.vscode-extensions; [
geequlim.godot-tools # For Godot GDScript support
woberg.godot-dotnet-tools # For Godot C# support
ms-dotnettools.csdevkit
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{ name = "godot-files";
publisher = "alfish";
version = "0.1.6";
sha256 = "sha256-FFtl1QXSa4nGKFUJh5f3R7AV7hZg59Qs5vBZHgSUCUw=";
}
];
};
};
 
home.packages = [
dotnetCorePackages.dotnet_9.sdk # For Godot-Mono VSCode-Extension CSharp
];
}}
 
== Configure VSCode as External Editor in Godot 4 ==
Click '''Editor''' [top menu] -> '''Editor Settings''' [menu item] -> '''General''' [Tab] -> Search for "dotnet" -> '''Dotnet''' [Category] -> '''Editor''' [Sub-Category]:


* '''Exec Path''' -> Add the output of <code>which code</code>, on my case would be: <code>/etc/profiles/per-user/REPLACE-USERNAME/bin/code</code>
* '''Exec Path''' -> Add the output of <code>which code</code>, on my case would be: <code>/etc/profiles/per-user/REPLACE-USERNAME/bin/code</code>
* '''Exec Flags''' -> <code>{project} --goto {file}:{line}:{col}</code>
* '''Exec Flags''' -> <code>{project} --goto {file}:{line}:{col}</code>
* '''Use External Editor''' -> <code>On</code>
* '''External Editor''' -> <code>Visual Studio Code and VSCodium</code>






[[Category:Csharp]]
[[Category:Csharp]]

Latest revision as of 21:04, 24 January 2026

☶︎
This article or section needs to be expanded. Further information may be found in the related discussion page. Please consult the pedia article metapage for guidelines on contributing.

Godot-Mono is Godot's game engine supporting C# language for creating both 2D and 3D games.

Installation

Add pkgs.godot-mono (GDScript + C#) to environment.systemPackages.

Export Templates

On Godot upgrade, the new export template version can be automatically provisioned this way:

home.file.".local/share/godot/export_templates/${builtins.replaceStrings [ "-" ] [ "." ] pkgs.godot-mono_4-export-templates.version}".source = pkgs.godot-mono_4-export-templates;

Note: `pkgs.godot-mono_4-export-templates` package is still pending in nixpkgs.

Configuring VSCode Editor for Godot-Mono (C#)

As Godot editor has poor support for C#, VSCode editor is recommended.

You can install and configure VSCode using Home Manager as such:

Minimal/Small Example

programs.vscode = {
	enable = true;
	package = pkgs.vscodium;
	profiles.default = {
		userSettings = {
			"dotnetAcquisitionExtension.sharedExistingDotnetPath" = "${pkgs.dotnet-sdk_9}/bin";
			"godotTools.lsp.serverPort" = 6005; # port should match your Godot configuration
		};
		extensions = with pkgs.vscode-extensions; [
			geequlim.godot-tools # For Godot GDScript support
			ms-dotnettools.csharp
			ms-dotnettools.vscode-dotnet-runtime
		];
	};
};

home.packages = [
	dotnetCorePackages.dotnet_9.sdk # For Godot-Mono VSCode-Extension CSharp
];

# The proposed solution above requires .Net SDK to be broadly available in the host.
# Code is ugly but works. Ideally we should find a better solution to this.
# If you wonder why solution got so complex, test VSCode extensions as immutable,
# using flag "programs.vscode.mutableExtensionsDir = false". (No external downloads.)


More elaborate Example

programs.vscode = {
	enable = true;
	package = pkgs.vscode; # `pkgs.vscodium` is unsupported by "C# Dev Kit" VSCode extension.
	profiles.default = {
		userSettings = {
			"dotnetAcquisitionExtension.existingDotnetPath" = [
				{
					"extensionId" = "ms-dotnettools.csharp";
					"path" = "${pkgs.dotnet-sdk_9}/bin";
				}
				{
					"extensionId" = "ms-dotnettools.csdevkit";
					"path" = "${pkgs.dotnet-sdk_9}/bin";
				}
				{
					"extensionId" = "woberg.godot-dotnet-tools";
					"path" = "${pkgs.dotnet-sdk_8}/bin"; # Godot-Mono uses DotNet8 version.
				}
			];
			"godotTools.lsp.serverPort" = 6005; # port should match your Godot configuration
		};
		extensions = with pkgs.vscode-extensions; [
			geequlim.godot-tools # For Godot GDScript support
			woberg.godot-dotnet-tools # For Godot C# support
			ms-dotnettools.csdevkit
			ms-dotnettools.csharp
			ms-dotnettools.vscode-dotnet-runtime
		] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
			{ name = "godot-files";
				publisher = "alfish";
				version = "0.1.6";
				sha256 = "sha256-FFtl1QXSa4nGKFUJh5f3R7AV7hZg59Qs5vBZHgSUCUw=";
			}
		];
	};
};

home.packages = [
	dotnetCorePackages.dotnet_9.sdk # For Godot-Mono VSCode-Extension CSharp
];

Configure VSCode as External Editor in Godot 4

Click Editor [top menu] -> Editor Settings [menu item] -> General [Tab] -> Search for "dotnet" -> Dotnet [Category] -> Editor [Sub-Category]:

  • Exec Path -> Add the output of which code, on my case would be: /etc/profiles/per-user/REPLACE-USERNAME/bin/code
  • Exec Flags -> {project} --goto {file}:{line}:{col}
  • External Editor -> Visual Studio Code and VSCodium