Skip to content

Instantly share code, notes, and snippets.

@Qyriad
Created March 11, 2024 01:03
Show Gist options
  • Select an option

  • Save Qyriad/1a09690c0e64c64558d69d3a2adfb265 to your computer and use it in GitHub Desktop.

Select an option

Save Qyriad/1a09690c0e64c64558d69d3a2adfb265 to your computer and use it in GitHub Desktop.
Nixpkgs stdenv.mkDerivation fixed point's doCheck is incorrect when cross compiling
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1709126324,
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1710116904,
"narHash": "sha256-3DS+98ECHRTinAHRyiORa1TPEmQ5qgbsZfnUfflWwZI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6ae71359c4ddd67dcea3edd4bc7b1c437aa1e7f3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/master";
flake-utils.url = "flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
localSystem = { inherit system; };
crossSystem = {
system = "armv7l-linux";
};
};
inherit (pkgs) lib;
pkgFn = {
lib,
stdenv,
writeShellScript,
}: stdenv.mkDerivation (finalAttrs: {
name = "mkderivation-fixedpoint-lies";
doCheck = true;
phases = [ "installPhase" ];
installPhase = ''
# Outputs `declare -x doCheck=""`, indicating that doCheck is set to an
# empty string, the string-coerced version of `false`.
declare -p doCheck | tee -a $out
# Outputs `finalAttrs.doCheck: true`.
echo "finalAttrs.doCheck: ${lib.boolToString finalAttrs.doCheck}" | tee -a $out
'';
});
package = pkgs.callPackage pkgFn { };
in {
packages.default = builtins.trace
# outputs `trace: package.doCheck fromoutside: false`
"package.doCheck from outside: ${lib.boolToString package.doCheck}"
package;
})
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment