tlaternet-server/flake.nix

139 lines
3.7 KiB
Nix
Raw Normal View History

{
description = "tlater.net host configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
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
};
};
outputs = {
self,
nixpkgs,
sops-nix,
2022-10-17 11:00:02 +01:00
nvfetcher,
deploy-rs,
tlaternet-webserver,
2022-10-12 01:17:49 +01:00
}: let
system = "x86_64-linux";
in {
##################
# Configurations #
##################
nixosConfigurations = {
# The actual system definition
tlaternet = self.lib.makeNixosSystem {
2022-10-12 01:17:49 +01:00
inherit system;
extraModules = [(import ./configuration/hardware-specific/linode)];
};
2022-10-12 01:17:49 +01:00
};
2021-04-22 22:32:54 +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;
####################
# Helper functions #
####################
lib = import ./lib {
inherit nixpkgs sops-nix tlaternet-webserver;
lib = nixpkgs.lib;
};
####################
# VM launch script #
####################
2022-10-17 11:00:02 +01:00
apps.${system} = let
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
in {
2022-10-17 11:00:02 +01:00
default = let
vm =
(self.lib.makeNixosSystem {
inherit system;
extraModules = [(import ./configuration/hardware-specific/vm.nix)];
})
.config
.system
.build
.vm;
2022-10-17 11:00:02 +01:00
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}/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
];
};
2022-10-12 01:17:49 +01:00
};
}