Initial commit
This commit is contained in:
commit
4602228be9
13 changed files with 451 additions and 0 deletions
167
flake.nix
Normal file
167
flake.nix
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
inputs = {
|
||||
self.submodules = true;
|
||||
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
# https://github.com/NixOS/nixpkgs/pull/444133
|
||||
nixpkgs.url = "git+https://github.com/valpackett/nixpkgs?shallow=1&submodules=1&ref=val/tsvwswkqrrsr";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
virtwl.url = "git+https://github.com/valpackett/wayland-proxy-virtwl?shallow=1&submodules=1&ref=wip";
|
||||
virtwl.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {self, nixpkgs, flake-utils, virtwl, ...}:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in {
|
||||
|
||||
packages.libkrunfw = pkgs.libkrunfw;
|
||||
# packages.libkrunfw = (pkgs.libkrunfw.overrideAttrs {
|
||||
# version = "4.10.0";
|
||||
# src = pkgs.fetchFromGitHub {
|
||||
# owner = "containers";
|
||||
# repo = "libkrunfw";
|
||||
# tag = "v4.10.0";
|
||||
# hash = "sha256-mq2gw0+xL6qUZE/fk0vLT3PEpzPV8p+iwRFJHXVOMnk=";
|
||||
# };
|
||||
# kernelSrc = pkgs.fetchurl {
|
||||
# url = "mirror://kernel/linux/kernel/v6.x/linux-6.12.34.tar.xz";
|
||||
# hash = "sha256-p/P+OB9n7KQXLptj77YaFL1/nhJ44DYD0P9ak/Jwwk0=";
|
||||
# };
|
||||
# cargoHash = "";
|
||||
# });
|
||||
|
||||
packages.libkrun = (pkgs.libkrun.override {
|
||||
withBlk = true;
|
||||
withGpu = true;
|
||||
withSound = true;
|
||||
withNet = true;
|
||||
libkrunfw = self.packages.${system}.libkrunfw;
|
||||
}).overrideAttrs (old: {
|
||||
src = ./libkrun;
|
||||
cargoDeps = pkgs.rustPlatform.importCargoLock {
|
||||
lockFile = ./libkrun/Cargo.lock;
|
||||
};
|
||||
# mesonFlags = [ (pkgs.lib.mesonOption "decoders" "gles,vulkan,composer") ]; # no magma(?)
|
||||
});
|
||||
|
||||
packages.muvm = (pkgs.muvm.override {
|
||||
libkrun = self.packages.${system}.libkrun;
|
||||
}).overrideAttrs (old: {
|
||||
postPatch = ""; # no more sysctl; udevd now takes the var anyway; XXX: fex
|
||||
MUVM_UDEVD_PATH = "${pkgs.systemd}/lib/systemd/systemd-udevd";
|
||||
src = ./muvm;
|
||||
cargoDeps = pkgs.rustPlatform.importCargoLock {
|
||||
lockFile = ./muvm/Cargo.lock;
|
||||
};
|
||||
});
|
||||
|
||||
packages.munix = let
|
||||
munixScript = (pkgs.writeScriptBin "munix" (builtins.readFile ./munix)).overrideAttrs(old: {
|
||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||
});
|
||||
munixInitRootHook = (pkgs.writeScriptBin "munix-init-root" (builtins.readFile ./munix-init-root)).overrideAttrs(old: {
|
||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||
});
|
||||
munixInitUserHook = (pkgs.writeScriptBin "munix-init-user" (builtins.readFile ./munix-init-user)).overrideAttrs(old: {
|
||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||
});
|
||||
in pkgs.symlinkJoin {
|
||||
name = "munix";
|
||||
paths = [ munixScript munixInitRootHook munixInitUserHook self.packages.${system}.muvm pkgs.passt pkgs.bubblewrap ];
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/munix --prefix PATH : $out/bin
|
||||
'';
|
||||
};
|
||||
|
||||
devShells.default = let
|
||||
projects = with self.packages.${system}; [ libkrun muvm ];
|
||||
in pkgs.mkShell {
|
||||
MUVM_UDEVD_PATH = "${pkgs.systemd}/lib/systemd/systemd-udevd";
|
||||
nativeBuildInputs = pkgs.lib.concatMap (pkg: pkg.nativeBuildInputs) projects;
|
||||
buildInputs = (pkgs.lib.concatMap (pkg: pkg.buildInputs) projects) ++ (with self.packages.${system}; [
|
||||
# virglrenderer
|
||||
]) ++ (with pkgs; [
|
||||
cargo
|
||||
rust-analyzer
|
||||
rustfmt
|
||||
passt
|
||||
bubblewrap
|
||||
]);
|
||||
};
|
||||
|
||||
packages.mesa = (pkgs.mesa.override {
|
||||
vulkanDrivers = [
|
||||
"amd"
|
||||
"intel"
|
||||
"microsoft-experimental" # removing this breaks the build
|
||||
"nouveau"
|
||||
"swrast"
|
||||
"virtio"
|
||||
"gfxstream" # probably not going to use this though
|
||||
];
|
||||
}).overrideAttrs (new: old: {
|
||||
mesonFlags = old.mesonFlags ++ [ (pkgs.lib.mesonBool "amdgpu-virtio" true) ];
|
||||
patches = old.patches ++ [ ./radvmmio.patch ]; # already merged to git
|
||||
});
|
||||
|
||||
nixosConfigurations.testvm = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
{
|
||||
system.stateVersion = "25.11";
|
||||
fileSystems."/".device = pkgs.lib.mkDefault "/dev/sda";
|
||||
boot.isContainer = true;
|
||||
|
||||
users.mutableUsers = false;
|
||||
users.users.appvm = {
|
||||
uid = 1001;
|
||||
isNormalUser = true;
|
||||
home = "/home/appvm";
|
||||
description = "microVM User";
|
||||
extraGroups = [ "wheel" "video" "input" ];
|
||||
};
|
||||
users.groups.appvm.gid = 1001;
|
||||
users.allowNoPasswordLogin = true;
|
||||
|
||||
hardware.graphics.enable = true;
|
||||
hardware.graphics.package = self.packages.${system}.mesa;
|
||||
system.replaceDependencies.replacements = [
|
||||
{
|
||||
original = pkgs.mesa;
|
||||
replacement = self.packages.${system}.mesa;
|
||||
}
|
||||
];
|
||||
environment.systemPackages = [
|
||||
pkgs.fastfetch
|
||||
pkgs.htop
|
||||
pkgs.radeontop
|
||||
virtwl.packages.x86_64-linux.proxy
|
||||
pkgs.wayland-utils
|
||||
pkgs.weston
|
||||
pkgs.waycheck
|
||||
pkgs.vulkan-tools
|
||||
pkgs.glxinfo
|
||||
pkgs.glmark2
|
||||
pkgs.mesa-demos
|
||||
pkgs.xorg.xeyes
|
||||
pkgs.xterm
|
||||
pkgs.vkquake
|
||||
pkgs.kdePackages.kate
|
||||
pkgs.adwaita-fonts
|
||||
pkgs.adwaita-icon-theme
|
||||
pkgs.gnome-text-editor
|
||||
pkgs.firefox
|
||||
pkgs.ffmpeg-full
|
||||
pkgs.mpv
|
||||
pkgs.libva-utils
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue