nixos-configs/apps/update/src/misc.ts
matt1432 2e3612b7fb
All checks were successful
Discord / discord commits (push) Has been skipped
chore: update flake.lock
Flake Inputs:
• Updated input 'agsV2':
    'github:Aylur/ags/a93f0ac' (2024-10-16)
  → 'github:Aylur/ags/b7f3896' (2024-10-19)

• Updated input 'astal':
    'github:Aylur/astal/f763c44' (2024-10-18)
  → 'github:Aylur/astal/bfb7e27' (2024-10-20)

• Updated input 'custom-sidebar-src':
    'github:elchininet/custom-sidebar/fcada91' (2024-10-15)
  → 'github:elchininet/custom-sidebar/80942f5' (2024-10-21)

• Updated input 'home-manager':
    'github:nix-community/home-manager/09a0c0c' (2024-10-18)
  → 'github:nix-community/home-manager/1e27f21' (2024-10-20)

• Updated input 'hyprland':
    'github:hyprwm/Hyprland/0e630e9' (2024-10-17)
  → 'github:hyprwm/Hyprland/62ee5cc' (2024-10-19)

• Updated input 'nix-gaming':
    'github:fufexan/nix-gaming/79f0e31' (2024-10-18)
  → 'github:fufexan/nix-gaming/177e270' (2024-10-20)

• Updated input 'nix-index-db':
    'github:Mic92/nix-index-database/5c54c33' (2024-10-13)
  → 'github:Mic92/nix-index-database/04f8a11' (2024-10-20)

• Updated input 'nixd':
    'github:nix-community/nixd/c38702b' (2024-10-01)
  → 'github:nix-community/nixd/d3c7e56' (2024-10-20)

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5785b6b' (2024-10-16)
  → 'github:NixOS/nixpkgs/4c2fcb0' (2024-10-18)

• Updated input 'nixpkgs-wayland':
    'github:nix-community/nixpkgs-wayland/2535bdd' (2024-10-18)
  → 'github:nix-community/nixpkgs-wayland/7c64c3c' (2024-10-20)

• Updated input 'pokemon-colorscripts-src':
    'gitlab:phoneybadger/pokemon-colorscripts/0483c85' (2022-10-28)
  → 'gitlab:phoneybadger/pokemon-colorscripts/5802ff6' (2024-10-19)

• Updated input 'sops-nix':
    'github:Mic92/sops-nix/06535d0' (2024-10-08)
  → 'github:Mic92/sops-nix/c504fd7' (2024-10-20)

• Updated input 'spotifywebapi-src':
    'github:thlucas1/SpotifyWebApiPython/4bb0658' (2024-10-14)
  → 'github:thlucas1/SpotifyWebApiPython/8c6aff1' (2024-10-19)

• Updated input 'tuya-local-src':
    'github:make-all/tuya-local/587d622' (2024-10-18)
  → 'github:make-all/tuya-local/38744c0' (2024-10-21)

Docker Images:
• rssbridge/rss-bridge latest:
   sha256:da785b43f43e4f718c525d71453d6b7011db98c68434f02315cb7ee1ecc88889
 → sha256:42b4d1d1e3fb2c361a3a2fe2921a847bbdcd0d6d14a4d411482665fc4560a58d
2024-10-20 21:42:54 -04:00

96 lines
2.9 KiB
TypeScript

import { readdirSync, writeFileSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
import { parseFetchurl } from './lib.ts';
/* Constants */
const FLAKE = process.env.FLAKE;
export const updateFlakeInputs = () => {
const output = spawnSync(
`git restore flake.lock &> /dev/null; nix flake update --flake ${FLAKE}` +
' |& grep -v "warning: updating lock file" |& grep -v "unpacking"',
[],
{ shell: true },
).stdout
.toString()
// Add an extra blank line between inputs
.split('\n•')
.join('\n\n•')
// Shorten git revs to help readability
.split('\n')
.map((l) => l
.replace(/.{33}\?narHash=sha256[^']*/, '')
.replace(/&rev=(.{7})[^'&]*/, (_, backref) => `&rev=${backref}`))
.join('\n');
return output;
};
export const updateDocker = () => {
let updates = '';
console.log('Updating jfa-go image');
updates += spawnSync('updateImages',
[`${FLAKE}/devices/nos/modules/jellyfin`],
{ shell: true })
.stdout.toString();
console.log('Updating netdaemon image');
updates += spawnSync('updateImages',
[`${FLAKE}/devices/homie/modules/home-assistant/netdaemon`],
{ shell: true })
.stdout.toString();
const FILE = `${FLAKE}/devices/nos/modules/docker`;
readdirSync(FILE, { withFileTypes: true, recursive: true }).forEach((path) => {
if (path.name === 'compose.nix') {
console.log(`Updating ${path.parentPath.split('/').at(-1)} images`);
updates += spawnSync('updateImages', [path.parentPath], { shell: true })
.stdout.toString();
}
});
return updates;
};
const genVueText = (
version: string,
hash: string,
url: string,
) => `# This file was autogenerated. DO NOT EDIT!
{
version = "${version}";
url = "${url}";
hash = "${hash}";
}
`;
export const updateVuetorrent = () => {
const FILE = `${FLAKE}/devices/nos/modules/qbittorrent/vuetorrent.nix`;
const OLD_VERSION = JSON.parse(spawnSync('nix',
['eval', '-f', FILE, '--json'],
{ shell: true }).stdout.toString()).version;
const VERSION = JSON.parse(spawnSync('curl',
['-s', 'https://api.github.com/repos/VueTorrent/VueTorrent/releases/latest'],
{ shell: true }).stdout.toString()).tag_name.replace('v', '');
const URL = `https://github.com/VueTorrent/VueTorrent/releases/download/v${VERSION}/vuetorrent.zip`;
const HASH = parseFetchurl(URL);
const fileText = genVueText(VERSION, HASH, URL);
writeFileSync(FILE, fileText);
return OLD_VERSION !== VERSION ? `Vuetorrent: ${OLD_VERSION} -> ${VERSION}` : '';
};
export const updateCustomSidebarDeps = () => spawnSync(
`nix run ${FLAKE}#legacyPackages.x86_64-linux.lovelace-components.custom-sidebar.update`,
[],
{ shell: true },
).stderr.toString();