-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathflake.nix
More file actions
121 lines (112 loc) · 3.43 KB
/
Copy pathflake.nix
File metadata and controls
121 lines (112 loc) · 3.43 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
{
description = "A ready to go Wayland status bar for Hyprland and Niri";
inputs = {
crane.url = "github:ipetkov/crane";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{
crane,
nixpkgs,
rust-overlay,
...
}:
let
forAllSystems = with nixpkgs; (lib.genAttrs lib.systems.flakeExposed);
perSystem = forAllSystems (system: rec {
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
craneLib = crane.mkLib pkgs;
rustToolchain = pkgs.rust-bin.stable.latest;
buildInputs = with pkgs; [
rustToolchain.default
rustPlatform.bindgenHook
pkg-config
libxkbcommon
libGL
pipewire
libpulseaudio
wayland
vulkan-loader
udev
];
runtimeDependencies = with pkgs; [
libpulseaudio
wayland
mesa
vulkan-loader
libGL
libglvnd
];
ldLibraryPath = pkgs.lib.makeLibraryPath runtimeDependencies;
# Filter source to only include files needed by the Rust build
# Excludes website/, docs/, screenshots/, etc. to avoid unnecessary rebuilds
src =
let
assetsFilter = path: _type: builtins.match ".*assets/.*" path != null;
i18nFilter =
path: _type: builtins.match ".*(i18n\\.toml|i18n/.*)" path != null;
srcFilter =
path: type:
(assetsFilter path type)
|| (i18nFilter path type)
|| (craneLib.filterCargoSources path type);
in
pkgs.lib.cleanSourceWith {
src = ./.;
filter = srcFilter;
};
# Shared build arguments for both deps and final build
commonArgs = {
inherit src;
strictDeps = true;
nativeBuildInputs = with pkgs; [
makeWrapper
pkg-config
autoPatchelfHook # Add runtimeDependencies to rpath
];
inherit buildInputs runtimeDependencies ldLibraryPath;
};
# Build only cargo dependencies — cached by Cargo.lock hash
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Final build reuses cached dependency artifacts
defaultPackage = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
postInstall = ''
wrapProgram "$out/bin/ashell" --prefix LD_LIBRARY_PATH : "${ldLibraryPath}"
'';
meta.mainProgram = "ashell";
}
);
devShell = pkgs.mkShell {
inherit ldLibraryPath;
buildInputs = buildInputs ++ [
pkgs.rust-analyzer-unwrapped
pkgs.nixfmt
];
RUST_SRC_PATH = "${rustToolchain.rust-src}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = ldLibraryPath;
};
formatter = pkgs.nixfmt;
});
in
{
packages = forAllSystems (system: {
default = perSystem.${system}.defaultPackage;
});
devShells = forAllSystems (system: {
default = perSystem.${system}.devShell;
});
formatter = forAllSystems (system: perSystem.${system}.formatter);
};
}