2022-07-28 09:29:58 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2023-01-17 08:05:11 +00:00
|
|
|
let
|
|
|
|
network = import ../plover/modules/hardware/networks.nix;
|
2023-01-19 12:16:01 +00:00
|
|
|
inherit (builtins) toString;
|
2023-01-23 05:29:42 +00:00
|
|
|
inherit (network)
|
2023-01-23 09:46:32 +00:00
|
|
|
interfaces
|
2023-01-23 05:29:42 +00:00
|
|
|
wireguardPort
|
|
|
|
wireguardPeers;
|
2023-01-17 08:05:11 +00:00
|
|
|
|
2023-01-23 09:46:32 +00:00
|
|
|
wireguardAllowedIPs = [
|
2023-06-22 10:01:19 +00:00
|
|
|
"${interfaces.lan.IPv4.address}/16"
|
|
|
|
"${interfaces.lan.IPv6.address}/64"
|
2023-01-23 09:46:32 +00:00
|
|
|
];
|
2023-01-17 08:05:11 +00:00
|
|
|
wireguardIFName = "wireguard0";
|
|
|
|
in
|
2021-11-25 11:55:30 +00:00
|
|
|
{
|
2021-12-11 05:37:27 +00:00
|
|
|
imports = [
|
|
|
|
# Include the results of the hardware scan.
|
2021-11-25 13:45:48 +00:00
|
|
|
./hardware-configuration.nix
|
2022-01-31 07:39:21 +00:00
|
|
|
|
2022-07-09 05:54:05 +00:00
|
|
|
(lib.mapHomeManagerUser "foo-dogsquared" {
|
2022-08-10 04:14:11 +00:00
|
|
|
extraGroups = [
|
|
|
|
"adbusers"
|
|
|
|
"wheel"
|
|
|
|
"audio"
|
|
|
|
"docker"
|
|
|
|
"podman"
|
|
|
|
"networkmanager"
|
2023-02-11 01:01:31 +00:00
|
|
|
"wireshark"
|
2022-08-10 04:14:11 +00:00
|
|
|
];
|
2022-07-09 05:54:05 +00:00
|
|
|
hashedPassword =
|
|
|
|
"$6$.cMYto0K0CHbpIMT$dRqyKs4q1ppzmTpdzy5FWP/V832a6X..FwM8CJ30ivK0nfLjQ7DubctxOZbeOtygfjcUd1PZ0nQoQpOg/WMvg.";
|
|
|
|
isNormalUser = true;
|
|
|
|
createHome = true;
|
|
|
|
home = "/home/foo-dogsquared";
|
2023-01-26 05:10:56 +00:00
|
|
|
description = "Gabriel Arazas";
|
2022-07-09 05:54:05 +00:00
|
|
|
})
|
2021-11-25 13:45:48 +00:00
|
|
|
];
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2022-07-17 05:25:36 +00:00
|
|
|
services.openssh.hostKeys = [{
|
2022-12-31 03:13:27 +00:00
|
|
|
path = config.sops.secrets."ni/ssh-key".path;
|
2022-07-17 05:25:36 +00:00
|
|
|
type = "ed25519";
|
|
|
|
}];
|
2022-12-31 03:13:27 +00:00
|
|
|
|
2023-05-27 05:17:35 +00:00
|
|
|
services.gonic = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
listen-addr = "127.0.0.1:4747";
|
|
|
|
cache-path = "/var/cache/gonic";
|
|
|
|
music-path = [
|
|
|
|
"/srv/music"
|
|
|
|
];
|
|
|
|
podcast-path = "/var/cache/gonic/podcasts";
|
|
|
|
|
|
|
|
jukebox-enabled = true;
|
|
|
|
|
|
|
|
scan-interval = 1;
|
|
|
|
scan-at-start-enabled = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-07 08:06:34 +00:00
|
|
|
sops.secrets =
|
|
|
|
let
|
|
|
|
getKey = key: {
|
|
|
|
inherit key;
|
|
|
|
sopsFile = ./secrets/secrets.yaml;
|
|
|
|
};
|
|
|
|
getSecrets = secrets:
|
|
|
|
lib.mapAttrs'
|
|
|
|
(secret: config:
|
|
|
|
lib.nameValuePair
|
|
|
|
"ni/${secret}"
|
|
|
|
((getKey secret) // config))
|
|
|
|
secrets;
|
|
|
|
in
|
2022-12-31 03:13:27 +00:00
|
|
|
getSecrets {
|
|
|
|
ssh-key = { };
|
2023-01-17 08:05:11 +00:00
|
|
|
"wireguard/private-key" = {
|
|
|
|
group = config.users.users.systemd-network.group;
|
|
|
|
reloadUnits = [ "systemd-networkd.service" ];
|
|
|
|
mode = "0640";
|
|
|
|
};
|
|
|
|
"wireguard/preshared-keys/plover" = {
|
|
|
|
group = config.users.users.systemd-network.group;
|
|
|
|
reloadUnits = [ "systemd-networkd.service" ];
|
|
|
|
mode = "0640";
|
|
|
|
};
|
|
|
|
"wireguard/preshared-keys/phone" = {
|
|
|
|
group = config.users.users.systemd-network.group;
|
|
|
|
reloadUnits = [ "systemd-networkd.service" ];
|
|
|
|
mode = "0640";
|
|
|
|
};
|
2022-12-31 03:13:27 +00:00
|
|
|
};
|
|
|
|
|
2022-07-17 05:25:36 +00:00
|
|
|
sops.age.keyFile = "/var/lib/sops-nix/key.txt";
|
|
|
|
|
2023-03-19 01:58:18 +00:00
|
|
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
2022-05-20 06:47:09 +00:00
|
|
|
boot.binfmt.emulatedSystems = [
|
|
|
|
"aarch64-linux"
|
|
|
|
"riscv64-linux"
|
|
|
|
];
|
|
|
|
|
2023-02-11 01:01:31 +00:00
|
|
|
programs.wireshark.package = pkgs.wireshark;
|
|
|
|
|
2022-07-14 00:20:02 +00:00
|
|
|
boot.initrd.supportedFilesystems = [ "btrfs" ];
|
|
|
|
boot.supportedFilesystems = [ "btrfs" ];
|
|
|
|
|
|
|
|
services.btrfs.autoScrub = {
|
|
|
|
enable = true;
|
|
|
|
fileSystems = [
|
|
|
|
"/mnt/archives"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# My custom configuration with my custom modules starts here.
|
2022-01-09 05:38:59 +00:00
|
|
|
profiles = {
|
2022-07-14 00:20:02 +00:00
|
|
|
i18n.enable = true;
|
2021-11-25 11:55:30 +00:00
|
|
|
archiving.enable = true;
|
2022-11-29 13:03:30 +00:00
|
|
|
desktop = {
|
2021-11-25 11:55:30 +00:00
|
|
|
enable = true;
|
|
|
|
audio.enable = true;
|
2021-11-27 11:21:08 +00:00
|
|
|
fonts.enable = true;
|
2021-12-06 07:27:51 +00:00
|
|
|
hardware.enable = true;
|
2021-12-11 05:37:27 +00:00
|
|
|
cleanup.enable = true;
|
2022-04-16 16:17:19 +00:00
|
|
|
autoUpgrade.enable = true;
|
2023-06-05 09:44:11 +00:00
|
|
|
wine.enable = true;
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
|
|
|
dev = {
|
|
|
|
enable = true;
|
|
|
|
shell.enable = true;
|
2021-11-29 09:56:24 +00:00
|
|
|
virtualization.enable = true;
|
2021-12-25 12:35:55 +00:00
|
|
|
neovim.enable = true;
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
2023-06-06 05:50:17 +00:00
|
|
|
gaming = {
|
|
|
|
enable = true;
|
|
|
|
emulators.enable = true;
|
|
|
|
retro-computing.enable = true;
|
|
|
|
};
|
|
|
|
vpn.personal.enable = true;
|
2022-01-09 05:38:59 +00:00
|
|
|
};
|
2022-06-12 05:47:55 +00:00
|
|
|
|
2023-03-03 09:13:40 +00:00
|
|
|
tasks.backup-archive.enable = true;
|
2022-08-23 10:24:44 +00:00
|
|
|
workflows.workflows.a-happy-gnome.enable = true;
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2022-08-11 01:45:19 +00:00
|
|
|
programs.pop-launcher = {
|
|
|
|
enable = true;
|
|
|
|
plugins = with pkgs; [
|
|
|
|
pop-launcher-plugin-duckduckgo-bangs
|
|
|
|
pop-launcher-plugin-brightness
|
|
|
|
];
|
|
|
|
};
|
2022-08-10 04:14:11 +00:00
|
|
|
|
|
|
|
programs.wezterm.enable = true;
|
|
|
|
programs.adb.enable = true;
|
|
|
|
|
2022-02-02 04:25:03 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
2023-01-20 05:15:53 +00:00
|
|
|
# Some sysadmin thingamajigs.
|
2023-01-17 14:25:15 +00:00
|
|
|
openldap
|
2023-01-20 05:15:53 +00:00
|
|
|
wireguard-tools
|
2023-03-03 09:18:42 +00:00
|
|
|
(swh.swh-core.overrideAttrs (attrs: {
|
|
|
|
pythonPath = with pkgs.swh; [
|
|
|
|
swh-model
|
2023-05-09 08:17:09 +00:00
|
|
|
swh-fuse
|
2023-03-03 09:18:42 +00:00
|
|
|
];
|
|
|
|
}))
|
2023-01-17 14:25:15 +00:00
|
|
|
|
2023-02-06 08:08:19 +00:00
|
|
|
# For debugging build environments in Nix packages.
|
|
|
|
cntr
|
2023-03-03 09:18:42 +00:00
|
|
|
|
|
|
|
# Searchsploit.
|
|
|
|
exploitdb
|
2022-02-02 04:25:03 +00:00
|
|
|
];
|
|
|
|
|
2022-01-31 07:39:21 +00:00
|
|
|
# Enable Guix service.
|
2022-08-27 05:30:04 +00:00
|
|
|
services.guix.enable = true;
|
2022-01-31 07:39:21 +00:00
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# Set your time zone.
|
|
|
|
time.timeZone = "Asia/Manila";
|
|
|
|
|
|
|
|
# Doxxing myself.
|
|
|
|
location = {
|
|
|
|
latitude = 15.0;
|
|
|
|
longitude = 121.0;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Some programs need SUID wrappers, can be configured further or are
|
|
|
|
# started in user sessions.
|
|
|
|
programs.mtr.enable = true;
|
|
|
|
|
2021-12-19 09:39:18 +00:00
|
|
|
services.auto-cpufreq.enable = true;
|
|
|
|
services.thermald.enable = true;
|
2021-12-26 10:43:49 +00:00
|
|
|
services.avahi.enable = true;
|
2021-12-19 09:39:18 +00:00
|
|
|
|
2021-11-25 13:45:48 +00:00
|
|
|
# The usual doas config.
|
|
|
|
security.doas = {
|
|
|
|
enable = true;
|
2022-08-10 04:14:11 +00:00
|
|
|
extraRules = [
|
|
|
|
{
|
|
|
|
groups = [ "wheel" ];
|
|
|
|
persist = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
# It is the primary user so we may as well just make this easier to run.
|
|
|
|
{
|
|
|
|
users = [ "foo-dogsquared" ];
|
|
|
|
cmd = "nixos-rebuild";
|
|
|
|
noPass = true;
|
|
|
|
}
|
|
|
|
];
|
2021-11-25 13:45:48 +00:00
|
|
|
};
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2023-01-18 03:10:31 +00:00
|
|
|
# We'll go with a software firewall. We're mostly configuring it as if we're
|
|
|
|
# using a server even though the chances of that is pretty slim.
|
|
|
|
networking = {
|
|
|
|
nftables.enable = true;
|
|
|
|
firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowedUDPPorts = [ wireguardPort ];
|
|
|
|
allowedTCPPorts = [
|
|
|
|
22 # Secure Shells.
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-06-19 04:28:33 +00:00
|
|
|
services.resolved.domains = [
|
|
|
|
"~plover.foodogsquared.one"
|
|
|
|
"~0.27.172.in-addr.arpa"
|
|
|
|
"~0.28.172.in-addr.arpa"
|
|
|
|
];
|
|
|
|
|
2023-05-25 03:10:22 +00:00
|
|
|
system.stateVersion = "23.05"; # Yes! I read the comment!
|
2022-12-31 03:14:08 +00:00
|
|
|
|
2023-01-17 08:05:11 +00:00
|
|
|
# Setting up Wireguard as a VPN tunnel. Since this is a laptop that meant to
|
|
|
|
# be used anywhere, we're configuring Wireguard here as a "client".
|
|
|
|
#
|
2023-02-05 08:27:49 +00:00
|
|
|
# We're using wg-quick here as this host is using network managers that can
|
|
|
|
# differ between workflows (i.e., GNOME and KDE Plasma using NetworkManager,
|
2023-02-09 06:50:11 +00:00
|
|
|
# others might be using systemd-networkd).
|
2023-06-08 13:19:17 +00:00
|
|
|
networking.wg-quick.interfaces.wireguard0 =
|
|
|
|
let
|
|
|
|
domains = [
|
|
|
|
"~plover.foodogsquared.one"
|
|
|
|
"~0.27.172.in-addr.arpa"
|
2023-06-19 04:28:33 +00:00
|
|
|
"~0.28.172.in-addr.arpa"
|
2023-06-08 13:19:17 +00:00
|
|
|
];
|
|
|
|
in
|
|
|
|
{
|
|
|
|
privateKeyFile = config.sops.secrets."ni/wireguard/private-key".path;
|
|
|
|
listenPort = wireguardPort;
|
2023-06-22 10:01:19 +00:00
|
|
|
dns = with interfaces.lan; [ IPv4.address IPv6.address ];
|
2023-06-08 13:19:17 +00:00
|
|
|
postUp =
|
|
|
|
let
|
|
|
|
resolvectl = "${lib.getBin pkgs.systemd}/bin/resolvectl";
|
|
|
|
in
|
|
|
|
''
|
2023-06-19 04:28:33 +00:00
|
|
|
${resolvectl} domain ${wireguardIFName} ${lib.concatStringsSep " " domains}
|
|
|
|
${resolvectl} dnssec ${wireguardIFName} no
|
2023-06-08 13:19:17 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
address = with wireguardPeers.desktop; [
|
|
|
|
"${IPv4}/32"
|
|
|
|
"${IPv6}/128"
|
|
|
|
];
|
2023-05-20 22:37:03 +00:00
|
|
|
|
2023-06-08 13:19:17 +00:00
|
|
|
peers = [
|
|
|
|
# The "server" peer.
|
|
|
|
{
|
|
|
|
publicKey = lib.removeSuffix "\n" (lib.readFile ../plover/files/wireguard/wireguard-public-key-plover);
|
|
|
|
presharedKeyFile = config.sops.secrets."ni/wireguard/preshared-keys/plover".path;
|
|
|
|
allowedIPs = wireguardAllowedIPs;
|
2023-06-22 10:01:19 +00:00
|
|
|
endpoint = "${interfaces.wan.IPv4.address}:${toString wireguardPort}";
|
2023-06-11 04:28:36 +00:00
|
|
|
persistentKeepalive = 25;
|
2023-06-08 13:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# The "phone" peer.
|
|
|
|
{
|
|
|
|
publicKey = lib.removeSuffix "\n" (lib.readFile ../plover/files/wireguard/wireguard-public-key-phone);
|
|
|
|
presharedKeyFile = config.sops.secrets."ni/wireguard/preshared-keys/phone".path;
|
|
|
|
allowedIPs = wireguardAllowedIPs;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-11-25 11:55:30 +00:00
|
|
|
}
|