WiP
This commit is contained in:
parent
6d9a15d2f2
commit
7813b8e037
10 changed files with 111 additions and 25 deletions
0
TODO.md
Normal file
0
TODO.md
Normal file
|
@ -22,11 +22,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1734536697,
|
||||
"narHash": "sha256-G/HnRTtU+ob8x967kjzMRqjNFbAdllrcjYc+IcaR15Y=",
|
||||
"lastModified": 1734623593,
|
||||
"narHash": "sha256-iA3kxtbds7yOc77oRBz2On9ZmOVI/1Pic+YQtYUyIsg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9c40bef08a5bdc0ccc3207f4282a1ded83e77a7a",
|
||||
"rev": "8af52ff6ba2ed83047881e877718db3bb02fad85",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./hardware-config.nix
|
||||
];
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
kropcloud = {
|
||||
|
@ -19,5 +23,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
services.qemuGuest.enable = true;
|
||||
|
||||
system.stateVersion = "24.11";
|
||||
}
|
27
hosts/base/hardware-config.nix
Normal file
27
hosts/base/hardware-config.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"ata_piix"
|
||||
"uhci_hcd"
|
||||
"virtio_pci"
|
||||
"virtio_scsi"
|
||||
"sd_mod"
|
||||
"sr_mod"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
kropcloud = {
|
||||
networking = {
|
||||
ipv4 = {
|
||||
enable = true;
|
||||
address = "192.168.1.160";
|
||||
prefixLength = 24;
|
||||
};
|
6
lib.nix
6
lib.nix
|
@ -11,8 +11,8 @@
|
|||
nixpkgs.lib.nixosSystem {
|
||||
system = arch;
|
||||
modules = [
|
||||
./hosts/base.nix
|
||||
./hosts/${name}.nix
|
||||
./hosts/base
|
||||
./hosts/${name}
|
||||
./nixosModules
|
||||
(
|
||||
{ ... }:
|
||||
|
@ -22,6 +22,8 @@
|
|||
};
|
||||
}
|
||||
)
|
||||
|
||||
inputs.disko.nixosModules.disko
|
||||
];
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
./networking
|
||||
./users
|
||||
./locale
|
||||
./drives
|
||||
];
|
||||
}
|
||||
|
|
51
nixosModules/drives/default.nix
Normal file
51
nixosModules/drives/default.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.kropcloud.drives;
|
||||
in
|
||||
{
|
||||
options.kropcloud.drives = {
|
||||
hasSecondDrive = lib.mkEnableOption "Whence this VM has second drive";
|
||||
};
|
||||
config = {
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = "/dev/sda";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
type = "EF00";
|
||||
size = "512M";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
end = "-8GB";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
};
|
||||
};
|
||||
swap = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "swap";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -5,6 +5,20 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.kropcloud.networking;
|
||||
ipopts = version: {
|
||||
address = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The server IPv${version} address";
|
||||
example = if version == 4 then "192.168.1.155" else null;
|
||||
default = null;
|
||||
};
|
||||
prefixLength = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
description = "The server IPv${version} address prefix length";
|
||||
default = null;
|
||||
example = if version == 4 then 24 else 64;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.kropcloud.networking = {
|
||||
|
@ -14,31 +28,16 @@ in
|
|||
default = true;
|
||||
example = false;
|
||||
};
|
||||
# TODO: fix this madness
|
||||
ipv4 = {
|
||||
enable = lib.mkEnableOption "Whence to enable IPv4 configuration";
|
||||
address = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The server IPv4 address";
|
||||
example = "192.168.1.155";
|
||||
default = null;
|
||||
};
|
||||
prefixLength = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = "The server IPv4 address prefix length";
|
||||
default = 24;
|
||||
example = 24;
|
||||
};
|
||||
};
|
||||
ipv4 = ipopts 4;
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = !(cfg.ipv4.enable && (cfg.ipv4.address == null || cfg.ipv4.address == "" || cfg.ipv4.prefixLength == null));
|
||||
assertion = !(cfg.ipv4.address == null || cfg.ipv4.prefixLength == null);
|
||||
message = ''
|
||||
You need to provide valid values for both `address` and `prefixLength` in `kropcloud.networking.ipv4`
|
||||
when `kropcloud.networking.ipv4.enable` is true.
|
||||
when either is set.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
@ -50,7 +49,7 @@ in
|
|||
};
|
||||
interfaces = {
|
||||
ens18 = {
|
||||
ipv4.addresses = lib.mkIf cfg.ipv4.enable [
|
||||
ipv4.addresses = lib.mkIf (cfg.ipv4.address != null || cfg.ipv4.prefixLength != null) [
|
||||
{
|
||||
address = cfg.ipv4.address;
|
||||
prefixLength = cfg.ipv4.prefixLength;
|
||||
|
@ -58,6 +57,7 @@ in
|
|||
];
|
||||
};
|
||||
};
|
||||
useDHCP = (cfg.ipv4.address == null || cfg.ipv4.prefixLength == null);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue