-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
131 lines (121 loc) · 3.74 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
hardware.url = "github:nixos/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
nur.url = "github:nix-community/NUR";
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
rekey = {
url = "github:oddlama/agenix-rekey";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
musnix = {
url = "github:musnix/musnix";
inputs.nixpkgs.follows = "nixpkgs";
};
mobile = {
url = "github:nixos/mobile-nixos";
flake = false;
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
stylix = {
url = "github:danth/stylix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, systems, ... }:
let
eachSystem = f: inputs.nixpkgs.lib.genAttrs (import systems)
(system: f (import inputs.nixpkgs { inherit system; }));
in
rec {
lib = rec {
username = "bryton";
hostname = "${username}.io";
name = "Bryton Hall";
email = "email@${hostname}";
# https://discourse.nixos.org/t/nix-function-to-merge-attributes-records-recursively-and-concatenate-arrays/2030
recursiveMergeAttrs = with inputs.nixpkgs.lib; fold (attrset: acc: recursiveUpdate attrset acc) { };
};
nixosConfigurations = import ./hosts {
inherit self lib;
modules = with inputs; (map (i: i.nixosModules.default) [
agenix
disko
home
# musnix
rekey
]) ++ [
impermanence.nixosModules.impermanence
stylix.nixosModules.stylix
nur.nixosModules.nur
({ ... }: {
nixpkgs.overlays = (map (o: o.overlays.default) [
rekey
self
]);
})
] ++ (with builtins; map (x: ./modules/${x}) (attrNames (readDir ./modules)));
};
overlays.default = final: prev: with builtins; listToAttrs (map
(name: {
inherit name;
value = import ./overlays/${name} final prev;
})
(attrNames (readDir ./overlays))
);
packages = with builtins; eachSystem (pkgs:
(pkgs.lib.trivial.pipe
# remove accessory files
(filter (name: !elem name [ "README.md" ])
(attrNames (readDir ./packages))) [
(map (name: {
inherit name;
value = pkgs.callPackage ./packages/${name} { };
}))
# remove unsupported packages
(filter (x: elem pkgs.system x.value.meta.platforms))
listToAttrs
])
);
devShells = eachSystem (pkgs: {
default = with pkgs; mkShell {
buildInputs = [
deploy-rs
inputs.rekey.packages.${system}.default
nixos-anywhere
# nixos-rebuild build --flake "$@" && nvd diff /run/current-system result
nvd
];
};
});
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy.lib;
deploy.nodes = builtins.mapAttrs
(hostname: config: {
inherit hostname;
profiles.system = {
user = "root";
path = inputs.deploy.lib.${config.pkgs.system}.activate.nixos config;
};
})
self.nixosConfigurations;
agenix-rekey = inputs.rekey.configure {
userFlake = self;
nodes = self.nixosConfigurations;
};
};
}