mirror of
https://github.com/tuxdotrs/nix-config.git
synced 2026-06-17 02:06:32 +05:30
feat(vps): add vps host
This commit is contained in:
57
modules/hosts/vps/config.nix
Normal file
57
modules/hosts/vps/config.nix
Normal file
@@ -0,0 +1,57 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
flake.modules.nixos.vps =
|
||||
{
|
||||
hostName,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports =
|
||||
with config.flake.modules.nixos;
|
||||
[
|
||||
boot
|
||||
hardware
|
||||
networking
|
||||
virtualisation
|
||||
services
|
||||
]
|
||||
++ [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
tnix = {
|
||||
boot = {
|
||||
legacy.enable = true;
|
||||
|
||||
impermanence = {
|
||||
enable = true;
|
||||
|
||||
home = {
|
||||
directories = [
|
||||
".local/share/nvim"
|
||||
".local/share/zsh"
|
||||
".local/share/zoxide"
|
||||
".local/state/lazygit"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.openssh.enable = true;
|
||||
|
||||
virtualisation = {
|
||||
docker.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
# --- Networking ---
|
||||
networking = {
|
||||
hostName = hostName;
|
||||
networkmanager.enable = true;
|
||||
firewall.enable = false;
|
||||
};
|
||||
|
||||
system.stateVersion = "26.05";
|
||||
};
|
||||
}
|
||||
23
modules/hosts/vps/default.nix
Normal file
23
modules/hosts/vps/default.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hostName = "vps";
|
||||
userName = "tux";
|
||||
userEmail = "t@tux.rs";
|
||||
system = "x86_64-linux";
|
||||
unstable = true;
|
||||
nixpkgs = if unstable then inputs.nixpkgs else inputs.nixpkgs-stable;
|
||||
in
|
||||
{
|
||||
flake.nixosConfigurations."${hostName}" = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit hostName userName userEmail; };
|
||||
modules = [
|
||||
config.flake.modules.nixos.core
|
||||
config.flake.modules.nixos.${hostName}
|
||||
];
|
||||
};
|
||||
}
|
||||
82
modules/hosts/vps/disko.nix
Normal file
82
modules/hosts/vps/disko.nix
Normal file
@@ -0,0 +1,82 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake.modules.nixos.vps =
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
hasOptinPersistence = config.tnix.boot.impermanence.enable;
|
||||
isLegacy = config.tnix.boot.legacy.enable;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
inputs.disko.nixosModules.disko
|
||||
];
|
||||
|
||||
disko.devices.disk.primary = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
size = "1G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
"umask=0077"
|
||||
];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "100%";
|
||||
type = "8300";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
# Base subvolumes that always exist
|
||||
subvolumes = {
|
||||
"/root" = {
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
"space_cache=v2"
|
||||
];
|
||||
mountpoint = "/";
|
||||
};
|
||||
"/nix" = {
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
"noacl"
|
||||
"space_cache=v2"
|
||||
];
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
}
|
||||
# Conditionally merge /persist only when impermanence is enabled
|
||||
// lib.optionalAttrs hasOptinPersistence {
|
||||
"/persist" = {
|
||||
mountOptions = [
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
"space_cache=v2"
|
||||
];
|
||||
mountpoint = "/persist";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs isLegacy {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/hosts/vps/home.nix
Normal file
6
modules/hosts/vps/home.nix
Normal file
@@ -0,0 +1,6 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.modules.homeManager.vps = {
|
||||
home.stateVersion = "26.05";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user