2021-04-12 01:35:24 +01:00
|
|
|
{
|
|
|
|
description = "tlater.net host configuration";
|
|
|
|
|
|
|
|
inputs = {
|
2022-06-09 22:42:03 +01:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
2021-04-12 01:35:24 +01:00
|
|
|
nixos-hardware.url = "github:nixos/nixos-hardware/master";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
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";
|
|
|
|
inputs = {
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
tlaternet-templates = {
|
|
|
|
url = "git+https://gitea.tlater.net/tlaternet/tlaternet-templates.git";
|
|
|
|
inputs = {
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
2021-04-12 01:35:24 +01:00
|
|
|
};
|
|
|
|
|
2022-04-23 04:06:50 +01:00
|
|
|
outputs = { self, nixpkgs, nixos-hardware, flake-utils, sops-nix
|
|
|
|
, tlaternet-webserver, tlaternet-templates, ... }@inputs:
|
2021-04-12 01:44:10 +01:00
|
|
|
let
|
|
|
|
overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
tlaternet-webserver =
|
|
|
|
tlaternet-webserver.legacyPackages.${prev.system}.packages;
|
|
|
|
tlaternet-templates =
|
|
|
|
tlaternet-templates.legacyPackages.${prev.system}.packages;
|
2021-04-25 04:50:30 +01:00
|
|
|
local = import ./pkgs {
|
|
|
|
pkgs = prev;
|
|
|
|
local-lib = self.lib.${prev.system};
|
|
|
|
};
|
2021-04-12 01:44:10 +01:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
in {
|
2021-04-12 01:35:24 +01:00
|
|
|
nixosConfigurations = {
|
2021-04-25 04:50:30 +01:00
|
|
|
tlaternet = let system = "x86_64-linux";
|
|
|
|
in nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
2021-04-12 01:35:24 +01:00
|
|
|
|
|
|
|
modules = [
|
2021-04-18 02:58:49 +01:00
|
|
|
({ modulesPath, ... }: {
|
|
|
|
imports = [ (modulesPath + "/profiles/headless.nix") ];
|
|
|
|
nixpkgs.overlays = overlays;
|
|
|
|
})
|
2021-04-12 01:40:19 +01:00
|
|
|
(import ./modules)
|
|
|
|
|
2021-04-12 01:35:24 +01:00
|
|
|
(import ./configuration)
|
|
|
|
(import ./configuration/linode.nix)
|
|
|
|
(import ./configuration/hardware-configuration.nix)
|
2022-04-23 04:06:50 +01:00
|
|
|
sops-nix.nixosModules.sops
|
2021-04-12 01:35:24 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-04-25 04:50:30 +01:00
|
|
|
vm = let system = "x86_64-linux";
|
|
|
|
in nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
2021-04-12 01:35:24 +01:00
|
|
|
|
|
|
|
modules = [
|
2021-04-18 02:58:49 +01:00
|
|
|
({ modulesPath, ... }: {
|
|
|
|
imports = [ (modulesPath + "/profiles/headless.nix") ];
|
|
|
|
nixpkgs.overlays = overlays;
|
|
|
|
})
|
2021-04-12 01:40:19 +01:00
|
|
|
(import ./modules)
|
|
|
|
|
2021-04-12 01:35:24 +01:00
|
|
|
(import ./configuration)
|
2022-04-23 04:06:50 +01:00
|
|
|
sops-nix.nixosModules.sops
|
2021-05-17 00:00:34 +01:00
|
|
|
({ lib, ... }: {
|
2021-04-12 01:35:24 +01:00
|
|
|
users.users.tlater.password = "insecure";
|
2021-04-25 02:29:01 +01:00
|
|
|
|
|
|
|
# Disable graphical tty so -curses works
|
|
|
|
boot.kernelParams = [ "nomodeset" ];
|
|
|
|
|
2021-05-17 00:00:34 +01:00
|
|
|
# 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";
|
|
|
|
|
2021-04-25 02:29:01 +01:00
|
|
|
# # Set up VM settings to match real VPS
|
2021-04-12 01:35:24 +01:00
|
|
|
# virtualisation.memorySize = 3941;
|
|
|
|
# virtualisation.cores = 2;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2021-04-22 22:32:54 +01:00
|
|
|
} // flake-utils.lib.eachDefaultSystem (system:
|
2022-04-23 04:06:50 +01:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
sops-pkgs = sops-nix.packages.${system};
|
2021-04-22 22:32:54 +01:00
|
|
|
in {
|
2022-04-23 04:06:50 +01:00
|
|
|
devShell =
|
|
|
|
pkgs.mkShell {
|
|
|
|
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
|
|
|
nativeBuildInputs = with sops-pkgs; [
|
|
|
|
sops-import-keys-hook
|
|
|
|
];
|
|
|
|
buildInputs = with pkgs; with sops-pkgs; [
|
2021-07-25 22:21:29 +01:00
|
|
|
nixfmt
|
|
|
|
git-lfs
|
2022-04-23 04:06:50 +01:00
|
|
|
sops-init-gpg-key
|
2021-07-25 22:21:29 +01:00
|
|
|
|
|
|
|
# For the minecraft mod update script
|
|
|
|
(python3.withPackages (pypkgs:
|
|
|
|
with pypkgs; [
|
2021-10-06 01:13:31 +01:00
|
|
|
dateutil
|
2021-07-25 22:21:29 +01:00
|
|
|
requests
|
|
|
|
|
|
|
|
ipython
|
2022-04-21 18:00:09 +01:00
|
|
|
|
|
|
|
python3.withPackages (ppkgs:
|
|
|
|
with pkgs; [
|
|
|
|
python-lsp-server
|
|
|
|
python-lsp-black
|
|
|
|
pyls-isort
|
|
|
|
pyls-mypy
|
|
|
|
rope
|
|
|
|
pyflakes
|
|
|
|
mccabe
|
|
|
|
pycodestyle
|
|
|
|
pydocstyle
|
|
|
|
])
|
2021-07-25 22:21:29 +01:00
|
|
|
]))
|
|
|
|
];
|
2022-04-23 04:08:45 +01:00
|
|
|
shellHook = let
|
|
|
|
inherit (pkgs.lib.attrsets) mapAttrsToList;
|
|
|
|
inherit (pkgs.lib.strings) concatStringsSep;
|
|
|
|
ports = {
|
|
|
|
"3022" = "2222";
|
|
|
|
"3080" = "80";
|
|
|
|
"3443" = "443";
|
|
|
|
"3021" = "2221";
|
|
|
|
"25565" = "25565";
|
|
|
|
"21025" = "21025"; # Starbound
|
|
|
|
};
|
|
|
|
QEMU_NET_OPTS =
|
|
|
|
concatStringsSep ","
|
|
|
|
(mapAttrsToList
|
|
|
|
(host: vm: "hostfwd=::${host}-:${vm}")
|
|
|
|
ports);
|
|
|
|
in
|
|
|
|
''
|
2021-04-22 22:32:54 +01:00
|
|
|
export QEMU_OPTS="-m 3941 -smp 2 -curses"
|
2022-04-23 04:08:45 +01:00
|
|
|
export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
|
2021-04-28 00:04:30 +01:00
|
|
|
|
|
|
|
# Work around sudo requiring a full terminal
|
|
|
|
export NIX_SSHOPTS="-t"
|
2021-04-22 22:32:54 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-04-25 04:50:30 +01:00
|
|
|
packages = import ./pkgs {
|
|
|
|
inherit pkgs;
|
|
|
|
local-lib = self.lib.${system};
|
|
|
|
};
|
|
|
|
|
|
|
|
lib = import ./lib {
|
|
|
|
inherit pkgs inputs;
|
|
|
|
lib = nixpkgs.lib;
|
|
|
|
};
|
2021-04-22 22:32:54 +01:00
|
|
|
});
|
2021-04-12 01:35:24 +01:00
|
|
|
}
|