ly: switch to zig.fetchDeps, add update script (#554553)

This commit is contained in:
tomberek
2026-08-23 03:31:46 +00:00
committed by GitHub
2 changed files with 16 additions and 164 deletions

View File

@@ -1,156 +0,0 @@
# generated by zon2nix (https://github.com/jcollie/zon2nix)
{
lib,
linkFarm,
fetchzip,
fetchurl,
fetchgit,
runCommandLocal,
zig_0_15,
zstd,
name ? "zig-packages",
}:
let
unpackZigArtifact =
{
name,
artifact,
}:
runCommandLocal name
{
nativeBuildInputs = [ zig_0_15 ];
}
''
hash="$(cd "$TMPDIR" && zig fetch --global-cache-dir "$TMPDIR" ${artifact})"
mv "$TMPDIR/p/$hash" "$out"
chmod 755 "$out"
'';
fetchZig =
{
name,
url,
hash,
unpack,
}:
let
artifact =
if unpack then
fetchzip {
inherit url hash;
nativeBuildInputs = [ zstd ];
}
else
fetchurl { inherit url hash; };
in
unpackZigArtifact { inherit name artifact; };
fetchGitZig =
{
name,
url,
hash,
}:
let
parts = lib.splitString "#" url;
url_base = builtins.elemAt parts 0;
url_without_query = builtins.elemAt (lib.splitString "?" url_base) 0;
rev_base = builtins.elemAt parts 1;
rev =
if builtins.match "^[a-fA-F0-9]{40}$" rev_base != null then rev_base else "refs/heads/${rev_base}";
in
fetchgit {
inherit name rev hash;
url = url_without_query;
deepClone = false;
fetchSubmodules = false;
};
fetchZigArtifact =
{
name,
url,
hash,
unpack,
}:
let
parts = lib.splitString "://" url;
proto = builtins.elemAt parts 0;
path = builtins.elemAt parts 1;
fetcher = {
"git+http" = fetchGitZig {
inherit name hash;
url = "http://${path}";
};
"git+https" = fetchGitZig {
inherit name hash;
url = "https://${path}";
};
http = fetchZig {
inherit name hash unpack;
url = "http://${path}";
};
https = fetchZig {
inherit name hash unpack;
url = "https://${path}";
};
};
in
fetcher.${proto};
in
linkFarm name [
{
name = "aro-0.0.0-JSD1Qi7QNgDnfcrdEJf82v3o6MhZySjYVrtdfEf3E4Se";
path = fetchZigArtifact {
name = "aro";
url = "git+https://github.com/Vexu/arocc#5f5a050569a95ecc40a426f0c3666ae7ef987ede";
hash = "sha256-f8Z0SXWx5Uia2TCMB5SUpcO8+xUnaWk32Oknva7xcxw=";
unpack = true;
};
}
{
name = "clap-0.11.0-oBajB7foAQC3Iyn4IVCkUdYaOVVng5IZkSncySTjNig1";
path = fetchZigArtifact {
name = "clap";
url = "git+https://github.com/Hejsil/zig-clap#fc1e5cc3f6d9d3001112385ee6256d694e959d2f";
hash = "sha256-sIDCZW4q9BQwy4AJjJ6r+mSkJ3usbnMmY9zkE4EVAy8=";
unpack = true;
};
}
{
name = "ini-0.1.0-YCQ9YiwsAACghqF8LZyjAF2H_NnL6n29QLuCe0fsmPTo";
path = fetchZigArtifact {
name = "ini";
url = "git+https://github.com/AshAmetrine/ziglibs-ini?ref=zig-0.16.0#3b733e10adc6c4c48050709b97a22258bc2e6156";
hash = "sha256-t+6zFMwpPgMrUygBcQCM0s10zK320D46xAgr2FSw3tU=";
unpack = true;
};
}
{
name = "N-V-__8AAAUXBQD6Fwpi9m0MBqWXFFaqW5l1lVrJC2Ynj7a-";
path = fetchZigArtifact {
name = "termbox2";
url = "git+https://github.com/AnErrupTion/termbox2?ref=master#c7f241e8888ce243e1748b05c26a42fcfaaad936";
hash = "sha256-7lA75r4sbKDHknZKK9jSbN/RNmTj56HQOvyYdazIEbA=";
unpack = true;
};
}
{
name = "translate_c-0.0.0-Q_BUWvP1BgCjAk6PWv5286tOlvzD9-X-NkuTzh0KxY0Q";
path = fetchZigArtifact {
name = "translate_c";
url = "git+https://codeberg.org/ziglang/translate-c#7a1a9fdc4ab00835748a6657ecbb835e3d5d45f7";
hash = "sha256-zdZ/it+/yNGfszHLqpXpi20Gkwm8fduMMs1/l9oaje8=";
unpack = true;
};
}
{
name = "zigini-0.5.0-BSkB7e9WAACfyCBABNZiWL3gFMw18GKn3qBcPs8L1Ec1";
path = fetchZigArtifact {
name = "zigini";
url = "git+https://github.com/AshAmetrine/zigini?ref=master#a665d081dda42664a96da2840ea09c5ccf9d0692";
hash = "sha256-8zwniFOQFTrFNOrfudhtoCXQBTBKSmc3XF1bNSb3Av8=";
unpack = true;
};
}
]

View File

@@ -1,5 +1,4 @@
{
callPackage,
fetchFromCodeberg,
lib,
libxcb,
@@ -10,8 +9,8 @@
versionCheckHook,
x11Support ? true,
zig_0_16,
nix-update-script,
}:
let
zig = zig_0_16;
in
@@ -36,11 +35,17 @@ stdenv.mkDerivation (finalAttrs: {
]
++ lib.optionals x11Support [ libxcb ];
zigBuildFlags = [
"--system"
"${callPackage ./deps.nix { }}"
"-Denable_x11_support=${lib.boolToString x11Support}"
];
zigDeps = zig.fetchDeps {
inherit (finalAttrs) src pname version;
fetchAll = true;
hash = "sha256-ZTGQhsDTpWfG4giM0WsfCjlDVr4htC6WWBpSGyKZUr0=";
};
postConfigure = ''
ln -s ${finalAttrs.zigDeps} "$ZIG_GLOBAL_CACHE_DIR/p"
'';
zigBuildFlags = [ "-Denable_x11_support=${lib.boolToString x11Support}" ];
postInstall = ''
install -Dm0644 res/config.ini "$out/etc/config.ini"
@@ -50,7 +55,10 @@ stdenv.mkDerivation (finalAttrs: {
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
passthru.tests = { inherit (nixosTests) ly; };
passthru = {
tests = { inherit (nixosTests) ly; };
updateScript = nix-update-script { };
};
meta = {
description = "TUI display manager";