Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
219 lines (211 loc) · 9.79 KB
/
Copy pathflake.nix
File metadata and controls
219 lines (211 loc) · 9.79 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
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
210
211
212
213
214
215
216
217
218
219
{
description = "Fredrik's unified Nix configurations";
# NOTE: The extra caches below are only honored for users in `trusted-users`,
# which is set in the system config (Darwin: nix.settings.trusted-users in
# nix/shared/system/darwin.nix; Pi: see nix/hosts/rpi5-homelab/README.md).
# Do NOT hand-edit /etc/nix/nix.conf — nix-darwin regenerates it on rebuild.
nixConfig = {
extra-substituters = [
"https://nixos-raspberrypi.cachix.org"
"https://cache.numtide.com"
];
extra-trusted-public-keys = [
"nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI="
"niks3.numtide.com-1:DTx8wZduET09hRmMtKdQDxNNthLQETkc/yaX7M4qK0g="
];
};
inputs = {
# Mixed stability approach:
# - Raspberry Pi: Anchored to nixos-raspberrypi's pinned nixpkgs
# (home-manager-rpi + disko follow that pin)
# - NixOS desktops and laptops: Use unstable (nixpkgs-unstable + home-manager-unstable)
# - Darwin/macOS: Uses unstable (nixpkgs-unstable + home-manager-unstable + nix-darwin)
#
# Rationale: Servers stay on stable; desktops and laptops benefit from the
# latest packages.
# The Pi has a single version anchor (the nixos-raspberrypi input), so
# updates to the unstable inputs cannot break the Pi, and kernel builds
# hit the nixos-raspberrypi.cachix.org binary cache.
#
# Version alignment references:
# - home-manager releases: https://github.com/nix-community/home-manager/releases
# - Darwin state versions: https://github.com/LnL7/nix-darwin/blob/master/modules/system/default.nix
# Stable nixpkgs: used for the Linux formatters and the `n` nix registry
# entry — NOT for the Pi system (which uses nixos-raspberrypi's pin).
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# NOTE: Do NOT make nixos-raspberrypi follow another nixpkgs: the Pi
# system is instantiated from its pinned nixpkgs, and the upstream binary
# cache only serves kernels built against that pin.
nixos-raspberrypi.url = "github:nvmd/nixos-raspberrypi/main";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixos-raspberrypi/nixpkgs";
};
home-manager-rpi = {
# NOTE: The branch must match the release of nixos-raspberrypi's pinned
# nixpkgs (check `nixpkgs.original.ref` under the nixos-raspberrypi node
# in flake.lock). Bump this branch when updating nixos-raspberrypi.
url = "github:nix-community/home-manager/release-26.05";
inputs.nixpkgs.follows = "nixos-raspberrypi/nixpkgs";
};
home-manager-unstable = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# AI coding agent CLIs (codex, gemini-cli, pi, ...), updated daily upstream.
# NOTE: Do NOT make this follow another nixpkgs: packages are built and
# cached against its own pinned nixpkgs-unstable, and cache.numtide.com
# only serves those builds.
llm-agents.url = "github:numtide/llm-agents.nix";
# Zen's normal upstream release channel is named Beta; Twilight is nightly.
zen-browser = {
url = "github:0xc000022070/zen-browser-flake/beta";
inputs.nixpkgs.follows = "nixpkgs-unstable";
inputs.home-manager.follows = "home-manager-unstable";
};
dux-calendar = {
url = "github:duxlabs-dev/dux-calendar";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
};
outputs =
{ self, ... }@inputs:
let
lib = import ./nix/lib { inherit inputs; };
stable = inputs.nixpkgs.legacyPackages;
unstable = inputs.nixpkgs-unstable.legacyPackages;
in
{
overlays.default = import ./nix/shared/overlays;
nixosConfigurations = {
rpi5-homelab = lib.mkRpiNixos {
configPath = ./nix/hosts/rpi5-homelab/configuration.nix;
};
renoir = lib.mkNixos {
configPath = ./nix/hosts/renoir/configuration.nix;
};
wily = lib.mkNixos {
configPath = ./nix/hosts/wily/configuration.nix;
};
};
darwinConfigurations = {
zap = lib.mkDarwin {
configPath = ./nix/hosts/zap/configuration.nix;
};
plumbus = lib.mkDarwin {
configPath = ./nix/hosts/plumbus/configuration.nix;
};
};
# `kaizen` off NixOS: `nix build ~/.dotfiles#kaizen`.
packages = inputs.nixpkgs-unstable.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: {
kaizen = unstable.${system}.callPackage ./kaizen/nix/package.nix { };
});
# Formatters for `nix fmt`: nixfmt over the tree, via treefmt
formatter.x86_64-linux = stable.x86_64-linux.nixfmt-tree;
formatter.aarch64-linux = stable.aarch64-linux.nixfmt-tree;
formatter.aarch64-darwin = unstable.aarch64-darwin.nixfmt-tree;
# Dev shell exposing the shared Neovim toolchain (nix/shared/toolchain.nix)
# for use outside Neovim, e.g. `nix develop ~/.dotfiles#dev -c <cmd>`.
devShells =
let
mkDevShell =
system:
let
channels = {
stable = stable.${system};
unstable = unstable.${system};
};
in
{
dev = channels.unstable.mkShell {
packages = import ./nix/shared/toolchain.nix channels;
# A project's mise.toml overrides come ahead, as in Neovim.
shellHook = ''
export PATH="$HOME/.local/share/mise/shims:$PATH"
'';
};
# Entered by direnv (.envrc) for work on this repo itself: the QML
# tooling for the hosts' Quickshell trees, which does not belong
# in the toolchain every Neovim carries. Neovim inherits the env
# when launched from a shell in this directory.
default =
let
pkgs = channels.unstable;
# Linux-only. Never built on Darwin: the x86_64-linux path
# substitutes from cache.nixos.org, and only lib/qt-6/qml
# (.qmltypes) is used here. Same nixpkgs as renoir, so the
# same types the ThinkPad runs; without the overlay's patches,
# which change no type.
quickshell = unstable.x86_64-linux.quickshell;
# Every kaizen host runs the one tree in kaizen/stow/; a host's
# plugins add theirs under stow/host/<host>/.config/kaizen/.
task =
name: text:
pkgs.writeShellScriptBin name ''
set -e
cd "$(git rev-parse --show-toplevel)/kaizen/stow/.config/quickshell/kaizen"
${text}
'';
in
pkgs.mkShell {
packages = [
pkgs.go_1_27 # kaizen/cli/, as package.nix builds it
pkgs.qt6.qtdeclarative # qmlls, qmllint, qmlformat, qmltestrunner
# Plugins import qs.Ui, which Quickshell maps to the tree's Ui/;
# qmllint finds it through a qs/Ui link on -I. Absolute paths:
# given a relative one, qmllint 6.12 misses a singleton its
# own qmldir declares.
(task "qml-lint" ''
imports=$(mktemp -d)
trap 'rm -rf "$imports"' EXIT
mkdir "$imports/qs"
ln -s "$PWD/Ui" "$imports/qs/Ui"
qmllint -E -I "$imports" -W 0 $(find "$PWD" "$(realpath ../../../../../stow/host)"/*/.config/kaizen/plugins -name '*.qml')
'')
# Tool defaults; prettier's match conform's flags for JS.
(task "qml-format" ''
dirs=". ../../../../../stow/host/*/.config/kaizen/plugins"
qmlformat -i $(find $dirs -name '*.qml')
# Prettier cannot parse QML's `.pragma`/`.import` JS.
prettier --log-level warn --write $(grep -LE '^\.(pragma|import)' $(find $dirs -name '*.js'))
'')
pkgs.prettier
(task "qml-test" ''
# QML_XHR_ALLOW_FILE_READ: tst_Compositors.qml reads the
# compositor configs.
export QT_QPA_PLATFORM=offscreen QT_QPA_PLATFORMTHEME= QML_XHR_ALLOW_FILE_READ=1
qmltestrunner -input tests
qmltestrunner -input plugins
'')
(task "requires-check" "tests/requires_test.sh")
pkgs.lua
]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
pkgs.niri
pkgs.umbriel
pkgs.jq
pkgs.wtype
pkgs.wlrctl
(task "compositor-test" "tests/config_test.sh")
(task "shell-smoke" "tests/shell_smoke.sh \"$@\"")
(task "shell-perf" "tests/shell_perf.sh \"$@\"")
];
# qmlls/qmllint/qmltestrunner take import paths from argv or
# env only (`-E` reads this); .qmlls.ini has no key for them.
QML_IMPORT_PATH = "${quickshell}/lib/qt-6/qml:${pkgs.qt6.qtdeclarative}/lib/qt-6/qml";
};
};
in
{
x86_64-linux = mkDevShell "x86_64-linux";
aarch64-linux = mkDevShell "aarch64-linux";
aarch64-darwin = mkDevShell "aarch64-darwin";
};
};
}