This repository was archived by the owner on Apr 30, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
167 lines (141 loc) · 4.54 KB
/
flake.nix
File metadata and controls
167 lines (141 loc) · 4.54 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
163
164
165
166
167
{
description = "darn - Distributed Automerge Resource Navigator";
inputs = {
nixpkgs.url = "nixpkgs/nixos-25.11";
command-utils.url = "git+https://codeberg.org/expede/nix-command-utils";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
flake-utils,
nixpkgs,
rust-overlay,
command-utils,
} @ inputs:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [
(import rust-overlay)
];
pkgs = import nixpkgs {
inherit system overlays;
};
rustVersion = "1.90.0";
rust-toolchain = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [
"cargo"
"clippy"
"llvm-tools-preview"
"rust-src"
"rust-std"
];
targets = [
"aarch64-apple-darwin"
"x86_64-apple-darwin"
"x86_64-unknown-linux-musl"
"aarch64-unknown-linux-musl"
];
};
nightly-rustfmt = pkgs.rust-bin.nightly."2026-02-23".default.override {
extensions = ["rustfmt"];
};
format-pkgs = with pkgs; [
alejandra
nixpkgs-fmt
taplo
];
cargo-installs = with pkgs; [
cargo-deny
cargo-expand
cargo-nextest
cargo-outdated
cargo-sort
cargo-udeps
cargo-watch
];
rust = command-utils.rust.${system};
cmd = command-utils.cmd.${system};
command_menu = command-utils.commands.${system} [
(rust.build {cargo = pkgs.cargo;})
(rust.test {
cargo = pkgs.cargo;
cargo-watch = pkgs.cargo-watch;
})
(rust.lint {cargo = pkgs.cargo;})
(rust.fmt {cargo = pkgs.cargo;})
(rust.doc {cargo = pkgs.cargo;})
(rust.watch {cargo-watch = pkgs.cargo-watch;})
];
in rec {
packages = {
darn = pkgs.rustPlatform.buildRustPackage {
pname = "darn";
version = "0.6.0";
meta = {
description = "Directory-based Automerge Replication Node";
longDescription = ''
A CLI for managing CRDT-backed files with automatic conflict
resolution and peer-to-peer synchronization. Uses Automerge
for conflict-free merging and Subduction for P2P sync.
'';
homepage = "https://github.com/inkandswitch/darn";
license = with pkgs.lib.licenses; [mit asl20];
platforms = pkgs.lib.platforms.unix;
mainProgram = "darn";
};
src = pkgs.lib.cleanSource ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [pkgs.pkg-config];
buildInputs =
pkgs.lib.optionals pkgs.stdenv.isLinux [pkgs.openssl]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.apple-sdk];
cargoBuildFlags = ["--bin" "darn"];
doCheck = pkgs.stdenv.buildPlatform.canExecute pkgs.stdenv.hostPlatform;
checkPhase = ''
cargo test --release --locked
'';
};
default = packages.darn;
};
devShells.default = pkgs.mkShell {
name = "darn_shell";
nativeBuildInputs =
[
command_menu
rust-toolchain
nightly-rustfmt
pkgs.rust-analyzer
pkgs.websocat
]
++ format-pkgs
++ cargo-installs
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.clang
pkgs.llvmPackages.libclang
pkgs.openssl.dev
pkgs.pkg-config
];
shellHook =
''
unset SOURCE_DATE_EPOCH
export WORKSPACE_ROOT="$(pwd)"
export RUSTFMT="${nightly-rustfmt}/bin/rustfmt"
export DYLD_LIBRARY_PATH="${nightly-rustfmt}/lib''${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
menu
''
+ pkgs.lib.optionalString pkgs.stdenv.isLinux ''
export OPENSSL_NO_VENDOR=1
export OPENSSL_LIB_DIR=${pkgs.openssl.out}/lib
export OPENSSL_INCLUDE_DIR=${pkgs.openssl.dev}/include
'';
};
formatter = pkgs.alejandra;
}
);
}