dotfiles/nix/deployments/nixops.nix

142 lines
4.3 KiB
Nix
Raw Normal View History

2022-08-09 22:52:38 -07:00
let
nasIp = "192.168.1.168";
in
2022-07-30 19:42:03 -07:00
{
network = {
name = "house";
enableRollback = true;
description = "machines used in my house";
storage.legacy = { };
};
defaults = { pkgs, ... }:
{
imports = [
# make sure you have properly added the home-manager channel!
<home-manager/nixos>
];
networking.wireless.networks."ShamblingHalfling 5Ghz-1" = {
pskRaw = (
(import ../system/framework/keys.nix).wifi."ShamblingHalfling 5Ghz-1".pskRaw
);
priority = 1;
};
networking.wireless.networks.N904 = {
pskRaw = (
(import ../system/framework/keys.nix).wifi.N904.pskRaw
);
priority = 2;
};
documentation.enable = false;
# for nixops to log in and perform operations as haak (instead of root)
security.sudo.wheelNeedsPassword = false;
2022-08-10 21:21:17 -07:00
home-manager.users.haak = (import ../home/commandline.nix);
# Configure the root account
users.users.root.openssh.authorizedKeys.keys = [
(import ../system/framework/keys.nix).ssh.public
];
2022-08-10 21:21:17 -07:00
users.extraUsers.root = {
shell = pkgs.zsh;
};
environment.systemPackages = with pkgs; [
tmux
ripgrep
2022-08-10 21:21:17 -07:00
htop
];
2022-08-10 21:21:17 -07:00
# Optimize nix store by hardlinking identitical files.
nix.settings.auto-optimise-store = true;
# Limit the systemd journal to 100 MB of disk or the
# last 7 days of logs, whichever happens first.
services.journald.extraConfig = ''
SystemMaxUse=100M
MaxFileSec=7day
'';
# servers should not auto-upgrade; it leads to strange behavior when they
# reboot, because of creating their own, new, generation outside of
# nixops management.
system.autoUpgrade.enable = false;
};
2022-08-09 22:52:38 -07:00
server =
{ nodes, ... }:
{
deployment.targetHost = "192.168.1.65";
imports = [ ../system/xps11/configuration.nix ];
2022-08-09 22:52:38 -07:00
fileSystems."/storage" = {
device = "${nasIp}:/storage";
fsType = "nfs";
};
};
2022-08-09 23:56:09 -07:00
nas =
{ pkgs, ... }:
{
deployment.targetHost = nasIp;
imports = [
../system/svalbard/configuration.nix
../home/programs/flood
];
2022-08-09 23:56:09 -07:00
services.nfs.server.enable = true;
services.nfs.server.exports = ''
2022-08-11 15:53:04 -07:00
/export 192.168.1.0/24(insecure,rw,sync,crossmnt,no_subtree_check,fsid=0)
/export/storage 192.168.1.0/24(rw,sync,nohide,no_subtree_check,insecure)
2022-08-09 23:56:09 -07:00
'';
networking.firewall = {
allowedTCPPorts = [ 2049 ]; # NFS port
allowedUDPPorts = [ 51820 ]; # Clients and peers can use the same port, see listenport
};
deployment.keys.wireguard.text = builtins.readFile ../../secrets/wireguard/svalbard;
# Enable WireGuard
networking.wg-quick.interfaces = {
# "wg0" is the network interface name. You can name the interface arbitrarily.
wg0 = {
# Determines the IP address and subnet of the client's end of the tunnel interface.
address = [ "10.64.168.213/32" "fc00:bbbb:bbbb:bb01::1:a8d4/128" ];
dns = [ "10.64.0.1" ];
listenPort = 51820; # to match firewall allowedUDPPorts (without this wg uses random port numbers)
# Note: The private key can also be included inline via the privateKey option,
# but this makes the private key world-readable; thus, using privateKeyFile is
# recommended.
privateKeyFile = "/run/keys/wireguard";
# For a client configuration, one peer entry for the server will suffice.
peers = [
# Sweden, Malmo, se15
{
# Public key of the server (not a file path).
publicKey = "5y66WShsFXqM5K7/4CPEGCWfk7PQyNhVBT2ILjbGm2I=";
# Forward all the traffic via VPN.
allowedIPs = [ "0.0.0.0/0" "::0/0" ];
# Set this to the server IP and port.
endpoint = "193.138.218.80:51820"; # ToDo: route to endpoint not automatically configured https://wiki.archlinux.org/index.php/WireGuard#Loop_routing https://discourse.nixos.org/t/solved-minimal-firewall-setup-for-wireguard-client/7577
# Send keepalives every 25 seconds. Important to keep NAT tables alive.
persistentKeepalive = 25;
}
];
};
};
2022-08-09 23:56:09 -07:00
};
2022-07-30 19:42:03 -07:00
}