🔨 chore: initial commit

Signed-off-by: xtrm <oss@xtrm.me>
This commit is contained in:
xtrm
2025-02-19 13:05:06 +01:00
commit e9f538ed92
14 changed files with 343 additions and 0 deletions

3
vm/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.qcow
*.qcow2
result

12
vm/aliases.nix Normal file
View File

@ -0,0 +1,12 @@
{
v = "nvim";
vi = "nvim";
vim = "nvim";
ls = "eza --color=auto --group-directories-first";
l = "ls -la --no-git";
ll = "ls -la";
cat = "bat";
gs = "git status";
gd = "git diff";
gds = "git diff --staged";
}

4
vm/cleanup.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
rm -v nixos.qcow2
rm -vfr result

63
vm/configuration.nix Normal file
View File

@ -0,0 +1,63 @@
{ config, pkgs, modulesPath, hostname, ... }:
{
imports = [
(modulesPath + "/profiles/minimal.nix")
];
networking.hostName = hostname;
nixpkgs.config.allowUnfree = true;
# Since `fileSystems` is ignored by nixos-generators, we need to be creative
systemd.services.mount-iot = {
description = "Mount the IOT shared folder";
# fstab entry:
# host0 /wherever 9p trans=virtio,version=9p2000.L 0 0
script = ''
mkdir -p /iot
/run/wrappers/bin/mount -t 9p -o trans=virtio,version=9p2000.L host0 /iot
'';
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
};
users.users.root = {
password = "toor";
shell = pkgs.zsh;
};
services = {
getty.autologinUser = "root";
};
programs = {
zsh = {
autosuggestions.enable = true;
syntaxHighlighting.enable = true;
enable = true;
enableBashCompletion = true;
shellAliases = (import ./aliases.nix);
};
};
environment = {
systemPackages = with pkgs; [
vagrant
git
zip
neovim
eza
bat
];
};
system.stateVersion = "24.11";
}

80
vm/flake.lock generated Normal file
View File

@ -0,0 +1,80 @@
{
"nodes": {
"nixlib": {
"locked": {
"lastModified": 1736643958,
"narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixlib": "nixlib",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1737057290,
"narHash": "sha256-3Pe0yKlCc7EOeq1X/aJVDH0CtNL+tIBm49vpepwL1MQ=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "d002ce9b6e7eb467cd1c6bb9aef9c35d191b5453",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1739736696,
"narHash": "sha256-zON2GNBkzsIyALlOCFiEBcIjI4w38GYOb+P+R4S8Jsw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d74a2335ac9c133d6bbec9fc98d91a77f1604c1f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1680978846,
"narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
"owner": "nix-systems",
"repo": "x86_64-linux",
"rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "x86_64-linux",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

70
vm/flake.nix Normal file
View File

@ -0,0 +1,70 @@
{
description = "A NixOS configuration for the Inception of Things";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
systems.url = "github:nix-systems/x86_64-linux";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
nixos-generators,
...
}@inputs:
let
inherit (self) outputs;
systems = (import inputs.systems);
forAllSystems = nixpkgs.lib.genAttrs systems;
hostname = "iot-box";
in
{
packages = forAllSystems (
system:
let
vm = nixos-generators.nixosGenerate {
inherit system;
specialArgs = {
inherit hostname;
};
modules = [
./configuration.nix
];
format = "vm";
};
in
{
inherit vm;
default = vm;
}
);
apps = forAllSystems (
system:
let
vm = {
type = "app";
program = "${self.packages.${system}.vm}/bin/run-${hostname}-vm";
programArgs = [ "-enable-kvm" ];
};
in
{
inherit vm;
default = vm;
}
);
formatter = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
pkgs.nixfmt-rfc-style
);
};
}

5
vm/run.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
nix run . -- -virtfs local,path=$(pwd)/..,mount_tag=host0,security_model=passthrough,id=host0