blob: 731dd6657f897ec71b9fac4ccf3652047f605855 (
plain)
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
|
{
description = "Nixos, home-manager, and deploy-rs configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
sops-nix.url = "github:Mic92/sops-nix";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs.url = "github:serokell/deploy-rs";
dns = {
url = "github:kirelagin/dns.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
nix-darwin = {
url = "path:/home/ivi/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
self,
nixpkgs,
home-manager,
sops-nix,
deploy-rs,
...
}: let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
lib = (nixpkgs.lib.extend (_: _: home-manager.lib)).extend (import ./ivi self);
# Gets module from ./machines/ and uses the lib to define which other modules
# the machine needs.
mkSystem = machine: machineConfig:
with lib;
lib.nixosSystem {
inherit lib system;
specialArgs = {inherit self machine inputs;};
modules = with lib;
machine.modules
++ [inputs.home-manager.nixosModules.default]
++ machineConfig
++ [
({config, ...}: {
nixpkgs.overlays = with lib; [
(composeManyExtensions [
(import ./overlays/vimPlugins.nix {inherit pkgs;})
(import ./overlays/openpomodoro-cli.nix {inherit pkgs lib;})
(import ./overlays/fzf.nix {inherit pkgs lib;})
inputs.neovim-nightly-overlay.overlay
])
];
})
];
};
in
with lib; {
inherit lib;
nixosConfigurations = with lib;
mapAttrs
(hostname: cfg:
mkSystem ivi.machines.${hostname} [cfg])
(modulesIn ./machines);
# // {
# windows = windowsModules: let
# wsl = recursiveUpdate ivi.machines.wsl {modules = ivi.machines.wsl.modules ++ windowsModules;};
# in (mkSystem wsl []);
# iso = mkSystem {modules = [./iso.nix];} [];
# };
darwinConfigurations."work" = let
machine = ivi.machines."work";
system = "aarch64-darwin";
pkgs = import nixpkgs {inherit system;};
lib = (nixpkgs.lib.extend (_: _: home-manager.lib)).extend (import ./ivi self);
in
inputs.nix-darwin.lib.darwinSystem
{
inherit lib system;
specialArgs = {inherit self machine inputs;};
modules =
[
./machines/work.nix
inputs.home-manager.darwinModules.default
]
++ (attrValues (modulesIn ./profiles/core))
++ (attrValues (modulesIn ./profiles/station))
++ [
({config, ...}: {
nixpkgs.overlays = with lib; [
(composeManyExtensions [
(import ./overlays/vimPlugins.nix {inherit pkgs;})
inputs.neovim-nightly-overlay.overlay
])
];
})
];
};
deploy.nodes =
mapAttrs
(hostname: machine: {
hostname = hostname + "." + ivi.domain;
sshUser = "root";
profiles.system.path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.${hostname};
})
(filterAttrs (_: machine: machine.isServer) ivi.machines);
devShells."${system}".hetzner = pkgs.mkShell {
name = "deploy";
buildInputs = [
pkgs.bashInteractive
deploy-rs.packages."${system}".default
];
shellHook = ''
export HCLOUD_TOKEN="$(pass show personal/hetzner-token)"
'';
};
templates =
mapAttrs
(name: type: {path = ./templates + "/${name}";})
(builtins.readDir ./templates);
};
}
|