-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
108 lines (92 loc) · 3.24 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
# https://github.com/cpu/woodwidelog/blob/bb549af2b33c5c50ae6e7361da4af3b1993caa1d/content/articles/rust-flake/index.md?plain=1#L50
{
description = "yeet the great flake";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixgl = {
url = "github:nix-community/nixGL";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, nixgl, flake-parts, rust-overlay, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
];
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, lib, ... }:
let
overlays = [ (import rust-overlay) nixgl.overlay ];
pkgs = import nixpkgs {
inherit system overlays;
};
toml_version = builtins.fromTOML (builtins.readFile ./Cargo.toml);
toml_name = builtins.fromTOML (builtins.readFile ./yeet/Cargo.toml);
package = (pkgs.makeRustPlatform {
cargo = pkgs.rust-bin.stable.latest.minimal;
rustc = pkgs.rust-bin.stable.latest.minimal;
}).buildRustPackage {
inherit (toml_name.package) name;
inherit (toml_version.workspace.package) version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildInputs = lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk.frameworks; [ AppKit Foundation ]
);
};
rust-stable = inputs'.rust-overlay.packages.rust.override {
extensions = [ "rust-src" "rust-analyzer" "clippy" ];
};
shell = pkgs.mkShell {
buildInputs = lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk.frameworks; [ AppKit Foundation ]
);
nativeBuildInputs = [
rust-stable
pkgs.asciinema
pkgs.asciinema-agg
pkgs.gh
pkgs.nil
pkgs.nixpkgs-fmt
pkgs.nodejs_20
pkgs.nodePackages.markdownlint-cli
pkgs.nodePackages.prettier
pkgs.chafa
pkgs.fd
pkgs.kitty
pkgs.wezterm
] ++ lib.optionals (!pkgs.stdenv.isDarwin) [
pkgs.vscode-extensions.vadimcn.vscode-lldb
];
shellHook = ''
export PATH=~/.cargo/bin:$PATH
${ if (!pkgs.stdenv.isDarwin) then
"export PATH=${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter:$PATH"
else
""
}
'';
RUST_BACKTRACE = "full";
};
in
{
overlayAttrs = {
inherit (config.packages) yeet;
};
packages = {
default = self'.packages.yeet;
yeet = package;
};
devShells.default = shell;
};
};
}