Remove flake-utils, update flake.lock, and reformat Nix sources
This commit is contained in:
parent
bad7e4c102
commit
f0a578b8f7
150
crane.nix
150
crane.nix
|
@ -18,90 +18,98 @@ let
|
||||||
}).overrideAttrs (old: {
|
}).overrideAttrs (old: {
|
||||||
# Remove the propagated libiconv since we want to add our static version
|
# Remove the propagated libiconv since we want to add our static version
|
||||||
depsTargetTargetPropagated = lib.filter (d: d.pname != "libiconv")
|
depsTargetTargetPropagated = lib.filter (d: d.pname != "libiconv")
|
||||||
(lib.flatten (old.depsTargetTargetPropagated or []));
|
(lib.flatten (old.depsTargetTargetPropagated or [ ]));
|
||||||
});
|
});
|
||||||
|
|
||||||
# For easy cross-compilation in devShells
|
# For easy cross-compilation in devShells
|
||||||
# We are just composing the pkgsCross.*.stdenv.cc together
|
# We are just composing the pkgsCross.*.stdenv.cc together
|
||||||
crossPlatforms = let
|
crossPlatforms =
|
||||||
makeCrossPlatform = crossSystem: let
|
let
|
||||||
pkgsCross =
|
makeCrossPlatform = crossSystem:
|
||||||
if crossSystem == system then pkgs
|
let
|
||||||
else import pkgs.path {
|
pkgsCross =
|
||||||
inherit system crossSystem;
|
if crossSystem == system then pkgs
|
||||||
overlays = [];
|
else
|
||||||
|
import pkgs.path {
|
||||||
|
inherit system crossSystem;
|
||||||
|
overlays = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform;
|
||||||
|
rustTargetSpecUnderscored = builtins.replaceStrings [ "-" ] [ "_" ] rustTargetSpec;
|
||||||
|
|
||||||
|
cargoLinkerEnv = lib.strings.toUpper "CARGO_TARGET_${rustTargetSpecUnderscored}_LINKER";
|
||||||
|
cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring
|
||||||
|
|
||||||
|
ccbin = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
name = crossSystem;
|
||||||
|
value = {
|
||||||
|
inherit rustTargetSpec;
|
||||||
|
cc = pkgsCross.stdenv.cc;
|
||||||
|
pkgs = pkgsCross;
|
||||||
|
buildInputs = makeBuildInputs pkgsCross;
|
||||||
|
env = {
|
||||||
|
"${cargoLinkerEnv}" = ccbin;
|
||||||
|
"${cargoCcEnv}" = ccbin;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems
|
||||||
rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform;
|
# Cross from aarch64-darwin -> x86_64-darwin doesn't work yet
|
||||||
rustTargetSpecUnderscored = builtins.replaceStrings [ "-" ] [ "_" ] rustTargetSpec;
|
# Hopefully the situation will improve with the SDK bumps
|
||||||
|
++ lib.optional (system == "x86_64-darwin") "aarch64-darwin";
|
||||||
cargoLinkerEnv = lib.strings.toUpper "CARGO_TARGET_${rustTargetSpecUnderscored}_LINKER";
|
in
|
||||||
cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring
|
builtins.listToAttrs (map makeCrossPlatform systems);
|
||||||
|
|
||||||
ccbin = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc";
|
|
||||||
in {
|
|
||||||
name = crossSystem;
|
|
||||||
value = {
|
|
||||||
inherit rustTargetSpec;
|
|
||||||
cc = pkgsCross.stdenv.cc;
|
|
||||||
pkgs = pkgsCross;
|
|
||||||
buildInputs = makeBuildInputs pkgsCross;
|
|
||||||
env = {
|
|
||||||
"${cargoLinkerEnv}" = ccbin;
|
|
||||||
"${cargoCcEnv}" = ccbin;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems
|
|
||||||
# Cross from aarch64-darwin -> x86_64-darwin doesn't work yet
|
|
||||||
# Hopefully the situation will improve with the SDK bumps
|
|
||||||
++ lib.optional (system == "x86_64-darwin") "aarch64-darwin";
|
|
||||||
in builtins.listToAttrs (map makeCrossPlatform systems);
|
|
||||||
|
|
||||||
cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms;
|
cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms;
|
||||||
cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) {} (builtins.attrValues crossPlatforms);
|
cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) { } (builtins.attrValues crossPlatforms);
|
||||||
|
|
||||||
makeBuildInputs = pkgs: with pkgs; []
|
makeBuildInputs = pkgs: with pkgs; [ ]
|
||||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||||
darwin.apple_sdk.frameworks.Security
|
darwin.apple_sdk.frameworks.Security
|
||||||
(libiconv.override { enableStatic = true; enableShared = false; })
|
(libiconv.override { enableStatic = true; enableShared = false; })
|
||||||
];
|
];
|
||||||
|
|
||||||
buildFor = system: let
|
buildFor = system:
|
||||||
crossPlatform = crossPlatforms.${system};
|
let
|
||||||
inherit (crossPlatform) pkgs;
|
crossPlatform = crossPlatforms.${system};
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
|
inherit (crossPlatform) pkgs;
|
||||||
crateName = craneLib.crateNameFromCargoToml {
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
|
||||||
cargoToml = ./nix-actions-cache/Cargo.toml;
|
crateName = craneLib.crateNameFromCargoToml {
|
||||||
};
|
cargoToml = ./nix-actions-cache/Cargo.toml;
|
||||||
|
|
||||||
src = nix-gitignore.gitignoreSource [] ./.;
|
|
||||||
|
|
||||||
commonArgs = {
|
|
||||||
inherit (crateName) pname version;
|
|
||||||
inherit src;
|
|
||||||
|
|
||||||
buildInputs = makeBuildInputs pkgs;
|
|
||||||
|
|
||||||
cargoExtraArgs = "--target ${crossPlatform.rustTargetSpec}";
|
|
||||||
|
|
||||||
cargoVendorDir = craneLib.vendorMultipleCargoDeps {
|
|
||||||
inherit (craneLib.findCargoFiles src) cargoConfigs;
|
|
||||||
cargoLockList = [
|
|
||||||
./Cargo.lock
|
|
||||||
"${rustNightly.passthru.availableComponents.rust-src}/lib/rustlib/src/rust/Cargo.lock"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
} // crossPlatform.env;
|
|
||||||
|
|
||||||
crate = craneLib.buildPackage (commonArgs // {
|
src = nix-gitignore.gitignoreSource [ ] ./.;
|
||||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
||||||
|
|
||||||
# The resulting executable must be standalone
|
commonArgs = {
|
||||||
allowedRequisites = [];
|
inherit (crateName) pname version;
|
||||||
});
|
inherit src;
|
||||||
in crate;
|
|
||||||
in {
|
buildInputs = makeBuildInputs pkgs;
|
||||||
|
|
||||||
|
cargoExtraArgs = "--target ${crossPlatform.rustTargetSpec}";
|
||||||
|
|
||||||
|
cargoVendorDir = craneLib.vendorMultipleCargoDeps {
|
||||||
|
inherit (craneLib.findCargoFiles src) cargoConfigs;
|
||||||
|
cargoLockList = [
|
||||||
|
./Cargo.lock
|
||||||
|
"${rustNightly.passthru.availableComponents.rust-src}/lib/rustlib/src/rust/Cargo.lock"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
} // crossPlatform.env;
|
||||||
|
|
||||||
|
crate = craneLib.buildPackage (commonArgs // {
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||||
|
|
||||||
|
# The resulting executable must be standalone
|
||||||
|
allowedRequisites = [ ];
|
||||||
|
});
|
||||||
|
in
|
||||||
|
crate;
|
||||||
|
in
|
||||||
|
{
|
||||||
inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly;
|
inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly;
|
||||||
|
|
||||||
nix-actions-cache = buildFor system;
|
nix-actions-cache = buildFor system;
|
||||||
|
|
66
flake.lock
66
flake.lock
|
@ -5,20 +5,18 @@
|
||||||
"flake-compat": [
|
"flake-compat": [
|
||||||
"flake-compat"
|
"flake-compat"
|
||||||
],
|
],
|
||||||
"flake-utils": [
|
"flake-utils": "flake-utils",
|
||||||
"flake-utils"
|
|
||||||
],
|
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1683505101,
|
"lastModified": 1687310026,
|
||||||
"narHash": "sha256-VBU64Jfu2V4sUR5+tuQS9erBRAe/QEYUxdVMcJGMZZs=",
|
"narHash": "sha256-20RHFbrnC+hsG4Hyeg/58LvQAK7JWfFItTPFAFamu8E=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "7b5bd9e5acb2bb0cfba2d65f34d8568a894cdb6c",
|
"rev": "116b32c30b5ff28e49f4fcbeeb1bbe3544593204",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -47,6 +45,24 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1685518550,
|
||||||
|
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681202837,
|
"lastModified": 1681202837,
|
||||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
|
@ -63,11 +79,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1684049129,
|
"lastModified": 1686960236,
|
||||||
"narHash": "sha256-7WB9LpnPNAS8oI7hMoHeKLNhRX7k3CI9uWBRSfmOCCE=",
|
"narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0470f36b02ef01d4f43c641bbf07020bcab71bf1",
|
"rev": "04af42f3b31dba0ef742d254456dc4c14eedac86",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -81,7 +97,6 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"crane": "crane",
|
"crane": "crane",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay_2"
|
"rust-overlay": "rust-overlay_2"
|
||||||
}
|
}
|
||||||
|
@ -98,11 +113,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1683080331,
|
"lastModified": 1685759304,
|
||||||
"narHash": "sha256-nGDvJ1DAxZIwdn6ww8IFwzoHb2rqBP4wv/65Wt5vflk=",
|
"narHash": "sha256-I3YBH6MS3G5kGzNuc1G0f9uYfTcNY9NYoRc3QsykLk4=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "d59c3fa0cba8336e115b376c2d9e91053aa59e56",
|
"rev": "c535b4f3327910c96dcf21851bbdd074d0760290",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -113,19 +128,17 @@
|
||||||
},
|
},
|
||||||
"rust-overlay_2": {
|
"rust-overlay_2": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": [
|
"flake-utils": "flake-utils_2",
|
||||||
"flake-utils"
|
|
||||||
],
|
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1683512408,
|
"lastModified": 1687400833,
|
||||||
"narHash": "sha256-QMJGp/37En+d5YocJuSU89GL14bBYkIJQ6mqhRfqkkc=",
|
"narHash": "sha256-rVENiSupjAE8o1+ZXNRIqewUzM2brm+aeme8MUrwl0U=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "75b07756c3feb22cf230e75fb064c1b4c725b9bc",
|
"rev": "fc0a266e836c079a9131108f4334e5af219dbb93",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -148,6 +161,21 @@
|
||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"systems_2": {
|
||||||
|
"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",
|
"root": "root",
|
||||||
|
|
212
flake.nix
212
flake.nix
|
@ -3,19 +3,16 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
|
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
crane = {
|
crane = {
|
||||||
url = "github:ipetkov/crane";
|
url = "github:ipetkov/crane";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.flake-compat.follows = "flake-compat";
|
inputs.flake-compat.follows = "flake-compat";
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
|
@ -24,121 +21,124 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: let
|
outputs = { self, nixpkgs, ... }@inputs:
|
||||||
supportedSystems = flake-utils.lib.defaultSystems;
|
let
|
||||||
in flake-utils.lib.eachSystem supportedSystems (system: let
|
overlays = [ inputs.rust-overlay.overlays.default ];
|
||||||
pkgs = import nixpkgs {
|
supportedSystems = [
|
||||||
inherit system;
|
"aarch64-linux"
|
||||||
overlays = [
|
"x86_64-linux"
|
||||||
rust-overlay.overlay
|
"aarch64-darwin"
|
||||||
|
"x86_64-darwin"
|
||||||
];
|
];
|
||||||
};
|
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
||||||
|
pkgs = import nixpkgs { inherit overlays system; };
|
||||||
|
cranePkgs = pkgs.callPackage ./crane.nix {
|
||||||
|
inherit supportedSystems;
|
||||||
|
inherit (inputs) crane;
|
||||||
|
};
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec {
|
||||||
|
inherit (cranePkgs) nix-actions-cache;
|
||||||
|
default = nix-actions-cache;
|
||||||
|
});
|
||||||
|
|
||||||
inherit (pkgs) lib;
|
devShells = forEachSupportedSystem ({ pkgs, cranePkgs, lib }: {
|
||||||
|
default = pkgs.mkShell ({
|
||||||
|
inputsFrom = [ cranePkgs.nix-actions-cache ];
|
||||||
|
packages = with pkgs; [
|
||||||
|
bashInteractive
|
||||||
|
cranePkgs.rustNightly
|
||||||
|
|
||||||
cranePkgs = pkgs.callPackage ./crane.nix {
|
cargo-bloat
|
||||||
inherit crane supportedSystems;
|
cargo-edit
|
||||||
};
|
cargo-udeps
|
||||||
in {
|
cargo-watch
|
||||||
packages = rec {
|
|
||||||
inherit (cranePkgs) nix-actions-cache;
|
|
||||||
default = nix-actions-cache;
|
|
||||||
};
|
|
||||||
devShells = {
|
|
||||||
default = pkgs.mkShell ({
|
|
||||||
inputsFrom = [ cranePkgs.nix-actions-cache ];
|
|
||||||
packages = with pkgs; [
|
|
||||||
bashInteractive
|
|
||||||
cranePkgs.rustNightly
|
|
||||||
|
|
||||||
cargo-bloat
|
age
|
||||||
cargo-edit
|
];
|
||||||
cargo-udeps
|
shellHook =
|
||||||
|
let
|
||||||
|
crossSystems = lib.filter (s: s != pkgs.system) (builtins.attrNames cranePkgs.crossPlatforms);
|
||||||
|
in
|
||||||
|
''
|
||||||
|
# Returns compiler environment variables for a platform
|
||||||
|
#
|
||||||
|
# getTargetFlags "suffixSalt" "nativeBuildInputs" "buildInputs"
|
||||||
|
getTargetFlags() {
|
||||||
|
# Here we only call the setup-hooks of nativeBuildInputs.
|
||||||
|
#
|
||||||
|
# What's off-limits for us:
|
||||||
|
#
|
||||||
|
# - findInputs
|
||||||
|
# - activatePackage
|
||||||
|
# - Other functions in stdenv setup that depend on the private accumulator variables
|
||||||
|
(
|
||||||
|
suffixSalt="$1"
|
||||||
|
nativeBuildInputs="$2"
|
||||||
|
buildInputs="$3"
|
||||||
|
|
||||||
age
|
# Offsets for the nativeBuildInput (e.g., gcc)
|
||||||
];
|
hostOffset=-1
|
||||||
|
targetOffset=0
|
||||||
|
|
||||||
# We _can_ cross-compile to multiple systems with one shell :)
|
# In stdenv, the hooks are first accumulated before being called.
|
||||||
#
|
# Here we call them immediately
|
||||||
# Currently stdenv isn't set up to do that, but we can invoke
|
addEnvHooks() {
|
||||||
# the setup mechinary in a sub-shell then compose the results.
|
local depHostOffset="$1"
|
||||||
shellHook = let
|
# For simplicity, we only call the hook on buildInputs
|
||||||
crossSystems = lib.filter (s: s != pkgs.system) (builtins.attrNames cranePkgs.crossPlatforms);
|
for pkg in $buildInputs; do
|
||||||
in ''
|
depTargetOffset=1
|
||||||
# Returns compiler environment variables for a platform
|
$2 $pkg
|
||||||
#
|
done
|
||||||
# getTargetFlags "suffixSalt" "nativeBuildInputs" "buildInputs"
|
}
|
||||||
getTargetFlags() {
|
|
||||||
# Here we only call the setup-hooks of nativeBuildInputs.
|
|
||||||
#
|
|
||||||
# What's off-limits for us:
|
|
||||||
#
|
|
||||||
# - findInputs
|
|
||||||
# - activatePackage
|
|
||||||
# - Other functions in stdenv setup that depend on the private accumulator variables
|
|
||||||
(
|
|
||||||
suffixSalt="$1"
|
|
||||||
nativeBuildInputs="$2"
|
|
||||||
buildInputs="$3"
|
|
||||||
|
|
||||||
# Offsets for the nativeBuildInput (e.g., gcc)
|
unset _PATH
|
||||||
hostOffset=-1
|
unset NIX_CFLAGS_COMPILE
|
||||||
targetOffset=0
|
unset NIX_LDFLAGS
|
||||||
|
|
||||||
# In stdenv, the hooks are first accumulated before being called.
|
# For simplicity, we only call the setup-hooks of nativeBuildInputs
|
||||||
# Here we call them immediately
|
for nbi in $nativeBuildInputs; do
|
||||||
addEnvHooks() {
|
addToSearchPath _PATH "$nbi/bin"
|
||||||
local depHostOffset="$1"
|
|
||||||
# For simplicity, we only call the hook on buildInputs
|
if [ -e "$nbi/nix-support/setup-hook" ]; then
|
||||||
for pkg in $buildInputs; do
|
source "$nbi/nix-support/setup-hook"
|
||||||
depTargetOffset=1
|
fi
|
||||||
$2 $pkg
|
done
|
||||||
done
|
|
||||||
|
echo "export NIX_CFLAGS_COMPILE_''${suffixSalt}='$NIX_CFLAGS_COMPILE'"
|
||||||
|
echo "export NIX_LDFLAGS_''${suffixSalt}='$NIX_LDFLAGS'"
|
||||||
|
echo "export PATH=$PATH''${_PATH+:$_PATH}"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
unset _PATH
|
target_flags=$(mktemp)
|
||||||
|
${lib.concatMapStrings (system: let
|
||||||
|
crossPlatform = cranePkgs.crossPlatforms.${system};
|
||||||
|
in ''
|
||||||
|
getTargetFlags \
|
||||||
|
"${crossPlatform.cc.suffixSalt}" \
|
||||||
|
"${crossPlatform.cc} ${crossPlatform.cc.bintools}" \
|
||||||
|
"${builtins.concatStringsSep " " (crossPlatform.buildInputs ++ crossPlatform.pkgs.stdenv.defaultBuildInputs)}" >$target_flags
|
||||||
|
. $target_flags
|
||||||
|
'') crossSystems}
|
||||||
|
rm $target_flags
|
||||||
|
|
||||||
|
# Suffix flags for current system as well
|
||||||
|
export NIX_CFLAGS_COMPILE_${pkgs.stdenv.cc.suffixSalt}="$NIX_CFLAGS_COMPILE"
|
||||||
|
export NIX_LDFLAGS_${pkgs.stdenv.cc.suffixSalt}="$NIX_LDFLAGS"
|
||||||
unset NIX_CFLAGS_COMPILE
|
unset NIX_CFLAGS_COMPILE
|
||||||
unset NIX_LDFLAGS
|
unset NIX_LDFLAGS
|
||||||
|
'';
|
||||||
|
} // cranePkgs.cargoCrossEnvs);
|
||||||
|
|
||||||
# For simplicity, we only call the setup-hooks of nativeBuildInputs
|
keygen = pkgs.mkShellNoCC {
|
||||||
for nbi in $nativeBuildInputs; do
|
packages = with pkgs; [
|
||||||
addToSearchPath _PATH "$nbi/bin"
|
age
|
||||||
|
];
|
||||||
if [ -e "$nbi/nix-support/setup-hook" ]; then
|
};
|
||||||
source "$nbi/nix-support/setup-hook"
|
});
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "export NIX_CFLAGS_COMPILE_''${suffixSalt}='$NIX_CFLAGS_COMPILE'"
|
|
||||||
echo "export NIX_LDFLAGS_''${suffixSalt}='$NIX_LDFLAGS'"
|
|
||||||
echo "export PATH=$PATH''${_PATH+:$_PATH}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
target_flags=$(mktemp)
|
|
||||||
${lib.concatMapStrings (system: let
|
|
||||||
crossPlatform = cranePkgs.crossPlatforms.${system};
|
|
||||||
in ''
|
|
||||||
getTargetFlags \
|
|
||||||
"${crossPlatform.cc.suffixSalt}" \
|
|
||||||
"${crossPlatform.cc} ${crossPlatform.cc.bintools}" \
|
|
||||||
"${builtins.concatStringsSep " " (crossPlatform.buildInputs ++ crossPlatform.pkgs.stdenv.defaultBuildInputs)}" >$target_flags
|
|
||||||
. $target_flags
|
|
||||||
'') crossSystems}
|
|
||||||
rm $target_flags
|
|
||||||
|
|
||||||
# Suffix flags for current system as well
|
|
||||||
export NIX_CFLAGS_COMPILE_${pkgs.stdenv.cc.suffixSalt}="$NIX_CFLAGS_COMPILE"
|
|
||||||
export NIX_LDFLAGS_${pkgs.stdenv.cc.suffixSalt}="$NIX_LDFLAGS"
|
|
||||||
unset NIX_CFLAGS_COMPILE
|
|
||||||
unset NIX_LDFLAGS
|
|
||||||
'';
|
|
||||||
} // cranePkgs.cargoCrossEnvs);
|
|
||||||
keygen = pkgs.mkShellNoCC {
|
|
||||||
packages = with pkgs; [
|
|
||||||
age
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue