Files
roowho2/nix/vm.nix
T
oysteikt f281bff291
Build and test / build (push) Successful in 1m52s
Build and test / test (push) Successful in 2m1s
Build and test / check (push) Successful in 2m6s
Build and test / docs (push) Successful in 5m7s
nix/vm: enable bsd-fingerd in container
2026-07-21 05:19:19 +09:00

166 lines
4.1 KiB
Nix

{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.roowho2-crane
];
};
in
nixpkgs.lib.nixosSystem {
inherit system pkgs;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
"${nixpkgs}/nixos/tests/common/user-account.nix"
self.nixosModules.default
({ config, lib, ... }: {
system.stateVersion = config.system.nixos.release;
virtualisation.graphics = false;
virtualisation.memorySize = 256;
boot.kernelParams = [
"audit=1"
"audit_backlog_limit=1024"
];
users.users.alice.extraGroups = [ "wheel" ];
users.users.bob.uid = 1001;
services.getty.autologinUser = "alice";
users.motd = ''
=================================
Welcome to the roowho2 vm!
Try running any of:
rwho
ruptime
finger "alice"
To log into other containers, use:
machinectl shell c1
machinectl shell c2
Password for alice is 'foobar'
To exit, press Ctrl+A, then X
=================================
'';
services.roowho2 = {
enable = true;
settings.log_level = "trace";
settings.fingerd.ignoreUsers = [
"bob"
];
};
programs.vim = {
enable = true;
defaultEditor = true;
};
security.polkit.enable = true;
networking = {
useNetworkd = true;
macvlans.mv-eth0-host = {
interface = "eth0";
mode = "bridge";
};
};
systemd.network.enable = true;
systemd.network.networks."mv-eth0-host" = {
matchConfig.Name = "mv-eth0-host";
gateway = [
"10.0.0.255"
];
DHCP = "no";
address = [
"10.0.0.128/24"
];
};
containers = let
commonContainerConfig = n: {
autoStart = true;
macvlans = [ "eth0" ];
config = {
imports = [
"${nixpkgs}/nixos/tests/common/user-account.nix"
self.nixosModules.default
];
system.stateVersion = config.system.nixos.release;
nixpkgs.pkgs = pkgs;
networking = {
hostName = "c${toString n}";
useDHCP = false;
useNetworkd = true;
useHostResolvConf = false;
};
systemd.network.enable = true;
systemd.network.networks."mv-eth0" = {
matchConfig.Name = "mv-eth0";
gateway = [ "10.0.0.255" ];
address = [ "10.0.0.${toString n}/24" ];
dhcpV4Config.ClientIdentifier = "mac";
};
users.users.alice.extraGroups = [ "wheel" ];
users.motd = ''
=================================
Welcome to the roowho2 c${toString n} container!
Try running any of:
rwho
ruptime
Password for alice is 'foobar'
=================================
'';
services.roowho2 = {
enable = true;
};
programs.vim = {
enable = true;
defaultEditor = true;
};
systemd.sockets.fingerd = {
wantedBy = [ "sockets.target" ];
socketConfig = {
ListenStream = 79;
Accept = true;
};
};
systemd.services."fingerd@" = {
serviceConfig = {
Type = "simple";
StandardInput = "socket";
StandardOutput = "socket";
StandardError = "journal";
ExecStart = "${pkgs.bsd-fingerd}/bin/fingerd -L ${lib.getExe pkgs.bsd-finger} -t 60";
};
};
networking.firewall.allowedTCPPorts = [ 79 ];
};
};
in {
c1 = commonContainerConfig 1;
c2 = commonContainerConfig 2;
};
})
];
}