-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
173 lines (154 loc) · 4.91 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
{
description = "chin39-config";
nixConfig = {
substituters = [
# personal cache server
"https://chinrw.cachix.org"
# cache mirror located in China
# status: https://mirror.sjtu.edu.cn/
# "https://mirror.sjtu.edu.cn/nix-channels/store"
# status: https://mirrors.ustc.edu.cn/status/
# "https://mirrors.ustc.edu.cn/nix-channels/store"
# Tuna mirror
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store/"
"https://cache.nixos.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"chinrw.cachix.org-1:TShvVLuNeWsGoLW2/VGdUT4k8T+03RuQEXA6ZiN16Rw="
];
};
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixpkgs-master.url = "github:nixos/nixpkgs";
# Home manager
home-manager = {
url = "github:nix-community/home-manager";
};
_1password-shell-plugins = {
url = "github:1Password/shell-plugins";
};
flake-utils.url = "github:numtide/flake-utils";
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
yazi.url = "github:sxyazi/yazi";
nixgl.url = "github:nix-community/nixGL";
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
# support for wsl
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
# Rust development
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Zellij plugin
# FIX: may need to update
zjstatus.url = "github:dj95/zjstatus/v0.18.1";
};
outputs =
{ self
, nixpkgs
, home-manager
, flake-utils
, rust-overlay
, ...
} @ inputs:
let
inherit (self) outputs;
systems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
];
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = nixpkgs.lib.genAttrs systems;
stateVersion = "25.05";
helpers = import ./lib { inherit inputs outputs stateVersion; };
in
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
{
devShells.rust = import ./shell/rust.nix { inherit pkgs inputs; };
devShells.hm = import ./shell/home-manager.nix { inherit pkgs inputs; };
})
// {
# Your custom packages
# Accessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays { inherit inputs; };
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
# nixosModules = import ./modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
# homeManagerModules = import ./modules/home-manager;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
wsl = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
system = "x86_64-linux";
# > Our main nixos configuration file <
modules = [
inputs.nixos-wsl.nixosModules.default
./nixos/configuration.nix
];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
"chin39@desktop" = helpers.mkHome {
hostname = "desktop";
noGUI = false;
};
"chin39@wsl" = helpers.mkHome {
username = "chin39";
hostname = "wsl";
noGUI = false;
};
"ruowen@ringo" = helpers.mkHome {
username = "ruowen";
hostname = "gentoo";
noGUI = false;
isServer = true;
};
"chin39@archlinux" = helpers.mkHome {
hostname = "archlinux";
isServer = true;
};
"chin39@vm-gentoo" = helpers.mkHome {
hostname = "vm-gentoo";
platform = "aarch64-linux";
};
"chin39@wsl-gentoo" = helpers.mkHome {
hostname = "gentoo-vm";
};
"chin39@macos" = helpers.mkHome {
hostname = "macos";
platform = "aarch64-darwin";
};
"chin39@work" = helpers.mkHome {
hostname = "work";
};
};
};
}