forked from EmergentMind/nix-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
159 lines (140 loc) · 4.94 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
{
description = "DjCoke's Nix-Config, from EmergentMind's Nix-Config";
outputs =
{
self,
nixpkgs,
home-manager,
stylix,
...
}@inputs:
let
inherit (self) outputs;
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
#"aarch64-darwin"
];
inherit (nixpkgs) lib;
configVars = import ./vars { inherit inputs lib; };
configLib = import ./lib { inherit lib; };
letSpecialArgs = {
inherit
inputs
outputs
configVars
configLib
nixpkgs
;
};
nodes = [
"k3s-01" # master server
"k3s-02" # server
"k3s-03" # server
"k3s-04" # worker
"k3s-05" # worker
"k3s-06" # worker
"k3s-07" # Longhorn
"k3s-08" # Longhorn
"k3s-09" # Longhorn
];
in
{
# Custom modules to enable special functionality for nixos or home-manager oriented configs.
#nixosModules = { inherit (import ./modules/nixos); };
# homeManagerModules = { inherit (import ./modules/home-manager); };
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
# Custom modifications/overrides to upstream packages.
overlays = import ./overlays { inherit inputs outputs; };
# Custom packages to be shared or upstreamed.
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
import ./pkgs { inherit pkgs; }
);
checks = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
import ./checks { inherit inputs system pkgs; }
);
# Nix formatter available through 'nix fmt' https://nix-community.github.io/nixpkgs-fmt
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
# ################### DevShell ####################
#
# Custom shell for bootstrapping on new hosts, modifying nix-config, and secrets management
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
checks = self.checks.${system};
in
import ./shell.nix { inherit checks pkgs; }
);
#################### NixOS Configurations ####################
#
# Building configurations available through `just rebuild` or `nixos-rebuild --flake .#hostname`
nixosConfigurations = builtins.listToAttrs (
map (name: {
# getting the hostnames from nodes, and setting the hostname dynamically
name = name;
value = lib.nixosSystem {
specialArgs = letSpecialArgs // {
hostName = name;
};
modules = [
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = letSpecialArgs // {
hostName = name;
};
}
# Dynamically select the configuration file based on the hostname
(if builtins.match "k3s-.*" name != null then ./hosts/k3s else ./hosts/${name})
];
};
}) nodes
);
};
inputs = {
#################### Official NixOS and HM Package Sources ####################
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; # I saw this change from unstable to 24.11, from upstream, because of the mess?
# The next two are for pinning to stable vs unstable regardless of what the above is set to
# See also 'stable-packages' and 'unstable-packages' overlays at 'overlays/default.nix"
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
hardware.url = "github:nixos/nixos-hardware";
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
#################### Utilities ####################
# Declarative partitioning and formatting
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# Secrets management. See ./docs/secretsmgmt.md
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Theming
stylix.url = "github:danth/stylix/release-24.05"; # checked if it was still necessary to have 24.05 (it is still the case on 24-11-2024)
rose-pine-hyprcursor.url = "github:ndom91/rose-pine-hyprcursor";
#################### Personal Repositories ####################
# Private secrets repo. See ./docs/secretsmgmt.md
# Authenticate via ssh and use shallow clone
nix-secrets = {
url = "git+ssh://[email protected]/DjCoke/nix-secrets.git?ref=main&shallow=1";
inputs = { };
};
};
}