{ inputs = { utils.url = "github:numtide/flake-utils"; naersk.url = "github:nmattia/naersk"; mozillapkgs.url = "github:mozilla/nixpkgs-mozilla"; mozillapkgs.flake = false; }; outputs = { self, nixpkgs, utils, naersk, mozillapkgs }: utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages."${system}"; mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") {}; rust = (mozilla.rustChannelOf { channel = "stable"; date = "2021-10-04"; sha256 = "0swglfa63i14fpgg98agx4b5sz0nckn6phacfy3k6imknsiv8mrg"; }).rust; # Override the version used in naersk naersk-lib = naersk.lib."${system}".override { cargo = rust; rustc = rust; }; buildRustPackage = args: naersk-lib.buildPackage ({ src = ./.; targets = [ args.pname ]; cargoBuildOptions = opts: opts ++ [ "-p" args.pname ]; nativeBuildInputs = with pkgs; [ pkg-config ]; buildInputs = with pkgs; [ openssl ]; } // args); in rec { # `nix build` packages.heliwatch = buildRustPackage { pname = "heliwatch"; }; packages.http-json = buildRustPackage { pname = "http-json"; }; packages.collectd-stats = buildRustPackage { pname = "collectd-stats"; }; defaultPackage = packages.heliwatch; checks = packages; # `nix run` apps.heliwatch = utils.lib.mkApp { drv = packages.heliwatch; }; defaultApp = apps.heliwatch; # `nix develop` devShell = pkgs.mkShell { nativeBuildInputs = with defaultPackage; nativeBuildInputs ++ buildInputs; }; }) // { overlay = final: prev: { heliwatch = self.packages.${prev.system}; }; nixosModules.heliwatch = import ./heliwatch/module.nix { inherit self; }; }; }