Trying to replace all gnome packages with the ones from unstable

I wanted to try out GNOME 42 on NixOS.
My idea was to replace all the gnome.somepackage packages with the ones from the unstable branch since most of the are already on version 42.

However a package called libosinfo-1.9.0 failed to build.

All of the errors seem to come from gcc not linking the pthread functions correctly but I don’t know how to solve this or what I am doing wrong.

Important lines from the build log

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/l0r69nmmjnyf0q311padphnkv7xax8lf-libosinfo-1.9.0.tar.xz
source root is libosinfo-1.9.0
setting SOURCE_DATE_EPOCH to timestamp 1612340416 of file libosinfo-1.9.0/AUTHORS
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/gcc92zw12b6fy7dl3gg8pl59afiqza4d-osinfo-db-data-dir.patch
patching file osinfo/osinfo_loader.c
Hunk #1 succeeded at 2632 (offset 328 lines).
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
meson flags: --buildtype=plain         --libdir=/nix/store/1g3wmp5ihvacija3j12w3vb7rhfxhxxg-libosinfo-1.9.0/lib --libexecdir=/nix/store/1g3wmp5ihvacija3j12w3vb7rhfxhxxg-libosinfo-1.9.0/libe>
The Meson build system
Version: 0.57.1
Source dir: /build/libosinfo-1.9.0
Build dir: /build/libosinfo-1.9.0/build
Build type: native build
Project name: libosinfo
Project version: 1.9.0
C compiler for the host machine: gcc (gcc 10.3.0 "gcc (GCC) 10.3.0")
C linker for the host machine: gcc ld.bfd 2.35.2
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program g-ir-scanner found: YES (/nix/store/kw71ly7jjsvcxh1qg7wfkga3n0qr38q8-gobject-introspection-1.70.0-dev/bin/g-ir-scanner)
Vala compiler for the host machine: valac (valac 0.54.2)
Configuring libosinfo.spec using configuration
Configuring mingw-libosinfo.spec using configuration
Program build-aux/dist.sh found: YES (/build/libosinfo-1.9.0/build-aux/dist.sh)
Found pkg-config: /nix/store/7qjyyqv9sqgk1lkzpgf1ymmcx6zzix0p-pkg-config-wrapper-0.29.2/bin/pkg-config (0.29.2)
Run-time dependency glib-2.0 found: YES 2.70.1
Run-time dependency gio-2.0 found: YES 2.70.1
Run-time dependency gobject-2.0 found: YES 2.70.1
Run-time dependency libsoup-2.4 found: YES 2.74.2
Run-time dependency libxml-2.0 found: YES 2.9.13
Run-time dependency libxslt found: YES 1.1.34
Compiler for C supports arguments -W: YES 

...

Compiler for C supports arguments -Wno-string-plus-int: NO 

...

gcc  -o tools/osinfo-detect tools/osinfo-detect.p/meson-generated_.._.._osinfo_osinfo_enum_types.c.o tools/osinfo-detect.p/osinfo-detect.c.o -Wl,--as-needed -Wl,--no-undefined '-Wl,-rpath,$ORIGIN/../osinfo' -Wl,-rpath-link,/build/libosinfo-1.9.0/build/osinfo -Wl,--start-group osinfo/libosinfo-1.0.so.0.1009.0 /nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib/libglib-2.0.so /nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib/libgio-2.0.so /nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib/libgobject-2.0.so /nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib/libxml2.so /nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib/libsoup-2.4.so -Wl,--export-dynamic /nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib/libgmodule-2.0.so -pthread /nix/store/2k1ym7ci4hkz90gbqn4x16jy4p3q1ixh-libxslt-1.1.34/lib/libxslt.so -Wl,--end-group
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib/libxml2.so: undefined reference to `dlclose@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib/libxml2.so: undefined reference to `dlerror@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/qvs678k05yrv566dmqdnxfbzi4s6ir1n-sqlite-3.38.2/lib/libsqlite3.so.0: undefined reference to `pthread_mutexattr_init@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib/libsoup-2.4.so: undefined reference to `pthread_key_create@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib/libsoup-2.4.so: undefined reference to `pthread_setspecific@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/qvs678k05yrv566dmqdnxfbzi4s6ir1n-sqlite-3.38.2/lib/libsqlite3.so.0: undefined reference to `pthread_join@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/qvs678k05yrv566dmqdnxfbzi4s6ir1n-sqlite-3.38.2/lib/libsqlite3.so.0: undefined reference to `pthread_mutex_trylock@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib/libxml2.so: undefined reference to `dlsym@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib/libsoup-2.4.so: undefined reference to `pthread_getspecific@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib/libxml2.so: undefined reference to `dlopen@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/qvs678k05yrv566dmqdnxfbzi4s6ir1n-sqlite-3.38.2/lib/libsqlite3.so.0: undefined reference to `pthread_mutexattr_settype@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib/libsoup-2.4.so: undefined reference to `pthread_once@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/qvs678k05yrv566dmqdnxfbzi4s6ir1n-sqlite-3.38.2/lib/libsqlite3.so.0: undefined reference to `pthread_create@GLIBC_2.34'
/nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: /nix/store/qvs678k05yrv566dmqdnxfbzi4s6ir1n-sqlite-3.38.2/lib/libsqlite3.so.0: undefined reference to `pthread_mutexattr_destroy@GLIBC_2.34'
collect2: error: ld returned 1 exit status

...

linking of temporary binary failed: Command '['gcc', '-o', '/build/libosinfo-1.9.0/build/tmp-introspect6ancnsim/Libosinfo-1.0', '/build/libosinfo-1.9.0/build/tmp-introspect6ancnsim/Libosinfo-1.0.o', '-L.', '-Wl,-rpath,.', '-Wl,--no-as-needed', '-L./osinfo', '-L/nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib', '-Wl,-rpath,/nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib', '-L/nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib', '-Wl,-rpath,/nix/store/cv5jjgg8c6a3rxizlh0a6d5bdgkszajb-libsoup-2.74.2/lib', '-L/nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib', '-Wl,-rpath,/nix/store/sbshh5ifr678sx5fqkka81yqyyswsplw-libxml2-2.9.13/lib', '-L/nix/store/2k1ym7ci4hkz90gbqn4x16jy4p3q1ixh-libxslt-1.1.34/lib', '-Wl,-rpath,/nix/store/2k1ym7ci4hkz90gbqn4x16jy4p3q1ixh-libxslt-1.1.34/lib', '-L/nix/store/53qr6avdc276fh5g47fvgqa5f771kg92-libxml2-2.9.12/lib', '-Wl,-rpath,/nix/store/53qr6avdc276fh5g47fvgqa5f771kg92-libxml2-2.9.12/lib', '-L/nix/store/pxg983i056rjg7wf5ib2k9i8az777zig-gobject-introspection-1.70.0/lib', '-Wl,-rpath,/nix/store/pxg983i056rjg7wf5ib2k9i8az777zig-gobject-introspection-1.70.0/lib', '-losinfo-1.0', '-lgobject-2.0', '-lglib-2.0', '-lgio-2.0', '-lsoup-2.4', '-lgmodule-2.0', '-lxml2', '-lxslt', '-lgirepository-1.0', '-L/nix/store/f5jhxrj5cxq2mnahwj4nba3sw4g5956c-glib-2.70.1/lib', '-lgio-2.0', '-lgobject-2.0', '-Wl,--export-dynamic', '-lgmodule-2.0', '-pthread', '-lglib-2.0']' returned non-zero exit status 1.

My simplified pkgs configuration in the flake

{
  description = "NixOS configuration";

  inputs = {
    nixpkgs-stable.url = "nixpkgs/nixos-21.11";
    nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
  };

  outputs = { ... }@inputs:
    let
      system = "x86_64-linux";

      overlay-unstable = _: _: {
        unstable = import inputs.nixpkgs-unstable {
          inherit system;
          config.allowUnfree = true;
        };
      };

      pkgs = import inputs.nixpkgs-stable {
        inherit system;
        config.allowUnfree = true;
        overlays = [
          overlay-unstable
          (_: super: { gnome = super.unstable.gnome; })
        ];
      };

    in
    {
      # ... stuff
    };
}

My flake.lock (with home-manager)

{
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs-stable"
        ]
      },
      "locked": {
        "lastModified": 1643933536,
        "narHash": "sha256-yRmsWAG4DnLxLIUtlaZsl0kH7rN5xSoyNRlf0YZrcH4=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "2860d7e3bb350f18f7477858f3513f9798896831",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "release-21.11",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nixpkgs-stable": {
      "locked": {
        "lastModified": 1646258393,
        "narHash": "sha256-mKDoCi5Baqainjf0Nx6oTPhaxKQdj4P17XTdhTtXGRA=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "ed02c2ba0384b2800db41333045a6fb781f12aac",
        "type": "github"
      },
      "original": {
        "id": "nixpkgs",
        "ref": "nixos-21.11",
        "type": "indirect"
      }
    },
    "nixpkgs-unstable": {
      "locked": {
        "lastModified": 1651007983,
        "narHash": "sha256-GNay7yDPtLcRcKCNHldug85AhAvBpTtPEJWSSDYBw8U=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "e10da1c7f542515b609f8dfbcf788f3d85b14936",
        "type": "github"
      },
      "original": {
        "id": "nixpkgs",
        "ref": "nixos-unstable",
        "type": "indirect"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "nixpkgs-stable": "nixpkgs-stable",
        "nixpkgs-unstable": "nixpkgs-unstable"
      }
    }
  },
  "root": "root",
  "version": 7
}

It now applies without any problems but the system doesnt start gdm correctly.

I think this is just a bad idea.

pkgs = import inputs.nixpkgs-stable {
  inherit system;
  config.allowUnfree = true;
  overlays = [
    overlay-unstable
    (import ./overlays)
    (_: super: {
      gnome = super.unstable.gnome;
      libosinfo = super.unstable.libosinfo;
      tracker-miners = super.unstable.tracker-miners;
    })
  ];
};

You would probably also need to replace the modules as mentioned in Overriding package versions used by services - #2 by Mic92. Or you could try to pick just a subset of packages as described in Gnome 3.38 on latest release - #5 by jtojnar.

But either way, it will be too a lot of work catching all the incompatibilities. You would be better off just switching to unstable or trying it in a VM using nixos-rebuild build-vm -I nixos-config=path/to/your/configuration.nix -I nixpkgs=channel:nixos-unstable, if you cannot wait for NixOS 22.05 release.