heliwatch/flake.nix

71 lines
1.9 KiB
Nix
Raw Normal View History

2021-10-30 01:18:04 +02:00
{
inputs = {
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nmattia/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
2021-10-30 01:18:04 +02:00
};
outputs = { self, nixpkgs, utils, fenix, naersk }:
2022-05-26 03:51:24 +02:00
utils.lib.eachSystem (with utils.lib.system; [ x86_64-linux aarch64-linux ]) (system: let
2021-10-30 01:18:04 +02:00
pkgs = nixpkgs.legacyPackages."${system}";
rust = fenix.packages.${system}.complete.withComponents [
"cargo"
"rustc"
"rust-src" # just for rust-analyzer
"clippy"
];
2021-10-30 01:18:04 +02:00
# Override the version used in naersk
naersk-lib = naersk.lib."${system}".override {
cargo = rust;
rustc = rust;
};
2021-11-08 23:32:39 +01:00
buildRustPackage = args: naersk-lib.buildPackage ({
2021-11-09 01:13:27 +01:00
src = ./.;
targets = [ args.pname ];
cargoBuildOptions = opts: opts ++ [ "-p" args.pname ];
2021-10-30 01:18:04 +02:00
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
2021-11-08 23:32:39 +01:00
} // args);
in rec {
# `nix build`
packages.heliwatch = buildRustPackage {
pname = "heliwatch";
};
packages.http-json = buildRustPackage {
pname = "http-json";
};
packages.collectd-stats = buildRustPackage {
pname = "collectd-stats";
2021-10-30 01:18:04 +02:00
};
defaultPackage = packages.heliwatch;
2021-11-08 23:32:39 +01:00
checks = packages;
2021-10-30 01:18:04 +02:00
# `nix run`
apps.heliwatch = utils.lib.mkApp {
drv = packages.heliwatch;
};
defaultApp = apps.heliwatch;
# `nix develop`
devShell = pkgs.mkShell {
nativeBuildInputs = [
fenix.packages.${system}.rust-analyzer
] ++ (with defaultPackage;
nativeBuildInputs ++ buildInputs
);
2021-10-30 01:18:04 +02:00
};
2021-10-30 01:59:17 +02:00
}) // {
overlay = final: prev: {
heliwatch = self.packages.${prev.system};
};
2021-11-09 01:25:26 +01:00
2021-11-09 01:06:53 +01:00
nixosModules.heliwatch = import ./heliwatch/module.nix { inherit self; };
2021-10-30 01:59:17 +02:00
};
2021-10-30 01:18:04 +02:00
}