-
Notifications
You must be signed in to change notification settings - Fork 30
/
flake.nix
111 lines (96 loc) · 3.02 KB
/
flake.nix
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
{
description = "🎁 generate beautiful landing pages for your developer tools";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, flake-utils
, fenix
, ...
}:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
fenix.overlays.default
];
};
# Parse the local Cargo.toml so we track the usual rust workflow
cargo_toml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
package = with pkgs;
rustPlatform.buildRustPackage {
pname = cargo_toml.package.name;
version = cargo_toml.package.version;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
# Don't run checks
doCheck = false;
# Package metadata
meta = with pkgs.lib; {
description = cargo_toml.package.description;
homepage = cargo_toml.package.repository;
license = with licenses; [ asl20 mit ];
};
nativeBuildInputs = with pkgs; [
pkg-config
tailwindcss
];
buildInputs = with pkgs; ([
bzip2
oniguruma
openssl
xz
zstd
]
++ darwinInputs);
RUSTONIG_SYSTEM_LIBONIG = true;
ZSTD_SYS_USE_PKG_CONFIG = true;
NIX_LDFLAGS = nixLdFlags;
ORANDA_USE_TAILWIND_BINARY = true;
};
# Darwin-specific build requirements
frameworks = pkgs.darwin.apple_sdk.frameworks;
darwinInputs = with pkgs; (lib.optionals stdenv.isDarwin [ libiconv frameworks.Security ]);
nixLdFlags = with pkgs; (lib.optionalString (stdenv.isDarwin) "-F${frameworks.CoreServices}/Library/Frameworks -framework CoreServices -L${libiconv}/lib");
in
{
packages = rec {
oranda = package;
default = oranda;
};
devShells = with pkgs; {
default = mkShell {
nativeBuildInputs = package.nativeBuildInputs;
buildInputs =
[
(fenix.packages.${system}.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
]
++ darwinInputs;
# Allow rust-analyzer and other tools to see rust src
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
# Fix missing OpenSSL
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
shellHook = ''
export NIX_LDFLAGS="${nixLdFlags}"
'';
};
};
});
}