2021-04-12 01:35:24 +01:00
|
|
|
{
|
|
|
|
description = "tlater.net host configuration";
|
|
|
|
|
|
|
|
inputs = {
|
2022-10-12 19:58:09 +01:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
2022-10-21 20:48:14 +01:00
|
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2022-10-13 00:31:08 +01:00
|
|
|
deploy-rs.url = "github:serokell/deploy-rs";
|
2022-04-23 04:06:50 +01:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-10-17 11:00:02 +01:00
|
|
|
nvfetcher = {
|
|
|
|
url = "github:berberman/nvfetcher";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2021-04-12 01:44:10 +01:00
|
|
|
tlaternet-webserver = {
|
|
|
|
url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git";
|
2022-10-12 01:17:49 +01:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2021-04-12 01:44:10 +01:00
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
2022-10-10 13:03:08 +01:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
2022-10-21 20:48:14 +01:00
|
|
|
nixpkgs-unstable,
|
2022-10-10 13:03:08 +01:00
|
|
|
sops-nix,
|
2022-10-17 11:00:02 +01:00
|
|
|
nvfetcher,
|
2022-10-13 00:31:08 +01:00
|
|
|
deploy-rs,
|
2022-10-10 13:03:08 +01:00
|
|
|
tlaternet-webserver,
|
2022-10-12 01:17:49 +01:00
|
|
|
}: let
|
|
|
|
system = "x86_64-linux";
|
|
|
|
in {
|
2022-10-13 00:03:32 +01:00
|
|
|
##################
|
|
|
|
# Configurations #
|
|
|
|
##################
|
2022-10-17 14:22:08 +01:00
|
|
|
nixosConfigurations = {
|
2022-10-13 00:03:32 +01:00
|
|
|
# The actual system definition
|
2022-10-17 14:22:08 +01:00
|
|
|
tlaternet = self.lib.makeNixosSystem {
|
2022-10-12 01:17:49 +01:00
|
|
|
inherit system;
|
2022-10-17 14:22:08 +01:00
|
|
|
extraModules = [(import ./configuration/hardware-specific/linode)];
|
2022-10-10 13:03:08 +01:00
|
|
|
};
|
2022-10-12 01:17:49 +01:00
|
|
|
};
|
2021-04-22 22:32:54 +01:00
|
|
|
|
2022-10-13 00:31:08 +01:00
|
|
|
############################
|
|
|
|
# Deployment configuration #
|
|
|
|
############################
|
|
|
|
deploy.nodes.tlaternet = {
|
|
|
|
hostname = "tlater.net";
|
|
|
|
|
|
|
|
profiles.system = {
|
|
|
|
user = "root";
|
|
|
|
path = deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.tlaternet;
|
|
|
|
};
|
|
|
|
|
|
|
|
sshUser = "tlater";
|
|
|
|
sshOpts = ["-t" "-p" "2222"];
|
|
|
|
fastConnection = true;
|
|
|
|
# Currently broken, see https://github.com/serokell/deploy-rs/issues/78
|
|
|
|
magicRollback = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
#########
|
|
|
|
# Tests #
|
|
|
|
#########
|
|
|
|
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
####################
|
|
|
|
# Helper functions #
|
|
|
|
####################
|
2022-10-17 14:22:08 +01:00
|
|
|
lib = import ./lib {
|
2022-10-21 20:48:14 +01:00
|
|
|
inherit nixpkgs nixpkgs-unstable sops-nix tlaternet-webserver;
|
2022-10-17 14:22:08 +01:00
|
|
|
lib = nixpkgs.lib;
|
|
|
|
};
|
2022-10-13 00:03:32 +01:00
|
|
|
|
|
|
|
####################
|
|
|
|
# VM launch script #
|
|
|
|
####################
|
2022-10-17 11:00:02 +01:00
|
|
|
apps.${system} = let
|
2022-10-12 13:11:11 +01:00
|
|
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
|
|
|
in {
|
2022-10-17 11:00:02 +01:00
|
|
|
default = let
|
2022-10-17 14:22:08 +01:00
|
|
|
vm = self.lib.makeNixosSystem {
|
|
|
|
inherit system;
|
|
|
|
extraModules = [(import ./configuration/hardware-specific/vm.nix)];
|
|
|
|
};
|
|
|
|
|
2022-10-17 11:00:02 +01:00
|
|
|
qemuNetOpts = self.lib.makeQemuNetOpts {
|
|
|
|
"2222" = "2222";
|
|
|
|
"3080" = "80";
|
|
|
|
"3443" = "443";
|
2022-10-21 20:48:14 +01:00
|
|
|
"8448" = "8448"; # Matrix
|
2022-10-17 11:00:02 +01:00
|
|
|
"21025" = "21025"; # Starbound
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (writeShellScript "run-vm" ''
|
|
|
|
export QEMU_OPTS="-m 3941 -smp 2 -display curses"
|
|
|
|
export QEMU_NET_OPTS="${qemuNetOpts}"
|
2022-10-17 14:22:08 +01:00
|
|
|
"${vm.config.system.build.vm}/bin/run-tlaternet-vm"
|
2022-10-17 11:00:02 +01:00
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
|
|
|
update-nextcloud-apps = let
|
|
|
|
nvfetcher-bin = "${nvfetcher.defaultPackage.${system}}/bin/nvfetcher";
|
|
|
|
in {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (writeShellScript "update-nextcloud-apps" ''
|
|
|
|
cd "$(git rev-parse --show-toplevel)/pkgs"
|
|
|
|
${nvfetcher-bin} -o _sources_nextcloud -c nextcloud-apps.toml
|
|
|
|
'');
|
|
|
|
};
|
2022-10-12 13:11:11 +01:00
|
|
|
};
|
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
###########################
|
|
|
|
# Development environment #
|
|
|
|
###########################
|
2022-10-22 20:01:44 +01:00
|
|
|
devShells.${system}.default = nixpkgs.legacyPackages.${system}.mkShell {
|
|
|
|
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
|
|
|
nativeBuildInputs = [
|
|
|
|
sops-nix.packages.${system}.sops-import-keys-hook
|
|
|
|
];
|
2022-10-13 00:31:08 +01:00
|
|
|
|
2022-10-22 20:01:44 +01:00
|
|
|
packages = [
|
|
|
|
sops-nix.packages.${system}.sops-init-gpg-key
|
|
|
|
deploy-rs.packages.${system}.default
|
|
|
|
];
|
|
|
|
};
|
2022-10-12 01:17:49 +01:00
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
}
|