Skip to content

NixOS: nativeBuildInputs do not work #190289

@ck3d

Description

@ck3d

Describe the bug

Derivations defined with pkgs are not compatible with cross compilation as defined in Nixpkgs manual.
This is the case for all derivation defined in NixOS modules.

Steps To Reproduce

Following derivation fails to build, since pkgs is used:

with (import <nixpkgs> { crossSystem.system = "aarch64-linux"; });
runCommand "bad" { nativeBuildInputs = [ jq ]; } "jq > $out"

Following dervation builds, since __splicedPackages is used:

with (import <nixpkgs> { crossSystem.system = "aarch64-linux"; }).__splicedPackages;
runCommand "good" { nativeBuildInputs = [ jq ]; } "jq > $out"

The NixOS module system uses not __splicedPackages and therefor all derivations defined with pkgs which depends on nativeBuildInputs will fail to cross compile.

Workaround

Select the package by hand and do not use stdenv cross compilation automatism:

with (import <nixpkgs> { crossSystem.system = "aarch64-linux"; });
runCommand "workaround" { } "${pkgsBuildBuild.jq}/bin/jq > $out"

Expected behavior

Derivations defined in NixOS modules can be cross compiled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: cross-compilationBuilding packages on a different platform than they will be used on6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions