-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
129 lines (118 loc) · 3.56 KB
/
Copy pathflake.nix
File metadata and controls
129 lines (118 loc) · 3.56 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
{
description = "A development shell for rust";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
crane.url = "github:ipetkov/crane";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
rust-overlay,
crane,
treefmt-nix,
...
}: let
# Define systems
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
# Helper function to generate per-system attributes
forAllSystems = f: nixpkgs.lib.genAttrs systems f;
in {
# Define packages using crane to build
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default);
commonArgs = {
src = ./.;
strictDeps = true;
buildInputs = with pkgs; [
wayland
wayland-protocols
libxkbcommon
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
nativeBuildInputs = with pkgs; [
pkg-config
];
# Set environment variable for wayland-protocols location
WAYLAND_PROTOCOLS_DIR = "${pkgs.wayland-protocols}/share/wayland-protocols";
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
# Force rebuild of dependencies with protocol files
pname = "wrtype-deps";
});
in {
default = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
meta = with pkgs.lib; {
description = "A Rust implementation of wtype - xdotool type for Wayland";
homepage = "https://github.com/conneroisu/wrtype";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.linux;
};
});
wrtype = self.packages.${system}.default;
});
# Define devShells for all systems
devShells = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
# Optional: Initialize crane for building packages
# craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default);
# Optional: Example crane package build (uncomment to use)
# my-crate = craneLib.buildPackage {
# src = craneLib.cleanCargoSource ./.;
# strictDeps = true;
# };
in {
default = pkgs.mkShell {
name = "dev";
# Available packages on https://search.nixos.org/packages
buildInputs = with pkgs; [
alejandra # Nix
nixd
statix
deadnix
just
rust-bin.stable.latest.default
# Wayland development dependencies
wayland
wayland-protocols
libxkbcommon
pkg-config
];
shellHook = ''
echo "Welcome to the rust devshell!"
'';
};
});
formatter = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
treefmtModule = {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true; # Nix formatter
rustfmt.enable = true; # Rust formatter
};
};
in
treefmt-nix.lib.mkWrapper pkgs treefmtModule);
};
}