dotfiles/nixos/boxes/vpsfree1/vpsfree1-vpsadminos.nix

62 lines
2 KiB
Nix
Raw Normal View History

2022-03-05 14:34:27 +00:00
# This file provides compatibility for NixOS to run in a container on vpsAdminOS
# hosts.
#
# If you're experiencing issues, try updating this file to the latest version
# from vpsAdminOS repository:
#
# https://github.com/vpsfreecz/vpsadminos/blob/staging/os/lib/nixos-container/vpsadminos.nix
2022-12-19 09:09:08 +00:00
{
config,
pkgs,
lib,
...
}:
with lib; let
nameservers = ["1.1.1.1" "2606:4700:4700::1111"];
2022-03-10 12:25:23 +00:00
in {
networking.nameservers = mkDefault nameservers;
2022-12-19 09:09:08 +00:00
services.resolved = mkDefault {fallbackDns = nameservers;};
2022-03-05 14:34:27 +00:00
networking.dhcpcd.extraConfig = "noipv4ll";
systemd.services.systemd-sysctl.enable = false;
systemd.sockets."systemd-journald-audit".enable = false;
2022-12-19 09:09:08 +00:00
systemd.mounts = [
{
where = "/sys/kernel/debug";
enable = false;
}
];
2022-03-05 14:34:27 +00:00
systemd.services.systemd-udev-trigger.enable = false;
systemd.services.rpc-gssd.enable = false;
boot.isContainer = true;
boot.enableContainers = mkDefault true;
boot.loader.initScript.enable = true;
boot.specialFileSystems."/run/keys".fsType = mkForce "tmpfs";
2022-12-19 09:09:08 +00:00
boot.systemdExecutable =
mkDefault
"/run/current-system/systemd/lib/systemd/systemd systemd.unified_cgroup_hierarchy=0";
2022-03-05 14:34:27 +00:00
# Overrides for <nixpkgs/nixos/modules/virtualisation/container-config.nix>
documentation.enable = mkOverride 500 true;
documentation.nixos.enable = mkOverride 500 true;
networking.useHostResolvConf = mkOverride 500 false;
services.openssh.startWhenNeeded = mkOverride 500 false;
# Bring up the network, /ifcfg.{add,del} are supplied by the vpsAdminOS host
systemd.services.networking-setup = {
description = "Load network configuration provided by the vpsAdminOS host";
2022-12-19 09:09:08 +00:00
before = ["network.target"];
wantedBy = ["network.target"];
after = ["network-pre.target"];
path = [pkgs.iproute];
2022-03-05 14:34:27 +00:00
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.bash}/bin/bash /ifcfg.add";
ExecStop = "${pkgs.bash}/bin/bash /ifcfg.del";
};
unitConfig.ConditionPathExists = "/ifcfg.add";
};
}