Add LXC host for minimal LXC setup.
This commit is contained in:
parent
3d60c8b99a
commit
d2cf583200
5 changed files with 116 additions and 5 deletions
10
home/toph/lxc/default.nix
Normal file
10
home/toph/lxc/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
## Required Configs ##
|
||||||
|
../common/core # required
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,4 +1,9 @@
|
||||||
{ modulesPath, ... }:
|
{
|
||||||
|
modulesPath,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# Include the default lxc/lxd configuration.
|
# Include the default lxc/lxd configuration.
|
||||||
|
@ -6,10 +11,36 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
# Treats the system as a container.
|
# Treats the system as a container.
|
||||||
boot.isContainer = true;
|
boot = {
|
||||||
|
isContainer = true;
|
||||||
|
};
|
||||||
|
|
||||||
# Set your system kind (needed for flakes)
|
console.enable = true;
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
|
||||||
|
nix.settings = {
|
||||||
|
sandbox = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = {
|
||||||
|
mounts = [
|
||||||
|
{
|
||||||
|
enable = false;
|
||||||
|
where = "/sys/kernel/debug";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# By default only starts getty on tty0 but first on LXC is tty1
|
||||||
|
services."autovt@".unitConfig.ConditionPathExists = [
|
||||||
|
""
|
||||||
|
"/dev/%I"
|
||||||
|
];
|
||||||
|
|
||||||
|
# These are disabled by `console.enable` but console via tty is the default in Proxmox
|
||||||
|
services."getty@tty1".enable = lib.mkForce true;
|
||||||
|
services."autovt@".enable = lib.mkForce true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
|
||||||
# Supress systemd units that don't work because of LXC.
|
# Supress systemd units that don't work because of LXC.
|
||||||
# https://blog.xirion.net/posts/nixos-proxmox-lxc/#configurationnix-tweak
|
# https://blog.xirion.net/posts/nixos-proxmox-lxc/#configurationnix-tweak
|
||||||
|
|
58
hosts/nixos/lxc/default.nix
Normal file
58
hosts/nixos/lxc/default.nix
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
###############################################################
|
||||||
|
#
|
||||||
|
# Barebones LXC Container for Proxmox
|
||||||
|
#
|
||||||
|
# This is a special host for LXC installations in Proxmox.
|
||||||
|
# Has the barebones configuration needed to then setup the wanted new host config
|
||||||
|
#
|
||||||
|
###############################################################
|
||||||
|
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
username = "toph";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = lib.flatten [
|
||||||
|
## Hardware ##
|
||||||
|
./hardware.nix
|
||||||
|
|
||||||
|
(map lib.custom.relativeToRoot [
|
||||||
|
## Required Configs ##
|
||||||
|
"hosts/common/core"
|
||||||
|
|
||||||
|
## Proxy Specific ##
|
||||||
|
"hosts/users/${username}" # # Not the best solution but I always have one user so ¯\_(ツ)_/¯
|
||||||
|
])
|
||||||
|
];
|
||||||
|
|
||||||
|
## Host Specifications ##
|
||||||
|
hostSpec = {
|
||||||
|
hostName = "lxc";
|
||||||
|
username = username;
|
||||||
|
handle = "tophC7";
|
||||||
|
password = "[REDACTED]";
|
||||||
|
[REDACTED];
|
||||||
|
email = "[REDACTED]";
|
||||||
|
userFullName = "[REDACTED]";
|
||||||
|
isARM = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
enableIPv6 = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
## System-wide packages ##
|
||||||
|
programs.nix-ld.enable = true;
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
lazydocker
|
||||||
|
];
|
||||||
|
|
||||||
|
# https://wiki.nixos.org/wiki/FAQ/When_do_I_update_stateVersion
|
||||||
|
system.stateVersion = "25.05";
|
||||||
|
}
|
12
hosts/nixos/lxc/hardware.nix
Normal file
12
hosts/nixos/lxc/hardware.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = lib.flatten [
|
||||||
|
(map lib.custom.relativeToRoot [
|
||||||
|
"hosts/common/optional/system/lxc.nix"
|
||||||
|
"hosts/common/optional/system/pool.nix"
|
||||||
|
])
|
||||||
|
];
|
||||||
|
}
|
|
@ -46,7 +46,7 @@ in
|
||||||
# root's ssh key are mainly used for remote deployment, borg, and some other specific ops
|
# root's ssh key are mainly used for remote deployment, borg, and some other specific ops
|
||||||
users.users.root = {
|
users.users.root = {
|
||||||
shell = pkgs.bash;
|
shell = pkgs.bash;
|
||||||
password = hostSpec.password;
|
password = lib.mkForce hostSpec.password;
|
||||||
openssh.authorizedKeys.keys = config.users.users.${hostSpec.username}.openssh.authorizedKeys.keys; # root's ssh keys are mainly used for remote deployment.
|
openssh.authorizedKeys.keys = config.users.users.${hostSpec.username}.openssh.authorizedKeys.keys; # root's ssh keys are mainly used for remote deployment.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue