-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
89 lines (79 loc) · 2.42 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
{
description = "Johannes' NixOS Configurations";
inputs = {
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
agenix.url = "github:ryantm/agenix";
};
outputs =
{
self,
nixpkgs,
agenix,
nixos-hardware,
...
}@inputs:
let
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
# Bundle of common modules, including nix flakes
commonModules = name: [
{
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
networking.hostName = name;
}
./hosts/${name}/configuration.nix # Host-Specific configuration from /etc/nixos
./modules/services # Common system services
./modules/packages # Common packages
./modules/system # Common system settings
./modules/user # User configuration
];
agenixModules = system: [
agenix.nixosModules.default
{
environment.systemPackages = [ agenix.packages.${system}.default ];
}
];
# Define a system with common and extra modules
mkSystem =
name: cfg:
nixpkgs.lib.nixosSystem rec {
system = cfg.system or "x86_64-linux";
modules = (commonModules name) ++ (agenixModules system) ++ (cfg.modules or [ ]);
specialArgs = inputs;
};
systems = {
# ThinkPad
kirby = {
modules = [
nixos-hardware.nixosModules.lenovo-thinkpad-x230
nixos-hardware.nixosModules.common-pc-laptop-ssd
./modules/desktop
];
};
clay = {
modules = [
nixos-hardware.nixosModules.common-pc-laptop-ssd
./modules/desktop
];
};
};
# Read all modules from a specific folder
modulesFrom =
dir:
nixpkgs.lib.listToAttrs (
map (file: {
name = builtins.head (builtins.split "\\." file);
value = import (dir + "/${file}");
}) (nixpkgs.lib.attrNames (builtins.readDir dir))
);
in
{
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
# Include everything from our general folder
nixosModules = (modulesFrom ./modules);
nixosConfigurations = nixpkgs.lib.mapAttrs mkSystem systems;
};
}