nixos/flake.nix

351 lines
11 KiB
Nix

{
description = "Malte Tammena's system configuration";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixos-hardware = {
url = "github:NixOS/nixos-hardware";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};
emulator-2a = {
url = "github:MalteT/2a-emulator/develop";
inputs.nixpkgs.follows = "nixpkgs";
};
mensa = {
url = "github:MalteT/mensa/main";
inputs.nixpkgs.follows = "nixpkgs";
};
custom-udev-rules = {
url = "github:MalteT/custom-udev-rules";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
colmena = {
url = "github:zhaofengli/colmena";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
glados = {
url = "git+https://git.sr.ht/~megamanmalte/GLaDOS?ref=main";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
gruvbox-material-gtk = {
url = "github:sainnhe/gruvbox-material-gtk";
flake = false;
};
rip = {
url = "github:nivekuil/rip";
flake = false;
};
"2i-emulator" = {
url = "github:klemens/2i-emulator";
flake = false;
};
"cataclysm-dda" = {
url = "github:CleverRaven/Cataclysm-DDA";
flake = false;
};
"fend" = {
url = "github:MalteT/fend/flake";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixos-hardware, home-manager, ... }@inputs: {
colmena = {
meta = { nixpkgs = import nixpkgs { system = "x86_64-linux"; }; };
helix-texta = { name, nodes, pkgs, ... }: {
imports = [ self.nixosModules.helix-texta ];
config.deployment = {
allowLocalDeployment = true;
targetHost = null;
};
};
achatina-fulica = { ... }: {
imports = [ self.nixosModules.achatina-fulica ];
config.deployment = {
targetHost = "cal.tammena.rocks";
targetUser = "root";
};
};
cornu-aspersum = { ... }: {
imports = [ self.nixosModules.cornu-aspersum ];
config.deployment = {
targetHost = "ccqcraft.de";
targetUser = "root";
};
};
elysia-clarki = { ... }: {
imports = [ self.nixosModules.elysia-clarki ];
config.deployment = {
targetHost = "elysia-clarki";
targetUser = "root";
};
};
};
nixosModules = {
helix-texta = { pkgs, config, ... }: {
imports = [
./hosts/helix-texta.nix
./modules/light-actkbd.nix
./modules/scanner.nix
self.nixosModules.thinkpad-p1-gen3
home-manager.nixosModules.home-manager
self.nixosModules.home-manager-config
self.nixosModules.x86_64-linux-basics
];
config = {
nix = {
# add binary caches
binaryCachePublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
];
binaryCaches = nixpkgs.lib.mkForce [
"https://cache.nixos.org"
"https://nixpkgs-wayland.cachix.org"
];
};
environment.systemPackages =
[ inputs.colmena.packages.${config.nixpkgs.system}.colmena ];
# Overwrite basics
services.openssh.enable = false;
programs.mosh.enable = false;
# Overlays only relevant to my primary laptop
nixpkgs.overlays = [
inputs.nixpkgs-wayland.overlay
inputs.fenix.overlay
(import ./overlays/sane-backends.nix)
(import ./overlays/logisim.nix)
];
};
};
achatina-fulica = { ... }: {
imports = [
self.nixosModules.x86_64-linux-basics
inputs.glados.nixosModules.glados
./hosts/achatina-fulica.nix
./hardware/netcup-minimal.nix
./modules/nginx-reverse-proxy.nix
./modules/radicale.nix
./modules/grafana.nix
];
};
cornu-aspersum = { ... }: {
imports = [
self.nixosModules.x86_64-linux-basics
./hosts/cornu-aspersum.nix
./hardware/netcup-rs-2000-g9.nix
./modules/nginx-reverse-proxy.nix
./modules/ccqcraft.nix
];
};
elysia-clarki = { pkgs, ... }: {
imports = [
self.nixosModules.x86_64-linux-basics
./hosts/elysia-clarki.nix
./hardware/intel-nuc.nix
./modules/local-build-service.nix
./modules/nginx-reverse-proxy.nix
./modules/binary-cache.nix
./modules/ccqcraft-backups.nix
];
config = {
# Override kernel version for zfs
boot.kernelPackages = pkgs.linuxPackages_5_10;
};
};
trochulus-hispidus = { pkgs, ... }: {
imports = [
home-manager.nixosModules.home-manager
self.nixosModules.x86_64-linux-basics
self.nixosModules.home-manager-config
./hosts/trochulus-hispidus.nix
./hardware/latitude-e7440.nix
];
};
};
nixosModules.thinkpad-p1-gen3 = { ... }: {
imports = [
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-gpu-nvidia
nixos-hardware.nixosModules.common-pc-laptop
nixos-hardware.nixosModules.common-pc-laptop-ssd
nixos-hardware.nixosModules.common-pc-laptop-acpi_call
./hardware/thinkpad-p1-gen3.nix
];
};
nixosModules.home-manager-config = { ... }: {
home-manager.verbose = true;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
};
# Necessary for flakes to work
nixosModules.nixUnstable = { pkgs, ... }: {
nix.registry.nixpkgs.flake = nixpkgs;
nix.package = pkgs.nixUnstable;
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
nixpkgs.overlays = [ (self: super: { nix = super.nixUnstable; }) ];
};
# Some basics that every machine should have
nixosModules.x86_64-linux-basics = { pkgs, ... }: {
imports = [
inputs.custom-udev-rules.nixosModule
inputs.sops-nix.nixosModules.sops
self.nixosModules.nixUnstable
./modules/neovim.nix
];
# Basic system things
system.configurationRevision = pkgs.lib.mkIf (self ? rev) self.rev;
nixpkgs.config = {
allowUnfree = true;
joypixels.acceptLicense = true;
};
hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = true;
# Make sure that I can log in
users.users.root = {
openssh.authorizedKeys.keyFiles = [ ./malte/yubikey.pub ];
};
# Basic packages
environment.systemPackages = with pkgs; [ git sops htop ];
# Enable mosh for some SSH superpower
programs.mosh.enable = pkgs.lib.mkDefault true;
services.openssh.enable = pkgs.lib.mkDefault true;
# My timezone
time.timeZone = "Europe/Berlin";
# Default locale on all systems
i18n.defaultLocale = pkgs.lib.mkDefault "en_US.UTF-8";
# Some boot defaults
boot.kernelPackages = pkgs.lib.mkDefault pkgs.linuxPackages_latest;
boot.loader.timeout = pkgs.lib.mkDefault 1;
boot.loader.systemd-boot.configurationLimit = 50;
# This is set explicitly in all configurations, let's just do it here
networking.useDHCP = false;
# Add some useful overlays
nixpkgs.overlays = [
(self: super: {
# Add FiraCode as a package, but use NerdFonts
firaCodeNerd = super.nerdfonts.override { fonts = [ "FiraCode" ]; };
# Add the emulator
"2a-emulator" =
inputs.emulator-2a.packages.x86_64-linux."2a-emulator";
# Add my mensa tool
mensa = inputs.mensa.packages.x86_64-linux.mensa;
fend = inputs.fend.packages.x86_64-linux.fend;
})
# Some program adjustments
(import ./overlays/cataclysm-dda.nix)
];
};
# My thinkpad P1
nixosConfigurations.helix-texta = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ self.nixosModules.helix-texta ];
};
# Currently hosted by NetCup
nixosConfigurations.achatina-fulica = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ self.nixosModules.achatina-fulica ];
};
# Currently hosted by NetCup (mostly Minecraft server)
nixosConfigurations.cornu-aspersum = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ self.nixosModules.cornu-aspersum ];
};
# Server @home
nixosConfigurations.elysia-clarki = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.x86_64-linux-basics
./hosts/elysia-clarki.nix
./hardware/intel-nuc.nix
./modules/local-build-service.nix
./modules/nginx-reverse-proxy.nix
./modules/binary-cache.nix
./modules/ccqcraft-backups.nix
({ pkgs, ... }: {
# Override kernel version for zfs
boot.kernelPackages = pkgs.linuxPackages_5_10;
})
];
};
# Marie's laptop
nixosConfigurations.trochulus-hispidus = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ self.nixosModules.trochulus-hispidus ];
};
devShell.x86_64-linux =
let pkgs = import nixpkgs { system = "x86_64-linux"; };
in pkgs.mkShell {
packages = [
(with pkgs;
writeScriptBin "rebuild" ''
#!${stdenv.shell}
if [ -z $1 ]; then
echo "Need 'switch|boot|...'"
exit 1
fi
today=`${coreutils}/bin/date +%Y-%m-%d`
branch=`${git}/bin/git branch --show-current`
rev=`${git}/bin/git log -1 --format=%h`
dirty=`${git}/bin/git diff --quiet || echo '~'`
NIXOS_LABEL_VERSION=$today-$branch-$rev$dirty
# Extract build secrets
echo Extracting build secrets..
${sops}/bin/sops --extract '["multimc-client-id"]' -d secrets/secrets.yaml > build-secrets/multimc-client-id
sudo ${nixos-rebuild}/bin/nixos-rebuild $1 --flake .
'')
inputs.colmena.packages.x86_64-linux.colmena
];
};
};
}