update template

This commit is contained in:
Tobias Berger 2024-10-16 14:11:05 +02:00
parent 95f1229c14
commit 01b89f0473
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
29 changed files with 367 additions and 207 deletions

View file

@ -4,9 +4,7 @@
"tools": {
"roslynator.dotnet.cli": {
"version": "0.8.4",
"commands": [
"roslynator"
]
"commands": ["roslynator"]
}
}
}

2
.envrc
View file

@ -1 +1,3 @@
use flake
npm i

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/.vscode/obj
/.direnv/
/log/rimworld.log
/node_modules/

View file

@ -1,8 +1,5 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
encoding="utf-8"
indent="yes" />
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" />
<xsl:strip-space elements="*" />
<!-- Match ModMetaData and its descendants, modify modVersion element -->
<xsl:template match="/Project/PropertyGroup/ModMetaData|ModMetaData/@*|ModMetaData//node()">

10
.vscode/build.sh vendored
View file

@ -1,4 +1,5 @@
set -e
set -x
script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir)
@ -7,11 +8,12 @@ pushd $script_dir
configuration=${1:-Debug}
# build dll
rm -f ../1.4/Assemblies/*
dotnet build mod.csproj -c ${configuration}
echo "Building for RimWorld 1.5"
rm -f $mod_dir/1.5/Assemblies/BetterAutocastVPE.dll
dotnet build $script_dir/mod.csproj -c ${configuration} -p:GAME_VERSION=v1.5
# generate About.xml
rm -f ../About/About.xml
xsltproc -o ../About/About.xml ./about.xml.xslt ./mod.csproj
rm -f $mod_dir/About/About.xml
xsltproc -o $mod_dir/About/About.xml $script_dir/about.xml.xslt $script_dir/mod.csproj
popd

5
.vscode/fmt.sh vendored
View file

@ -1,9 +1,12 @@
set -e
set -x
script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir)
pushd $mod_dir
nix fmt
treefmt
dotnet tool restore
dotnet roslynator format $script_dir/mod.csproj
popd

6
.vscode/launch.sh vendored
View file

@ -1,9 +1,11 @@
set -e
set -x
script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir)
pushd $script_dir
game_dir=$(realpath ~/.local/share/Steam/steamapps/common/RimWorld/)
pushd $mod_dir
SDL_VIDEODRIVER=X11 LC_ALL=C steam-run ~/.local/share/Steam/steamapps/common/RimWorld/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@
SDL_VIDEODRIVER=X11 LC_ALL=C steam-run $game_dir/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@
popd

58
.vscode/mod.csproj vendored
View file

@ -1,4 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Condition="'$(GAME_VERSION)'==''">
<DefineConstants>v1_5</DefineConstants>
<OutputPath>../1.5/Assemblies</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(GAME_VERSION)'=='v1.5'">
<DefineConstants>v1_5</DefineConstants>
<OutputPath>../1.5/Assemblies</OutputPath>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net480</TargetFramework>
@ -6,25 +14,25 @@
<!-- Modify [RootNamespace], [AssemblyName], [OutputPath], [VersionPrefix] -->
<RootNamespace>Template</RootNamespace>
<AssemblyName>Template</AssemblyName>
<OutputPath>../1.4/Assemblies</OutputPath>
<LangVersion>latest</LangVersion>
<VersionPrefix>0.1.0.0</VersionPrefix>
<VersionPrefix>0.0.0.0</VersionPrefix>
<!-- do not generate pdb file -->
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>enable</Nullable>
<Deterministic>True</Deterministic>
<!-- Contents of About.xml
See https://rimworldwiki.com/wiki/Modding_Tutorials/About.xml -->
<ModMetaData>
<packageId>dev.tobot.mod-template</packageId>
<name>Mod Template</name>
<packageId>dev.tobot.rimworld.template</packageId>
<name>Toby's Mod Template</name>
<authors>
<li>Toby</li>
</authors>
<description>A mod template.\nReady to build on NixOS.</description>
<description>Template mod for nix and VS Code</description>
<supportedVersions>
<li>1.4</li>
<li>1.5</li>
</supportedVersions>
<modVersion IgnoreIfNoMatchingField="True">
<!-- Gets automatically populated with VersionPrefix (see above) -->
@ -32,17 +40,21 @@
<url>https://git.tobot.dev/toby/rimworld-mod-template</url>
<modDependencies />
<modDependenciesByVersion>
<!-- <v1.4>
<v1.5>
<li>
<packageId>brrainz.harmony</packageId>
<displayName>Harmony</displayName>
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</v1.4> -->
</v1.5>
</modDependenciesByVersion>
<loadAfter />
<loadAfterByVersion />
<loadAfterByVersion>
<v1.5>
<li>brrainz.harmony</li>
</v1.5>
</loadAfterByVersion>
<forceLoadAfter />
<loadBefore />
<loadBeforeByVersion />
@ -51,22 +63,20 @@
<incompatibleWithByVersion />
</ModMetaData>
</PropertyGroup>
<ItemGroup Condition="'$(GAME_VERSION)'==''">
<!-- <PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4104" /> -->
<Reference Include="RimWorld" HintPath="/home/toby/.local/share/Steam/steamapps/common/RimWorld/RimWorldLinux_Data/Managed/Assembly-CSharp.dll" IncludeAssets="compile" Private="false" />
<PackageReference Include="Lib.Harmony" Version="2.3.3" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup Condition="'$(GAME_VERSION)'=='v1.5'">
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4104" />
<!-- <Reference Include="RimWorld" HintPath="/home/toby/.local/share/Steam/steamapps/common/RimWorld/RimWorldLinux_Data/Managed/Assembly-CSharp.dll" IncludeAssets="compile" Private="false" /> -->
<PackageReference Include="Lib.Harmony" Version="2.3.3" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<!-- Mod -->
<Compile Include="../Source/**/*" />
<PackageReference Include="Krafs.Rimworld.Ref"
Version="1.4.3901" />
<!-- Set IncludeAssets to 'compile' to enable Harmony -->
<PackageReference Include="Lib.Harmony"
Version="2.3.3"
IncludeAssets="none" />
<PackageReference Include="roslynator.analyzers"
Version="4.12.0"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<PackageReference Include="roslynator.formatting.analyzers"
Version="4.12.0"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<Compile Include="../Source/**/*.cs" />
<PackageReference Include="roslynator.analyzers" Version="4.12.5" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" PrivateAssets="all" />
<PackageReference Include="roslynator.formatting.analyzers" Version="4.12.5" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" PrivateAssets="all" />
</ItemGroup>
</Project>

View file

@ -1,9 +1,11 @@
set -e
set -x
script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir)
pushd $mod_dir
dotnet tool restore
dotnet roslynator analyze $script_dir/mod.csproj
popd

36
.vscode/settings.json vendored
View file

@ -3,29 +3,13 @@
"files.exclude": {
".direnv": true,
".vscode/obj": true,
"*/Assemblies/": true
"*/Assemblies/": true,
"1.4": true
},
"files.readonlyInclude": {
"log/rimworld.log": true,
"About/About.xml": true
},
"omnisharp.organizeImportsOnFormat": true,
"dotnet.inlayHints.enableInlayHintsForParameters": true,
"dotnet.inlayHints.enableInlayHintsForLiteralParameters": true,
"dotnet.inlayHints.enableInlayHintsForIndexerParameters": true,
"dotnet.inlayHints.enableInlayHintsForObjectCreationParameters": true,
"dotnet.inlayHints.enableInlayHintsForOtherParameters": true,
"dotnet.inlayHints.suppressInlayHintsForParametersThatDifferOnlyBySuffix": true,
"dotnet.inlayHints.suppressInlayHintsForParametersThatMatchMethodIntent": true,
"dotnet.inlayHints.suppressInlayHintsForParametersThatMatchArgumentName": true,
"csharp.inlayHints.enableInlayHintsForTypes": true,
"csharp.inlayHints.enableInlayHintsForImplicitVariableTypes": true,
"csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true,
"csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": true,
"csharp.suppressDotnetInstallWarning": true,
"csharp.suppressDotnetRestoreNotification": true,
"dotnet.server.useOmnisharp": true,
"omnisharp.enableLspDriver": false,
"[xml]": {
"editor.quickSuggestions": {
"other": "on",
@ -36,8 +20,18 @@
"[jsonc]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": true,
"csharp.inlayHints.enableInlayHintsForImplicitVariableTypes": true,
"csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true,
"csharp.inlayHints.enableInlayHintsForTypes": true,
"dotnet.inlayHints.enableInlayHintsForIndexerParameters": true,
"dotnet.inlayHints.enableInlayHintsForLiteralParameters": true,
"dotnet.inlayHints.enableInlayHintsForObjectCreationParameters": true,
"dotnet.inlayHints.enableInlayHintsForOtherParameters": true,
"dotnet.inlayHints.enableInlayHintsForParameters": true,
"dotnet.inlayHints.suppressInlayHintsForParametersThatDifferOnlyBySuffix": true,
"dotnet.inlayHints.suppressInlayHintsForParametersThatMatchArgumentName": true,
"dotnet.inlayHints.suppressInlayHintsForParametersThatMatchMethodIntent": true
}

7
.vscode/setup.sh vendored
View file

@ -6,16 +6,13 @@ mod_dir=$(dirname $script_dir)
pushd $script_dir
mod_name="${mod_dir##*/}"
target_dir=$(readlink -f ~/.local/share/Steam/steamapps/common/RimWorld/Mods/)/$mod_name
dotnet tool restore
target_dir=${1:-$(realpath ~/.local/share/Steam/steamapps/common/RimWorld/Mods/)/$mod_name}
if [ "$target_dir" = "$mod_dir" ]; then
echo "Target directory is the same as the mod directory. Cloned in RimWorld/Mods. Skipping setup"
else
mkdir -p $target_dir
rsync -av --exclude '$mod_dir/*' --delete $mod_dir/1.4 $mod_dir/About $mod_dir/README $mod_dir/LICENSE $target_dir
rsync -av --exclude '$mod_dir/*' --delete $mod_dir/1.4 $mod_dir/1.5 $mod_dir/About $mod_dir/README $mod_dir/LICENSE $mod_dir/Changelog.md $target_dir
fi
popd

Binary file not shown.

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<LetterDef>
<defName>success_letter</defName>
<color>(65, 200, 65)</color>
<flashColor>(85, 255, 85)</flashColor>
<flashInterval>6</flashInterval>
<bounce>false</bounce>
<arriveSound>LetterArrive_Good</arriveSound>
<description>If you can see this letter, then mod template is set up correctly.</description>
</LetterDef>
</Defs>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>
<TemplateMod.SettingsCategory>Template Mod</TemplateMod.SettingsCategory>
</LanguageData>

BIN
1.5/Assemblies/Template.dll Normal file

Binary file not shown.

12
1.5/Defs/LetterDef.xml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<LetterDef>
<defName>success_letter</defName>
<color>(65, 200, 65)</color>
<flashColor>(85, 255, 85)</flashColor>
<flashInterval>6</flashInterval>
<bounce>false</bounce>
<arriveSound>LetterArrive_Good</arriveSound>
<description>If you can see this letter, then mod template is set up correctly.</description>
</LetterDef>
</Defs>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>
<TemplateMod.SettingsCategory>Template Mod</TemplateMod.SettingsCategory>
</LanguageData>

24
About/About.xml Normal file → Executable file
View file

@ -1,33 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<packageId>dev.tobot.mod-template</packageId>
<name>Mod Template</name>
<packageId>dev.tobot.rimworld.template</packageId>
<name>Toby's Mod Template</name>
<authors>
<li>Toby</li>
</authors>
<description>A mod template.\nReady to build on NixOS.</description>
<description>Template mod for nix and VS Code</description>
<supportedVersions>
<li>1.4</li>
<li>1.5</li>
</supportedVersions>
<modVersion IgnoreIfNoMatchingField="True">0.1.0.0</modVersion>
<modVersion IgnoreIfNoMatchingField="True">0.0.0.0</modVersion>
<url>https://git.tobot.dev/toby/rimworld-mod-template</url>
<modDependencies/>
<modDependenciesByVersion>
<!-- <v1.4>
<v1.5>
<li>
<packageId>brrainz.harmony</packageId>
<displayName>Harmony</displayName>
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</v1.4> -->
</v1.5>
</modDependenciesByVersion>
<loadAfter/>
<loadAfterByVersion/>
<loadAfterByVersion>
<v1.5>
<li>brrainz.harmony</li>
</v1.5>
</loadAfterByVersion>
<forceLoadAfter/>
<loadBefore/>
<loadBeforeByVersion/>
<forceLoadBefore/>
<incompatibleWith/>
<incompatibleWithByVersion/>
<incompatibleWithByVersion>
<v1.5/>
</incompatibleWithByVersion>
</ModMetaData>

View file

@ -0,0 +1,21 @@
global using static Template.Extensions.TranslateExtension;
namespace Template.Extensions;
static class TranslateExtension
{
public static Verse.TaggedString TranslateSafe(
this string self,
params Verse.NamedArgument[] args
)
{
if (!Verse.Translator.CanTranslate(self))
{
TemplateMod.DebugError(
$"Untranslated key: {self}",
Verse.GenString.GetHashCodeSafe(self)
);
}
return Verse.TranslatorFormattedStringExtensions.Translate(self, args);
}
}

View file

@ -7,28 +7,33 @@ namespace Template;
using Settings;
using UnityEngine;
#if DEBUG
#warning Compiling in Debug mode
#endif
public class TemplateMod : Mod
{
internal static string Translate(string key)
{
const string TranslationKey = nameof(TemplateMod);
return (TranslationKey + "." + key).Translate();
}
public TemplateMod(ModContentPack content)
: base(content)
{
#if v1_5
const string GAME_VERSION = "v1.5";
#else
#error No version defined
const string GAME_VERSION = "UNDEFINED";
#endif
#if DEBUG
const string build = "Debug";
#else
const string build = "Release";
#endif
Log.Message(
$"Running Version {Assembly.GetAssembly(typeof(TemplateMod)).GetName().Version} "
Log(
$"Running Version {Assembly.GetAssembly(typeof(TemplateMod)).GetName().Version} {build} compiled for RimWorld version {GAME_VERSION}"
+ build
);
Log.Message(content.ModMetaData.packageIdLowerCase);
Log(content.ModMetaData.packageIdLowerCase);
Settings = GetSettings<TemplateSettings>();
WriteSettings();
@ -42,54 +47,52 @@ public class TemplateMod : Mod
#nullable enable
public void ResetSettings()
{
Settings = new();
}
public override void DoSettingsWindowContents(Rect inRect) =>
SettingsWindow.DoSettingsWindowContents(inRect);
public override string SettingsCategory() => SettingsWindow.SettingsCategory();
public static class Log
{
const string LogPrefix = "Toby's Template Mod - ";
public static void DebugError(string message)
public static void DebugError(string message, int? key = null)
{
#if DEBUG
Error(message);
Error(message, key);
#endif
}
public static void Error(string message)
public static void Error(string message, int? key = null)
{
if (key is int keyNotNull)
Verse.Log.ErrorOnce(LogPrefix + message, keyNotNull);
else
Verse.Log.Error(LogPrefix + message);
}
public static void DebugWarn(string message)
public static void DebugWarn(string message, int? key = null)
{
#if DEBUG
Warn(message);
Warn(message, key);
#endif
}
public static void Warn(string message)
public static void Warn(string message, int? key = null)
{
if (key is int keyNotNull)
Verse.Log.WarningOnce(LogPrefix + message, keyNotNull);
else
Verse.Log.Warning(LogPrefix + message);
}
public static void DebugLog(string message)
{
#if DEBUG
Message(message);
Log(message);
#endif
}
public static void Message(string message)
public static void Log(string message)
{
Verse.Log.Message(LogPrefix + message);
}
}
}

View file

@ -25,6 +25,6 @@ public static class SettingsWindow
public static string SettingsCategory()
{
return TemplateMod.Translate("SettingsCategory");
return "TemplateMod.SettingsCategory".TranslateSafe();
}
}

View file

@ -1,15 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using Verse;
namespace Template.Settings;
public class TemplateSettings : ModSettings
{
private static TemplateSettings DefaultValues() => new();
#region Scribe Helpers
private static void LookField<T>(ref T value, string label, T defaultValue)
where T : struct
private void LookStruct<T>(Expression<Func<T>> expression)
{
Scribe_Values.Look(ref value, label, defaultValue);
if (
expression.Body
is not MemberExpression
{
Member: MemberInfo { MemberType: MemberTypes.Field, Name: string memberName }
}
)
{
throw new ArgumentException(
"Invalid expression passed to LookField",
nameof(expression)
);
}
FieldInfo fieldInfo = typeof(TemplateSettings).GetField(memberName);
T? value = fieldInfo.GetValue(this).ChangeType<T>();
T defaultValue = fieldInfo.GetValue(DefaultValues()).ChangeType<T>();
Scribe_Values.Look(ref value, memberName, defaultValue);
fieldInfo.SetValue(this, value);
}
private static void LookHashSet<T>(
@ -21,24 +43,34 @@ public class TemplateSettings : ModSettings
{
if (Scribe.mode == LoadSaveMode.Saving && valueHashSet is null)
{
TemplateMod.Log.Warn(
label + " is null before saving. Reinitializing with default values."
);
TemplateMod.Warn(label + " is null before saving. Reinitializing with default values.");
valueHashSet = defaultValues;
}
Scribe_Collections.Look(ref valueHashSet, label, lookMode: LookMode.Value);
if (Scribe.mode == LoadSaveMode.LoadingVars && valueHashSet is null)
{
TemplateMod.Log.Warn(
label + " is null after loading. Reinitializing with default values."
);
TemplateMod.Warn(label + " is null after loading. Reinitializing with default values.");
valueHashSet = defaultValues;
}
}
#endregion
public bool TemplateEnabled;
public TemplateSettings()
{
Reset();
}
public void Reset()
{
TemplateEnabled = true;
}
public override void ExposeData()
{
base.ExposeData();
LookStruct(() => TemplateEnabled);
}
}

View file

@ -6,7 +6,7 @@ using Verse;
namespace Template;
[DefOf]
public static class StinkyTweaksDefOf
public static class TemplateDefOf
{
public static LetterDef success_letter;
}

View file

@ -12,9 +12,8 @@ public class TemplateMapComponent(Map map) : MapComponent(map)
Messages.Message("Success", null, MessageTypeDefOf.PositiveEvent);
Find.LetterStack.ReceiveLetter(
"Success",
StinkyTweaksDefOf.success_letter.description,
StinkyTweaksDefOf.success_letter,
null
TemplateDefOf.success_letter.description,
TemplateDefOf.success_letter
);
}
}

View file

@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"lastModified": 1727826117,
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
"type": "github"
},
"original": {
@ -20,52 +20,30 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1712963716,
"narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=",
"owner": "nixos",
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cfd6b5fc90b15709b780a5a1619695a88505a176",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1711703276,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github"
"lastModified": 1727825735,
"narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1708475490,
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
}
},
"root": {
@ -93,14 +71,16 @@
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1711963903,
"narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=",
"lastModified": 1729077719,
"narHash": "sha256-zayHqZO9gA1U85c4CPvVSnLV8/cBgc2yVrSKWaKeBUs=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac",
"rev": "5307ba60125bb024d7e52d71d582eafd511f3fee",
"type": "github"
},
"original": {

View file

@ -1,10 +1,13 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
# Dev tools
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
@ -22,16 +25,17 @@
...
}:
{
# Rust dev environment
devShells.default = pkgs.mkShell {
inputsFrom = [ config.treefmt.build.devShell ];
nativeBuildInputs = with pkgs; [
dotnet-sdk_8
libxslt
dotnetCorePackages.dotnet_8.sdk
nixfmt-rfc-style
omnisharp-roslyn
libxslt.bin
nodePackages.npm
];
shellHook = ''
DOTNET_ROOT="${pkgs.dotnet-sdk_8}";
'';
DOTNET_ROOT = "${pkgs.dotnet-sdk_8}";
};
# Add your auto-formatters here.
@ -39,10 +43,48 @@
treefmt.config = {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
csharpier.enable = true;
nixfmt-rfc-style.enable = true;
csharpier = {
enable = true;
dotnet-sdk = pkgs.dotnet-sdk_6;
package = pkgs.csharpier;
};
nixfmt.enable = true;
shfmt.enable = true;
prettier = {
enable = true;
includes = [
"**/*.xml"
"**/*.xslt"
"**/*.json"
"**/*.csproj"
".github/workflows/*"
];
settings = {
plugins = [ "@prettier/plugin-xml" ];
bracketSameLine = true;
printWidth = 1000;
overrides = [
{
files = "*.xml";
options = {
xmlQuoteAttributes = "double";
xmlSortAttributesByKey = true;
xmlWhitespaceSensitivity = "preserve";
};
}
];
};
};
};
settings.global.excludes = [
".direnv"
"node_modules"
"1.4/**/*"
"*.ase"
"*.dll"
"*.png"
"About/About.xml"
];
};
};
};

64
package-lock.json generated Normal file
View file

@ -0,0 +1,64 @@
{
"name": "no-nutrient-ingredients",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"@prettier/plugin-xml": "^3.4.1"
}
},
"node_modules/@prettier/plugin-xml": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-3.4.1.tgz",
"integrity": "sha512-Uf/6/+9ez6z/IvZErgobZ2G9n1ybxF5BhCd7eMcKqfoWuOzzNUxBipNo3QAP8kRC1VD18TIo84no7LhqtyDcTg==",
"license": "MIT",
"dependencies": {
"@xml-tools/parser": "^1.0.11"
},
"peerDependencies": {
"prettier": "^3.0.0"
}
},
"node_modules/@xml-tools/parser": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@xml-tools/parser/-/parser-1.0.11.tgz",
"integrity": "sha512-aKqQ077XnR+oQtHJlrAflaZaL7qZsulWc/i/ZEooar5JiWj1eLt0+Wg28cpa+XLney107wXqneC+oG1IZvxkTA==",
"license": "Apache-2.0",
"dependencies": {
"chevrotain": "7.1.1"
}
},
"node_modules/chevrotain": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-7.1.1.tgz",
"integrity": "sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==",
"license": "Apache-2.0",
"dependencies": {
"regexp-to-ast": "0.5.0"
}
},
"node_modules/prettier": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
"license": "MIT",
"peer": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/regexp-to-ast": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz",
"integrity": "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==",
"license": "MIT"
}
}
}

5
package.json Normal file
View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@prettier/plugin-xml": "^3.4.1"
}
}