-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
187 lines (173 loc) · 5.4 KB
/
flake.nix
File metadata and controls
187 lines (173 loc) · 5.4 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
{
description = "Gui's Nix-Config";
outputs =
{
self,
nixpkgs,
nix-darwin,
treefmt-nix,
...
}@inputs:
let
inherit (self) outputs;
#
# ========= Architectures =========
#
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-darwin"
];
# ========== Extend lib with lib.custom ==========
# NOTE: This approach allows lib.custom to propagate into hm
# see: https://github.com/nix-community/home-manager/pull/3454
lib = nixpkgs.lib.extend (
self: super: {
custom = import ./lib {
inherit (nixpkgs) lib;
inherit inputs;
};
}
);
in
{
#
# ========= Overlays =========
#
# Custom modifications/overrides to upstream packages
overlays = import ./overlays { inherit inputs; };
#
# ========= Host Configurations =========
#
# Building configurations is available through `nixos-rebuild --flake .#hostname`
nixosConfigurations = builtins.listToAttrs (
map (host: {
name = host;
value = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs lib;
isDarwin = false;
configPath = builtins.getEnv "PWD";
};
modules = [ ./hosts/nixos/${host} ];
};
}) (builtins.attrNames (builtins.readDir ./hosts/nixos))
);
darwinConfigurations = builtins.listToAttrs (
map (host: {
name = host;
value = nix-darwin.lib.darwinSystem {
specialArgs = {
inherit inputs outputs lib;
isDarwin = true;
configPath = builtins.getEnv "PWD";
};
modules = [ ./hosts/darwin/${host} ];
};
}) (builtins.attrNames (builtins.readDir ./hosts/darwin))
);
#
# ========= Packages =========
#
# Expose custom packages
/*
NOTE: This is only for exposing packages exterally; ie, `nix build .#packages.x86_64-linux.cd-gitroot`
For internal use, these packages are added through the default overlay in `overlays/default.nix`
*/
packages = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in
nixpkgs.lib.packagesFromDirectoryRecursive {
callPackage = nixpkgs.lib.callPackageWith pkgs;
directory = ./pkgs/common;
}
);
#
# ========= Formatting =========
#
# Tree formatter using treefmt-nix
formatter = forAllSystems (
system:
treefmt-nix.lib.mkWrapper nixpkgs.legacyPackages.${system} {
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
}
);
# Pre-commit checks
checks = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
import ./checks.nix { inherit inputs system pkgs; }
);
#
# ========= DevShell =========
#
# Custom shell for bootstrapping on new hosts, modifying nix-config, and secrets management
devShells = forAllSystems (
system:
import ./shell.nix {
pkgs = nixpkgs.legacyPackages.${system};
checks = self.checks.${system};
}
);
};
inputs = {
#
# ========= Official NixOS, Darwin, and HM Package Sources =========
#
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
# The next two are for pinning to stable vs unstable regardless of what the above is set to
# This is particularly useful when an upcoming stable release is in beta because you can effectively
# keep 'nixpkgs-stable' set to stable for critical packages while setting 'nixpkgs' to the beta branch to
# get a jump start on deprecation changes.
# See also 'stable-packages' and 'unstable-packages' overlays at 'overlays/default.nix"
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
hardware.url = "github:nixos/nixos-hardware";
home-manager = {
url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-25.05-darwin";
nix-darwin = {
url = "github:nix-darwin/nix-darwin/nix-darwin-25.05";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
#
# ========= Utilities =========
#
# Declarative partitioning and formatting
# disko = {
# url = "github:nix-community/disko";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# A good way to configure neovim
nixvim = {
url = "github:nix-community/nixvim/nixos-25.05";
inputs.nixpkgs.follows = "nixpkgs";
#url = "github:nix-community/nixvim";
#inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# Pre-commit
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Tree formatter
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
#
# ========= Personal Repositories =========
#
# Utility to package a collection of scripts for the CLI
sub.url = "github:juanibiapina/sub";
};
}