-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflake.nix
122 lines (104 loc) · 3.69 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
{
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
inputs.nixos-hardware.url = "github:NixOS/nixos-hardware";
inputs.disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.cachix-deploy.url = "github:cachix/cachix-deploy-flake";
inputs.nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, disko, flake-compat, nixpkgs, nixos-generators, nixos-hardware, cachix-deploy, treefmt-nix }@attrs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
cachix-deploy-lib = cachix-deploy.lib pkgs;
revision = "${self.lastModifiedDate}-${self.shortRev or "dirty"}";
mkMachine = system: modules: nixpkgs.lib.nixosSystem {
inherit system;
modules = modules ++ [ ./modules/common.nix ];
specialArgs = attrs;
};
mqtt-dash-listen = pkgs.writeScriptBin "mqtt-dash-listen" ''
echo 1>&2 "Press Publish Metrics in the MQTT Dash app..."
${pkgs.mosquitto}/bin/mosquitto_sub -h mqtt -t 'metrics/exchange' -C 1 | ${pkgs.jq}/bin/jq -r .
'';
dashboard-linter = pkgs.callPackage ./modules/grafana/dashboard-linter.nix { };
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
{
nixosConfigurations = {
x1 = mkMachine "x86_64-linux" [ ./x1.nix ];
x230 = mkMachine "x86_64-linux" [ ./x230.nix ];
nuc = mkMachine "x86_64-linux" [ ./host-nuc.nix ];
rp3 = mkMachine "aarch64-linux" [ ./host-rp3.nix ];
rp4 = mkMachine "aarch64-linux" [ ./host-rp4.nix ];
};
formatter.${system} = treefmtEval.config.build.wrapper;
apps.${system} = {
mqtt-dash-listen = {
type = "app";
program = "${mqtt-dash-listen}/bin/mqtt-dash-listen";
};
dashboard-linter = {
type = "app";
program = "${dashboard-linter}/bin/dashboard-linter";
};
};
packages.${system} = with pkgs; {
sensors = callPackage ./nodemcu/provision.nix { };
cachix-deploy-spec = cachix-deploy-lib.spec {
agents = {
nuc = self.nixosConfigurations.nuc.config.system.build.toplevel;
x1 = self.nixosConfigurations.x1.config.system.build.toplevel;
x230 = self.nixosConfigurations.x230.config.system.build.toplevel;
rp3 = self.nixosConfigurations.rp3.config.system.build.toplevel;
rp4 = self.nixosConfigurations.rp4.config.system.build.toplevel;
};
};
};
packages.aarch64-linux = {
sdcard = nixos-generators.nixosGenerate {
system = "aarch64-linux";
format = "sd-aarch64";
specialArgs = attrs;
modules = [ ./host-rp3.nix ];
};
sdcard-rp4 = nixos-generators.nixosGenerate {
system = "aarch64-linux";
format = "sd-aarch64";
specialArgs = attrs;
modules = [ ./host-rp4.nix ];
};
};
checks.${system} = with pkgs; {
formatting = treefmtEval.config.build.check self;
markdownlint = runCommand "mdl"
{
buildInputs = [ mdl ];
}
''
mkdir $out
mdl ${./README.md}
'';
shellcheck = runCommand "shellcheck"
{
buildInputs = [ shellcheck ];
}
''
mkdir $out
shellcheck --shell bash ${./scripts}/*
'';
};
};
}