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