-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
182 lines (168 loc) · 4.96 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
{
inputs = {
systems.url = "github:nix-systems/default";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
#inputs.lix.url = "https://git.lix.systems/jade/lix/archive/jade/macos-lowdown.tar.gz";
};
# Repos
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
master.url = "github:NixOS/nixpkgs/master";
home.url = "github:QuentinI/home-manager/librewolf";
nur.url = "github:nix-community/NUR";
apple-silicon = {
url = "github:damien-biasotto/nixos-apple-silicon/bugfix/wifi";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
mergiraf = {
url = "https://codeberg.org/mergiraf/mergiraf/archive/main.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin";
# Neovim configuration
nvim = {
url = "github:QuentinI/nvim";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
telegram-desktop-patched = {
url = "github:shwewo/telegram-desktop-patched";
};
# Themes
base16-unclaimed-schemes = {
flake = false;
url = "github:chriskempson/base16-unclaimed-schemes";
};
base16-nord-scheme = {
flake = false;
url = "github:spejamchr/base16-nord-scheme/master";
};
nord-dircolors = {
flake = false;
url = "github:arcticicestudio/nord-dircolors/master";
};
base16-solarized-scheme = {
flake = false;
url = "github:mk12/base16-solarized-scheme/main";
};
# various MPV scripts
mpv-scripts = {
flake = false;
url = "github:wiiaboo/mpv-scripts/master";
};
mpv-chapters = {
flake = false;
url = "github:zxhzxhz/mpv-chapters/master";
};
mpv-search-page = {
flake = false;
url = "github:CogentRedTester/mpv-search-page/master";
};
mpv-user-input = {
flake = false;
url = "github:CogentRedTester/mpv-user-input/master";
};
mpv-scroll-list = {
flake = false;
url = "github:CogentRedTester/mpv-scroll-list/master";
};
# Manually substituted for actual secrets
secrets.url = "github:QuentinI/dummy-flake";
};
outputs =
inputs@{
self,
nixpkgs,
nixpkgs-stable,
master,
nur,
home,
secrets,
flake-utils,
...
}:
let
hostnames = builtins.attrNames (builtins.readDir ./hosts);
findSystem =
path: system:
let
file = nixpkgs.lib.path.append path "${system}.nix";
dir = nixpkgs.lib.path.append path "${system}/default.nix";
in
if (builtins.pathExists file) then
import file
else if (builtins.pathExists dir) then
import dir
else
null;
filterNull = attrs: nixpkgs.lib.filterAttrsRecursive (n: v: v != null) attrs;
hosts = filterNull (
builtins.foldl' nixpkgs.lib.recursiveUpdate { } (
map (hostname: {
darwinConfigurations.${hostname} = findSystem ./hosts/${hostname} "darwin";
nixosConfigurations.${hostname} = findSystem ./hosts/${hostname} "linux";
}) hostnames
)
);
configurations = nixpkgs.lib.mapAttrsRecursiveCond (as: !(as ? "system")) (
path: value:
value.configuration rec {
system = value.system;
hostname = nixpkgs.lib.last path;
common-cfg = {
inherit system;
config.allowUnfree = true;
};
pkgs = import inputs.nixpkgs common-cfg;
pkgs-stable = import inputs.nixpkgs-stable common-cfg;
nur = import inputs.nur {
nurpkgs = pkgs;
inherit pkgs;
};
flake-inputs = inputs;
inherit vars secrets mkImports;
overlays = [
(final: prev: {
master = import master common-cfg;
})
(import ./packages)
inputs.nvim.overlays."${system}".default
];
}
) hosts;
mkImports =
scope: imports:
map (
modspec:
let
mod = if builtins.isPath modspec then import modspec else modspec;
in
if builtins.isAttrs mod && builtins.hasAttr scope mod then builtins.getAttr scope mod else mod
) imports;
vars = {
username = "quentin";
fullname = "Quentin Inkling";
theme = "dark";
};
in
configurations
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
formatter = pkgs.nixfmt-rfc-style;
}
);
}