Created
October 29, 2023 01:04
-
-
Save astro/63e3bd4cd9c494cf75ae1cf48331d2f0 to your computer and use it in GitHub Desktop.
microvm.nix CHV + tap example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nodes": { | |
"flake-utils": { | |
"inputs": { | |
"systems": "systems" | |
}, | |
"locked": { | |
"lastModified": 1694529238, | |
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"type": "github" | |
} | |
}, | |
"microvm": { | |
"inputs": { | |
"flake-utils": "flake-utils", | |
"nixpkgs": [ | |
"nixpkgs" | |
] | |
}, | |
"locked": { | |
"lastModified": 1698504395, | |
"narHash": "sha256-92+0zv8p0awLLigXNFHsuNBYzeOuBqMqPqLTbmHWRCA=", | |
"owner": "astro", | |
"repo": "microvm.nix", | |
"rev": "dfe2d3db94e4829e317f97e3a095d6fd8b91f30c", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "astro", | |
"repo": "microvm.nix", | |
"type": "github" | |
} | |
}, | |
"nixpkgs": { | |
"locked": { | |
"lastModified": 1696375444, | |
"narHash": "sha256-Sv0ICt/pXfpnFhTGYTsX6lUr1SljnuXWejYTI2ZqHa4=", | |
"path": "/nix/store/h93pa4qif40f0hjwrs155ihb3lpf36m7-source", | |
"rev": "81e8f48ebdecf07aab321182011b067aafc78896", | |
"type": "path" | |
}, | |
"original": { | |
"id": "nixpkgs", | |
"type": "indirect" | |
} | |
}, | |
"root": { | |
"inputs": { | |
"microvm": "microvm", | |
"nixpkgs": "nixpkgs" | |
} | |
}, | |
"systems": { | |
"locked": { | |
"lastModified": 1681028828, | |
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
"owner": "nix-systems", | |
"repo": "default", | |
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "nix-systems", | |
"repo": "default", | |
"type": "github" | |
} | |
} | |
}, | |
"root": "root", | |
"version": 7 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "NixOS in MicroVMs"; | |
inputs.microvm.url = "github:astro/microvm.nix"; | |
inputs.microvm.inputs.nixpkgs.follows = "nixpkgs"; | |
outputs = { self, nixpkgs, microvm }: | |
let | |
system = "x86_64-linux"; | |
in { | |
defaultPackage.${system} = self.packages.${system}.my-microvm; | |
packages.${system} = { | |
# To run: | |
# > sudo ip tuntap add mode tap user $USER name vm-chv | |
# > sudo ip l s vm-chv up | |
# > nix run .#my-microvm | |
my-microvm = self.nixosConfigurations.my-microvm.config.microvm.declaredRunner; | |
}; | |
nixosConfigurations = { | |
my-microvm = nixpkgs.lib.nixosSystem { | |
inherit system; | |
modules = [ | |
microvm.nixosModules.microvm | |
{ | |
networking.hostName = "my-microvm"; | |
users.users.root.password = ""; | |
services.openssh = { | |
enable = true; | |
settings.PermitRootLogin = "yes"; | |
}; | |
microvm = { | |
hypervisor = "cloud-hypervisor"; | |
socket = "control.socket"; | |
interfaces = [ { | |
type = "tap"; | |
id = "vm-chv"; | |
mac = "00:00:00:00:00:01"; | |
} ]; | |
}; | |
} | |
]; | |
}; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment