Skip to content

Commit 1bc9198

Browse files
committed
chore: added base files with shell env
1 parent ebe886a commit 1bc9198

File tree

20 files changed

+1099
-3
lines changed

20 files changed

+1099
-3
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXAMPLE=666

.github/workflows/test.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Test CI"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Clone the repository
10+
uses: actions/checkout@v4
11+
12+
- name: Install Nix
13+
uses: DeterminateSystems/nix-installer-action@main
14+
15+
- name: Cache Nix store
16+
uses: DeterminateSystems/magic-nix-cache-action@main
17+
18+
- name: Check for flake configurations
19+
run: nix flake check --all-systems --show-trace
20+
21+
- name: Build the project
22+
run: nix-shell --run "cargo build --release --verbose"
23+
24+
- name: Run lint
25+
run: nix-shell --run "cargo clippy --verbose"
26+
27+
- name: Run format check
28+
run: nix-shell --run "cargo fmt --all -- --check"
29+
30+
- name: Run tests
31+
run: nix-shell --run "cargo test --verbose"
32+
33+
- name: Build nix package
34+
run: nix build .

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ target/
55

66
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
77
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
8+
# Cargo.lock
99

1010
# These are backup files generated by rustfmt
1111
**/*.rs.bk
@@ -18,4 +18,7 @@ Cargo.lock
1818
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
21-
#.idea/
21+
#.idea/
22+
23+
# Nix shell generated artifacts
24+
.nix-shell

Cargo.lock

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
[workspace]
3+
resolver = "2"
4+
members = [ "crates/registrar-bin", "crates/registrar-database","crates/registrar-http", "crates/registrar-templates"]
5+
6+
[workspace.package]
7+
authors = ["Sokhibjon Orzikulov <[email protected]>"]
8+
edition = "2021"
9+
version = "0.1.0"
10+
license = "Apache-2.0 OR MIT"
11+
homepage = "https://github.com/floss-uz/registrar"
12+
repository = "https://github.com/floss-uz/registrar"
13+
14+
[workspace.dependencies]
15+
serde = "1"
16+
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
17+
18+
[profile.release]
19+
codegen-units = 1
20+
incremental = true
21+
lto = true
22+
strip = true
23+
opt-level = "z"

crates/registrar-bin/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "registrar-bin"
3+
authors.workspace = true
4+
edition.workspace = true
5+
version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
10+
[dependencies]

crates/registrar-bin/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

crates/registrar-database/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "registrar-database"
3+
authors.workspace = true
4+
edition.workspace = true
5+
version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
10+
[dependencies]

crates/registrar-database/src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: u64, right: u64) -> u64 {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

crates/registrar-http/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "registrar-http"
3+
authors.workspace = true
4+
edition.workspace = true
5+
version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
10+
[dependencies]

crates/registrar-http/src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: u64, right: u64) -> u64 {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

crates/registrar-templates/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "registrar-templates"
3+
authors.workspace = true
4+
edition.workspace = true
5+
version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
10+
[dependencies]

crates/registrar-templates/src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: u64, right: u64) -> u64 {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

default.nix

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# For more, refer to:
2+
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md
3+
{ pkgs ? import <nixpkgs> { } }:
4+
let
5+
lib = pkgs.lib;
6+
getLibFolder = pkg: "${pkg}/lib";
7+
getFramwork = pkg: "${pkg}/Library/Frameworks";
8+
darwinOptions = if pkgs.stdenv.isDarwin then ''
9+
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.Security)}
10+
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.CoreFoundation)}
11+
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.CoreServices)}
12+
-F${(getFramwork pkgs.darwin.apple_sdk.frameworks.SystemConfiguration)}
13+
'' else "";
14+
manifest = (pkgs.lib.importTOML ./Cargo.toml).workspace.package;
15+
in
16+
pkgs.rustPlatform.buildRustPackage rec {
17+
pname = "registrar";
18+
version = manifest.version;
19+
cargoLock.lockFile = ./Cargo.lock;
20+
src = pkgs.lib.cleanSource ./.;
21+
22+
nativeBuildInputs = with pkgs; [
23+
gcc
24+
nixd
25+
rustc
26+
cargo
27+
cmake
28+
clippy
29+
gnumake
30+
libiconv
31+
cargo-watch
32+
pkg-config
33+
nixpkgs-fmt
34+
rust-analyzer
35+
llvmPackages.llvm
36+
llvmPackages.clang
37+
];
38+
39+
# Having hard times nix running from macOS 15 Beta?
40+
# add these to your buildInputs:
41+
# darwin.apple_sdk.frameworks.Security
42+
# darwin.apple_sdk.frameworks.CoreServices
43+
# darwin.apple_sdk.frameworks.CoreFoundation
44+
# darwin.apple_sdk.frameworks.SystemConfiguration
45+
buildInputs = with pkgs; [
46+
openssl
47+
libressl
48+
];
49+
50+
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
51+
(getLibFolder pkgs.gcc)
52+
(getLibFolder pkgs.libiconv)
53+
(getLibFolder pkgs.llvmPackages.llvm)
54+
];
55+
56+
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
57+
NIX_LDFLAGS = "-L${(getLibFolder pkgs.libiconv)} ${darwinOptions}";
58+
59+
# If you wanna get thorny
60+
# RUST_BACKTRACE = 1;
61+
62+
meta = with lib; {
63+
homepage = manifest.homepage;
64+
description = "Registrar for recording data at Floss Uzbekistan";
65+
license = with lib.licenses; [ mit asl20 ];
66+
67+
platforms = with platforms; linux ++ darwin;
68+
69+
maintainers = [
70+
{
71+
name = "Sokhibjon Orzikulov";
72+
email = "[email protected]";
73+
handle = "orzklv";
74+
github = "orzklv";
75+
githubId = 54666588;
76+
keys = [{
77+
fingerprint = "00D2 7BC6 8707 0683 FBB9 137C 3C35 D3AF 0DA1 D6A8";
78+
}];
79+
}
80+
];
81+
};
82+
}

flake.lock

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
description = "Registrar for keeping everything in one place";
3+
4+
inputs = {
5+
# Too old to work with most libraries
6+
# nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
7+
8+
# Perfect!
9+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
10+
11+
# The flake-utils library
12+
flake-utils.url = "github:numtide/flake-utils";
13+
};
14+
15+
outputs =
16+
{ self
17+
, nixpkgs
18+
, flake-utils
19+
, ...
20+
}:
21+
flake-utils.lib.eachDefaultSystem
22+
(
23+
system:
24+
let
25+
pkgs = nixpkgs.legacyPackages.${system};
26+
27+
# Output results
28+
binary = pkgs.callPackage ./. { };
29+
docker = pkgs.dockerTools.streamLayeredImage {
30+
name = "registrar";
31+
tag = "latest";
32+
contents = [ binary ];
33+
config = {
34+
Cmd = [ "${binary}/bin/orchestra" ];
35+
};
36+
};
37+
in
38+
{
39+
# Nix script formatter
40+
formatter = pkgs.nixpkgs-fmt;
41+
42+
# Development environment
43+
devShells.default = import ./shell.nix { inherit pkgs; };
44+
45+
# Output package
46+
packages.default = pkgs.callPackage ./. { };
47+
}
48+
)
49+
// {
50+
# Overlay module
51+
# nixosModules.xnux.bot = import ./module.nix self;
52+
};
53+
}

0 commit comments

Comments
 (0)