354 lines
11 KiB
Nix
354 lines
11 KiB
Nix
{
|
|
description = "Malte Tammena's system configuration";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
|
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
|
|
custom-udev-rules.url = "github:MalteT/custom-udev-rules";
|
|
|
|
nickel = {
|
|
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/develop";
|
|
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";
|
|
};
|
|
fend = {
|
|
url = "github:MalteT/fend/flake";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
hydra = {
|
|
url = "github:NixOS/hydra";
|
|
inputs.nixpkgs.follows = "nixForHydra/nixpkgs";
|
|
inputs.nix.follows = "nixForHydra";
|
|
};
|
|
nixForHydra = {
|
|
url = "github:NixOS/nix/2.7.0";
|
|
};
|
|
|
|
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;
|
|
};
|
|
radicale_infcloud = {
|
|
url = "github:Unrud/RadicaleInfCloud";
|
|
flake = false;
|
|
};
|
|
qmk-udev-rules = {
|
|
url = "github:qmk/qmk_firmware";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
utils,
|
|
nixpkgs,
|
|
nixos-hardware,
|
|
...
|
|
} @ inputs: let
|
|
pkgs = self.pkgs.x86_64-linux.nixpkgs;
|
|
|
|
hosts = [
|
|
"helix-texta"
|
|
"murex-pecten"
|
|
"cornu-aspersum"
|
|
"elysia-clarki"
|
|
"trochulus-hispidus"
|
|
];
|
|
|
|
defaultModules = [
|
|
inputs.home-manager.nixosModules.home-manager
|
|
self.nixosModules.home-manager-config
|
|
inputs.custom-udev-rules.nixosModule
|
|
inputs.sops-nix.nixosModules.sops
|
|
self.nixosModules.nixUnstable
|
|
./modules/base-system.nix
|
|
];
|
|
in
|
|
utils.lib.mkFlake {
|
|
inherit self inputs;
|
|
|
|
supportedSystems = ["x86_64-linux"];
|
|
nix.generateRegistryFromInputs = true;
|
|
nix.linkInputs = true;
|
|
|
|
sharedOverlays = [
|
|
inputs.fenix.overlay
|
|
inputs.nixpkgs-wayland.overlay
|
|
inputs.colmena.overlay
|
|
utils.overlay
|
|
(self: super: {
|
|
# Add fonts
|
|
firaCodeNerd = super.nerdfonts.override {fonts = ["FiraCode"];};
|
|
hackNerdLigatures = super.callPackage ./pkgs/hack.nix {};
|
|
# 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;
|
|
# TODO: Replace with upstream
|
|
fend = inputs.fend.packages.x86_64-linux.fend;
|
|
nickel = inputs.nickel.defaultPackage.x86_64-linux;
|
|
hydra = inputs.hydra.defaultPackage.x86_64-linux;
|
|
# TODO: Remove once hydra fixes these removed aliases
|
|
buildPerlPackage = super.perlPackages.buildPerlPackage;
|
|
netcat-openbsd = super.libressl.nc;
|
|
})
|
|
# Override cataclysm to use git
|
|
(import ./overlays/cataclysm-dda.nix)
|
|
(import ./overlays/qmk-udev-rules.nix)
|
|
(import ./overlays/sane-backends.nix)
|
|
(import ./overlays/logisim.nix)
|
|
];
|
|
|
|
hostDefaults.system = "x86_64-linux";
|
|
hostDefaults.modules = defaultModules;
|
|
|
|
hosts = builtins.listToAttrs (map (host: {
|
|
name = host;
|
|
value = {modules = [self.nixosModules.${host}];};
|
|
})
|
|
hosts);
|
|
|
|
nixosModules = {
|
|
home-manager-config = {...}: {
|
|
home-manager.verbose = true;
|
|
home-manager.useGlobalPkgs = true;
|
|
home-manager.useUserPackages = true;
|
|
};
|
|
|
|
nixUnstable = {pkgs, ...}: {
|
|
nix.registry.nixpkgs.flake = nixpkgs;
|
|
nix.package = pkgs.nixUnstable;
|
|
nix.extraOptions = ''
|
|
experimental-features = nix-command flakes
|
|
'';
|
|
};
|
|
|
|
helix-texta = {
|
|
pkgs,
|
|
config,
|
|
...
|
|
}: {
|
|
imports = [
|
|
./hosts/helix-texta.nix
|
|
./modules/light-actkbd.nix
|
|
./modules/scanner.nix
|
|
self.nixosModules.thinkpad-p1-gen3
|
|
];
|
|
|
|
config = {
|
|
# Overwrite basics
|
|
services.openssh.enable = false;
|
|
programs.mosh.enable = false;
|
|
};
|
|
};
|
|
murex-pecten = {...}: {
|
|
imports = [
|
|
nixos-hardware.nixosModules.common-pc
|
|
nixos-hardware.nixosModules.common-pc-ssd
|
|
nixos-hardware.nixosModules.common-cpu-amd
|
|
nixos-hardware.nixosModules.common-gpu-amd
|
|
./hosts/murex-pecten.nix
|
|
./hardware/aorus.nix
|
|
];
|
|
};
|
|
cornu-aspersum = {...}: {
|
|
imports = [
|
|
./hosts/cornu-aspersum.nix
|
|
./hardware/netcup-rs-2000-g9.nix
|
|
./modules/nginx-reverse-proxy.nix
|
|
./modules/ccqcraft.nix
|
|
inputs.glados.nixosModules.glados
|
|
];
|
|
};
|
|
elysia-clarki = {pkgs, ...}: {
|
|
imports = [
|
|
./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
|
|
#inputs.hydra.nixosModules.hydra
|
|
];
|
|
config = {
|
|
# Override kernel version for zfs
|
|
boot.kernelPackages = pkgs.linuxPackages_5_10;
|
|
};
|
|
};
|
|
trochulus-hispidus = {pkgs, ...}: {
|
|
imports = [
|
|
./modules/scanner.nix
|
|
./hosts/trochulus-hispidus.nix
|
|
./hardware/latitude-e7440.nix
|
|
nixos-hardware.nixosModules.common-cpu-intel
|
|
nixos-hardware.nixosModules.common-pc-laptop
|
|
nixos-hardware.nixosModules.common-pc-laptop-ssd
|
|
];
|
|
};
|
|
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
|
|
];
|
|
};
|
|
};
|
|
|
|
colmena =
|
|
{
|
|
meta = {nixpkgs = pkgs;};
|
|
defaults = {...}: {imports = defaultModules;};
|
|
}
|
|
// (builtins.listToAttrs (map (
|
|
host: {
|
|
name = host;
|
|
value = {
|
|
imports = [self.nixosModules.${host}];
|
|
config.deployment = {
|
|
targetHost = host;
|
|
targetUser = "root";
|
|
};
|
|
};
|
|
}
|
|
)
|
|
hosts));
|
|
|
|
hydraJobs = {
|
|
shell.x86_64-linux = self.devShell.x86_64-linux;
|
|
nixosConfigurations.x86_64-linux = builtins.listToAttrs (map (host: {
|
|
name = host;
|
|
value = self.nixosConfigurations.${host}.config.system.build.toplevel;
|
|
})
|
|
hosts);
|
|
};
|
|
|
|
outputsBuilder = channels: {
|
|
devShell = channels.nixpkgs.mkShell {
|
|
packages = let
|
|
date = "${pkgs.coreutils}/bin/date";
|
|
git = "${pkgs.git}/bin/git";
|
|
nixos-rebuild = "${pkgs.nixos-rebuild}/bin/nixos-rebuild";
|
|
sops = "${pkgs.sops}/bin/sops";
|
|
bat = "${pkgs.bat}/bin/bat";
|
|
echo = "${pkgs.coreutils}/bin/echo";
|
|
personalCache = "http://elysia-clarki:5000";
|
|
pingPersonalCache = "${pkgs.nix}/bin/nix store ping --store ${personalCache} --option connect-timeout 1 --option download-attempt 1 2>/dev/null";
|
|
in
|
|
with pkgs; [
|
|
(writeScriptBin "rebuild" ''
|
|
#!${stdenv.shell}
|
|
if [ -z $1 ]; then
|
|
echo "Need 'switch|boot|...'"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if personal cache is online
|
|
if ${pingPersonalCache}; then
|
|
extraSubstituters="--option extra-substituters ${personalCache}"
|
|
else
|
|
${echo} "Cache ${personalCache} is unreachable!"
|
|
fi
|
|
|
|
today=`${date} +%Y-%m-%d`
|
|
branch=`${git} branch --show-current`
|
|
rev=`${git} log -1 --format=%h`
|
|
dirty=`${git} diff --quiet || echo '~'`
|
|
|
|
NIXOS_LABEL_VERSION=$today-$branch-$rev$dirty
|
|
sudo ${nixos-rebuild} $1 --flake . $extraSubstituters
|
|
'')
|
|
(writeScriptBin "all-hosts" ''
|
|
nix eval --json .#nixosConfigurations --apply builtins.attrNames 2>/dev/null | jq -r .[]
|
|
'')
|
|
(writeScriptBin "push-to" ''
|
|
if [ -z $2 ]; then
|
|
echo "Need 'switch|boot|...'"
|
|
exit 1
|
|
fi
|
|
host=$1
|
|
action=$2
|
|
${nixos-rebuild} --flake .#$host --build-host root@$host --target-host root@$host $action
|
|
'')
|
|
(writeScriptBin "option" ''
|
|
host=$1
|
|
option=$2
|
|
nix eval .#nixosConfigurations.$host.config.$option
|
|
'')
|
|
(writeScriptBin "hm-option" ''
|
|
host=$1
|
|
option=$2
|
|
user=$3
|
|
if [[ -z $user ]]; then
|
|
user=$USER
|
|
fi
|
|
nix eval .#nixosConfigurations.$host.config.home-manager.users.$user.$option 2>/dev/null
|
|
'')
|
|
(writeScriptBin "test-config" ''
|
|
#!${stdenv.shell}
|
|
for host in $(all-hosts); do
|
|
echo == Checking ''${host}..
|
|
${nixos-rebuild} --flake .#$host dry-build 2> /tmp/build-output
|
|
if [[ $? -ne 0 ]]; then
|
|
${bat} --file-name "Failed to verify config for $host" /tmp/build-output
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo === All checks passed
|
|
'')
|
|
inputs.colmena.packages.x86_64-linux.colmena
|
|
fup-repl
|
|
alejandra
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|