Initial commit
This commit is contained in:
commit
7fa4bb5fa6
5 changed files with 104 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
result
|
||||||
|
.direnv
|
||||||
|
nixos.qcow2
|
||||||
44
flake.lock
generated
Normal file
44
flake.lock
generated
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1652776076,
|
||||||
|
"narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"ref": "v1.0.0",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1701282334,
|
||||||
|
"narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "23.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
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 ]; };
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
2
module.nix
Normal file
2
module.nix
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
{ services.getty.autologinUser = "root";
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue