diff options
author | Ryan Lahfa <masterancpp@gmail.com> | 2023-07-08 13:58:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 13:58:20 +0200 |
commit | 49413e25e09cb35cde536087daebc542f3f34d72 (patch) | |
tree | b2f02215ac015fa8479d2440f02334ccc6801c1e /nixos | |
parent | 67eec418ab1bb44ce222944caaf62aeda5efa145 (diff) | |
parent | 21e36654c8900860cddce3c68c2589fa7ba49c05 (diff) | |
download | nixlib-49413e25e09cb35cde536087daebc542f3f34d72.tar nixlib-49413e25e09cb35cde536087daebc542f3f34d72.tar.gz nixlib-49413e25e09cb35cde536087daebc542f3f34d72.tar.bz2 nixlib-49413e25e09cb35cde536087daebc542f3f34d72.tar.lz nixlib-49413e25e09cb35cde536087daebc542f3f34d72.tar.xz nixlib-49413e25e09cb35cde536087daebc542f3f34d72.tar.zst nixlib-49413e25e09cb35cde536087daebc542f3f34d72.zip |
Merge pull request #241314 from jnsgruk/master
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/virtualisation/lxd.nix | 12 | ||||
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/lxd-ui.nix | 35 |
3 files changed, 48 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/lxd.nix b/nixos/modules/virtualisation/lxd.nix index 738382ef41a5..22e336c895f9 100644 --- a/nixos/modules/virtualisation/lxd.nix +++ b/nixos/modules/virtualisation/lxd.nix @@ -85,6 +85,14 @@ in { considered failed and systemd will attempt to restart it. ''; }; + + ui = { + enable = lib.mkEnableOption (lib.mdDoc '' + Enables the (experimental) LXD UI. + ''); + + package = mkPackageOption pkgs.lxd "ui" { }; + }; }; }; @@ -143,6 +151,10 @@ in { path = [ pkgs.util-linux ] ++ optional cfg.zfsSupport config.boot.zfs.package; + environment = mkIf (cfg.ui.enable) { + "LXD_UI" = cfg.ui.package; + }; + serviceConfig = { ExecStart = "@${cfg.package}/bin/lxd lxd --group lxd"; ExecStartPost = "${cfg.package}/bin/lxd waitready --timeout=${cfg.startTimeout}"; diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 587fb07ed7b5..790de7bbdc47 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -436,6 +436,7 @@ in { lxd = handleTest ./lxd.nix {}; lxd-nftables = handleTest ./lxd-nftables.nix {}; lxd-image-server = handleTest ./lxd-image-server.nix {}; + lxd-ui = handleTest ./lxd-ui.nix {}; #logstash = handleTest ./logstash.nix {}; lorri = handleTest ./lorri/default.nix {}; maddy = discoverTests (import ./maddy { inherit handleTest; }); diff --git a/nixos/tests/lxd-ui.nix b/nixos/tests/lxd-ui.nix new file mode 100644 index 000000000000..19eaa226c0bf --- /dev/null +++ b/nixos/tests/lxd-ui.nix @@ -0,0 +1,35 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: { + name = "lxd-ui"; + + meta = with pkgs.lib.maintainers; { + maintainers = [ jnsgruk ]; + }; + + nodes.machine = { lib, ... }: { + virtualisation = { + lxd.enable = true; + lxd.ui.enable = true; + }; + + environment.systemPackages = [ pkgs.curl ]; + }; + + testScript = '' + machine.wait_for_unit("sockets.target") + machine.wait_for_unit("lxd.service") + machine.wait_for_file("/var/lib/lxd/unix.socket") + + # Wait for lxd to settle + machine.succeed("lxd waitready") + + # Configure LXC listen address + machine.succeed("lxc config set core.https_address :8443") + machine.succeed("systemctl restart lxd") + + # Check that the LXD_UI environment variable is populated in the systemd unit + machine.succeed("cat /etc/systemd/system/lxd.service | grep 'LXD_UI'") + + # Ensure the endpoint returns an HTML page with 'LXD UI' in the title + machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>LXD UI</title>'") + ''; +}) |