-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
121 lines (110 loc) · 3.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
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
{
description = "Nixos configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
flake-utils = {
url = "github:numtide/flake-utils/main";
inputs.systems.follows = "systems";
};
devshell = {
url = "github:numtide/devshell";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix/main";
inputs = {
nixpkgs.follows = "nixpkgs";
home-manager.follows = "home-manager";
systems.follows = "systems";
};
};
zeroad = {
url = "github:chvp/0ad-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
hardware = {
url = "github:NixOS/nixos-hardware";
};
};
outputs = { self, nixpkgs, home-manager, flake-utils, agenix, zeroad, devshell, hardware, systems }:
let
version-suffix = nixpkgs.rev or (builtins.toString nixpkgs.lastModified);
pkgsFor = system: import nixpkgs {
inherit system;
};
mkSystem = system: hostname: extraModules: nixpkgs.lib.nixosSystem {
inherit system;
modules = [
# Add extra input arguments to modules
({ config._module.args = {
inherit self;
util = import ./util.nix; };
})
# Secrets management
agenix.nixosModules.default
({
nixpkgs.overlays = [
(self: super: {
# Actual budgetting server
actual-server = self.callPackage ./packages/actual {};
# Agenix secrets
agenix = agenix.packages.${system}.default;
lego = self.symlinkJoin {
name = "lego";
paths = [ super.lego ];
buildInputs = [ self.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/lego \
--set LEGO_DISABLE_CNAME_SUPPORT true
'';
};
})
];
})
# Enable home-manager
home-manager.nixosModules.home-manager
# Set global home-manager options
({
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
})
# Automatically load custom modules
(./modules)
# Expose the currently deployed nixpkgs in /etc/nixpkgs/
({ pkgs, ... }: {
environment.etc."nixpkgs".source = (pkgs.runCommand "nixpkgs" { } ''
cp -r ${nixpkgs} $out
chmod 700 $out
echo "${version-suffix}" > $out/.version-suffix
'');
nix.nixPath = [ "nixpkgs=/etc/nixpkgs" ];
})
# Load the config for our current machine
(./. + "/machines/${hostname}")
] ++ extraModules;
};
in
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = pkgsFor system;
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [ nixpkgs-fmt ];
};
}) // {
nixosConfigurations = {
chaos = mkSystem "x86_64-linux" "chaos" [];
space = mkSystem "x86_64-linux" "space" [];
entropy = mkSystem "x86_64-linux" "entropy" [];
};
};
}