-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
209 lines (184 loc) · 6.65 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
{
description = "A dynamic tiled window management that bridges the gap between yabai and krohnkite";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devenv.url = "github:cachix/devenv";
nix2container.url = "github:nlewo/nix2container";
nix2container.inputs.nixpkgs.follows = "nixpkgs";
mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix.url = "github:numtide/treefmt-nix";
flake-root.url = "github:srid/flake-root";
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = [
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
"https://mirrors.ustc.edu.cn/nix-channels/store"
"https://devenv.cachix.org"
];
};
outputs = inputs @ {
flake-parts,
nixpkgs,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [inputs.devenv.flakeModule inputs.treefmt-nix.flakeModule inputs.flake-root.flakeModule];
systems = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
cargoBuildInputs =
pkgs.lib.optionals pkgs.stdenv.isDarwin
(with pkgs.darwin.apple_sdk; [
frameworks.Security
frameworks.CoreServices
]);
in {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
devenv.shells.default = {
name = "yakite mono repo";
imports = [
# This is just like the imports in devenv.nix.
# See https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module
# ./devenv-foo.nix
];
# https://devenv.sh/reference/options/
packages = with pkgs;
[bun]
++ [zellij]
++ [pkg-config libsodium cmake] # zeromq
++ [nodePackages.pnpm npm-check-updates];
# https://devenv.sh/basics/
env = {
GREET = "🛠️ Let's hack 🧑🏻💻";
};
# https://devenv.sh/scripts/
scripts.hello.exec = "echo $GREET";
scripts.up.exec = "ncu -i";
scripts."krohnkite-core:build".exec = ''
cd $DEVENV_ROOT/apps/krohnkite-core
pnpm build
'';
scripts."yakite-yabai:build".exec = ''
cd $DEVENV_ROOT/apps/yakite-yabai
pnpm build
'';
scripts."yakite-yabai:test".exec = ''
cd $DEVENV_ROOT/apps/yakite-yabai
pnpm test
'';
scripts."yakite-bridge:build".exec = ''
cd $DEVENV_ROOT/apps/yakite-bridge
pnpm build
'';
scripts."yakite-daemon:build".exec = ''
cd $DEVENV_ROOT/apps/yakite-daemon
pnpm build
'';
scripts."yakite-daemon:run".exec = ''
cd $DEVENV_ROOT/apps/yakite-daemon
./dist/bin/yakite-daemon.js
'';
scripts."yakite:build".exec = ''
cd $DEVENV_ROOT/apps/yakite
cargo build --release
'';
scripts."yakite-toast:build".exec = ''
cd $DEVENV_ROOT/apps/yakite-toast/src
mkdir ../dist
/usr/bin/clang -framework Cocoa -target arm64-apple-macos11 yakite-toast.m -o ../dist/yakite-toast-arm64
/usr/bin/clang -framework Cocoa -arch x86_64 yakite-toast.m -o ../dist/yakite-toast-x86_64
/usr/bin/lipo ../dist/yakite-toast-arm64 ../dist/yakite-toast-x86_64 -create -output ../dist/yakite-toast \
&& bunx chalk-cli green bold 'Build Done!' \
|| bunx chalk-cli red bold 'Build Failed!'
'';
scripts."yakite-toast:test".exec = ''
cd $DEVENV_ROOT/apps/yakite-toast/dist
./yakite-toast --time 3.14 --text "Tile Layout"
'';
scripts."all:build".exec = ''
cd $DEVENV_ROOT
sh -c $'sleep 0.314;zellij -s yakite -s yakite action write-chars "zellij run -- yakite-toast:build\n"' &
sh -c $'sleep 0.314;zellij -s yakite -s yakite action write-chars "zellij run -- yakite:build\n"' &
sh -c $'sleep 0.314;zellij -s yakite -s yakite action write-chars "zellij run -- pnpm --recursiv build\n"' &
zellij --session yakite || zellij attach yakite
'';
scripts."one-click".exec = ''
pnpm i && all:build
yakite-daemon:run
'';
scripts."git-user:setup".exec = ''
git config user.name I-Want-ToBelieve
git config user.email [email protected]
'';
enterShell = ''
hello
'';
# https://devenv.sh/languages/
# yakite-daemon yakite-bridge krohnkite-core yabai
languages.javascript = {
enable = true;
package = pkgs.nodejs_20; # latest lts version
};
languages.typescript = {enable = true;};
# yakite
languages.rust = {
enable = true;
channel = "stable";
components = ["rustc" "cargo" "clippy" "rustfmt" "rust-analyzer"];
};
# Make diffs fantastic
difftastic.enable = true;
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
# commons
editorconfig-checker.enable = true;
# configs
yamllint.enable = true;
# nix
alejandra.enable = true;
# javascript
prettier.enable = false;
eslint.enable = true;
# rust
rustfmt.enable = true;
clippy.enable = true;
# objective-c
clang-format.enable = false;
};
# Plugin configuration
pre-commit.settings = {yamllint.relaxed = true;};
};
treefmt.config = {
inherit (config.flake-root) projectRootFile;
# This is the default, and can be overriden.
package = pkgs.treefmt;
# formats .nix files
programs.alejandra.enable = true;
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}