From 954e9101ba3d35da2d9319f7947fc5f2be6e37c9 Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Fri, 28 Feb 2025 13:14:16 +0100 Subject: [PATCH] Add host attribute of github/gitlab flakerefs to URL serialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `GitArchiveInputScheme::toUrl` currently drops the `host` attribute, creating invalid urls when locking `github:` or `gitlab:` urls pointing to alterative instances and serializing the input back to a url. ``` ❯ cat flake.nix { inputs.gnome-2048 = { url = "gitlab:GNOME/gnome-2048?host=gitlab.gnome.org"; flake = false; }; outputs = inputs: {}; } f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35 ❯ nix flake metadata warning: creating lock file '/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35/flake.lock': • Added input 'gnome-2048': 'gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D' (2025-02-21) Resolved URL: path:/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35 Locked URL: path:/private/var/folders/fb/f1xb57354q79t_jpw5_h79cw0000gq/T/tmp.MOBbzbpT35?lastModified=1740744684&narHash=sha256-nxUL/JiTYbZX2c1XiN/TC6aA1hf%2B1YXsUvhL7ASY2uE%3D Path: /nix/store/f4xczpwhdxs8gal1rika1c5bvhyd472l-source Last modified: 2025-02-28 13:11:24 Inputs: └───gnome-2048: gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D (2025-02-21 23:18:46) ``` Note the gnome-2048 input url missing the original host query. The Url after this commit: ``` [...] Inputs: └───gnome-2048: gitlab:GNOME/gnome-2048/70e0e430ca4bf590990433a3abdce6b631d50e6e?host=gitlab.gnome.org&narHash=sha256-bya45ug2mDSU4SMn0fSBlZCuPl9y15B12ubKeb2A58s%3D (2025-02-21 23:18:46) ``` --- src/libfetchers/github.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index 9cddd8571..ea4dbe338 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -149,6 +149,9 @@ struct GitArchiveInputScheme : InputScheme }; if (auto narHash = input.getNarHash()) url.query.insert_or_assign("narHash", narHash->to_string(HashFormat::SRI, true)); + auto host = maybeGetStrAttr(input.attrs, "host"); + if (host) + url.query.insert_or_assign("host", *host); return url; }