forked from lldap/lldap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
162 lines (134 loc) · 5.25 KB
/
Copy pathflake.nix
File metadata and controls
162 lines (134 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{
description = "LLDAP - Light LDAP implementation for authentication";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
# MSRV from the project
rustVersion = "1.89.0";
# Rust toolchain with required components
rustToolchain = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [ "rust-src" "clippy" "rustfmt" ];
targets = [
"wasm32-unknown-unknown"
"x86_64-unknown-linux-musl"
"aarch64-unknown-linux-musl"
"armv7-unknown-linux-musleabihf"
];
};
craneLib = crane.lib.${system}.overrideToolchain rustToolchain;
# Common build inputs
nativeBuildInputs = with pkgs; [
# Rust toolchain and tools
rustToolchain
wasm-pack
# Build tools
pkg-config
# Compression and utilities
gzip
curl
wget
# Development tools
git
jq
# Cross-compilation support
gcc
];
buildInputs = with pkgs; [
# System libraries that might be needed
openssl
sqlite
] ++ lib.optionals stdenv.isDarwin [
# macOS specific dependencies
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
# Environment variables
commonEnvVars = {
CARGO_TERM_COLOR = "always";
RUST_BACKTRACE = "1";
# Cross-compilation environment
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER = "${pkgs.pkgsStatic.stdenv.cc}/bin/cc";
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER = "${pkgs.pkgsCross.aarch64-multiplatform.stdenv.cc}/bin/aarch64-unknown-linux-gnu-gcc";
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER = "${pkgs.pkgsCross.armv7l-hf-multiplatform.stdenv.cc}/bin/arm-unknown-linux-gnueabihf-gcc";
};
in
{
# Development shells
devShells = {
default = pkgs.mkShell ({
inherit nativeBuildInputs buildInputs;
shellHook = ''
echo "🔐 LLDAP Development Environment"
echo "==============================================="
echo "Rust version: ${rustVersion}"
echo "Standard cargo commands available:"
echo " cargo build --workspace - Build the workspace"
echo " cargo test --workspace - Run tests"
echo " cargo clippy --tests --workspace -- -D warnings - Run linting"
echo " cargo fmt --check --all - Check formatting"
echo " ./app/build.sh - Build frontend WASM"
echo " ./export_schema.sh - Export GraphQL schema"
echo "==============================================="
echo ""
# Ensure wasm-pack is available
if ! command -v wasm-pack &> /dev/null; then
echo "⚠️ wasm-pack not found in PATH"
fi
# Check if we're in the right directory
if [[ "$(git rev-parse --show-toplevel 2>/dev/null)" == "$PWD" ]]; then
echo "⚠️ Run this from the project root directory"
fi
'';
} // commonEnvVars);
# Minimal shell for CI-like environment
ci = pkgs.mkShell ({
inherit nativeBuildInputs buildInputs;
shellHook = ''
echo "🤖 LLDAP CI Environment"
echo "Running with Rust ${rustVersion}"
'';
} // commonEnvVars);
};
# Package outputs (optional - for building with Nix)
packages = {
default = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.);
inherit nativeBuildInputs buildInputs;
# Build only the server by default
cargoExtraArgs = "-p lldap";
# Skip tests in the package build
doCheck = false;
meta = with pkgs.lib; {
description = "Light LDAP implementation for authentication";
homepage = "https://github.com/lldap/lldap";
license = licenses.gpl3Only;
maintainers = with maintainers; [ ];
platforms = platforms.unix;
};
};
};
# Formatter for the flake itself
formatter = pkgs.nixpkgs-fmt;
# Apps for running via `nix run`
apps = {
default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
};
};
});
}