From 0f4ae2a2fdb23c1cc7232af03a1f97c79b5b7302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 15 Jan 2024 23:11:46 +0200 Subject: [PATCH] add vm --- .gitignore | 1 + Makefile | 4 ++++ flake.nix | 13 +++++++++++-- modules/e11sync/default.nix | 1 + vm.nix | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 vm.nix diff --git a/.gitignore b/.gitignore index f083d0b..6946804 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ __pycache__ db.sqlite3 +vm.qcow2 /.pre-commit-config.yaml diff --git a/Makefile b/Makefile index c07c747..3f55164 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,7 @@ run-backend: .PHONY: run-frontend run-frontend: nix run .#e11sync-frontend + +.PHONY: vm +vm: + nix run .#nixosConfigurations.x86_64-linux.vm.config.system.build.vm diff --git a/flake.nix b/flake.nix index 037efd4..e3d39d6 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,8 @@ inherit geoip2-tarball; }; + e11sync-module = import ./modules/e11sync; + e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {}; e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix { @@ -77,8 +79,7 @@ ''; }; - nixosModules.e11sync = import ./modules/e11sync; - nixosModules.default = self.nixosModules.e11sync; + nixosModules.e11sync = e11sync-module; apps = { e11sync-frontend = { @@ -129,5 +130,13 @@ }; formatter = pkgs.alejandra; + + nixosConfigurations.vm = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./vm.nix + e11sync-module + ]; + }; }); } diff --git a/modules/e11sync/default.nix b/modules/e11sync/default.nix index 6cce2d8..7c991dd 100644 --- a/modules/e11sync/default.nix +++ b/modules/e11sync/default.nix @@ -2,6 +2,7 @@ config, lib, e11sync-backend, + ... }: { options.e11sync = with lib.types; { enable = lib.mkEnableOption "Enable e11sync"; diff --git a/vm.nix b/vm.nix new file mode 100644 index 0000000..6ff5788 --- /dev/null +++ b/vm.nix @@ -0,0 +1,37 @@ +{ + pkgs, + modulesPath, + ... +}: { + #e11sync.enable = true; + + imports = [(modulesPath + "/virtualisation/qemu-vm.nix")]; + virtualisation.graphics = false; + + environment.systemPackages = with pkgs; [ + tmux + htop + ]; + + nix.extraOptions = '' + experimental-features = nix-command flakes + trusted-users = vm + ''; + users = { + mutableUsers = false; + users.nixos = { + extraGroups = ["wheel"]; + isNormalUser = true; + hashedPassword = ""; + }; + }; + security.sudo.wheelNeedsPassword = false; + services.getty.autologinUser = "nixos"; + networking = { + hostName = "vm"; + firewall = { + allowedTCPPorts = [8001]; + }; + }; + system.stateVersion = "23.11"; +}