From dac5c2a1a8c60b1985546e8551e3fd879856c970 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Tue, 17 Jan 2023 13:45:37 +0100 Subject: [PATCH] Initial virtualisation server setup --- flake.lock | 39 +++++-- flake.nix | 5 + machines/default.nix | 3 + machines/odin/configuration.nix | 57 ++++++++++ machines/odin/storage.nix | 104 ++++++++++++++++++ modules/base/plymouth-nixos-blur/default.nix | 8 +- .../plymouth-nixos-blur/nixos-blur.plymouth | 4 +- 7 files changed, 205 insertions(+), 15 deletions(-) create mode 100644 machines/odin/configuration.nix create mode 100644 machines/odin/storage.nix diff --git a/flake.lock b/flake.lock index 4b72c03..63040dc 100644 --- a/flake.lock +++ b/flake.lock @@ -24,6 +24,26 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673488360, + "narHash": "sha256-oqYrGBGA3HfZD9E2LSa+WHGJy40DfHgc3Z3oe0Mnstk=", + "owner": "nix-community", + "repo": "disko", + "rev": "d4ad9595432959440984b2ba33064cfe3399d0e3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "emacs-overlay": { "inputs": { "flake-utils": [ @@ -34,11 +54,11 @@ ] }, "locked": { - "lastModified": 1673602276, - "narHash": "sha256-MdtgFTSRTxWQtZAsv061haJh1iRKwORtUl2V6vWA9CY=", + "lastModified": 1673630223, + "narHash": "sha256-0ZmQaImsdtJ8KKIuV0BuxM85nKE7FtagrV3ACuuf4k4=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "0e8abd1a198a954a1206b0306c10285da76a1d1a", + "rev": "b14ac8cc285517482b2fd8e20db355a3980f59f0", "type": "github" }, "original": { @@ -179,11 +199,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1673526825, - "narHash": "sha256-GukJtWwrkkf3ApkBTc7tW7DcsS1gKHWWs7OJYnv9om8=", + "lastModified": 1673609484, + "narHash": "sha256-kVaUV1RZ6k4/Re2/IEsnwz/SVhU4ptWrpVbE1qArSY8=", "owner": "Hyprwm", "repo": "Hyprland", - "rev": "cbd31ba481c5be65e015647851eef4b396869073", + "rev": "9c77415cda40eb334dd9306c504c0003dc14b53f", "type": "github" }, "original": { @@ -378,11 +398,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1673281605, - "narHash": "sha256-v6U0G3pJe0YaIuD1Ijhz86EhTgbXZ4f/2By8sLqFk4c=", + "lastModified": 1673627351, + "narHash": "sha256-oppRxEg/7ICcG67ErBvu1UlXt3su6zMcNoQmKaHPs5I=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "f8992fb404c7e79638192a10905b7ea985818050", + "rev": "496e4505c2ddf5f205242eae8064d7d89cd976c0", "type": "github" }, "original": { @@ -394,6 +414,7 @@ "root": { "inputs": { "deploy-rs": "deploy-rs", + "disko": "disko", "emacs-overlay": "emacs-overlay", "flake-utils": "flake-utils", "ha-now-playing": "ha-now-playing", diff --git a/flake.nix b/flake.nix index 85a265d..74b22fb 100644 --- a/flake.nix +++ b/flake.nix @@ -59,6 +59,11 @@ inputs.rust-overlay.follows = "rust-overlay"; }; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nomachine = { url = "github:rytec-nl/nixpkgs/submit/add-nomachine-server"; }; diff --git a/machines/default.nix b/machines/default.nix index 9b95012..aefa2e5 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -21,6 +21,9 @@ inputs: { minio = { config = import ./minio/configuration.nix inputs; }; + odin = { + config = import ./odin/configuration.nix inputs; + }; proxy = { config = import ./proxy/configuration.nix inputs; }; diff --git a/machines/odin/configuration.nix b/machines/odin/configuration.nix new file mode 100644 index 0000000..4381e21 --- /dev/null +++ b/machines/odin/configuration.nix @@ -0,0 +1,57 @@ +{ nixos-hardware, disko, ... }: +{ modulesPath, ... }: +{ + imports = [ + "${modulesPath}/nixos/virtualisation/qemu-guest-agent.nix" + + nixos-hardware.nixosModules.common-cpu-intel + nixos-hardware.nixosModules.common-pc-ssd + + disko.nixosModules.disko + + ./storage.nix + ]; + + eboskma = { + users.erwin = { + enable = true; + }; + + base = { + plymouth.enable = true; + }; + + nix-common = { + enable = true; + remote-builders = true; + }; + + # libvirt.enable = true; + systemd.enable = true; + }; + + networking.hostName = "odin"; + + boot = { + loader = { + systemd-boot = { + enable = true; + configurationLimit = 10; + }; + efi.canTouchEfiVariables = true; + }; + + initrd = { + availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + kernelModules = [ ]; + }; + + kernelModules = [ "kvm-intel" ]; + }; + + hardware.enableAllFirmware = true; + + services.qemuGuest = { + enable = true; + }; +} diff --git a/machines/odin/storage.nix b/machines/odin/storage.nix new file mode 100644 index 0000000..2dbdd57 --- /dev/null +++ b/machines/odin/storage.nix @@ -0,0 +1,104 @@ +{ disko, ... }: +{ + disko.devices = { + disk = { + sda = { + device = "/dev/vda"; + type = "disk"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + name = "boot"; + start = "1MiB"; + end = "512MiB"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + type = "partition"; + name = "root_pv_sda"; + start = "512MiB"; + end = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + } + ]; + }; + }; + sdb = { + device = "/dev/sdb"; + type = "disk"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + name = "root_pv_sdb"; + start = "0%"; + end = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + } + ]; + }; + }; + }; + + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "32GiB"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ "defaults" ]; + }; + }; + + swap = { + size = "8GiB"; + content = { + type = "swap"; + randomEncryption = false; + }; + }; + + data = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/data"; + mountOptions = [ "defaults" ]; + }; + }; + }; + }; + }; + }; + # fileSystems."/" = { + # device = "/dev/disk/by-label/nixos"; + # fsType = "ext4"; + # }; + + # fileSystems."/data" = { + # device = "/dev/disk/by-label/data"; + # fsType = "btrfs"; + # }; + +} diff --git a/modules/base/plymouth-nixos-blur/default.nix b/modules/base/plymouth-nixos-blur/default.nix index db464d6..7d9d6b7 100644 --- a/modules/base/plymouth-nixos-blur/default.nix +++ b/modules/base/plymouth-nixos-blur/default.nix @@ -11,11 +11,11 @@ stdenv.mkDerivation { phases = [ "installPhase" ]; installPhase = '' - install -Dm 0644 *.png $out/share/plymouth/themes/nixos-blur/images/ - install -Dm 0644 nixos-blur.script $out/share/plymouth/themes/nixos-blur/ - install -Dm 0644 nixos-blur.plymouth $out/share/plymouth/themes/nixos-blur/ - sed -i 's/@OUT@/${placeholder "out"}/' $out/share/plymouth/themes/nixos-blur/nixos-blur.plymouth + install -Dm 0644 -t $out/share/plymouth/themes/nixos-blur/images/ $src/*.png + install -Dm 0644 $src/nixos-blur.script $out/share/plymouth/themes/nixos-blur/nixos-blur.script + install -Dm 0644 $src/nixos-blur.plymouth $out/share/plymouth/themes/nixos-blur/nixos-blur.plymouth ''; + # substituteInPlace $out/share/plymouth/themes/nixos-blur/nixos-blur.plymouth --replace '@OUT@' $out meta = with lib; { description = "Plymouth theme nixos-blur"; diff --git a/modules/base/plymouth-nixos-blur/nixos-blur.plymouth b/modules/base/plymouth-nixos-blur/nixos-blur.plymouth index 431740f..c355b33 100644 --- a/modules/base/plymouth-nixos-blur/nixos-blur.plymouth +++ b/modules/base/plymouth-nixos-blur/nixos-blur.plymouth @@ -5,5 +5,5 @@ Comment=created By Gurkan (gurkan.in) ModuleName=script [script] -ImageDir=@OUT@/plymouth/themes/nixos-blur/images -ScriptFile=@OUT@/plymouth/themes/nixos-blur/nixos-blur.script +ImageDir=/etc/plymouth/themes/nixos-blur/images +ScriptFile=/etc/plymouth/themes/nixos-blur/nixos-blur.script