Tristan Daniël Maat
3e200c896a
Flake lock file updates: • Updated input 'flake-utils': 'github:numtide/flake-utils/a4b154ebbdc88c8498a5c7b01589addc9e9cb678' (2022-04-11) → 'github:numtide/flake-utils/1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1' (2022-05-30) • Updated input 'nixos-hardware': 'github:nixos/nixos-hardware/6b4ebea9093c997c5f275c820e679108de4871ab' (2022-04-21) → 'github:nixos/nixos-hardware/0cab18a48de7914ef8cad35dca0bb36868f3e1af' (2022-06-01) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/9887f024766aa27704d1f89f623efd1d063da92a' (2022-04-21) → 'github:nixos/nixpkgs/11e805f9935f6ab4b049351ac14f2d1aa93cf1d3' (2022-06-07) • Updated input 'sops-nix': 'github:Mic92/sops-nix/c2614c4fe61943b3d280ac1892fcebe6e8eaf8c8' (2022-04-12) → 'github:Mic92/sops-nix/f075361ecbde21535b38e41dfaa28a28f160855c' (2022-06-05) • Added input 'sops-nix/nixpkgs-21_11': 'github:NixOS/nixpkgs/2de556c4cd46a59e8ce2f85ee4dd400983213d45' (2022-06-04) • Added input 'sops-nix/nixpkgs-22_05': 'github:NixOS/nixpkgs/d6cb04299ce8964290ae7fdcb87aa50da0500b5c' (2022-06-04)
170 lines
5 KiB
Nix
170 lines
5 KiB
Nix
{
|
|
description = "tlater.net host configuration";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
|
nixos-hardware.url = "github:nixos/nixos-hardware/master";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, nixos-hardware, flake-utils, sops-nix
|
|
, tlaternet-webserver, tlaternet-templates, ... }@inputs:
|
|
let
|
|
overlays = [
|
|
(final: prev: {
|
|
tlaternet-webserver =
|
|
tlaternet-webserver.legacyPackages.${prev.system}.packages;
|
|
tlaternet-templates =
|
|
tlaternet-templates.legacyPackages.${prev.system}.packages;
|
|
local = import ./pkgs {
|
|
pkgs = prev;
|
|
local-lib = self.lib.${prev.system};
|
|
};
|
|
})
|
|
];
|
|
|
|
in {
|
|
nixosConfigurations = {
|
|
tlaternet = let system = "x86_64-linux";
|
|
in 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
|
|
];
|
|
};
|
|
|
|
vm = let system = "x86_64-linux";
|
|
in 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";
|
|
|
|
# # Set up VM settings to match real VPS
|
|
# virtualisation.memorySize = 3941;
|
|
# virtualisation.cores = 2;
|
|
})
|
|
];
|
|
};
|
|
};
|
|
} // flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
sops-pkgs = sops-nix.packages.${system};
|
|
in {
|
|
devShell =
|
|
pkgs.mkShell {
|
|
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
|
nativeBuildInputs = with sops-pkgs; [
|
|
sops-import-keys-hook
|
|
];
|
|
buildInputs = with pkgs; with sops-pkgs; [
|
|
nixfmt
|
|
git-lfs
|
|
sops-init-gpg-key
|
|
|
|
# For the minecraft mod update script
|
|
(python3.withPackages (pypkgs:
|
|
with pypkgs; [
|
|
dateutil
|
|
requests
|
|
|
|
ipython
|
|
|
|
python3.withPackages (ppkgs:
|
|
with pkgs; [
|
|
python-lsp-server
|
|
python-lsp-black
|
|
pyls-isort
|
|
pyls-mypy
|
|
rope
|
|
pyflakes
|
|
mccabe
|
|
pycodestyle
|
|
pydocstyle
|
|
])
|
|
]))
|
|
];
|
|
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
|
|
''
|
|
export QEMU_OPTS="-m 3941 -smp 2 -curses"
|
|
export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
|
|
|
|
# Work around sudo requiring a full terminal
|
|
export NIX_SSHOPTS="-t"
|
|
'';
|
|
};
|
|
|
|
packages = import ./pkgs {
|
|
inherit pkgs;
|
|
local-lib = self.lib.${system};
|
|
};
|
|
|
|
lib = import ./lib {
|
|
inherit pkgs inputs;
|
|
lib = nixpkgs.lib;
|
|
};
|
|
});
|
|
}
|