feat(update): get nix-update options from updateScript attr
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
a22f10e47f
commit
d5db4c4e88
3 changed files with 39 additions and 23 deletions
|
@ -58,9 +58,7 @@ const main = async() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['m'] || args['material-rounded-theme']) {
|
if (args['m'] || args['material-rounded-theme']) {
|
||||||
console.log(runNixUpdate(
|
console.log(runNixUpdate('scopedPackages', 'lovelace-components', 'material-rounded-theme'));
|
||||||
'scopedPackages.x86_64-linux.lovelace-components.material-rounded-theme',
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['n'] || args['node_modules']) {
|
if (args['n'] || args['node_modules']) {
|
||||||
|
@ -68,10 +66,7 @@ const main = async() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['p'] || args['pam-fprint-grosshack']) {
|
if (args['p'] || args['pam-fprint-grosshack']) {
|
||||||
console.log(runNixUpdate(
|
console.log(runNixUpdate('pam-fprint-grosshack'));
|
||||||
'pam-fprint-grosshack',
|
|
||||||
['--version="$(curl -s https://gitlab.com/api/v4/projects/mishakmak%2Fpam-fprint-grosshack/repository/tags | jq -r .[0].name)"'],
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args['ph'] || args['protonhax']) {
|
if (args['ph'] || args['protonhax']) {
|
||||||
|
@ -131,8 +126,12 @@ const main = async() => {
|
||||||
// nix-update executions
|
// nix-update executions
|
||||||
let nixUpdateOutputs = '';
|
let nixUpdateOutputs = '';
|
||||||
|
|
||||||
const updatePackage = (pkg: string, opts: string[] = []): void => {
|
const updatePackage = (
|
||||||
const execution = runNixUpdate(pkg, opts);
|
attr: string,
|
||||||
|
scope?: string,
|
||||||
|
scopeAttr?: string,
|
||||||
|
): void => {
|
||||||
|
const execution = runNixUpdate(attr, scope, scopeAttr);
|
||||||
|
|
||||||
nixUpdateOutputs += execution.stdout;
|
nixUpdateOutputs += execution.stdout;
|
||||||
console.log(execution.stderr);
|
console.log(execution.stderr);
|
||||||
|
@ -141,15 +140,10 @@ const main = async() => {
|
||||||
|
|
||||||
updatePackage('homepage');
|
updatePackage('homepage');
|
||||||
updatePackage('jmusicbot');
|
updatePackage('jmusicbot');
|
||||||
updatePackage(
|
updatePackage('pam-fprint-grosshack');
|
||||||
'pam-fprint-grosshack',
|
|
||||||
['--version="$(curl -s https://gitlab.com/api/v4/projects/mishakmak%2Fpam-fprint-grosshack/repository/tags | jq -r .[0].name)"'],
|
|
||||||
);
|
|
||||||
updatePackage('protonhax');
|
updatePackage('protonhax');
|
||||||
updatePackage('trash-d');
|
updatePackage('trash-d');
|
||||||
updatePackage(
|
updatePackage('scopedPackages', 'lovelace-components', 'material-rounded-theme');
|
||||||
'scopedPackages.x86_64-linux.lovelace-components.material-rounded-theme',
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
spawnSync('nixFastBuild', [], {
|
spawnSync('nixFastBuild', [], {
|
||||||
|
|
|
@ -54,21 +54,36 @@ const getAttrVersion = (attr: string): string => spawnSync('nix',
|
||||||
|
|
||||||
export const runNixUpdate = (
|
export const runNixUpdate = (
|
||||||
attr: string,
|
attr: string,
|
||||||
options: string[] = [],
|
scope?: string,
|
||||||
|
scopeAttr?: string,
|
||||||
): { stdout: string, stderr: string } => {
|
): { stdout: string, stderr: string } => {
|
||||||
const OLD_VERSION = getAttrVersion(attr);
|
const realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr;
|
||||||
|
const OLD_VERSION = getAttrVersion(realAttr);
|
||||||
|
|
||||||
const execution = spawnSync(
|
const execOptions = spawnSync(
|
||||||
`nix-update --flake ${attr} ${options
|
`nix eval --json ${FLAKE}#${realAttr}.updateScript`,
|
||||||
.join(' ')} --write-commit-message >(head -n 1 -) > /dev/null`,
|
|
||||||
[],
|
[],
|
||||||
{ shell: true, cwd: FLAKE },
|
{ shell: true, cwd: FLAKE },
|
||||||
);
|
);
|
||||||
|
|
||||||
const NEW_VERSION = getAttrVersion(attr);
|
const options = execOptions.status === 0 ?
|
||||||
|
Array(JSON.parse(execOptions.stdout.toString()))[0].slice(1).join(' ') :
|
||||||
|
'';
|
||||||
|
|
||||||
|
const execution = spawnSync(
|
||||||
|
`nix-update --flake ${realAttr} ${options} --write-commit-message >(head -n 1 -) > /dev/null`,
|
||||||
|
[],
|
||||||
|
{ shell: true, cwd: FLAKE },
|
||||||
|
);
|
||||||
|
|
||||||
|
const NEW_VERSION = getAttrVersion(realAttr);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stdout: OLD_VERSION !== NEW_VERSION ? execution.stdout.toString() : '',
|
stdout: OLD_VERSION !== NEW_VERSION ?
|
||||||
|
scope ?
|
||||||
|
execution.stdout.toString().replaceAll(`${attr}.x86_64-linux.${scope}.`, '') :
|
||||||
|
execution.stdout.toString() :
|
||||||
|
'',
|
||||||
stderr: execution.stderr.toString(),
|
stderr: execution.stderr.toString(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
fetchFromGitLab,
|
fetchFromGitLab,
|
||||||
|
nix-update-script,
|
||||||
# deps
|
# deps
|
||||||
dbus,
|
dbus,
|
||||||
glib,
|
glib,
|
||||||
|
@ -70,6 +71,12 @@ in
|
||||||
"-Dsystemd_system_unit_dir=${placeholder "out"}/lib/systemd/system"
|
"-Dsystemd_system_unit_dir=${placeholder "out"}/lib/systemd/system"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
passthru.updateScript = nix-update-script {
|
||||||
|
extraArgs = [
|
||||||
|
''--version=$(curl -s https://gitlab.com/api/v4/projects/mishakmak%2Fpam-fprint-grosshack/repository/tags | jq -r .[0].name)''
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
license = with lib.licenses; [gpl2Plus];
|
license = with lib.licenses; [gpl2Plus];
|
||||||
homepage = "https://gitlab.com/mishakmak/pam-fprint-grosshack";
|
homepage = "https://gitlab.com/mishakmak/pam-fprint-grosshack";
|
||||||
|
|
Loading…
Add table
Reference in a new issue