We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
comenzar / flake.nix
1
{
2
description = "comenzar -- personal search assistant";
3
4
inputs = {
5
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
6
fenix = {
7
url = "github:nix-community/fenix";
8
inputs.nixpkgs.follows = "nixpkgs";
9
};
10
};
11
12
outputs =
13
{
14
self,
15
nixpkgs,
16
fenix,
17
}:
18
let
19
systems = [
20
"aarch64-darwin"
21
"aarch64-linux"
22
"x86_64-darwin"
23
"x86_64-linux"
24
];
25
eachSystem = nixpkgs.lib.genAttrs systems;
26
in
27
{
28
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
29
30
packages = eachSystem (
31
system:
32
let
33
toolchain = fenix.packages.${system}.stable.minimalToolchain;
34
pkgs = nixpkgs.legacyPackages.${system};
35
in
36
rec {
37
default = comenzar;
38
39
comenzar =
40
(pkgs.makeRustPlatform {
41
cargo = toolchain;
42
rustc = toolchain;
43
}).buildRustPackage
44
{
45
pname = "comenzar";
46
version = "0.1.0";
47
48
nativeBuildInputs = [ pkgs.pkg-config ];
49
buildInputs = [ pkgs.openssl ];
50
51
src = ./.;
52
53
postInstall = ''
54
mkdir $out/assets
55
cp ./assets/* $out/assets/
56
'';
57
58
cargoLock.lockFile = ./Cargo.lock;
59
};
60
}
61
);
62
63
devShells = eachSystem (
64
system:
65
let
66
pkgs = nixpkgs.legacyPackages.${system};
67
in
68
{
69
default = pkgs.mkShell {
70
name = "comenzar";
71
72
packages = [
73
(fenix.packages.${system}.stable.withComponents [
74
"cargo"
75
"rustc"
76
"rust-analyzer"
77
"clippy"
78
"rustfmt"
79
"rust-src"
80
])
81
pkgs.pkg-config
82
pkgs.openssl
83
];
84
};
85
}
86
);
87
88
nixosModules = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ] (system: {
89
default =
90
{
91
config,
92
lib,
93
...
94
}:
95
let
96
cfg = config.services.comenzar;
97
inherit (lib)
98
mkIf
99
mkEnableOption
100
mkOption
101
types
102
;
103
in
104
{
105
options.services.comenzar = {
106
enable = mkEnableOption "Enable the comenzar service";
107
108
package = mkOption {
109
type = types.package;
110
default = self.packages.${system}.default;
111
description = "Package to use for comenzar (defaults to this flake's).";
112
};
113
114
logFile = mkOption {
115
type = types.nullOr types.path;
116
default = null;
117
description = "The logfile to use for the comenzar service.";
118
};
119
};
120
121
config = mkIf (cfg.enable) {
122
systemd.services.comenzar = {
123
description = "Comenzar web search helper!";
124
wantedBy = [ "multi-user.target" ];
125
126
serviceConfig = {
127
DynamicUser = "yes";
128
ExecStart = "${cfg.package}/bin/comenzar";
129
Restart = "on-failure";
130
RestartSec = "5s";
131
};
132
133
environment = {
134
COMENZAR_ASSET_BASE = "${cfg.package}/assets";
135
};
136
};
137
};
138
};
139
});
140
141
darwinModules = nixpkgs.lib.genAttrs [ "aarch64-darwin" "x86_64-darwin" ] (system: {
142
default =
143
{
144
config,
145
lib,
146
...
147
}:
148
let
149
cfg = config.services.comenzar;
150
inherit (lib)
151
mkIf
152
mkEnableOption
153
mkOption
154
types
155
;
156
in
157
{
158
options.services.comenzar = {
159
enable = mkEnableOption "Enable the comenzar service";
160
161
package = mkOption {
162
type = types.package;
163
default = self.packages.${system}.default;
164
description = "Package to use for comenzar (defaults to this flake's).";
165
};
166
167
logFile = mkOption {
168
type = types.nullOr types.path;
169
default = null;
170
description = "The logfile to use for the comenzar service.";
171
};
172
};
173
174
config = mkIf (cfg.enable) {
175
launchd.user.agents.comenzar = {
176
serviceConfig = {
177
ProgramArguments = [ "${cfg.package}/bin/comenzar" ];
178
KeepAlive = true;
179
RunAtLoad = true;
180
ProcessType = "Background";
181
StandardOutPath = cfg.logFile;
182
StandardErrorPath = cfg.logFile;
183
EnvironmentVariables = {
184
COMENZAR_ASSET_BASE = "${cfg.package}/assets";
185
};
186
};
187
};
188
};
189
};
190
});
191
192
};
193
}
194