-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
102 lines (89 loc) · 2.78 KB
/
flake.nix
File metadata and controls
102 lines (89 loc) · 2.78 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
{
description = "trein – select area -> OCR -> DeepL translate for Wayland";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux"] (
system: let
pkgs = import nixpkgs {inherit system;};
muslTarget =
{
x86_64-linux = "x86_64-unknown-linux-musl";
aarch64-linux = "aarch64-unknown-linux-musl";
}.${
system
};
in rec {
packages.trein = pkgs.pkgsStatic.rustPlatform.buildRustPackage {
pname = "trein";
version = "0.1.1";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
# Ensure cargo targets musl; some crates require explicit crt-static.
CARGO_BUILD_TARGET = muslTarget;
RUSTFLAGS = "-C target-feature=+crt-static";
cargoBuildFlags = ["--locked"];
doCheck = false;
};
packages.default = packages.trein;
apps.default = {
type = "app";
program = "${packages.trein}/bin/trein";
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
rustc
cargo
clippy
rustfmt
pkg-config
mold
grim
slurp
tesseract
wl-clipboard
];
shellHook = ''
export RUSTFLAGS="-C link-arg=-fuse-ld=mold"
'';
};
checks.build = packages.trein;
formatter = pkgs.nixpkgs-fmt;
treinPreBuiltVersion = "0.1.1";
treinRelease =
{
x86_64-linux = {
url = "https://github.com/MathieuMoalic/trein/releases/download/v${treinPreBuiltVersion}/trein-v${treinPreBuiltVersion}-linux-x86_64";
hash = "sha256-7tE141CuhMC6lkJlIH5Qu0ayNrx9p3NYEh5rGObmDPw=";
};
aarch64-linux = {
url = "https://github.com/MathieuMoalic/trein/releases/download/v${treinPreBuiltVersion}/trein-v${treinPreBuiltVersion}-linux-aarch64";
hash = "sha256-hGATLL2Lmjd+A6vleSBu1MB6e50dHuedx1CaC5oJ+54=";
};
}.${
system
};
packages.trein-bin = pkgs.stdenvNoCC.mkDerivation {
pname = "trein";
version = treinPreBuiltVersion;
src = pkgs.fetchurl {
inherit (treinRelease) url hash;
};
dontUnpack = true;
installPhase = ''
install -Dm755 "$src" "$out/bin/trein"
'';
};
apps.trein-bin = {
type = "app";
program = "${packages.trein-bin}/bin/trein";
};
}
);
}