-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
description = "Assistant for Uzbek Rust community"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; | ||
# nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = | ||
{ self | ||
, nixpkgs | ||
, flake-utils | ||
, ... | ||
} @ inputs: | ||
let | ||
lib = nixpkgs.lib; | ||
systems = [ | ||
"aarch64-linux" | ||
"x86_64-linux" | ||
"aarch64-darwin" | ||
"x86_64-darwin" | ||
]; | ||
|
||
forAllSystems = nixpkgs.lib.genAttrs systems; | ||
forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system}); | ||
|
||
pkgsFor = lib.genAttrs systems (system: | ||
import nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; | ||
}); | ||
|
||
devShellFor = system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; | ||
}; | ||
script = import ./shell.nix { inherit pkgs; }; | ||
in | ||
script; | ||
in | ||
{ | ||
# Nix script formatter | ||
formatter = | ||
forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt); | ||
|
||
# Development environment | ||
devShell = lib.mapAttrs (system: _: devShellFor system) (lib.genAttrs systems { }); | ||
|
||
# Output package | ||
packages = forAllSystems (system: { | ||
default = pkgsFor.${system}.callPackage ./. { }; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
let | ||
getLibFolder = pkg: "${pkg}/lib"; | ||
getFramwork = pkg: "${pkg}/Library/Frameworks"; | ||
darwinOptions = if pkgs.stdenv.isDarwin then '' | ||
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.Security)} | ||
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.CoreFoundation)} | ||
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.CoreServices)} | ||
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.SystemConfiguration)} | ||
'' else ""; | ||
in | ||
pkgs.stdenv.mkDerivation { | ||
name = "telegram"; | ||
|
||
nativeBuildInputs = [ | ||
pkgs.gcc | ||
pkgs.rustc | ||
pkgs.cargo | ||
pkgs.cargo-watch | ||
pkgs.pkg-config | ||
pkgs.rust-analyzer | ||
pkgs.llvmPackages.llvm | ||
pkgs.llvmPackages.clang | ||
]; | ||
|
||
buildInputs = [ | ||
pkgs.openssl | ||
pkgs.darwin.apple_sdk.frameworks.Security | ||
pkgs.darwin.apple_sdk.frameworks.CoreServices | ||
pkgs.darwin.apple_sdk.frameworks.CoreFoundation | ||
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration | ||
]; | ||
|
||
# Set Environment Variables | ||
RUST_BACKTRACE = 1; | ||
NIX_LDFLAGS = "-L${(getLibFolder pkgs.libiconv)} ${darwinOptions}"; | ||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; | ||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ | ||
(getLibFolder pkgs.gcc) | ||
(getLibFolder pkgs.libiconv) | ||
(getLibFolder pkgs.llvmPackages.llvm) | ||
]; | ||
|
||
shellHook = '' | ||
# Load the environment variables from the .env file | ||
if [ ! -f .env ]; then | ||
echo "Please enter your telegram bot token: "; | ||
read -r TELOXIDE_TOKEN; | ||
echo "TELOXIDE_TOKEN=$TELOXIDE_TOKEN" > .env; | ||
else | ||
source .env; | ||
fi | ||
# Set the environment variable | ||
export TELOXIDE_TOKEN=$TELOXIDE_TOKEN; | ||
# Start watching for changes | ||
# Start watching for changes in the background | ||
# cargo watch -x "run" & | ||
# Store the PID of the background process | ||
# CARGO_WATCH_PID=$! | ||
# Function to clean up the background process on exit | ||
# cleanup() { | ||
# kill $CARGO_WATCH_PID | ||
# } | ||
# Trap EXIT signal to run cleanup function | ||
# trap cleanup EXIT | ||
''; | ||
} |