conduit/flake.nix

117 lines
3.2 KiB
Nix
Raw Permalink Normal View History

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane?ref=master";
inputs.nixpkgs.follows = "nixpkgs";
2023-01-28 00:10:21 +03:00
};
attic.url = "github:zhaofengli/attic?ref=main";
};
2024-05-09 16:20:48 +03:00
outputs = inputs: let
# Keep sorted
mkScope = pkgs:
pkgs.lib.makeScope pkgs.newScope (self: {
craneLib =
(inputs.crane.mkLib pkgs).overrideToolchain self.toolchain;
default = self.callPackage ./nix/pkgs/default {};
inherit inputs;
oci-image = self.callPackage ./nix/pkgs/oci-image {};
book = self.callPackage ./nix/pkgs/book {};
2024-05-09 16:20:48 +03:00
rocksdb = let
version = "9.1.1";
in
2024-05-09 16:20:48 +03:00
pkgs.rocksdb.overrideAttrs (old: {
inherit version;
src = pkgs.fetchFromGitHub {
owner = "facebook";
repo = "rocksdb";
rev = "v${version}";
hash = "sha256-/Xf0bzNJPclH9IP80QNaABfhj4IAR5LycYET18VFCXc=";
};
});
shell = self.callPackage ./nix/shell.nix {};
# The Rust toolchain to use
2024-05-09 16:20:48 +03:00
toolchain =
inputs
.fenix
.packages
.${pkgs.pkgsBuildHost.system}
.fromToolchainFile {
file = ./rust-toolchain.toml;
# See also `rust-toolchain.toml`
sha256 = "sha256-opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU=";
};
});
2024-05-09 16:20:48 +03:00
in
inputs.flake-utils.lib.eachDefaultSystem (
system: let
pkgs = inputs.nixpkgs.legacyPackages.${system};
2024-05-09 16:20:48 +03:00
in {
packages =
{
default = (mkScope pkgs).default;
oci-image = (mkScope pkgs).oci-image;
book = (mkScope pkgs).book;
}
// builtins.listToAttrs
(
builtins.concatLists
(
builtins.map
(
crossSystem: let
binaryName = "static-${crossSystem}";
pkgsCrossStatic =
(import inputs.nixpkgs {
inherit system;
crossSystem = {
config = crossSystem;
};
2024-05-09 16:20:48 +03:00
})
.pkgsStatic;
in [
# An output for a statically-linked binary
{
name = binaryName;
value = (mkScope pkgsCrossStatic).default;
}
# An output for an OCI image based on that binary
{
name = "oci-image-${crossSystem}";
value = (mkScope pkgsCrossStatic).oci-image;
}
]
)
[
"x86_64-unknown-linux-musl"
"aarch64-unknown-linux-musl"
]
)
);
2024-03-22 01:40:10 +03:00
devShells.default = (mkScope pkgs).shell;
}
);
}