parent
d17f6d9880
commit
dfc8337342
5 changed files with 122 additions and 61 deletions
apps/update-sources
configurations/homie/modules/home-assistant/netdaemon
|
@ -23,6 +23,7 @@ buildApp {
|
|||
nodejs_latest
|
||||
prefetch-npm-deps
|
||||
(callPackage ../../modules/docker/updateImage.nix {})
|
||||
(callPackage ../../configurations/homie/modules/home-assistant/netdaemon/update.nix {})
|
||||
];
|
||||
|
||||
meta.description = ''
|
||||
|
|
|
@ -8,6 +8,7 @@ import updateCaddyPlugins from './caddy';
|
|||
import updateDocker from './docker';
|
||||
import updateFirefoxAddons from '././firefox';
|
||||
import updateFlakeInputs from './flake';
|
||||
import updateNetDaemon from './netdaemon';
|
||||
import runNixUpdate from './nix-update';
|
||||
import updateNodeModules from './node-modules';
|
||||
import updateVuetorrent from './vuetorrent';
|
||||
|
@ -56,6 +57,10 @@ const main = async() => {
|
|||
console.log(runNixUpdate('scopedPackages', 'lovelace-components', 'material-rounded-theme'));
|
||||
}
|
||||
|
||||
if (args['netdaemon']) {
|
||||
console.log(updateNetDaemon());
|
||||
}
|
||||
|
||||
if (args['node'] || args['node_modules']) {
|
||||
console.log((await updateNodeModules()) ?? 'No updates');
|
||||
}
|
||||
|
@ -97,6 +102,11 @@ const main = async() => {
|
|||
console.log(dockerOutput ?? 'No updates');
|
||||
|
||||
|
||||
const netdaemonOutput = updateNetDaemon();
|
||||
|
||||
console.log(netdaemonOutput ?? 'No updates');
|
||||
|
||||
|
||||
const nodeModulesOutput = await updateNodeModules();
|
||||
|
||||
console.log(nodeModulesOutput ?? 'No updates');
|
||||
|
@ -171,6 +181,9 @@ const main = async() => {
|
|||
if (caddyPluginsOutput) {
|
||||
output.push(`Caddy Plugins:\n${indentOutput(caddyPluginsOutput)}\n`);
|
||||
}
|
||||
if (netdaemonOutput) {
|
||||
output.push(`NetDaemon:\n${indentOutput(netdaemonOutput)}\n`);
|
||||
}
|
||||
if (nixUpdateOutputs.length > 0) {
|
||||
output.push(`nix-update executions:\n${indentOutput(nixUpdateOutputs.join('\n'))}\n`);
|
||||
}
|
||||
|
|
32
apps/update-sources/src/netdaemon.ts
Normal file
32
apps/update-sources/src/netdaemon.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { styleText } from 'node:util';
|
||||
|
||||
|
||||
/* Constants */
|
||||
const FLAKE = process.env.FLAKE;
|
||||
|
||||
export default (): string | null => {
|
||||
console.log(styleText(['magenta'], '\nUpdating NetDaemon:\n'));
|
||||
|
||||
const FOLDER = `${FLAKE}/configurations/homie/modules/home-assistant/netdaemon`;
|
||||
|
||||
const OLD_VERSION = readFileSync(`${FOLDER}/.version`).toString().replace('\n', '');
|
||||
|
||||
const VERSION = JSON.parse(spawnSync('curl',
|
||||
['-s', 'https://api.github.com/repos/net-daemon/netdaemon/releases/latest'],
|
||||
{ shell: true }).stdout.toString()).tag_name.replace('v', '');
|
||||
|
||||
if (OLD_VERSION !== VERSION) {
|
||||
writeFileSync(`${FOLDER}/.version`, `${VERSION}\n`);
|
||||
|
||||
spawnSync('bumpNetdaemonDeps', [], {
|
||||
cwd: FOLDER,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
return `NetDaemon: ${OLD_VERSION} -> ${VERSION}\n`;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
|
@ -1,10 +1,9 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrValues replaceStrings;
|
||||
inherit (builtins) attrValues;
|
||||
inherit (config.sops) secrets;
|
||||
|
||||
inherit (pkgs.callPackage ./package.nix {}) netdaemonConfig;
|
||||
|
@ -40,64 +39,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = let
|
||||
nixFetchDeps =
|
||||
replaceStrings [(toString self)] ["$FLAKE"]
|
||||
#nix
|
||||
''
|
||||
let
|
||||
config = (builtins.getFlake ("$FLAKE")).nixosConfigurations.homie;
|
||||
inherit (config) pkgs;
|
||||
|
||||
netdaemonConfig = pkgs.callPackage ${toString ./package.nix} {};
|
||||
in
|
||||
netdaemonConfig.fetch-deps
|
||||
'';
|
||||
in [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "bumpNetdaemonDeps";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
dos2unix
|
||||
dotnet-sdk_9
|
||||
];
|
||||
|
||||
text = ''
|
||||
# Install codegen
|
||||
dotnet tool install --create-manifest-if-needed NetDaemon.HassModel.CodeGen --version "$(cat ./.version)"
|
||||
|
||||
# Run it
|
||||
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="([^"]*)"'
|
||||
|
||||
find . -type f -name '*.csproj' | while read -r file; do
|
||||
# Extract unique package names from the .csproj file
|
||||
packages=$(grep -oP "$regex" "$file" | sed -E 's/.*Include="([^"]*)".*/\1/' | sort -u)
|
||||
|
||||
# Loop through each package and update
|
||||
for package in $packages; do
|
||||
echo -e "\033[35mUpdate $file package: $package\033[0m"
|
||||
dotnet add "$file" package "$package"
|
||||
done
|
||||
done
|
||||
|
||||
$(nix build --no-link --print-out-paths --impure --expr "$(cat <<EOF
|
||||
${nixFetchDeps}
|
||||
EOF
|
||||
)") .
|
||||
|
||||
alejandra -q .
|
||||
rm -r "$FLAKE/.config"
|
||||
|
||||
sed -i "s/finalImageTag = .*/finalImageTag = \"$(cat ./.version)\";/" ./images/netdaemon.nix
|
||||
updateImages .
|
||||
'';
|
||||
})
|
||||
environment.systemPackages = [
|
||||
(pkgs.callPackage ./update.nix {})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
# nix build inputs
|
||||
writeShellApplication,
|
||||
# deps
|
||||
alejandra,
|
||||
dos2unix,
|
||||
dotnet-sdk_9,
|
||||
findutils,
|
||||
gnused,
|
||||
nix,
|
||||
...
|
||||
}: let
|
||||
nixFetchDeps =
|
||||
#nix
|
||||
''
|
||||
let
|
||||
config = (builtins.getFlake ("$FLAKE")).nixosConfigurations.homie;
|
||||
inherit (config) pkgs;
|
||||
|
||||
netdaemonConfig = pkgs.callPackage ${toString ./package.nix} {};
|
||||
in
|
||||
netdaemonConfig.fetch-deps
|
||||
'';
|
||||
in
|
||||
writeShellApplication {
|
||||
name = "bumpNetdaemonDeps";
|
||||
|
||||
runtimeInputs = [
|
||||
alejandra
|
||||
dos2unix
|
||||
dotnet-sdk_9
|
||||
findutils
|
||||
gnused
|
||||
nix
|
||||
];
|
||||
|
||||
text = ''
|
||||
# Install codegen
|
||||
dotnet tool install --create-manifest-if-needed NetDaemon.HassModel.CodeGen --version "$(cat ./.version)"
|
||||
|
||||
# Run it
|
||||
dotnet tool run nd-codegen -token "$(sed 's/HomeAssistant__Token=//' /run/secrets/netdaemon)"
|
||||
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="([^"]*)"'
|
||||
|
||||
find . -type f -name '*.csproj' | while read -r file; do
|
||||
# Extract unique package names from the .csproj file
|
||||
packages=$(grep -oP "$regex" "$file" | sed -E 's/.*Include="([^"]*)".*/\1/' | sort -u)
|
||||
|
||||
# Loop through each package and update
|
||||
for package in $packages; do
|
||||
echo -e "\033[35mUpdate $file package: $package\033[0m"
|
||||
dotnet add "$file" package "$package"
|
||||
done
|
||||
done
|
||||
|
||||
$(nix build --no-link --print-out-paths --impure --expr "$(cat <<EOF
|
||||
${nixFetchDeps}
|
||||
EOF
|
||||
)") .
|
||||
|
||||
alejandra -q .
|
||||
rm -r "$FLAKE/.config"
|
||||
|
||||
sed -i "s/finalImageTag = .*/finalImageTag = \"$(cat ./.version)\";/" ./images/netdaemon.nix
|
||||
updateImages .
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue