This commit is contained in:
root 2024-05-27 19:03:21 +02:00
parent 9ca8c5e59b
commit d6a6b21ea4
3 changed files with 191 additions and 0 deletions

View file

@ -2,6 +2,12 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
outputs = { self, nixpkgs, ... }@attrs: {
nixosConfigurations."oven" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = attrs;
modules = [ ./oven/configuration.nix ];
};
nixosConfigurations."pastila" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = attrs;

156
oven/configuration.nix Normal file
View file

@ -0,0 +1,156 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the GRUB 2 boot loader.
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/sda";
# serial console
boot.kernelParams = [ "console=ttyS1" ];
# Activate nix flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# network config
networking =
let
# ports forwarded to pastila (on the same port)
portsPastila = [
80
22
];
pastila = proto: portFrom: portTo: {
destination = "10.0.42.100:" + builtins.toString portTo;
proto = proto;
sourcePort = portFrom;
};
in
{
hostName = "oven";
useDHCP = false;
# Static public IP, online.net gateway & DNS
interfaces."enp1s0".ipv4.addresses = [{
address = "51.15.168.181";
prefixLength = 24;
}];
defaultGateway = {
address = "51.15.168.1";
interface = "enp1s0";
};
nameservers = [
"51.159.47.28"
"51.159.47.26"
];
bridges = {
"br0" = { interfaces = []; };
};
interfaces."br0".ipv4.addresses = [{
address = "10.0.42.1";
prefixLength = 24;
}];
nat = {
enable = true;
internalInterfaces = ["br0"];
externalInterface = "enp1s0";
forwardPorts =
builtins.map (port: pastila "tcp" port port) portsPastila ++
builtins.map (port: pastila "udp" port port) portsPastila;
};
firewall = {
allowedTCPPorts = portsPastila ++ [ 2222 ];
allowedUDPPorts = portsPastila;
};
};
# Set your time zone.
time.timeZone = "Europe/Paris";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "fr-bepo";
};
users.users.armael = {
isNormalUser = true;
extraGroups = [ "wheel" "libvirtd" ];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDRa9ABfjRX61sygceiefWnyWK0+gZ5YaaCDxUQeE2LT armael@teabox"
];
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
vim
wget
emacs
htop
bmon
git
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.openssh.settings.PermitRootLogin = "no";
services.openssh.ports = [ 2222 ];
# Set up the hypervisor
virtualisation.libvirtd = {
enable = true;
qemu.runAsRoot = false;
onShutdown = "shutdown";
parallelShutdown = 10;
};
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "24.05"; # Did you read the comment?
}

View file

@ -0,0 +1,29 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ahci" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/01b807a8-cd90-43a3-9eea-09e0dbff23af";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/3bf7e190-38c0-40e7-89ab-e577f835f337";
fsType = "ext2";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/97a10cbc-deb3-4b8e-8c77-9855c3cb6456"; }
];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}