From 8d533df06850c5140f72d301123d1a4e3dc215fa Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Wed, 2 Nov 2022 17:20:48 -0400 Subject: [PATCH] fix: Added a check for vagrant. --- flake.nix | 14 +++++++++++++- nixos/modules/virtualisation/vagrant.nix | 23 ++++++++++++----------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index ece5e91..bc3ba86 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,22 @@ { - description = "A very basic flake"; + description = "Utilities for running Laravel, particularly with Vagrant"; outputs = { nixpkgs, self }: { nixosModules = { laravel = import ./nixos/modules/web-apps/laravel.nix; vagrant = { ... }: { imports = [ ./nixos/modules/virtualisation/vagrant.nix ]; }; }; + + checks."x86_64-linux".vagrant = let pkgs = nixpkgs.legacyPackages."x86_64-linux"; in + pkgs.nixosTest { + name = "vagrant-box-test"; + nodes.machine = { pkgs, ... }: { imports = with self.nixosModules; [ vagrant ]; }; + testScript = '' + # run hello on machine and check for output + machine.succeed('hello | grep "Hello, world!"') + machine.succeed('goodbye | grep "Hello, world!"') + # test is a simple python script + ''; + }; }; } diff --git a/nixos/modules/virtualisation/vagrant.nix b/nixos/modules/virtualisation/vagrant.nix index ef4f58c..c126740 100644 --- a/nixos/modules/virtualisation/vagrant.nix +++ b/nixos/modules/virtualisation/vagrant.nix @@ -2,6 +2,9 @@ let cfg = config.services.laravel; in { + imports = [ + ../web-apps/laravel.nix + ]; config = lib.mkMerge [ { nix.settings.experimental-features = [ "nix-command" "flakes" ]; @@ -15,10 +18,10 @@ in options = [ "rw,uid=1001,gid=60,_netdev" ]; # mount as vagrant:nginx }; - networking.hostName = hostName; - networking.extraHosts = '' - 127.0.0.1 ${config.networking.hostName}.local - ''; + # networking.hostName = hostName; + # networking.extraHosts = '' + # 127.0.0.1 ${config.networking.hostName}.local + # ''; security.sudo.wheelNeedsPassword = false; @@ -56,12 +59,10 @@ in cd /vagrant; ''; } - (lib.mkIf - cfg.enable - { - services.laravel.root = lib.mkDefault "/vagrant"; - services.laravel.domain = lib.mkDefault (hostName + ".local"); - services.laravel.user = lib.mkDefault "vagrant"; - }) + (lib.mkIf (cfg.enable == true) { + services.laravel.root = lib.mkDefault "/vagrant"; + # services.laravel.domain = lib.mkDefault (hostName + ".local"); + services.laravel.user = lib.mkDefault "vagrant"; + }) ]; }