From 6fd3990534fa4d69c945217a8faa948e1e742e53 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Thu, 26 Sep 2024 14:52:50 +0200 Subject: [PATCH] trivial: make symlinkJoin support pname+version alone --- doc/build-helpers/trivial-build-helpers.chapter.md | 2 +- pkgs/build-support/trivial-builders/default.nix | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/build-helpers/trivial-build-helpers.chapter.md b/doc/build-helpers/trivial-build-helpers.chapter.md index ff00548e049a..13b1835ee505 100644 --- a/doc/build-helpers/trivial-build-helpers.chapter.md +++ b/doc/build-helpers/trivial-build-helpers.chapter.md @@ -732,7 +732,7 @@ writeShellApplication { ## `symlinkJoin` {#trivial-builder-symlinkJoin} -This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within. +This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` (or alternatively `pname` and `version`) is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within. Here is an example: ```nix # adds symlinks of hello and stack to current build and prints "links added" diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index a02fe1fd6d0a..7d68a2ae6ea8 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -469,7 +469,11 @@ rec { as a easy way to build multiple derivations at once. */ symlinkJoin = - args_@{ name + args_@{ + name ? + assert lib.assertMsg (args_ ? pname && args_ ? version) + "symlinkJoin requires either a `name` OR `pname` and `version`"; + "${args_.pname}-${args_.version}" , paths , preferLocalBuild ? true , allowSubstitutes ? false