2022-01-31 02:06:46 +03:00
|
|
|
{
|
|
|
|
description = "Build a cargo project with alternative crate registries";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
2024-08-30 02:29:16 +03:00
|
|
|
crane.url = "github:ipetkov/crane";
|
2022-01-31 02:06:46 +03:00
|
|
|
|
|
|
|
flake-utils = {
|
|
|
|
url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, crane, flake-utils, ... }:
|
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
2023-11-26 21:37:43 +03:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2022-01-31 02:06:46 +03:00
|
|
|
|
2024-05-19 04:07:07 +03:00
|
|
|
craneLibOrig = crane.mkLib pkgs;
|
2022-01-31 02:06:46 +03:00
|
|
|
craneLib = craneLibOrig.appendCrateRegistries [
|
|
|
|
# Automatically infer the download URL from the registry's index
|
|
|
|
#
|
|
|
|
# Note that this approach requires checking out the full index at the specified revision
|
|
|
|
# and adding a copy to the Nix store.
|
|
|
|
#
|
|
|
|
# Also note that the specified git revision _does not need to track updates to the index
|
|
|
|
# itself_ as long as the pinned revision contains the most recent version of the
|
|
|
|
# registry's `config.json` file. In other words, this commit revision only needs to be
|
|
|
|
# updated if the `config.json` file changes the download endpoint for this registry.
|
|
|
|
(craneLibOrig.registryFromGitIndex {
|
2022-01-31 02:10:28 +03:00
|
|
|
indexUrl = "https://github.com/Hirevo/alexandrie-index";
|
2022-01-31 02:06:46 +03:00
|
|
|
rev = "90df25daf291d402d1ded8c32c23d5e1498c6725";
|
2022-11-21 03:22:13 +03:00
|
|
|
fetchurlExtraArgs = {
|
|
|
|
# Extra parameters which will be passed to the fetchurl invocation for each crate
|
|
|
|
};
|
2022-01-31 02:06:46 +03:00
|
|
|
})
|
|
|
|
|
2023-06-13 05:03:18 +03:00
|
|
|
# If the registry in question is a sparse index, instead configure as
|
2023-06-19 02:16:45 +03:00
|
|
|
#(craneLibOrig.registryFromSparse {
|
|
|
|
# indexUrl = "https://index.crates.io";
|
|
|
|
# # where the sha256 is the sha256 of https://index.crates.io/config.json.
|
|
|
|
# configSha256 = "d16740883624df970adac38c70e35cf077a2a105faa3862f8f99a65da96b14a3";
|
|
|
|
# fetchurlExtraArgs = {
|
|
|
|
# # Extra parameters which will be passed to the fetchurl invocation for each crate
|
|
|
|
# };
|
|
|
|
#})
|
2023-06-13 05:03:18 +03:00
|
|
|
|
2022-01-31 02:06:46 +03:00
|
|
|
# As a more lightweight alternative, the `dl` endpoint of the registry's `config.json`
|
|
|
|
# file can be copied here to avoid needing to copy the index to the Nix store.
|
|
|
|
# (craneLibOrig.registryFromDownloadUrl {
|
2022-01-31 02:10:28 +03:00
|
|
|
# indexUrl = "https://github.com/Hirevo/alexandrie-index";
|
2022-01-31 02:06:46 +03:00
|
|
|
# dl = "https://crates.polomack.eu/api/v1/crates/{crate}/{version}/download";
|
2022-11-21 03:22:13 +03:00
|
|
|
# fetchurlExtraArgs = {
|
|
|
|
# # Extra parameters which will be passed to the fetchurl invocation for each crate
|
|
|
|
# };
|
2022-01-31 02:06:46 +03:00
|
|
|
# })
|
|
|
|
];
|
|
|
|
|
|
|
|
my-crate = craneLib.buildPackage {
|
2024-06-11 06:53:46 +03:00
|
|
|
src = craneLib.cleanCargoSource ./.;
|
2023-10-16 01:25:34 +03:00
|
|
|
strictDeps = true;
|
2022-01-31 02:06:46 +03:00
|
|
|
|
2022-11-20 03:08:15 +03:00
|
|
|
buildInputs = [
|
|
|
|
# Add additional build inputs here
|
2023-10-16 01:25:34 +03:00
|
|
|
pkgs.openssl
|
2022-11-20 03:08:15 +03:00
|
|
|
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
|
|
# Additional darwin specific inputs can be set here
|
|
|
|
pkgs.libiconv
|
|
|
|
pkgs.darwin.apple_sdk.frameworks.Security
|
|
|
|
];
|
|
|
|
|
2022-01-31 02:06:46 +03:00
|
|
|
# Specific to our example, but not always necessary in the general case.
|
2023-10-16 01:25:34 +03:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgs.pkg-config
|
2022-01-31 02:06:46 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
checks = {
|
|
|
|
# Build the crate as part of `nix flake check` for convenience
|
|
|
|
inherit my-crate;
|
|
|
|
};
|
|
|
|
|
2022-04-28 05:23:30 +03:00
|
|
|
packages.default = my-crate;
|
2022-01-31 02:06:46 +03:00
|
|
|
|
2022-04-28 05:23:30 +03:00
|
|
|
apps.default = flake-utils.lib.mkApp {
|
2022-01-31 02:06:46 +03:00
|
|
|
drv = my-crate;
|
|
|
|
};
|
|
|
|
|
2023-09-03 20:33:10 +03:00
|
|
|
devShells.default = craneLib.devShell {
|
|
|
|
# Inherit inputs from checks.
|
|
|
|
checks = self.checks.${system};
|
2022-01-31 02:06:46 +03:00
|
|
|
|
2023-09-03 20:33:10 +03:00
|
|
|
# Additional dev-shell environment variables can be set directly
|
|
|
|
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
|
|
|
|
|
|
|
# Extra inputs can be added here; cargo and rustc are provided by default.
|
|
|
|
packages = [
|
|
|
|
# pkgs.ripgrep
|
2022-01-31 02:06:46 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|