From fa29886b8ab5d7091104c4d10809aef04bd3bcbd Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 21 Oct 2024 02:48:43 -0400 Subject: [PATCH] refactor(netd): don't count auto-gen code in repo --- .../modules/home-assistant/netdaemon/.envrc | 1 + .../home-assistant/netdaemon/.gitignore | 1 + ...antGenerated.cs => HomeAssistantGenerated} | Bin 617091 -> 617091 bytes .../home-assistant/netdaemon/default.nix | 7 +++++-- .../home-assistant/netdaemon/package.nix | 10 +++++++--- 5 files changed, 14 insertions(+), 5 deletions(-) rename devices/homie/modules/home-assistant/netdaemon/{HomeAssistantGenerated.cs => HomeAssistantGenerated} (99%) diff --git a/devices/homie/modules/home-assistant/netdaemon/.envrc b/devices/homie/modules/home-assistant/netdaemon/.envrc index 7ce9ad6f..6c6e7886 100644 --- a/devices/homie/modules/home-assistant/netdaemon/.envrc +++ b/devices/homie/modules/home-assistant/netdaemon/.envrc @@ -1 +1,2 @@ use flake "$FLAKE#netdaemon" +cp -rf ./HomeAssistantGenerated ./HomeAssistantGenerated.cs diff --git a/devices/homie/modules/home-assistant/netdaemon/.gitignore b/devices/homie/modules/home-assistant/netdaemon/.gitignore index ee601ae0..3d6d7307 100644 --- a/devices/homie/modules/home-assistant/netdaemon/.gitignore +++ b/devices/homie/modules/home-assistant/netdaemon/.gitignore @@ -1,3 +1,4 @@ obj bin NetDaemonCodegen +HomeAssistantGenerated.cs diff --git a/devices/homie/modules/home-assistant/netdaemon/HomeAssistantGenerated.cs b/devices/homie/modules/home-assistant/netdaemon/HomeAssistantGenerated similarity index 99% rename from devices/homie/modules/home-assistant/netdaemon/HomeAssistantGenerated.cs rename to devices/homie/modules/home-assistant/netdaemon/HomeAssistantGenerated index 8fc8f6966b60b2778e34d2457e624a87d078a126..b7856a0bec14c5630779be766e389689035b2793 100644 GIT binary patch delta 58 zcmV-A0LA}<)g^<~C6KrhF;p-zIx#XjG&e3XGB-3cH8z3Dg~|bi$^wPT1BJ>2g~|nm Q$_9nX2ZhQAwaN*(X>t)3ssI20 delta 58 zcmV-A0LA}<)g^<~C6KrhFjO%(Iy5#qF)=PPH#ImlGc2g~|nm Q$_9nX2ZhQAwaN*(X>-jMv;Y7A diff --git a/devices/homie/modules/home-assistant/netdaemon/default.nix b/devices/homie/modules/home-assistant/netdaemon/default.nix index bf53758a..e1c03ba9 100644 --- a/devices/homie/modules/home-assistant/netdaemon/default.nix +++ b/devices/homie/modules/home-assistant/netdaemon/default.nix @@ -7,7 +7,7 @@ inherit (builtins) attrValues replaceStrings; inherit (config.sops) secrets; - compiled = pkgs.callPackage ./package.nix {}; + inherit (pkgs.callPackage ./package.nix {}) netdaemonConfig; in { khepri.compositions."netdaemon" = { networks.netdaemon = {external = true;}; @@ -26,7 +26,7 @@ in { TZ = "America/New_York"; }; - volumes = ["${compiled.lib}:/data"]; + volumes = ["${netdaemonConfig}:/data"]; networks = ["netdaemon"]; }; }; @@ -70,6 +70,9 @@ in { dotnet tool run nd-codegen -token "$(sed 's/HomeAssistant__Token=//' ${secrets.netdaemon.path})" dos2unix ./HomeAssistantGenerated.cs + # This is to not have it count towards CSharp in the repo + mv ./HomeAssistantGenerated.cs ./HomeAssistantGenerated + # Update all nugets to latest versions regex='PackageReference Include="([^"]*)" Version="([^"]*)"' diff --git a/devices/homie/modules/home-assistant/netdaemon/package.nix b/devices/homie/modules/home-assistant/netdaemon/package.nix index 9770921a..afdfe768 100644 --- a/devices/homie/modules/home-assistant/netdaemon/package.nix +++ b/devices/homie/modules/home-assistant/netdaemon/package.nix @@ -6,7 +6,7 @@ inherit (lib) any hasInfix hasSuffix removeSuffix; srcDirs = ["apps"]; - srcPatterns = [".cs" ".csproj" ".json" ".version"]; + srcPatterns = [".cs" ".csproj" ".json" ".version" "HomeAssistantGenerated"]; pname = "netdaemon-config"; in @@ -22,6 +22,10 @@ in || any (s: hasSuffix s file) srcPatterns; }; + preBuild = '' + mv HomeAssistantGenerated HomeAssistantGenerated.cs + ''; + projectFile = "netdaemon.csproj"; nugetDeps = ./deps.nix; @@ -30,8 +34,8 @@ in executables = []; postFixup = '' - cp -r $out/lib/${pname} $lib + cp -r $out/lib/${pname} $netdaemonConfig ''; - outputs = ["out" "lib"]; + outputs = ["out" "netdaemonConfig"]; }