2021-04-12 01:35:24 +01:00
|
|
|
{
|
|
|
|
description = "tlater.net host configuration";
|
|
|
|
|
|
|
|
inputs = {
|
2023-12-29 15:11:46 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
2023-02-26 05:46:11 +00:00
|
|
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-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
|
|
|
};
|
2023-05-11 22:02:57 +01:00
|
|
|
foundryvtt = {
|
|
|
|
url = "github:reckenrode/nix-foundryvtt";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
2022-10-10 13:03:08 +01:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
sops-nix,
|
2022-10-17 11:00:02 +01:00
|
|
|
nvfetcher,
|
2022-10-13 00:31:08 +01:00
|
|
|
deploy-rs,
|
2023-02-26 05:44:54 +00:00
|
|
|
...
|
|
|
|
} @ inputs: let
|
2022-10-12 01:17:49 +01:00
|
|
|
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
|
2023-02-26 05:44:54 +00:00
|
|
|
tlaternet = nixpkgs.lib.nixosSystem {
|
2022-10-12 01:17:49 +01:00
|
|
|
inherit system;
|
2023-02-26 05:44:54 +00:00
|
|
|
specialArgs.flake-inputs = inputs;
|
|
|
|
|
|
|
|
modules = [
|
|
|
|
./configuration
|
|
|
|
./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";
|
2022-11-05 17:59:27 +00:00
|
|
|
sshOpts = ["-p" "2222" "-o" "ForwardAgent=yes"];
|
2022-10-13 00:31:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#########
|
|
|
|
# Tests #
|
|
|
|
#########
|
|
|
|
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
####################
|
|
|
|
# Helper functions #
|
|
|
|
####################
|
2023-02-26 05:44:54 +00:00
|
|
|
lib = import ./lib {inherit (nixpkgs) lib;};
|
2022-10-13 00:03:32 +01:00
|
|
|
|
2022-11-05 16:00:50 +00:00
|
|
|
###################
|
|
|
|
# Utility scripts #
|
|
|
|
###################
|
|
|
|
packages.${system} = let
|
2023-10-07 21:14:43 +01:00
|
|
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript writeShellScriptBin;
|
2023-02-26 05:44:54 +00:00
|
|
|
vm = nixpkgs.lib.nixosSystem {
|
2023-01-11 01:59:35 +00:00
|
|
|
inherit system;
|
2023-02-26 05:44:54 +00:00
|
|
|
specialArgs.flake-inputs = inputs;
|
|
|
|
|
|
|
|
modules = [
|
|
|
|
./configuration
|
|
|
|
./configuration/hardware-specific/vm.nix
|
|
|
|
];
|
2023-01-11 01:59:35 +00:00
|
|
|
};
|
2022-10-12 13:11:11 +01:00
|
|
|
in {
|
2023-01-11 01:59:35 +00:00
|
|
|
default = vm.config.system.build.vm;
|
2022-11-05 16:00:50 +00:00
|
|
|
|
|
|
|
run-vm = let
|
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
|
|
|
|
};
|
2022-11-05 16:00:50 +00:00
|
|
|
in
|
|
|
|
writeShellScript "run-vm" ''
|
2022-10-17 11:00:02 +01:00
|
|
|
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-11-05 16:00:50 +00:00
|
|
|
'';
|
2022-10-17 11:00:02 +01:00
|
|
|
|
2023-10-07 21:14:43 +01:00
|
|
|
update-pkgs = let
|
|
|
|
nvfetcher-bin = "${nvfetcher.packages.${system}.default}/bin/nvfetcher";
|
|
|
|
in
|
|
|
|
writeShellScriptBin "update-pkgs" ''
|
|
|
|
cd "$(git rev-parse --show-toplevel)/pkgs"
|
|
|
|
${nvfetcher-bin} -o _sources_pkgs -c nvfetcher.toml
|
|
|
|
'';
|
|
|
|
|
2022-10-17 11:00:02 +01:00
|
|
|
update-nextcloud-apps = let
|
2023-01-11 02:11:01 +00:00
|
|
|
nvfetcher-bin = "${nvfetcher.packages.${system}.default}/bin/nvfetcher";
|
2022-11-05 16:00:50 +00:00
|
|
|
in
|
|
|
|
writeShellScript "update-nextcloud-apps" ''
|
2022-10-17 11:00:02 +01:00
|
|
|
cd "$(git rev-parse --show-toplevel)/pkgs"
|
|
|
|
${nvfetcher-bin} -o _sources_nextcloud -c nextcloud-apps.toml
|
2022-11-05 16:00:50 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-01-11 01:59:35 +00:00
|
|
|
apps.${system} = {
|
2022-11-05 16:00:50 +00:00
|
|
|
default = {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString self.packages.${system}.run-vm;
|
|
|
|
};
|
|
|
|
|
|
|
|
update-nextcloud-apps = {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString self.packages.${system}.update-nextcloud-apps;
|
2022-10-17 11:00:02 +01:00
|
|
|
};
|
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
|
|
|
}
|