-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
189 lines (172 loc) · 6.53 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
183
184
185
186
187
188
189
{
description = "My NixOS configurations";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixos-hardware.url = "github:nixos/nixos-hardware";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-colors.url = "github:misterio77/nix-colors";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs =
inputs@{ self
, nixpkgs
, home-manager
, nix-colors
, pre-commit-hooks
, flake-parts
, ...
}:
flake-parts.lib.mkFlake { inherit inputs; }
{
flake = rec {
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
# Covers all packages and customizations.
overlays = import ./overlays { };
# NixOS configurations
# Some of them already ship with home-manager configuration.
nixosConfigurations = {
x13 = nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
specialArgs = {
inherit inputs nixosModules;
overlays = builtins.attrValues overlays;
};
modules = [
./hosts/x13/configuration.nix
./hosts/x13/hardware-configuration.nix
];
};
netboot = nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
modules = [
./hosts/netboot.nix
];
};
vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs;
overlays = builtins.attrValues overlays;
};
modules = [
./hosts/vm/configuration.nix
./hosts/x13/hardware-configuration.nix # placeholder
home-manager.nixosModules.home-manager
{
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jtraue = import ./hosts/vm/home-configuration.nix;
home-manager.extraSpecialArgs = {
inherit homeManagerModules nix-colors;
overlays = builtins.attrValues overlays;
hostname = "vm";
};
}
]
++ (builtins.attrValues nixosModules);
};
};
homeConfigurations = {
# home-manager configurations - intended for non NixOS machines
"jtraue@l14" = home-manager.lib.homeManagerConfiguration {
# Workaround for using unfree packages with home-manager
# (see https://github.com/nix-community/home-manager/issues/2942#issuecomment-1378627909)
pkgs = import nixpkgs {
system = "x86_64-linux";
config.allowUnfree = true;
};
extraSpecialArgs = {
inherit homeManagerModules nix-colors;
overlays = builtins.attrValues overlays;
};
modules = [
./hosts/l14/home-configuration.nix
];
};
"jtraue@x13" = home-manager.lib.homeManagerConfiguration {
# Workaround for using unfree packages with home-manager
# (see https://github.com/nix-community/home-manager/issues/2942#issuecomment-1378627909)
pkgs = import nixpkgs {
system = "x86_64-linux";
config.allowUnfree = true;
};
extraSpecialArgs = {
inherit homeManagerModules nix-colors;
overlays = builtins.attrValues overlays;
};
modules = [
./hosts/x13/home-configuration.nix
];
};
};
};
systems = [ "x86_64-linux" ];
imports = [
inputs.pre-commit-hooks.flakeModule
];
perSystem = { pkgs, config, system, ... }: {
# Custom packages that are not yet packaged elsewhere.
packages =
import ./pkgs { inherit pkgs; } //
{
# Demo package for netboot. Use via:
# * nix build .\#netboot-experiment && nix-shell -p python3Packages.python --run 'python3 -m http.server --directory result 8888'
# * qemu-ipxe -m 4096 -b
netboot-experiment =
let
bootSystem = self.nixosConfigurations.netboot;
inherit (bootSystem.config.system) build;
# Pass `cmdline` variable to NixOS ipxe script.
ipxe-script = nixpkgs.legacyPackages.x86_64-linux.writeText "ipxe-default.cfg" ''
#!ipxe
set cmdline earlyprintk=serial,ttyS0,115200n8,keep console=ttyS0 loglevel=7
chain http://''${next-server}:8888/netboot.ipxe
'';
in
nixpkgs.legacyPackages.x86_64-linux.runCommand "netboot-files" { } ''
mkdir -p $out
ln -s ${build.netbootRamdisk}/initrd $out/initrd
ln -s ${build.kernel}/bzImage $out/bzImage
ln -s ${ipxe-script} $out/ipxe-default.cfg
ln -s ${build.netbootIpxeScript}/netboot.ipxe $out/netboot.ipxe
'';
};
devShells.default = pkgs.mkShellNoCC {
# For onboarding a system that doesn't use flakes yet.
NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake";
inputsFrom = [ config.pre-commit.settings.run ];
buildInputs = with pkgs; [
nix
home-manager.packages."${system}".default
git
cachix
];
shellHook = config.pre-commit.installationScript;
};
pre-commit = {
check.enable = true;
settings = {
hooks = {
nixpkgs-fmt.enable = true;
deadnix = {
enable = true;
settings = {
noLambdaPatternNames = true;
noLambdaArg = true;
};
};
statix.enable = true;
shellcheck.enable = false;
};
};
};
};
};
}