forked from SergioRibera/sss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
101 lines (96 loc) · 2.67 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
{
description = "Standar cross compile flake for Rust Lang Projects";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils.url = "github:numtide/flake-utils";
fenix.url = "github:nix-community/fenix/monthly";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane";
};
outputs =
inputs @ { flake-parts
, fenix
, nixpkgs
, flake-utils
, crane
, self
, ...
}:
inputs.flake-parts.lib.mkFlake
{
inherit inputs;
}
{
systems = [ "x86_64-linux" ];
perSystem =
{ config
, pkgs
, system
, ...
}:
let
inherit (pkgs) lib;
# Toolchain
toolchain = with fenix.packages.${system};
fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-U2yfueFohJHjif7anmJB5vZbpP7G6bICH4ZsjtufRoU=";
};
craneLib = crane.lib.${system}.overrideToolchain toolchain;
src = craneLib.cleanCargoSource (craneLib.path ./.);
buildInputs = with pkgs; [
pkg-config
fontconfig
dbus
wayland
wayland-protocols
libxkbcommon
xorg.libXcursor
xorg.libxcb
xorg.libX11
xorg.libXi
xorg.libXrandr
];
commonArgs = {
inherit src;
inherit buildInputs;
};
# Compile all artifacts for x86_64-unknown-linux-gnu
linuxArtifacts = craneLib.buildDepsOnly (commonArgs
// {
CARGO_BUILD_TARGET = "x86_64-unknown-linux-gnu";
doCheck = false;
});
# Compile app for x86_64-unknown-linux-gnu
linuxApp = craneLib.buildPackage (
commonArgs
// {
doCheck = false;
cargoArtifacts = linuxArtifacts;
}
);
in
{
# nix build
packages = {
default = linuxApp;
};
# nix run
apps = {
default = flake-utils.lib.mkApp {
drv = linuxApp;
};
};
# nix develop
devShells.default = craneLib.devShell {
packages = with pkgs; [
toolchain
oranda
cargo-dist
cargo-release
] ++ buildInputs;
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
};
};
};
}