I’m using the flake below to attempt getting a statically linked build of qt6. It fails with this error, that makes it look like the gobject-introspection package has hard coded references to shared library outputs. Is this expected? I don’t know what the nixpkgs policy is for whether packages have to work with static linking, it would be really useful though (for using NixOS to build binaries that work on any distro) if it worked.
$ nix develop --option cores 4
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:34:12:
33|
34| strict = derivationStrict drvAttrs;
| ^
35|
… while evaluating derivation 'nix-shell-x86_64-unknown-linux-musl'
whose name attribute is located at /nix/store/lv9bmgm6v1wc3fiz00v29gi4rk13ja6l-source/pkgs/stdenv/generic/make-derivation.nix:333:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell-x86_64-unknown-linux-musl'
at /nix/store/lv9bmgm6v1wc3fiz00v29gi4rk13ja6l-source/pkgs/stdenv/generic/make-derivation.nix:377:7:
376| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
377| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
378| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: attribute 'sharedLibrary' missing
at /nix/store/lv9bmgm6v1wc3fiz00v29gi4rk13ja6l-source/pkgs/development/libraries/gobject-introspection/default.nix:161:33:
160| postCheck = ''
161| rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
| ^
162| '';
{
description = "Example C++ environment with musl + static using legacyPackages";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*.tar.gz";
};
outputs = { self, nixpkgs }: let
system = "x86_64-linux";
# Custom overlay with compiler flags
compilerFlagsOverlay = final: prev: let
isBootstrap = name: builtins.match "bootstrap-.*" name != null;
in {
stdenv = if isBootstrap prev.stdenv.name
then prev.stdenv
else prev.withCFlags [ "-frecord-gcc-switches" ] prev.stdenv;
};
# Base package set using legacyPackages
basePkgs = nixpkgs.legacyPackages.${system};
# Musl static package set with our overlay
muslStaticPkgs = basePkgs.pkgsCross.musl64.pkgsStatic.extend compilerFlagsOverlay;
in {
devShells.${system}.default = muslStaticPkgs.mkShell {
packages = with muslStaticPkgs; [
hello
qt6.qtbase
qt6.qtcharts
];
};
};
}