-
Notifications
You must be signed in to change notification settings - Fork 8
/
flake.nix
154 lines (141 loc) · 5.29 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# my packages
bookdb = {
url = "github:barrucadu/bookdb";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
inputs.rust-overlay.follows = "rust-overlay";
};
bookmarks = {
url = "github:barrucadu/bookmarks";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
inputs.rust-overlay.follows = "rust-overlay";
};
prometheus-awair-exporter = {
url = "github:barrucadu/prometheus-awair-exporter";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
};
resolved = {
url = "github:barrucadu/resolved";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
inputs.rust-overlay.follows = "rust-overlay";
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, sops-nix, ... }@flakeInputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
in
{
formatter.${system} = pkgs.nixpkgs-fmt;
nixosConfigurations =
let
mkNixosConfiguration = name: extraModules: nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit flakeInputs; };
modules = [
{
networking.hostName = name;
nixpkgs.overlays = [ (_: _: { nixfiles = self.packages.${system}; }) ];
sops.defaultSopsFile = ./hosts + "/${name}" + /secrets.yaml;
}
./shared
(./hosts + "/${name}" + /configuration.nix)
(./hosts + "/${name}" + /hardware.nix)
sops-nix.nixosModules.sops
] ++ extraModules;
};
in
{
carcosa = mkNixosConfiguration "carcosa" [ "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix" ];
nyarlathotep = mkNixosConfiguration "nyarlathotep" [ "${nixpkgs}/nixos/modules/installer/scan/not-detected.nix" ];
yuggoth = mkNixosConfiguration "yuggoth" [ "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix" ];
};
packages.${system} =
{
bookdb = flakeInputs.bookdb.packages.${system}.default;
bookmarks = flakeInputs.bookmarks.packages.${system}.default;
prometheus-awair-exporter = flakeInputs.prometheus-awair-exporter.packages.${system}.default;
resolved = flakeInputs.resolved.packages.${system}.default;
};
apps.${system} =
let
mkApp = name: script: {
type = "app";
program = toString (pkgs.writeShellScript "${name}.sh" script);
};
in
{
backups = mkApp "backups" ''
PATH=${with pkgs; lib.makeBinPath [ restic sops nettools ]}
${pkgs.lib.fileContents ./scripts/backups.sh}
'';
fmt = mkApp "fmt" ''
PATH=${with pkgs; lib.makeBinPath [ nix git python3Packages.black ]}
${pkgs.lib.fileContents ./scripts/fmt.sh}
'';
lint = mkApp "lint" ''
# TODO: add nix-linter back when the package is no longer broken
PATH=${with pkgs; lib.makeBinPath [ findutils shellcheck git gnugrep python3Packages.flake8 ]}
${pkgs.lib.fileContents ./scripts/lint.sh}
'';
secrets = mkApp "secrets" ''
PATH=${with pkgs; lib.makeBinPath [ sops nettools vim ]}
export EDITOR=vim
${pkgs.lib.fileContents ./scripts/secrets.sh}
'';
documentation =
let
eval = pkgs.lib.evalModules {
modules = [
{ config._module.args = { inherit pkgs; }; }
./shared/options.nix
# modules
./shared/bookdb/options.nix
./shared/bookmarks/options.nix
./shared/concourse/options.nix
./shared/erase-your-darlings/options.nix
./shared/finder/options.nix
./shared/foundryvtt/options.nix
./shared/minecraft/options.nix
./shared/oci-containers/options.nix
./shared/pleroma/options.nix
./shared/resolved/options.nix
./shared/restic-backups/options.nix
./shared/torrents/options.nix
./shared/umami/options.nix
# host templates
./shared/host-templates/website-mirror/options.nix
];
};
optionsDoc = pkgs.nixosOptionsDoc {
options = eval.options;
};
in
mkApp "documentation" ''
PATH=${with pkgs; lib.makeBinPath [ coreutils gnused mdbook mdbook-admonish python3 ]}
export NIXOS_OPTIONS_JSON="${optionsDoc.optionsJSON}/share/doc/nixos/options.json"
${pkgs.lib.fileContents ./scripts/documentation.sh}
'';
};
};
}