bin/flake.nix

73 lines
2.1 KiB
Nix
Raw Permalink Normal View History

2023-10-18 16:14:44 +02:00
{
description = "bin service";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
crane = {
url = "github:ipetkov/crane";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
2023-10-18 20:39:43 +02:00
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane}: let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
2023-10-22 00:29:02 +02:00
] (system: function system nixpkgs.legacyPackages.${system});
in rec {
packages = forAllSystems(system: syspkgs: let
2023-10-18 16:14:44 +02:00
pkgs = import nixpkgs {
2023-10-18 20:39:43 +02:00
inherit system;
overlays = [ (import rust-overlay) ];
2023-10-18 16:14:44 +02:00
};
rustToolchain = pkgs.rust-bin.stable.latest.default;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
2023-10-22 00:29:02 +02:00
filter = path: type:
2023-11-06 21:53:45 +01:00
(pkgs.lib.hasSuffix "\.stpl" path) ||
(pkgs.lib.hasInfix "static" path) ||
2023-10-22 00:29:02 +02:00
(craneLib.filterCargoSources path type)
;
2023-10-18 16:14:44 +02:00
};
nativeBuildInputs = with pkgs; [ rustToolchain pkg-config ];
buildInputs = with pkgs; [ ];
commonArgs = {
inherit src buildInputs nativeBuildInputs;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
bin = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
2023-10-22 00:29:02 +02:00
pname = "bin";
});
binctl = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
pname = "binctl";
2023-10-18 16:14:44 +02:00
});
2023-10-22 00:29:02 +02:00
in {
inherit bin binctl;
2023-10-18 20:39:43 +02:00
default = bin;
});
2023-10-22 00:29:02 +02:00
devShells = forAllSystems(system: pkgs: pkgs.mkShell {
inputsFrom = [packages.${system}.bin packages.${system}.binctl];
2023-10-18 20:39:43 +02:00
});
2023-10-22 00:29:02 +02:00
hydraJobs."bin" = forAllSystems(system: pkgs: packages.${system}.bin);
hydraJobs."binctl" = forAllSystems(system: pkgs: packages.${system}.binctl);
2023-10-18 20:39:43 +02:00
};
2023-10-18 16:14:44 +02:00
}