Skip to content

Commit

Permalink
Improve schema, only update direct inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Oct 13, 2024
1 parent 46609ca commit 3109449
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/modules/manager/nix/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export function extractPackageFile(

const flakeLock = flakeLockParsed.data;

if (flakeLock.version !== 7) {
logger.debug({ packageFile }, 'Unsupported flake lock version');
return null;
}

for (const depName of Object.keys(flakeLock.nodes ?? {})) {
// the root input is a magic string for the entrypoint and only references other flake inputs
if (depName === 'root') {
Expand All @@ -40,6 +35,11 @@ export function extractPackageFile(
continue;

Check warning on line 35 in lib/modules/manager/nix/extract.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/manager/nix/extract.ts#L35

Added line #L35 was not covered by tests
}

// skip all locked nodes which are not in the flake.nix and cannot be updated
if (!(depName in (flakeLock.nodes['root'].inputs ?? []))) {
continue;
}

const flakeInput = flakeLock.nodes[depName];
const flakeLocked = flakeInput.locked;
const flakeOriginal = flakeInput.original;
Expand All @@ -52,7 +52,7 @@ export function extractPackageFile(
continue;

Check warning on line 52 in lib/modules/manager/nix/extract.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/manager/nix/extract.ts#L52

Added line #L52 was not covered by tests
}

// indirect inputs cannot be updated via normal means
// indirect inputs cannot be reliable updated because they depend on the flake registry
if (flakeOriginal.type === 'indirect') {
continue;

Check warning on line 57 in lib/modules/manager/nix/extract.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/manager/nix/extract.ts#L57

Added line #L57 was not covered by tests
}
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/manager/nix/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ export const OriginalInput = z.object({
});

export const NixInput = z.object({
inputs: z.record(z.string(), z.string()).optional(),
inputs: z.record(z.string(), z.string().or(z.array(z.string()))).optional(),
locked: LockedInput.optional(),
original: OriginalInput.optional(),
});

export const NixFlakeLock = Json.pipe(
z.object({
nodes: z.record(z.string(), NixInput).optional(),
root: z.string(),
version: z.number(),
root: z.literal('root').optional(),
version: z.literal(7),
}),
);

Expand Down

0 comments on commit 3109449

Please sign in to comment.