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-04-23 04:06:50 +01:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
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,
|
|
|
|
sops-nix,
|
|
|
|
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 #
|
|
|
|
##################
|
|
|
|
nixosConfigurations = let
|
|
|
|
# Modules that should be generic to all systems
|
|
|
|
genericModule = {...}: {
|
|
|
|
imports = [
|
|
|
|
# Inject flake dependencies
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
tlaternet-webserver.nixosModules.default
|
|
|
|
|
|
|
|
# Import actual configuration
|
|
|
|
(import ./configuration)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
# The actual system definition
|
2022-10-12 01:17:49 +01:00
|
|
|
tlaternet = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
modules = [
|
2022-10-13 00:03:32 +01:00
|
|
|
genericModule
|
|
|
|
(import ./configuration/hardware-specific/linode)
|
2022-10-10 13:03:08 +01:00
|
|
|
];
|
2022-10-12 01:17:49 +01:00
|
|
|
};
|
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
# A qemu VM to test the above with
|
2022-10-12 01:17:49 +01:00
|
|
|
vm = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
modules = [
|
2022-10-13 00:03:32 +01:00
|
|
|
genericModule
|
|
|
|
(import ./configuration/hardware-specific/vm.nix)
|
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:03:32 +01:00
|
|
|
####################
|
|
|
|
# Helper functions #
|
|
|
|
####################
|
|
|
|
lib = import ./lib {lib = nixpkgs.lib;};
|
|
|
|
|
|
|
|
####################
|
|
|
|
# VM launch script #
|
|
|
|
####################
|
2022-10-12 13:11:11 +01:00
|
|
|
apps.${system}.default = let
|
|
|
|
inherit (self.nixosConfigurations.vm.config.system.build) vm;
|
|
|
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
2022-10-13 00:03:32 +01:00
|
|
|
qemuNetOpts = self.lib.makeQemuNetOpts {
|
2022-10-12 13:11:11 +01:00
|
|
|
"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 -curses"
|
2022-10-13 00:03:32 +01:00
|
|
|
export QEMU_NET_OPTS="${qemuNetOpts}"
|
2022-10-12 13:11:11 +01:00
|
|
|
"${vm}/bin/run-tlaternet-vm"
|
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
###########################
|
|
|
|
# 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
|
|
|
|
2022-10-13 00:03:32 +01:00
|
|
|
shellHook = ''
|
|
|
|
# Work around sudo requiring a full terminal when deploying to
|
|
|
|
# a remote host
|
|
|
|
export NIX_SSHOPTS="-t"
|
|
|
|
'';
|
|
|
|
};
|
2022-10-12 01:17:49 +01:00
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
}
|