134 lines
3.6 KiB
Nix
134 lines
3.6 KiB
Nix
{
|
|
description = "tlater.net host configuration";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
|
deploy-rs.url = "github:serokell/deploy-rs";
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
nvfetcher = {
|
|
url = "github:berberman/nvfetcher";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
tlaternet-webserver = {
|
|
url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
sops-nix,
|
|
nvfetcher,
|
|
deploy-rs,
|
|
tlaternet-webserver,
|
|
}: let
|
|
system = "x86_64-linux";
|
|
in {
|
|
##################
|
|
# Configurations #
|
|
##################
|
|
nixosConfigurations = {
|
|
# The actual system definition
|
|
tlaternet = self.lib.makeNixosSystem {
|
|
inherit system;
|
|
extraModules = [(import ./configuration/hardware-specific/linode)];
|
|
};
|
|
};
|
|
|
|
############################
|
|
# 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;
|
|
|
|
####################
|
|
# Helper functions #
|
|
####################
|
|
lib = import ./lib {
|
|
inherit nixpkgs sops-nix tlaternet-webserver;
|
|
lib = nixpkgs.lib;
|
|
};
|
|
|
|
####################
|
|
# VM launch script #
|
|
####################
|
|
apps.${system} = let
|
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
|
in {
|
|
default = let
|
|
vm = self.lib.makeNixosSystem {
|
|
inherit system;
|
|
extraModules = [(import ./configuration/hardware-specific/vm.nix)];
|
|
};
|
|
|
|
qemuNetOpts = self.lib.makeQemuNetOpts {
|
|
"2222" = "2222";
|
|
"3080" = "80";
|
|
"3443" = "443";
|
|
"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}"
|
|
"${vm.config.system.build.vm}/bin/run-tlaternet-vm"
|
|
'');
|
|
};
|
|
|
|
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
|
|
'');
|
|
};
|
|
};
|
|
|
|
###########################
|
|
# Development environment #
|
|
###########################
|
|
devShells.${system}.default = let
|
|
inherit (sops-nix.packages.${system}) sops-import-keys-hook sops-init-gpg-key;
|
|
deploy-rs-bin = deploy-rs.packages.${system}.default;
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
nixpkgs.legacyPackages.${system}.mkShell {
|
|
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
|
nativeBuildInputs = [
|
|
sops-import-keys-hook
|
|
];
|
|
|
|
packages = with pkgs; [
|
|
nixfmt
|
|
git-lfs
|
|
sops-init-gpg-key
|
|
deploy-rs-bin
|
|
];
|
|
};
|
|
};
|
|
}
|