refactor(upScript): separate funcs in more files
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
cd7bcf34c1
commit
df50815aba
8 changed files with 78 additions and 67 deletions
|
@ -15,7 +15,7 @@ in
|
|||
inherit (packageJSON) version;
|
||||
|
||||
src = ./.;
|
||||
npmDepsHash = "sha256-Vl27uo1cwRNjZCcSZTMqZBEwZNwwiqik0sJo4PVxg3c=";
|
||||
npmDepsHash = "sha256-5miQfnSy559jVsqyZM5LqegMuIVsd+LOdsZ8FaHy24A=";
|
||||
|
||||
runtimeInputs = [
|
||||
(callPackage ../../nixosModules/docker/updateImage.nix {})
|
||||
|
|
BIN
apps/update/package-lock.json
generated
BIN
apps/update/package-lock.json
generated
Binary file not shown.
|
@ -12,7 +12,7 @@
|
|||
"@types/node": "22.9.0",
|
||||
"esbuild": "0.24.0",
|
||||
"eslint": "9.14.0",
|
||||
"eslint-plugin-jsdoc": "50.4.3",
|
||||
"eslint-plugin-jsdoc": "50.5.0",
|
||||
"jiti": "2.4.0",
|
||||
"typescript": "5.6.3",
|
||||
"typescript-eslint": "8.14.0"
|
||||
|
|
|
@ -2,14 +2,11 @@ import { spawnSync } from 'node:child_process';
|
|||
import { writeFileSync } from 'node:fs';
|
||||
|
||||
import { parseArgs } from './lib.ts';
|
||||
import { updateFirefoxAddons } from '././firefox.ts';
|
||||
|
||||
import {
|
||||
updateCustomPackage,
|
||||
updateDocker,
|
||||
updateFlakeInputs,
|
||||
updateVuetorrent,
|
||||
} from './misc.ts';
|
||||
import { updateDocker } from './docker.ts';
|
||||
import { updateFirefoxAddons } from '././firefox.ts';
|
||||
import { updateFlakeInputs } from './flake.ts';
|
||||
import { updateCustomPackage, updateVuetorrent } from './misc.ts';
|
||||
|
||||
|
||||
/* Constants */
|
||||
|
|
33
apps/update/src/docker.ts
Normal file
33
apps/update/src/docker.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { readdirSync } from 'node:fs';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
|
||||
/* Constants */
|
||||
const FLAKE = process.env.FLAKE;
|
||||
|
||||
export const updateDocker = () => {
|
||||
const updateImages = (imagePath: string): string | undefined => {
|
||||
console.log(`Updating ${imagePath.split('/').at(-1)} images`);
|
||||
|
||||
const out = spawnSync('updateImages', [imagePath], { shell: true }).stdout.toString();
|
||||
|
||||
if (!out.startsWith('# Locked')) {
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
let updates = '';
|
||||
|
||||
updates += updateImages(`${FLAKE}/devices/nos/modules/jellyfin`) ?? '';
|
||||
updates += updateImages(`${FLAKE}/devices/homie/modules/home-assistant/netdaemon`) ?? '';
|
||||
|
||||
const DIR = `${FLAKE}/devices/nos/modules/docker`;
|
||||
|
||||
readdirSync(DIR, { withFileTypes: true, recursive: true }).forEach((path) => {
|
||||
if (path.name === 'compose.nix') {
|
||||
updates += updateImages(path.parentPath) ?? '';
|
||||
}
|
||||
});
|
||||
|
||||
return updates;
|
||||
};
|
35
apps/update/src/flake.ts
Normal file
35
apps/update/src/flake.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
|
||||
/* 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•')
|
||||
.filter((input) => ![
|
||||
'systems',
|
||||
'flake-utils',
|
||||
'flake-parts',
|
||||
'treefmt-nix',
|
||||
'lib-aggregate',
|
||||
'lib-aggregate/nixpkgs-lib',
|
||||
'sops-nix/nixpkgs-stable',
|
||||
].some((inputName) => input.startsWith(` Updated input '${inputName}'`)))
|
||||
.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;
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
import { readdirSync, writeFileSync } from 'node:fs';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
import { parseFetchurl } from './lib.ts';
|
||||
|
@ -7,63 +7,6 @@ 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•')
|
||||
.filter((input) => ![
|
||||
'systems',
|
||||
'flake-utils',
|
||||
'flake-parts',
|
||||
'treefmt-nix',
|
||||
'lib-aggregate',
|
||||
'lib-aggregate/nixpkgs-lib',
|
||||
'sops-nix/nixpkgs-stable',
|
||||
].some((inputName) => input.startsWith(` Updated input '${inputName}'`)))
|
||||
.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 = () => {
|
||||
const updateImages = (imagePath: string): string | undefined => {
|
||||
console.log(`Updating ${imagePath.split('/').at(-1)} images`);
|
||||
|
||||
const out = spawnSync('updateImages', [imagePath], { shell: true }).stdout.toString();
|
||||
|
||||
if (!out.startsWith('# Locked')) {
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
let updates = '';
|
||||
|
||||
updates += updateImages(`${FLAKE}/devices/nos/modules/jellyfin`) ?? '';
|
||||
updates += updateImages(`${FLAKE}/devices/homie/modules/home-assistant/netdaemon`) ?? '';
|
||||
|
||||
const DIR = `${FLAKE}/devices/nos/modules/docker`;
|
||||
|
||||
readdirSync(DIR, { withFileTypes: true, recursive: true }).forEach((path) => {
|
||||
if (path.name === 'compose.nix') {
|
||||
updates += updateImages(path.parentPath) ?? '';
|
||||
}
|
||||
});
|
||||
|
||||
return updates;
|
||||
};
|
||||
|
||||
const genVueText = (
|
||||
version: string,
|
||||
hash: string,
|
||||
|
|
|
@ -8,4 +8,7 @@ final: prev: {
|
|||
--replace-fail 'REQUIRED_ARGS: -Icompilable' 'REQUIRED_ARGS: -Icompilable -L--no-demangle'
|
||||
'';
|
||||
});
|
||||
|
||||
# FIXME: https://github.com/debug-js/debug/issues/975
|
||||
nodejs_latest = prev.nodejs_22;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue