Initial commit
This commit is contained in:
commit
7fa4bb5fa6
5 changed files with 104 additions and 0 deletions
53
flake.nix
Normal file
53
flake.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
|
||||
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/23.11";
|
||||
};
|
||||
|
||||
outputs = { flake-utils, nixpkgs, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
|
||||
base = { lib, modulesPath, ... }: {
|
||||
imports = [ "${modulesPath}/virtualisation/qemu-vm.nix" ];
|
||||
|
||||
# https://github.com/utmapp/UTM/issues/2353
|
||||
networking.nameservers = lib.mkIf pkgs.stdenv.isDarwin [ "8.8.8.8" ];
|
||||
|
||||
virtualisation = {
|
||||
graphics = false;
|
||||
|
||||
host = { inherit pkgs; };
|
||||
};
|
||||
};
|
||||
|
||||
machine = nixpkgs.lib.nixosSystem {
|
||||
system = builtins.replaceStrings [ "darwin" ] [ "linux" ] system;
|
||||
|
||||
modules = [ base ./module.nix ];
|
||||
};
|
||||
|
||||
program = pkgs.writeShellScript "run-vm.sh" ''
|
||||
export NIX_DISK_IMAGE=$(mktemp -u -t nixos.qcow2)
|
||||
|
||||
trap "rm -f $NIX_DISK_IMAGE" EXIT
|
||||
|
||||
${machine.config.system.build.vm}/bin/run-nixos-vm
|
||||
'';
|
||||
|
||||
in {
|
||||
packages = { inherit machine; };
|
||||
|
||||
apps.default = {
|
||||
type = "app";
|
||||
|
||||
program = "${program}";
|
||||
};
|
||||
|
||||
devShells.default =
|
||||
pkgs.mkShell { buildInputs = with pkgs; [ nixfmt nil ]; };
|
||||
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue