mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 02:09:26 +08:00
modules.services.nixvirt: init
This commit is contained in:
@@ -30,7 +30,8 @@ inputs:
|
||||
hardware.cpus = [ "intel" ];
|
||||
services =
|
||||
{
|
||||
beesd."/".hashTableSizeMB = 128;
|
||||
# 大部分空间用于存储虚拟机(nodatacow),其它内容不多
|
||||
beesd."/".hashTableSizeMB = 32;
|
||||
sshd = {};
|
||||
};
|
||||
virtualization.kvmHost = { enable = true; gui = true; };
|
||||
|
||||
@@ -27,4 +27,5 @@ mungekey -k munge.key
|
||||
mv munge.key munge.key.orig
|
||||
sops -e --input-type binary --output-type binary munge.key.orig > munge.key
|
||||
rm munge.key.orig
|
||||
sudo nix build --store 'local?root=/mnt' --option substituters https://nix-store.chn.moe --option require-sigs false /nix/store/khhqmly5295ns33dz1s3m3sb79icj6bi-nixos-system-srv3-production-24.11
|
||||
```
|
||||
|
||||
21
flake.lock
generated
21
flake.lock
generated
@@ -982,6 +982,26 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixvirt": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1741549407,
|
||||
"narHash": "sha256-f9SXK+/rvlryDNlc++Eva/hYjbkf7OCalWwmwifRhtI=",
|
||||
"owner": "AshleyYakeley",
|
||||
"repo": "NixVirt",
|
||||
"rev": "9950b932dce4ae6b9bda7c83d41705c1a14e10f0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "AshleyYakeley",
|
||||
"repo": "NixVirt",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nu-scripts": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@@ -1287,6 +1307,7 @@
|
||||
"nixpkgs-23.05": "nixpkgs-23.05",
|
||||
"nixpkgs-23.11": "nixpkgs-23.11",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"nixvirt": "nixvirt",
|
||||
"nu-scripts": "nu-scripts",
|
||||
"nur-linyinfeng": "nur-linyinfeng",
|
||||
"nur-xddxdd": "nur-xddxdd",
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
winapps = { url = "github:winapps-org/winapps/feat-nix-packaging"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
aagl = { url = "github:ezKEa/aagl-gtk-on-nix/release-24.11"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
cachyos-lts.url = "github:drakon64/nixos-cachyos-kernel";
|
||||
nixvirt = { url = "github:AshleyYakeley/NixVirt"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
|
||||
misskey = { url = "git+https://github.com/CHN-beta/misskey?submodules=1"; flake = false; };
|
||||
rsshub = { url = "github:DIYgod/RSSHub"; flake = false; };
|
||||
|
||||
@@ -11,6 +11,7 @@ inputs: let inherit (inputs) topInputs; in
|
||||
{ config.chaotic.nyx.overlay.onTopOf = "user-pkgs"; }
|
||||
topInputs.catppuccin.nixosModules.catppuccin
|
||||
topInputs.aagl.nixosModules.default
|
||||
topInputs.nixvirt.nixosModules.default
|
||||
(inputs:
|
||||
{
|
||||
config =
|
||||
|
||||
47
modules/services/nixvirt.nix
Normal file
47
modules/services/nixvirt.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.services.nixvirt = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.attrsOf (types.submodule
|
||||
{
|
||||
storage = mkOption { type = types.nonEmptyStr; };
|
||||
memoryGB = mkOption { type = types.ints.unsigned; };
|
||||
cpus = mkOption { type = types.ints.unsigned; };
|
||||
vncPort = mkOption { type = types.ints.unsigned; };
|
||||
}));
|
||||
default = null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.services) nixvirt; in inputs.lib.mkIf (nixvirt != {})
|
||||
{
|
||||
# TODO: switch on nixos.virtualisation.kvm
|
||||
virtualisation.libvirt =
|
||||
{
|
||||
enable = true;
|
||||
verbose = true;
|
||||
connections."qemu:///system" = let inherit (inputs.topInputs.nixvirt) lib; in
|
||||
{
|
||||
domains =
|
||||
[{
|
||||
definition = lib.domain.writeXML (lib.domain.templates.linux
|
||||
{
|
||||
name = "Penguin";
|
||||
uuid = "cc7439ed-36af-4696-a6f2-1f0c4474d87e";
|
||||
memory = { count = 6; unit = "GiB"; };
|
||||
storage_vol = { pool = "MyPool"; volume = "Penguin.qcow2"; };
|
||||
});
|
||||
}];
|
||||
networks =
|
||||
[{
|
||||
definition = lib.network.writeXML (lib.network.templates.bridge
|
||||
{
|
||||
uuid = "8f403474-f8d6-4fa7-991a-f62f40d51191";
|
||||
subnet_byte = 122;
|
||||
});
|
||||
active = true;
|
||||
}];
|
||||
# 不通过它来定义存储,手动控制存储
|
||||
pools = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user