-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
89 lines (78 loc) · 1.95 KB
/
default.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
{ pkgs
, lib
, resources
, config
, nodes
, binaryCacheUrl ? s3://nix-build?region=us-east-1
, binaryCachePrivateKey ? config.deployment.keys.binary-cache-key.path
, binaryCachePublicKey
, ...
}:
let
# See https://nixos.org/manual/nix/unstable/advanced-topics/post-build-hook.html
uploadToS3Cache = pkgs.writeShellScript "upload-to-s3-cache.sh" ''
set -eu
set -f # disable globbing
export IFS=' '
echo "Signing" $OUT_PATHS
echo nix store sign \
--key-file ${binaryCachePrivateKey} \
$OUT_PATHS
nix store sign-paths \
--key-file ${binaryCachePrivateKey} \
$OUT_PATHS
echo "Uploading" $OUT_PATHS
echo exec ${pkgs.ts}/bin/ts nix copy \
--to 's3://nix-build?region=us-east-1¶llel-compression' \
$OUT_PATHS
exec ${pkgs.ts}/bin/ts nix copy \
--to 's3://nix-build?region=us-east-1¶llel-compression' \
$OUT_PATHS
'';
in
{
networking.firewall = {
enable = true;
};
services = {
openssh = {
enable = true;
# Larger MaxAuthTries helps to avoid ssh 'Too many authentication failures' issue
# See https://github.com/NixOS/nixops/issues/593#issue-203407250
extraConfig = ''
MaxAuthTries 20
'';
openFirewall = true;
};
};
nixpkgs.config.allowUnfree = true;
boot.loader.grub.device = "/dev/xvda";
fileSystems."/" = {
label = "nixos";
fsType = "ext4";
};
environment.systemPackages =
with pkgs;
[
];
nix.sshServe = {
enable = true;
keys = [
# Add your own public key here
];
protocol = "ssh-ng";
};
# Note that the nix package affects nix.sshServe
nix.package = pkgs.nixFlakes;
nix.extraOptions = ''
post-build-hook = ${uploadToS3Cache}
experimental-features = nix-command flakes
'';
nix.binaryCaches = [
http://cache.nixos.org/
];
nix.binaryCachePublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
binaryCachePublicKey
];
}