121 lines
3.1 KiB
Nix
121 lines
3.1 KiB
Nix
{
|
|
description = "A very basic flake";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
crane.url = "github:ipetkov/crane";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
process-compose-wrapper = {
|
|
url = "git+https://git.scug.io/nikkuss/process-compose-wrapper.git?ref=dev";
|
|
};
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
nixpkgs,
|
|
crane,
|
|
flake-utils,
|
|
process-compose-wrapper,
|
|
rust-overlay,
|
|
...
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
(final: prev: {
|
|
tdlib = prev.tdlib.overrideAttrs (_: {
|
|
version = "1.8.29";
|
|
src = prev.fetchFromGitHub {
|
|
owner = "tdlib";
|
|
repo = "td";
|
|
rev = "af69dd4397b6dc1bf23ba0fd0bf429fcba6454f6";
|
|
hash = "sha256-2RhKSxy0AvuA74LHI86pqUxv9oJZ+ZxxDe4TPI5UYxE=";
|
|
# hash = "sha256-mbhxuJjrV3nC8Ja7N0WWF9ByHovJLmoLLuuzoU4khjU=";
|
|
};
|
|
|
|
});
|
|
})
|
|
(import rust-overlay)
|
|
];
|
|
};
|
|
process-compose = process-compose-wrapper.lib.mkLib pkgs;
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain (
|
|
p:
|
|
p.rust-bin.nightly.latest.default.override {
|
|
extensions = [
|
|
"rustc-codegen-cranelift-preview"
|
|
"rust-analyzer"
|
|
"rust-src"
|
|
];
|
|
}
|
|
);
|
|
src = lib.cleanSourceWith {
|
|
src = ./.;
|
|
filter = (
|
|
path: type: (craneLib.filterCargoSources path type) || (builtins.match ".*/\.env$" path != null)
|
|
);
|
|
name = "source";
|
|
};
|
|
commonArgs = {
|
|
inherit src;
|
|
strictDeps = true;
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config
|
|
];
|
|
buildInputs = with pkgs; [
|
|
tdlib
|
|
openssl
|
|
];
|
|
};
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
server = craneLib.buildPackage (
|
|
commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
|
|
postInstall = ''
|
|
${pkgs.upx}/bin/upx --lzma --best $out/bin/telegram-exporter
|
|
'';
|
|
}
|
|
);
|
|
in
|
|
{
|
|
packages = {
|
|
process-compose = process-compose.mkWrapper {
|
|
name = "process-compose";
|
|
config = (import ./process-compose.nix { inherit pkgs; });
|
|
modules = [ ];
|
|
};
|
|
default = server;
|
|
inherit server;
|
|
};
|
|
|
|
devShells.default = craneLib.devShell {
|
|
packages = with pkgs; [
|
|
mold
|
|
llvmPackages.clang
|
|
llvmPackages.lld
|
|
watchexec
|
|
openssl
|
|
pkg-config
|
|
tdlib
|
|
];
|
|
};
|
|
|
|
}
|
|
);
|
|
|
|
}
|