Compare commits

..

2 commits

Author SHA1 Message Date
ab3cc0c217 vm: Serve www directory from a shared directory
Run the VM as

    WWW="$PWD/www" nix run

to serve the www directory from within the VM.
2024-01-14 21:52:48 +01:00
dbbc8c63b8 vm: Serve todo-app from www directory 2024-01-14 21:43:05 +01:00
2 changed files with 29 additions and 7 deletions

View file

@ -6,13 +6,7 @@
virtualHosts.localhost.locations."/" = {
index = "index.html";
root = pkgs.writeTextDir "index.html" ''
<html>
<body>
Hello World!
</body>
</html>
'';
root = "/var/www";
};
};
};
@ -25,5 +19,10 @@
host.port = 8080;
}];
virtualisation.sharedDirectories.www = {
source = "$WWW";
target = "/var/www";
};
system.stateVersion = "23.11";
}

23
www/index.html Normal file
View file

@ -0,0 +1,23 @@
<html>
<body>
<button id='add'>+</button>
</body>
<script>
let add = document.getElementById('add');
function newTask() {
let subtract = document.createElement('button');
subtract.textContent = "-";
let input = document.createElement('input');
input.setAttribute('type', 'text');
let div = document.createElement('div');
div.replaceChildren(subtract, input);
function remove() {
div.replaceChildren();
div.remove();
}
subtract.addEventListener('click', remove);
add.before(div);
}
add.addEventListener('click', newTask);
</script>
</html>