From 63714311997cd3d6bcd368577a113f2ddd5db65a Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Sun, 4 May 2025 12:33:28 +0200 Subject: [PATCH 1/3] containerlab: fix version definition in LDFLAGS Without the change, containerlab will always report the installed version to be 0.0.0, as wrong LDFLAGS were used in the package. The correct LDFLAGS can be seen in containerlab Makefile: https://github.com/srl-labs/containerlab/blob/main/Makefile If the version cannot be detected, e.g., containerlabs vscode extension will not work. --- pkgs/by-name/co/containerlab/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/co/containerlab/package.nix b/pkgs/by-name/co/containerlab/package.nix index 8e80f0f9ed14..92a028ff4b49 100644 --- a/pkgs/by-name/co/containerlab/package.nix +++ b/pkgs/by-name/co/containerlab/package.nix @@ -23,9 +23,9 @@ buildGoModule rec { ldflags = [ "-s" "-w" - "-X github.com/srl-labs/containerlab/cmd.version=${version}" - "-X github.com/srl-labs/containerlab/cmd.commit=${src.rev}" - "-X github.com/srl-labs/containerlab/cmd.date=1970-01-01T00:00:00Z" + "-X github.com/srl-labs/containerlab/cmd/version.Version=${version}" + "-X github.com/srl-labs/containerlab/cmd/version.commit=${src.rev}" + "-X github.com/srl-labs/containerlab/cmd/version.date=1970-01-01T00:00:00Z" ]; preCheck = '' From 6c83a7c6104d1e11ca7d2593a04f0d1271f9f425 Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Thu, 8 May 2025 22:11:23 +0200 Subject: [PATCH 2/3] containerlab: add version check checks the version after building the package as suggested by @Aleksanaa --- pkgs/by-name/co/containerlab/package.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/by-name/co/containerlab/package.nix b/pkgs/by-name/co/containerlab/package.nix index 92a028ff4b49..d58db901cd19 100644 --- a/pkgs/by-name/co/containerlab/package.nix +++ b/pkgs/by-name/co/containerlab/package.nix @@ -3,6 +3,7 @@ buildGoModule, fetchFromGitHub, installShellFiles, + versionCheckHook }: buildGoModule rec { @@ -41,6 +42,12 @@ buildGoModule rec { --zsh <($out/bin/containerlab completion zsh) ''; + nativeInstallCheckInputs = [ + versionCheckHook + ]; + doInstallCheck = true; + versionCheckProgramArg = "version"; + meta = { description = "Container-based networking lab"; homepage = "https://containerlab.dev/"; From 870855abfffd0fbaf4fcefdbe338d62775006bcb Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Thu, 8 May 2025 22:41:24 +0200 Subject: [PATCH 3/3] containerlab: fix nix file format --- pkgs/by-name/co/containerlab/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/co/containerlab/package.nix b/pkgs/by-name/co/containerlab/package.nix index d58db901cd19..ab1f24407686 100644 --- a/pkgs/by-name/co/containerlab/package.nix +++ b/pkgs/by-name/co/containerlab/package.nix @@ -3,7 +3,7 @@ buildGoModule, fetchFromGitHub, installShellFiles, - versionCheckHook + versionCheckHook, }: buildGoModule rec {