diff options
author | Alyssa Ross <hi@alyssa.is> | 2024-02-13 12:25:07 +0100 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2024-02-13 12:25:07 +0100 |
commit | a5e1520e4538e29ecfbd4b168306f890566d7bfd (patch) | |
tree | 28099c268b5d4b1e33c2b29f0714c45f0b961382 /nixpkgs/doc/languages-frameworks | |
parent | 822f7c15c04567fbdc27020e862ea2b70cfbf8eb (diff) | |
parent | 3560d1c8269d0091b9aae10731b5e85274b7bbc1 (diff) | |
download | nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.tar nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.tar.gz nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.tar.bz2 nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.tar.lz nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.tar.xz nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.tar.zst nixlib-a5e1520e4538e29ecfbd4b168306f890566d7bfd.zip |
Merge branch 'nixos-unstable-small' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/nixos/modules/services/mail/rss2email.nix nixpkgs/pkgs/build-support/go/module.nix
Diffstat (limited to 'nixpkgs/doc/languages-frameworks')
-rw-r--r-- | nixpkgs/doc/languages-frameworks/beam.section.md | 2 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/dart.section.md | 20 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/dotnet.section.md | 50 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/emscripten.section.md | 6 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/haskell.section.md | 107 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/idris2.section.md | 6 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/qt.section.md | 57 | ||||
-rw-r--r-- | nixpkgs/doc/languages-frameworks/rust.section.md | 2 |
8 files changed, 153 insertions, 97 deletions
diff --git a/nixpkgs/doc/languages-frameworks/beam.section.md b/nixpkgs/doc/languages-frameworks/beam.section.md index 1e83d4b93c7c..992149090c63 100644 --- a/nixpkgs/doc/languages-frameworks/beam.section.md +++ b/nixpkgs/doc/languages-frameworks/beam.section.md @@ -216,7 +216,7 @@ in packages.mixRelease { Setup will require the following steps: - Move your secrets to runtime environment variables. For more information refer to the [runtime.exs docs](https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-runtime-configuration). On a fresh Phoenix build that would mean that both `DATABASE_URL` and `SECRET_KEY` need to be moved to `runtime.exs`. -- `cd assets` and `nix-shell -p node2nix --run node2nix --development` will generate a Nix expression containing your frontend dependencies +- `cd assets` and `nix-shell -p node2nix --run "node2nix --development"` will generate a Nix expression containing your frontend dependencies - commit and push those changes - you can now `nix-build .` - To run the release, set the `RELEASE_TMP` environment variable to a directory that your program has write access to. It will be used to store the BEAM settings. diff --git a/nixpkgs/doc/languages-frameworks/dart.section.md b/nixpkgs/doc/languages-frameworks/dart.section.md index fca87fa70e4e..019765f75354 100644 --- a/nixpkgs/doc/languages-frameworks/dart.section.md +++ b/nixpkgs/doc/languages-frameworks/dart.section.md @@ -80,6 +80,8 @@ Do _not_ use `dart run <package_name>`, as this will attempt to download depende ### Usage with nix-shell {#ssec-dart-applications-nix-shell} +#### Using dependencies from the Nix store {#ssec-dart-applications-nix-shell-deps} + As `buildDartApplication` provides dependencies instead of `pub get`, Dart needs to be explicitly told where to find them. Run the following commands in the source directory to configure Dart appropriately. @@ -101,7 +103,10 @@ See the [Dart documentation](#ssec-dart-applications) for more details on requir flutter.buildFlutterApplication { pname = "firmware-updater"; - version = "unstable-2023-04-30"; + version = "0-unstable-2023-04-30"; + + # To build for the Web, use the targetFlutterPlatform argument. + # targetFlutterPlatform = "web"; src = fetchFromGitHub { owner = "canonical"; @@ -117,4 +122,15 @@ flutter.buildFlutterApplication { ### Usage with nix-shell {#ssec-dart-flutter-nix-shell} -See the [Dart documentation](#ssec-dart-applications-nix-shell) for nix-shell instructions. +Flutter-specific `nix-shell` usage notes are included here. See the [Dart documentation](#ssec-dart-applications-nix-shell) for general `nix-shell` instructions. + +#### Entering the shell {#ssec-dart-flutter-nix-shell-enter} + +By default, dependencies for only the `targetFlutterPlatform` are available in the +build environment. This is useful for keeping closures small, but be problematic +during development. It's common, for example, to build Web apps for Linux during +development to take advantage of native features such as stateful hot reload. + +To enter a shell with all the usual target platforms available, use the `multiShell` attribute. + +e.g. `nix-shell '<nixpkgs>' -A fluffychat-web.multiShell`. diff --git a/nixpkgs/doc/languages-frameworks/dotnet.section.md b/nixpkgs/doc/languages-frameworks/dotnet.section.md index 978ec07cb961..7987aa41636c 100644 --- a/nixpkgs/doc/languages-frameworks/dotnet.section.md +++ b/nixpkgs/doc/languages-frameworks/dotnet.section.md @@ -93,7 +93,11 @@ The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given To package Dotnet applications, you can use `buildDotnetModule`. This has similar arguments to `stdenv.mkDerivation`, with the following additions: * `projectFile` is used for specifying the dotnet project file, relative to the source root. These have `.sln` (entire solution) or `.csproj` (single project) file extensions. This can be a list of multiple projects as well. When omitted, will attempt to find and build the solution (`.sln`). If running into problems, make sure to set it to a file (or a list of files) with the `.csproj` extension - building applications as entire solutions is not fully supported by the .NET CLI. -* `nugetDeps` takes either a path to a `deps.nix` file, or a derivation. The `deps.nix` file can be generated using the script attached to `passthru.fetch-deps`. This file can also be generated manually using `nuget-to-nix` tool, which is available in nixpkgs. If the argument is a derivation, it will be used directly and assume it has the same output as `mkNugetDeps`. +* `nugetDeps` takes either a path to a `deps.nix` file, or a derivation. The `deps.nix` file can be generated using the script attached to `passthru.fetch-deps`. If the argument is a derivation, it will be used directly and assume it has the same output as `mkNugetDeps`. +::: {.note} +For more detail about managing the `deps.nix` file, see [Generating and updating NuGet dependencies](#generating-and-updating-nuget-dependencies) +::: + * `packNupkg` is used to pack project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`. * `projectReferences` can be used to resolve `ProjectReference` project items. Referenced projects can be packed with `buildDotnetModule` by setting the `packNupkg = true` attribute and passing a list of derivations to `projectReferences`. Since we are sharing referenced projects as NuGets they must be added to csproj/fsproj files as `PackageReference` as well. For example, your project has a local dependency: @@ -144,7 +148,7 @@ in buildDotnetModule rec { projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure. - dotnet-sdk = dotnetCorePackages.sdk_6.0; + dotnet-sdk = dotnetCorePackages.sdk_6_0; dotnet-runtime = dotnetCorePackages.runtime_6_0; executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`. @@ -156,6 +160,8 @@ in buildDotnetModule rec { } ``` +Keep in mind that you can tag the [`@NixOS/dotnet`](https://github.com/orgs/nixos/teams/dotnet) team for help and code review. + ## Dotnet global tools {#dotnet-global-tools} [.NET Global tools](https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools) are a mechanism provided by the dotnet CLI to install .NET binaries from Nuget packages. @@ -212,5 +218,43 @@ buildDotnetGlobalTool { }; } ``` +## Generating and updating NuGet dependencies {#generating-and-updating-nuget-dependencies} + +First, restore the packages to the `out` directory, ensure you have cloned +the upstream repository and you are inside it. + +```bash +$ dotnet restore --packages out + Determining projects to restore... + Restored /home/lychee/Celeste64/Celeste64.csproj (in 1.21 sec). +``` + +Next, use `nuget-to-nix` tool provided in nixpkgs to generate a lockfile to `deps.nix` from +the packages inside the `out` directory. + +```bash +$ nuget-to-nix out > deps.nix +``` +Which `nuget-to-nix` will generate an output similar to below +``` +{ fetchNuGet }: [ + (fetchNuGet { pname = "FosterFramework"; version = "0.1.15-alpha"; sha256 = "0pzsdfbsfx28xfqljcwy100xhbs6wyx0z1d5qxgmv3l60di9xkll"; }) + (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1gjz379y61ag9whi78qxx09bwkwcznkx2mzypgycibxk61g11da1"; }) + (fetchNuGet { pname = "Microsoft.NET.ILLink.Tasks"; version = "8.0.1"; sha256 = "1drbgqdcvbpisjn8mqfgba1pwb6yri80qc4mfvyczqwrcsj5k2ja"; }) + (fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1g5b30f4l8a1zjjr3b8pk9mcqxkxqwa86362f84646xaj4iw3a4d"; }) + (fetchNuGet { pname = "SharpGLTF.Core"; version = "1.0.0-alpha0031"; sha256 = "0ln78mkhbcxqvwnf944hbgg24vbsva2jpih6q3x82d3h7rl1pkh6"; }) + (fetchNuGet { pname = "SharpGLTF.Runtime"; version = "1.0.0-alpha0031"; sha256 = "0lvb3asi3v0n718qf9y367km7qpkb9wci38y880nqvifpzllw0jg"; }) + (fetchNuGet { pname = "Sledge.Formats"; version = "1.2.2"; sha256 = "1y0l66m9rym0p1y4ifjlmg3j9lsmhkvbh38frh40rpvf1axn2dyh"; }) + (fetchNuGet { pname = "Sledge.Formats.Map"; version = "1.1.5"; sha256 = "1bww60hv9xcyxpvkzz5q3ybafdxxkw6knhv97phvpkw84pd0jil6"; }) + (fetchNuGet { pname = "System.Numerics.Vectors"; version = "4.5.0"; sha256 = "1kzrj37yzawf1b19jq0253rcs8hsq1l2q8g69d7ipnhzb0h97m59"; }) +] +``` + +Finally, you move the `deps.nix` file to the appropriate location to be used by `nugetDeps`, then you're all set! + +If you ever need to update the dependencies of a package, you instead do + +* `nix-build -A package.fetch-deps` to generate the update script for `package` +* Run `./result deps.nix` to regenerate the lockfile to `deps.nix`, keep in mind if a location isn't provided, it will write to a temporary path instead +* Finally, move the file where needed and look at its contents to confirm it has updated the dependencies. -When packaging a new .NET application in nixpkgs, you can tag the [`@NixOS/dotnet`](https://github.com/orgs/nixos/teams/dotnet) team for help and code review. diff --git a/nixpkgs/doc/languages-frameworks/emscripten.section.md b/nixpkgs/doc/languages-frameworks/emscripten.section.md index 20d358f2e9e3..9ce48db2c2de 100644 --- a/nixpkgs/doc/languages-frameworks/emscripten.section.md +++ b/nixpkgs/doc/languages-frameworks/emscripten.section.md @@ -86,9 +86,9 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update postPatch = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' substituteInPlace configure \ - --replace '/usr/bin/libtool' 'ar' \ - --replace 'AR="libtool"' 'AR="ar"' \ - --replace 'ARFLAGS="-o"' 'ARFLAGS="-r"' + --replace-fail '/usr/bin/libtool' 'ar' \ + --replace-fail 'AR="libtool"' 'AR="ar"' \ + --replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"' ''; }) ``` diff --git a/nixpkgs/doc/languages-frameworks/haskell.section.md b/nixpkgs/doc/languages-frameworks/haskell.section.md index b0b5f5c3bb2f..bec72cb3c0d3 100644 --- a/nixpkgs/doc/languages-frameworks/haskell.section.md +++ b/nixpkgs/doc/languages-frameworks/haskell.section.md @@ -70,39 +70,42 @@ compilers like this: ```console $ nix-env -f '<nixpkgs>' -qaP -A haskell.compiler haskell.compiler.ghc810 ghc-8.10.7 -haskell.compiler.ghc88 ghc-8.8.4 haskell.compiler.ghc90 ghc-9.0.2 -haskell.compiler.ghc924 ghc-9.2.4 haskell.compiler.ghc925 ghc-9.2.5 haskell.compiler.ghc926 ghc-9.2.6 -haskell.compiler.ghc92 ghc-9.2.7 -haskell.compiler.ghc942 ghc-9.4.2 -haskell.compiler.ghc943 ghc-9.4.3 -haskell.compiler.ghc94 ghc-9.4.4 -haskell.compiler.ghcHEAD ghc-9.7.20221224 -haskell.compiler.ghc8102Binary ghc-binary-8.10.2 -haskell.compiler.ghc8102BinaryMinimal ghc-binary-8.10.2 -haskell.compiler.ghc8107BinaryMinimal ghc-binary-8.10.7 +haskell.compiler.ghc927 ghc-9.2.7 +haskell.compiler.ghc92 ghc-9.2.8 +haskell.compiler.ghc945 ghc-9.4.5 +haskell.compiler.ghc946 ghc-9.4.6 +haskell.compiler.ghc947 ghc-9.4.7 +haskell.compiler.ghc94 ghc-9.4.8 +haskell.compiler.ghc963 ghc-9.6.3 +haskell.compiler.ghc96 ghc-9.6.4 +haskell.compiler.ghc98 ghc-9.8.1 +haskell.compiler.ghcHEAD ghc-9.9.20231121 haskell.compiler.ghc8107Binary ghc-binary-8.10.7 haskell.compiler.ghc865Binary ghc-binary-8.6.5 haskell.compiler.ghc924Binary ghc-binary-9.2.4 -haskell.compiler.ghc924BinaryMinimal ghc-binary-9.2.4 -haskell.compiler.integer-simple.ghc810 ghc-integer-simple-8.10.7 haskell.compiler.integer-simple.ghc8107 ghc-integer-simple-8.10.7 -haskell.compiler.integer-simple.ghc88 ghc-integer-simple-8.8.4 -haskell.compiler.integer-simple.ghc884 ghc-integer-simple-8.8.4 +haskell.compiler.integer-simple.ghc810 ghc-integer-simple-8.10.7 haskell.compiler.native-bignum.ghc90 ghc-native-bignum-9.0.2 haskell.compiler.native-bignum.ghc902 ghc-native-bignum-9.0.2 -haskell.compiler.native-bignum.ghc924 ghc-native-bignum-9.2.4 haskell.compiler.native-bignum.ghc925 ghc-native-bignum-9.2.5 haskell.compiler.native-bignum.ghc926 ghc-native-bignum-9.2.6 -haskell.compiler.native-bignum.ghc92 ghc-native-bignum-9.2.7 haskell.compiler.native-bignum.ghc927 ghc-native-bignum-9.2.7 -haskell.compiler.native-bignum.ghc942 ghc-native-bignum-9.4.2 -haskell.compiler.native-bignum.ghc943 ghc-native-bignum-9.4.3 -haskell.compiler.native-bignum.ghc94 ghc-native-bignum-9.4.4 -haskell.compiler.native-bignum.ghc944 ghc-native-bignum-9.4.4 -haskell.compiler.native-bignum.ghcHEAD ghc-native-bignum-9.7.20221224 +haskell.compiler.native-bignum.ghc92 ghc-native-bignum-9.2.8 +haskell.compiler.native-bignum.ghc928 ghc-native-bignum-9.2.8 +haskell.compiler.native-bignum.ghc945 ghc-native-bignum-9.4.5 +haskell.compiler.native-bignum.ghc946 ghc-native-bignum-9.4.6 +haskell.compiler.native-bignum.ghc947 ghc-native-bignum-9.4.7 +haskell.compiler.native-bignum.ghc94 ghc-native-bignum-9.4.8 +haskell.compiler.native-bignum.ghc948 ghc-native-bignum-9.4.8 +haskell.compiler.native-bignum.ghc963 ghc-native-bignum-9.6.3 +haskell.compiler.native-bignum.ghc96 ghc-native-bignum-9.6.4 +haskell.compiler.native-bignum.ghc964 ghc-native-bignum-9.6.4 +haskell.compiler.native-bignum.ghc98 ghc-native-bignum-9.8.1 +haskell.compiler.native-bignum.ghc981 ghc-native-bignum-9.8.1 +haskell.compiler.native-bignum.ghcHEAD ghc-native-bignum-9.9.20231121 haskell.compiler.ghcjs ghcjs-8.10.7 ``` @@ -1226,10 +1229,12 @@ in in { - haskell = lib.recursiveUpdate prev.haskell { - compiler.${ghcName} = prev.haskell.compiler.${ghcName}.override { - # Unfortunately, the GHC setting is named differently for historical reasons - enableProfiledLibs = enableProfiling; + haskell = prev.haskell // { + compiler = prev.haskell.compiler // { + ${ghcName} = prev.haskell.compiler.${ghcName}.override { + # Unfortunately, the GHC setting is named differently for historical reasons + enableProfiledLibs = enableProfiling; + }; }; }; }) @@ -1241,31 +1246,33 @@ in in { - haskell = lib.recursiveUpdate prev.haskell { - packages.${ghcName} = prev.haskell.packages.${ghcName}.override { - overrides = hfinal: hprev: { - mkDerivation = args: hprev.mkDerivation (args // { - # Since we are forcing our ideas upon mkDerivation, this change will - # affect every package in the package set. - enableLibraryProfiling = enableProfiling; - - # To actually use profiling on an executable, executable profiling - # needs to be enabled for the executable you want to profile. You - # can either do this globally or… - enableExecutableProfiling = enableProfiling; - }); - - # …only for the package that contains an executable you want to profile. - # That saves on unnecessary rebuilds for packages that you only depend - # on for their library, but also contain executables (e.g. pandoc). - my-executable = haskellLib.enableExecutableProfiling hprev.my-executable; - - # If you are disabling profiling to save on build time, but want to - # retain the ability to substitute from the binary cache. Drop the - # override for mkDerivation above and instead have an override like - # this for the specific packages you are building locally and want - # to make cheaper to build. - my-library = haskellLib.disableLibraryProfiling hprev.my-library; + haskell = prev.haskell // { + packages = prev.haskell.packages // { + ${ghcName} = prev.haskell.packages.${ghcName}.override { + overrides = hfinal: hprev: { + mkDerivation = args: hprev.mkDerivation (args // { + # Since we are forcing our ideas upon mkDerivation, this change will + # affect every package in the package set. + enableLibraryProfiling = enableProfiling; + + # To actually use profiling on an executable, executable profiling + # needs to be enabled for the executable you want to profile. You + # can either do this globally or… + enableExecutableProfiling = enableProfiling; + }); + + # …only for the package that contains an executable you want to profile. + # That saves on unnecessary rebuilds for packages that you only depend + # on for their library, but also contain executables (e.g. pandoc). + my-executable = haskellLib.enableExecutableProfiling hprev.my-executable; + + # If you are disabling profiling to save on build time, but want to + # retain the ability to substitute from the binary cache. Drop the + # override for mkDerivation above and instead have an override like + # this for the specific packages you are building locally and want + # to make cheaper to build. + my-library = haskellLib.disableLibraryProfiling hprev.my-library; + }; }; }; }; diff --git a/nixpkgs/doc/languages-frameworks/idris2.section.md b/nixpkgs/doc/languages-frameworks/idris2.section.md index 47bcbf46aee9..f1f0277cc609 100644 --- a/nixpkgs/doc/languages-frameworks/idris2.section.md +++ b/nixpkgs/doc/languages-frameworks/idris2.section.md @@ -2,7 +2,7 @@ In addition to exposing the Idris2 compiler itself, Nixpkgs exposes an `idris2Packages.buildIdris` helper to make it a bit more ergonomic to build Idris2 executables or libraries. -The `buildIdris` function takes a package set that defines at a minimum the `src` and `projectName` of the package to be built and any `idrisLibraries` required to build it. The `src` is the same source you're familiar with but the `projectName` must be the name of the `ipkg` file for the project (omitting the `.ipkg` extension). The `idrisLibraries` is a list of other library derivations created with `buildIdris`. You can optionally specify other derivation properties as needed but sensible defaults for `configurePhase`, `buildPhase`, and `installPhase` are provided. +The `buildIdris` function takes an attribute set that defines at a minimum the `src` and `ipkgName` of the package to be built and any `idrisLibraries` required to build it. The `src` is the same source you're familiar with and the `ipkgName` must be the name of the `ipkg` file for the project (omitting the `.ipkg` extension). The `idrisLibraries` is a list of other library derivations created with `buildIdris`. You can optionally specify other derivation properties as needed but sensible defaults for `configurePhase`, `buildPhase`, and `installPhase` are provided. Importantly, `buildIdris` does not create a single derivation but rather an attribute set with two properties: `executable` and `library`. The `executable` property is a derivation and the `library` property is a function that will return a derivation for the library with or without source code included. Source code need not be included unless you are aiming to use IDE or LSP features that are able to jump to definitions within an editor. @@ -10,7 +10,7 @@ A simple example of a fully packaged library would be the [`LSP-lib`](https://gi ```nix { fetchFromGitHub, idris2Packages }: let lspLibPkg = idris2Packages.buildIdris { - projectName = "lsp-lib"; + ipkgName = "lsp-lib"; src = fetchFromGitHub { owner = "idris-community"; repo = "LSP-lib"; @@ -31,7 +31,7 @@ A slightly more involved example of a fully packaged executable would be the [`i # Assuming the previous example lives in `lsp-lib.nix`: let lspLib = callPackage ./lsp-lib.nix { }; lspPkg = idris2Packages.buildIdris { - projectName = "idris2-lsp"; + ipkgName = "idris2-lsp"; src = fetchFromGitHub { owner = "idris-community"; repo = "idris2-lsp"; diff --git a/nixpkgs/doc/languages-frameworks/qt.section.md b/nixpkgs/doc/languages-frameworks/qt.section.md index 5d2850de3dca..1edceb53cfe4 100644 --- a/nixpkgs/doc/languages-frameworks/qt.section.md +++ b/nixpkgs/doc/languages-frameworks/qt.section.md @@ -3,72 +3,61 @@ Writing Nix expressions for Qt libraries and applications is largely similar as for other C++ software. This section assumes some knowledge of the latter. -The major caveat with Qt applications is that Qt uses a plugin system to load additional modules at runtime, -from a list of well-known locations. In Nixpkgs, we patch QtCore to instead use an environment variable, -and wrap Qt applications to set it to the right paths. This effectively makes the runtime dependencies -pure and explicit at build-time, at the cost of introducing an extra indirection. +The major caveat with Qt applications is that Qt uses a plugin system to load additional modules at runtime. +In Nixpkgs, we wrap Qt applications to inject environment variables telling Qt where to discover the required plugins and QML modules. + +This effectively makes the runtime dependencies pure and explicit at build-time, at the cost of introducing +an extra indirection. ## Nix expression for a Qt package (default.nix) {#qt-default-nix} ```nix -{ stdenv, lib, qtbase, wrapQtAppsHook }: +{ stdenv, lib, qt6, wrapQtAppsHook }: stdenv.mkDerivation { pname = "myapp"; version = "1.0"; - buildInputs = [ qtbase ]; - nativeBuildInputs = [ wrapQtAppsHook ]; + buildInputs = [ qt6.qtbase ]; + nativeBuildInputs = [ qt6.wrapQtAppsHook ]; } ``` -It is important to import Qt modules directly, that is: `qtbase`, `qtdeclarative`, etc. *Do not* import Qt package sets such as `qt5` because the Qt versions of dependencies may not be coherent, causing build and runtime failures. - -Additionally all Qt packages must include `wrapQtAppsHook` in `nativeBuildInputs`, or you must explicitly set `dontWrapQtApps`. - -`pkgs.callPackage` does not provide injections for `qtbase` or the like. -Instead you want to either use `pkgs.libsForQt5.callPackage`, or `pkgs.qt6Packages.callPackage`, depending on the Qt version you want to use. +Any Qt package should include `wrapQtAppsHook` in `nativeBuildInputs`, or explicitly set `dontWrapQtApps` to bypass generating the wrappers. -For example (from [here](https://github.com/NixOS/nixpkgs/blob/2f9286912cb215969ece465147badf6d07aa43fe/pkgs/top-level/all-packages.nix#L30106)) +::: {.note} +Graphical Linux applications should also include `qtwayland` in `buildInputs`, to ensure the Wayland platform plugin is available. -```nix - zeal-qt5 = libsForQt5.callPackage ../data/documentation/zeal { }; - zeal-qt6 = qt6Packages.callPackage ../data/documentation/zeal { }; - zeal = zeal-qt5; -``` +This may become default in the future, see [NixOS/nixpkgs#269674](https://github.com/NixOS/nixpkgs/pull/269674). +::: -## Locating runtime dependencies {#qt-runtime-dependencies} +## Packages supporting multiple Qt versions {#qt-versions} -Qt applications must be wrapped to find runtime dependencies. -Include `wrapQtAppsHook` in `nativeBuildInputs`: +If your package is a library that can be built with multiple Qt versions, you may want to take Qt modules as separate arguments (`qtbase`, `qtdeclarative` etc.), and invoke the package from `pkgs/top-level/qt5-packages.nix` or `pkgs/top-level/qt6-packages.nix` using the respective `callPackage` functions. -```nix -{ stdenv, wrapQtAppsHook }: +Applications should generally be built with upstream's preferred Qt version. -stdenv.mkDerivation { - # ... - nativeBuildInputs = [ wrapQtAppsHook ]; -} -``` +## Locating additional runtime dependencies {#qt-runtime-dependencies} Add entries to `qtWrapperArgs` are to modify the wrappers created by `wrapQtAppsHook`: ```nix -{ stdenv, wrapQtAppsHook }: +{ stdenv, qt6 }: stdenv.mkDerivation { # ... - nativeBuildInputs = [ wrapQtAppsHook ]; + nativeBuildInputs = [ qt6.wrapQtAppsHook ]; qtWrapperArgs = [ ''--prefix PATH : /path/to/bin'' ]; } ``` The entries are passed as arguments to [wrapProgram](#fun-wrapProgram). -Set `dontWrapQtApps` to stop applications from being wrapped automatically. -Wrap programs manually with `wrapQtApp`, using the syntax of -[wrapProgram](#fun-wrapProgram): +If you need more control over the wrapping process, set `dontWrapQtApps` to disable automatic wrapper generation, +and then create wrappers manually in `fixupPhase`, using `wrapQtApp`, which itself is a small wrapper over [wrapProgram](#fun-wrapProgram): + +The `makeWrapper` arguments required for Qt are also exposed in the environment as `$qtWrapperArgs`. ```nix { stdenv, lib, wrapQtAppsHook }: diff --git a/nixpkgs/doc/languages-frameworks/rust.section.md b/nixpkgs/doc/languages-frameworks/rust.section.md index a81ba1e456e8..72bade25a9fb 100644 --- a/nixpkgs/doc/languages-frameworks/rust.section.md +++ b/nixpkgs/doc/languages-frameworks/rust.section.md @@ -701,7 +701,7 @@ with import <nixpkgs> {}; hello = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") { postPatch = '' substituteInPlace lib/zoneinfo.rs \ - --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo" + --replace-fail "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo" ''; }; }; |