From 548d780afd3904d80148b6912ce7e445d10d4ab3 Mon Sep 17 00:00:00 2001 From: Alexander Sieg Date: Mon, 17 Mar 2025 12:36:34 +0100 Subject: [PATCH] fix(nix): urldecode gitlab subgroups Do to a bug in nix one needs to uri encode the owner of a gitlab repository that resides in a subgroups, in this case the `/` as `%20F`. This however breaks the `git ls-remotes` which renovate runs to discover if the input can be updated. This commit passes the owner attribute through `decodeURIComponent` to ensure that `git` is unware of this workaround on nixs side. Nix PR: https://github.com/NixOS/nix/pull/9163 --- lib/modules/manager/nix/extract.spec.ts | 41 +++++++++++++++++++++++++ lib/modules/manager/nix/extract.ts | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/nix/extract.spec.ts b/lib/modules/manager/nix/extract.spec.ts index 2d1a011d58c..67dd53c68d9 100644 --- a/lib/modules/manager/nix/extract.spec.ts +++ b/lib/modules/manager/nix/extract.spec.ts @@ -602,4 +602,45 @@ describe('modules/manager/nix/extract', () => { ], }); }); + + const flake12Lock = `{ + "nodes": { + "subgroup-project": { + "locked": { + "lastModified": 1739792862, + "narHash": "sha256-n0MrSIZZknq2OqOYgNS0iMp2yVRekpBFGhrhsT7aXGg=", + "owner": "group%2Fsub-group", + "repo": "subgroup-project", + "rev": "24b560624f154c9e962d146217b2a964faaf2055", + "type": "gitlab" + }, + "original": { + "owner": "group%2Fsub-group", + "repo": "subgroup-project", + "type": "gitlab" + } + }, + "root": { + "inputs": { + "subgroup-project": "subgroup-project" + } + } + }, + "root": "root", + "version": 7 + }`; + + it('uri decode gitlab subgroup', async () => { + fs.readLocalFile.mockResolvedValueOnce(flake12Lock); + expect(await extractPackageFile('', 'flake.nix')).toMatchObject({ + deps: [ + { + currentDigest: '24b560624f154c9e962d146217b2a964faaf2055', + datasource: 'git-refs', + depName: 'subgroup-project', + packageName: 'https://gitlab.com/group/sub-group/subgroup-project', + }, + ], + }); + }); }); diff --git a/lib/modules/manager/nix/extract.ts b/lib/modules/manager/nix/extract.ts index c9f17eb681b..9acb65ae5ee 100644 --- a/lib/modules/manager/nix/extract.ts +++ b/lib/modules/manager/nix/extract.ts @@ -105,7 +105,7 @@ export async function extractPackageFile( currentValue: flakeOriginal.ref, currentDigest: flakeLocked.rev, datasource: GitRefsDatasource.id, - packageName: `https://${flakeOriginal.host ?? 'gitlab.com'}/${flakeOriginal.owner}/${flakeOriginal.repo}`, + packageName: `https://${flakeOriginal.host ?? 'gitlab.com'}/${decodeURIComponent(flakeOriginal.owner!)}/${flakeOriginal.repo}`, }); break; case 'git':