forked from Fediversity/Fediversity
Compare commits
No commits in common. "96641d2d3db3af5fd65d49fc04ab464278718f13" and "54f484ddd7e05783fa5823be8038ec01e8746ddf" have entirely different histories.
96641d2d3d
...
54f484ddd7
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +0,0 @@
|
||||||
.envrc
|
|
||||||
.direnv
|
|
||||||
result
|
|
|
@ -1,15 +0,0 @@
|
||||||
# fediversity.eu webserver
|
|
||||||
|
|
||||||
This directory contains the configuration for the server hosting https://fediversity.eu
|
|
||||||
|
|
||||||
Build the configuration:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nix-build -A machine
|
|
||||||
```
|
|
||||||
|
|
||||||
Deploy via SSH:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
env SSH_OPTS="..." nix-shell --run deploy-webserver
|
|
||||||
```
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
# Edit this configuration file to define what should be installed on
|
# Edit this configuration file to define what should be installed on
|
||||||
# your system. Help is available in the configuration.nix(5) man page
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
|
@ -6,8 +7,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
imports =
|
imports =
|
||||||
[
|
[ # Include the results of the hardware scan.
|
||||||
# Include the results of the hardware scan.
|
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
services.nginx.virtualHosts."www.fediversity.eu" = {
|
services.nginx.virtualHosts."www.fediversity.eu" = {
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
root = "${(import ../website { }).build}";
|
root = "/var/www/www.fediversity.eu/fediversity.eu/public";
|
||||||
locations."/.well-known/matrix/client" = {
|
locations."/.well-known/matrix/client" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
return 200 '{"m.homeserver": {"base_url": "https://matrix.fediversity.eu", "public_baseurl": "https://matrix.fediversity.eu"}}';
|
return 200 '{"m.homeserver": {"base_url": "https://matrix.fediversity.eu", "public_baseurl": "https://matrix.fediversity.eu"}}';
|
||||||
|
@ -197,7 +197,6 @@
|
||||||
# Select internationalisation properties.
|
# Select internationalisation properties.
|
||||||
i18n.defaultLocale = "en_US.UTF-8";
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
security.sudo.wheelNeedsPassword = false;
|
|
||||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||||
users.users.procolix = {
|
users.users.procolix = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
|
@ -246,17 +245,24 @@
|
||||||
})
|
})
|
||||||
wget
|
wget
|
||||||
git
|
git
|
||||||
|
hugo
|
||||||
|
go
|
||||||
|
nodejs
|
||||||
];
|
];
|
||||||
|
|
||||||
# List services that you want to enable:
|
# List services that you want to enable:
|
||||||
|
|
||||||
# Enable the OpenSSH daemon.
|
# Enable the OpenSSH daemon.
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
services.openssh.settings.PasswordAuthentication = false;
|
|
||||||
|
|
||||||
# Enable xe-guest-utilities
|
# Enable xe-guest-utilities
|
||||||
services.xe-guest-utilities.enable = true;
|
services.xe-guest-utilities.enable = true;
|
||||||
|
|
||||||
|
# Copy the NixOS configuration file and link it from the resulting system
|
||||||
|
# (/run/current-system/configuration.nix). This is useful in case you
|
||||||
|
# accidentally delete configuration.nix.
|
||||||
|
system.copySystemConfiguration = true;
|
||||||
|
|
||||||
# This value determines the NixOS release from which the default
|
# This value determines the NixOS release from which the default
|
||||||
# settings for stateful data, like file locations and database versions
|
# settings for stateful data, like file locations and database versions
|
||||||
# on your system were taken. It‘s perfectly fine and recommended to leave
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||||
|
@ -266,3 +272,4 @@
|
||||||
system.stateVersion = "23.11"; # Did you read the comment?
|
system.stateVersion = "23.11"; # Did you read the comment?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
{ sources ? import ../website/npins
|
|
||||||
, system ? builtins.currentSystem
|
|
||||||
, pkgs ? import sources.nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
config = { };
|
|
||||||
overlays = [ ];
|
|
||||||
}
|
|
||||||
, lib ? import "${sources.nixpkgs}/lib"
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
# TODO: don't hard code target hosts; wire all of it up with NixOps4
|
|
||||||
host = "vm02117.procolix.com";
|
|
||||||
deploy = pkgs.writeShellApplication {
|
|
||||||
name = "deploy-webserver";
|
|
||||||
text = ''
|
|
||||||
# HACK: decouple system evaluation from shell evaluation
|
|
||||||
# the structured way for using this hack is encoded in https://github.com/fricklerhandwerk/lazy-drv
|
|
||||||
result="$(nix-build ${toString ./.} -A machine --no-out-link --eval-store auto --store ssh-ng://${host})"
|
|
||||||
# shellcheck disable=SC2087
|
|
||||||
ssh ${host} << EOF
|
|
||||||
sudo nix-env -p /nix/var/nix/profiles/system --set "$result"
|
|
||||||
sudo "$result"/bin/switch-to-configuration switch
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
nixos-configuration = config:
|
|
||||||
import "${pkgs.path}/nixos/lib/eval-config.nix" {
|
|
||||||
modules = [
|
|
||||||
config
|
|
||||||
];
|
|
||||||
system = null;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
rec {
|
|
||||||
nixos = nixos-configuration ./configuration.nix;
|
|
||||||
machine = nixos.config.system.build.toplevel;
|
|
||||||
shell = pkgs.mkShellNoCC {
|
|
||||||
packages = with pkgs; [
|
|
||||||
deploy
|
|
||||||
];
|
|
||||||
env = {
|
|
||||||
# TODO: reusing other pins for now; wire up the whole repo to use the same dependencies
|
|
||||||
NPINS_DIRECTORY = toString ../website/npins;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
(import ./. { }).shell
|
|
|
@ -57,6 +57,16 @@ nix build .#installers.peertube
|
||||||
Upload the image in `./result` to Proxmox when creating a VM.
|
Upload the image in `./result` to Proxmox when creating a VM.
|
||||||
Booting the image will format the disk and install NixOS with the desired configuration.
|
Booting the image will format the disk and install NixOS with the desired configuration.
|
||||||
|
|
||||||
|
# Deploying an updated machine configuration
|
||||||
|
|
||||||
|
> TODO: There is currently no way to specify an actual target machine by name.
|
||||||
|
|
||||||
|
Assuming you have SSH configuration with access to the remote `root` user stored for a machine called e.g. `peertube`, deploy the configuration by the same name:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix run .#deploy.peertube
|
||||||
|
```
|
||||||
|
|
||||||
## debugging notes
|
## debugging notes
|
||||||
|
|
||||||
- it is sometimes useful to `cat result/bin/run-nixos-vm` to see what's really going on (e.g. which ports are getting forwarded)
|
- it is sometimes useful to `cat result/bin/run-nixos-vm` to see what's really going on (e.g. which ports are getting forwarded)
|
||||||
|
|
13
services/deploy.nix
Normal file
13
services/deploy.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{ writeShellApplication }:
|
||||||
|
name: _config:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "deploy";
|
||||||
|
text = ''
|
||||||
|
result="$(nix build --print-out-paths ${./.}#nixosConfigurations#${name} --eval-store auto --store ssh-ng://${name})"
|
||||||
|
# shellcheck disable=SC2087
|
||||||
|
ssh ${name} << EOF
|
||||||
|
nix-env -p /nix/var/nix/profiles/system --set "$result"
|
||||||
|
"$result"/bin/switch-to-configuration switch
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
|
@ -114,6 +114,12 @@
|
||||||
mkInstaller = import ./installer.nix;
|
mkInstaller = import ./installer.nix;
|
||||||
installers = lib.mapAttrs (_: config: self.mkInstaller nixpkgs config) self.nixosConfigurations;
|
installers = lib.mapAttrs (_: config: self.mkInstaller nixpkgs config) self.nixosConfigurations;
|
||||||
|
|
||||||
|
deploy =
|
||||||
|
let
|
||||||
|
deployCommand = (pkgs.callPackage ./deploy.nix { });
|
||||||
|
in
|
||||||
|
lib.mapAttrs (name: config: deployCommand name config) self.nixosConfigurations;
|
||||||
|
|
||||||
checks.${system} = {
|
checks.${system} = {
|
||||||
mastodon-garage = import ./tests/mastodon-garage.nix { inherit pkgs self; };
|
mastodon-garage = import ./tests/mastodon-garage.nix { inherit pkgs self; };
|
||||||
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit pkgs self; };
|
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit pkgs self; };
|
||||||
|
|
|
@ -127,10 +127,8 @@ header > nav > ul > li > details > nav ul li {
|
||||||
padding: 0.25em 0;
|
padding: 0.25em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu-toggle,
|
#menu-toggle {
|
||||||
#menu-toggle + label {
|
|
||||||
display: none;
|
display: none;
|
||||||
appearance: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 50em) {
|
@media (max-width: 50em) {
|
||||||
|
@ -138,22 +136,14 @@ header > nav > ul > li > details > nav ul li {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu-toggle ~ label {
|
#menu-toggle::before {
|
||||||
position: absolute;
|
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 20 20'%3E%3Cpath d='M0 3h20v2H0V3z m0 6h20v2H0V9z m0 6h20v2H0V0z'/%3E%3C/svg%3E");
|
||||||
right: 1em;
|
|
||||||
top: 0.5em;
|
|
||||||
cursor: pointer;
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-close,
|
#menu-toggle:checked::before {
|
||||||
.menu-open {
|
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 20 20'%3E%3Cpolygon points='11 9 22 9 22 11 11 11 11 22 9 22 9 11 -2 11 -2 9 9 9 9 -2 11 -2' transform='rotate(45 10 10)'/%3E%3C/svg%3E");
|
||||||
cursor: pointer;
|
|
||||||
fill: var(--text-color);
|
|
||||||
}
|
}
|
||||||
.menu-close { display: none; }
|
|
||||||
#menu-toggle:checked + label .menu-close { display: block; }
|
|
||||||
#menu-toggle:checked + label .menu-open { display: none; }
|
|
||||||
|
|
||||||
header > nav {
|
header > nav {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
@ -220,4 +210,14 @@ header > nav > ul > li > details > nav ul li {
|
||||||
header {
|
header {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* for some reason this must be at the end to work */
|
||||||
|
#menu-toggle {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
right: 1em;
|
||||||
|
top: 0.5em;
|
||||||
|
appearance: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,15 +63,7 @@ in
|
||||||
body.content = [
|
body.content = [
|
||||||
''
|
''
|
||||||
<header>
|
<header>
|
||||||
<input type="checkbox" id="menu-toggle" hidden>
|
<input type="checkbox" id="menu-toggle">
|
||||||
<label for="menu-toggle" hidden>
|
|
||||||
<svg class="menu-open" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 20 20">
|
|
||||||
<path d="M0 3h20v2H0V3z m0 6h20v2H0V9z m0 6h20v2H0V0z"/>
|
|
||||||
</svg>
|
|
||||||
<svg class="menu-close" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 20 20">
|
|
||||||
<polygon points="11 9 22 9 22 11 11 11 11 22 9 22 9 11 -2 11 -2 9 9 9 9 -2 11 -2" transform="rotate(45 10 10)"/>
|
|
||||||
</svg>
|
|
||||||
</label>
|
|
||||||
${lib.indent " " (cfg.menus.main.outputs.html page)}
|
${lib.indent " " (cfg.menus.main.outputs.html page)}
|
||||||
</header>
|
</header>
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in a new issue