-
Notifications
You must be signed in to change notification settings - Fork 1
/
module.nix
56 lines (53 loc) · 1.81 KB
/
module.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
{ config, lib, pkgs, ... }:
let
defpkg = (import ./. { inherit pkgs; }).nix-sandwich-local;
cfg = config.programs.nix-sandwich;
in with lib; {
options = {
programs.nix-sandwich = {
enable = mkEnableOption "nix download helper";
differ = mkOption {
description = "url to remote differ";
type = types.str;
default = throw "must set config.programs.nix-sandwich.differ!";
example = "https://abc213";
};
port = mkOption {
description = "port to listen on";
type = types.int;
default = 7419;
};
package = mkOption {
description = "nix-sandwich package";
type = types.package;
default = defpkg;
};
};
};
config = mkIf cfg.enable {
nix.settings = {
trusted-substituters = [ "http://localhost:${toString cfg.port}" ];
# TODO: These are needed since we don't cache "recents" across restarts.
# After we can do that, remove this.
narinfo-cache-positive-ttl = 15;
narinfo-cache-negative-ttl = 15;
};
systemd.sockets.nix-sandwich = {
description = "nix download helper activation socket";
wantedBy = [ "sockets.target" ];
socketConfig.ListenStream = "127.0.0.1:${toString cfg.port}";
};
systemd.services.nix-sandwich = {
description = "nix download helper";
serviceConfig.ExecStart = "${cfg.package}/bin/nix-sandwich";
serviceConfig.Type = "notify";
serviceConfig.NotifyAccess = "all";
serviceConfig.DynamicUser = true;
serviceConfig.LogsDirectory = "nix-sandwich-analytics";
serviceConfig.TemporaryFileSystem = "/tmpfs:size=16G,mode=1777"; # force tmpfs
environment.nix_sandwich_subst_idle_time = "15m";
environment.nix_sandwich_differ = cfg.differ;
environment.TMPDIR = "/tmpfs";
};
};
}