2021-04-12 01:35:24 +01:00
|
|
|
{
|
|
|
|
description = "tlater.net host configuration";
|
|
|
|
|
|
|
|
inputs = {
|
2021-12-17 18:40:40 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
|
2021-04-12 01:35:24 +01:00
|
|
|
nixos-hardware.url = "github:nixos/nixos-hardware/master";
|
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,
|
|
|
|
nixos-hardware,
|
|
|
|
sops-nix,
|
|
|
|
tlaternet-webserver,
|
2022-10-12 01:17:49 +01:00
|
|
|
}: let
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
2022-10-10 13:03:08 +01:00
|
|
|
overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
local = import ./pkgs {
|
|
|
|
pkgs = prev;
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
2022-10-10 13:03:08 +01:00
|
|
|
})
|
|
|
|
];
|
2022-10-12 01:17:49 +01:00
|
|
|
|
|
|
|
pkgs = import nixpkgs {inherit system overlays;};
|
|
|
|
sops-pkgs = sops-nix.packages.${system};
|
|
|
|
in {
|
|
|
|
nixosConfigurations = {
|
|
|
|
tlaternet = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
modules = [
|
|
|
|
({modulesPath, ...}: {
|
|
|
|
imports = [(modulesPath + "/profiles/headless.nix")];
|
|
|
|
nixpkgs.overlays = overlays;
|
|
|
|
})
|
|
|
|
(import ./modules)
|
|
|
|
|
|
|
|
(import ./configuration)
|
|
|
|
(import ./configuration/linode.nix)
|
|
|
|
(import ./configuration/hardware-configuration.nix)
|
|
|
|
sops-nix.nixosModules.sops
|
2022-10-12 19:58:09 +01:00
|
|
|
tlaternet-webserver.nixosModules.default
|
2022-10-10 13:03:08 +01:00
|
|
|
];
|
2022-10-12 01:17:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
vm = nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
modules = [
|
|
|
|
({modulesPath, ...}: {
|
|
|
|
imports = [(modulesPath + "/profiles/headless.nix")];
|
|
|
|
nixpkgs.overlays = overlays;
|
|
|
|
})
|
|
|
|
(import ./modules)
|
|
|
|
|
|
|
|
(import ./configuration)
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
({lib, ...}: {
|
|
|
|
users.users.tlater.password = "insecure";
|
|
|
|
|
|
|
|
# Disable graphical tty so -curses works
|
|
|
|
boot.kernelParams = ["nomodeset"];
|
|
|
|
|
|
|
|
# Sets the base domain for nginx to localhost so that we
|
|
|
|
# can easily test locally with the VM.
|
|
|
|
services.nginx.domain = lib.mkOverride 99 "localhost";
|
|
|
|
|
2022-10-12 02:03:22 +01:00
|
|
|
# Use the staging secrets
|
|
|
|
sops.defaultSopsFile = lib.mkOverride 99 ./keys/staging.yaml;
|
|
|
|
|
2022-10-12 01:17:49 +01:00
|
|
|
# # Set up VM settings to match real VPS
|
|
|
|
# virtualisation.memorySize = 3941;
|
|
|
|
# virtualisation.cores = 2;
|
|
|
|
})
|
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-12 13:11:11 +01:00
|
|
|
apps.${system}.default = let
|
|
|
|
inherit (self.nixosConfigurations.vm.config.system.build) vm;
|
|
|
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
|
|
|
inherit (nixpkgs.lib.attrsets) mapAttrsToList;
|
|
|
|
inherit (nixpkgs.lib.strings) concatStringsSep;
|
|
|
|
ports = {
|
|
|
|
"2222" = "2222";
|
|
|
|
"3080" = "80";
|
|
|
|
"3443" = "443";
|
|
|
|
"2221" = "2221";
|
|
|
|
"21025" = "21025"; # Starbound
|
|
|
|
};
|
|
|
|
QEMU_NET_OPTS =
|
|
|
|
concatStringsSep ","
|
|
|
|
(mapAttrsToList
|
|
|
|
(host: vm: "hostfwd=::${host}-:${vm}")
|
|
|
|
ports);
|
|
|
|
in {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (writeShellScript "run-vm" ''
|
|
|
|
export QEMU_OPTS="-m 3941 -smp 2 -curses"
|
|
|
|
export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
|
|
|
|
"${vm}/bin/run-tlaternet-vm"
|
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
2022-10-12 01:17:49 +01:00
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
|
|
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
|
|
|
nativeBuildInputs = [
|
|
|
|
sops-pkgs.sops-import-keys-hook
|
|
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
nixfmt
|
|
|
|
git-lfs
|
|
|
|
sops-pkgs.sops-init-gpg-key
|
|
|
|
];
|
|
|
|
|
2022-10-12 13:11:11 +01:00
|
|
|
shellHook = ''
|
2022-10-12 01:17:49 +01:00
|
|
|
# Work around sudo requiring a full terminal when deploying to
|
|
|
|
# a remote host
|
|
|
|
export NIX_SSHOPTS="-t"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
}
|