synix/flake.nix
sid ecf5132cbb
Some checks failed
Build tests / build-hosts (pull_request) Failing after 3s
Flake check / flake-check (pull_request) Failing after 13s
enforce new flake schema. formatting.
2026-05-31 18:50:41 +02:00

292 lines
8.6 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
nix.url = "github:DeterminateSystems/nix-src/flake-schemas";
flake-schemas.url = "github:DeterminateSystems/flake-schemas";
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-25.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixvim.url = "github:nix-community/nixvim/nixos-25.11";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
nur.url = "github:nix-community/NUR";
nur.inputs.nixpkgs.follows = "nixpkgs";
stylix.url = "github:nix-community/stylix/release-25.11";
stylix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
...
}@inputs:
let
inherit (self) outputs;
systems = [
"x86_64-linux"
"aarch64-linux" # For testing only. Use at your own risk.
];
lib = nixpkgs.lib.extend (_final: _prev: self.lib.utils or { });
mkPkgs =
{
system,
config ? { },
}:
import nixpkgs {
inherit system;
inherit config;
overlays = [
self.overlays.modifications
self.overlays.additions
inputs.nix.overlays.default
(final: prev: { synix = self.overlays.additions final prev; })
];
};
forAllSystems =
function:
lib.genAttrs systems (
system:
function (mkPkgs {
inherit system;
})
);
mkNixosConfiguration =
system: modules:
nixpkgs.lib.nixosSystem {
inherit system modules;
specialArgs = {
inherit inputs outputs lib;
};
};
mkHomeConfiguration =
system: modules:
inputs.home-manager.lib.homeManagerConfiguration {
pkgs = mkPkgs { inherit system; };
inherit modules;
extraSpecialArgs = {
inherit inputs outputs;
};
};
in
{
inherit (inputs.flake-schemas) schemas;
apps = forAllSystems (
pkgs:
let
mkApp = name: description: {
type = "app";
program = pkgs.lib.getExe (pkgs.callPackage ./apps/${name} { });
meta.description = description;
};
in
{
create = mkApp "create" "Create a new NixOS configuration.";
deploy = mkApp "deploy" "Deploy NixOS configurations in your flake.";
install = mkApp "install" "Install a NixOS configuration.";
rebuild = mkApp "rebuild" "Wrapper script for 'nixos-rebuild switch' and 'home-manager switch' commands.";
update-packages = mkApp "update-packages" "Update all packages in this flake.";
wake-host = mkApp "wake-host" "Wake a host with WakeOnLan.";
}
);
lib = {
utils = import ./lib/utils.nix { inherit (nixpkgs) lib; };
helpers = {
inherit mkPkgs;
};
};
packages = forAllSystems (
pkgs:
let
inherit (pkgs.stdenv.hostPlatform) system;
allArchs = import ./pkgs { inherit pkgs; };
x64only =
if system == "x86_64-linux" then
{
}
else
{ };
in
allArchs // x64only
);
overlays = import ./overlays { inherit inputs; };
nixosModules = import ./modules/nixos;
homeModules = import ./modules/home;
# test configs
nixosConfigurations = {
nixos-hyprland = mkNixosConfiguration "x86_64-linux" [ ./tests/build/nixos-hyprland ];
nixos-server = mkNixosConfiguration "x86_64-linux" [ ./tests/build/nixos-server ];
};
homeConfigurations = {
hm-hyprland = mkHomeConfiguration "x86_64-linux" [ ./tests/build/hm-hyprland ];
};
devShells = forAllSystems (
pkgs:
let
inherit (pkgs.stdenv.hostPlatform) system;
inherit (self.checks.${system}.pre-commit-check) shellHook enabledPackages;
in
{
default = pkgs.mkShell {
inherit shellHook;
nativeBuildInputs = [
enabledPackages
pkgs.nix
]
++ (with pkgs; [
(python313.withPackages (
p: with p; [
mkdocs
mkdocs-material
mkdocs-material-extensions
pygments
]
))
]);
};
nix-config = pkgs.mkShell {
inherit shellHook;
nativeBuildInputs = [ enabledPackages ];
};
install-hm = pkgs.mkShell {
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
nativeBuildInputs = [ pkgs.home-manager ];
};
}
);
formatter = forAllSystems (
pkgs:
let
inherit (pkgs.stdenv.hostPlatform) system;
inherit (self.checks.${system}.pre-commit-check.config) package configFile;
in
pkgs.writeShellScriptBin "pre-commit-run" "${pkgs.lib.getExe package} run --all-files --config ${configFile}"
);
checks = forAllSystems (
pkgs:
let
inherit (pkgs.stdenv.hostPlatform) system;
in
{
pre-commit-check = inputs.git-hooks.lib.${system}.run {
src = ./.;
hooks = {
actionlint.enable = true;
nixfmt = {
enable = true;
settings.width = 120;
};
shellcheck.enable = true;
statix.enable = true;
yamllint = {
enable = true;
excludes = [ "secrets.yaml" ];
settings.configData = "{rules: {line-length: {max: 120}}}";
};
};
};
build-additions = pkgs.linkFarm "added-packages-${system}" self.packages.${system};
build-modifications = pkgs.linkFarm "modified-packages-${system}" (
lib.filterAttrs (_: v: lib.isDerivation v) (self.overlays.modifications pkgs pkgs)
);
synapse-test =
let
testPkgs = mkPkgs {
inherit system;
config.permittedInsecurePackages = [ "olm-3.2.16" ];
};
in
testPkgs.testers.runNixOSTest ./tests/run/synapse.nix;
open-webui-oci-test = pkgs.testers.runNixOSTest ./tests/run/open-webui-oci.nix;
# librechat-oci-test = pkgs.testers.runNixOSTest ./tests/run/librechat-oci.nix; # FIXME: unable to copy from source docker://quay.io/mongo:7.0
}
);
hydraJobs = {
inherit (self)
packages
;
};
templates = {
hetzner-amd = {
path = ./templates/nix-configs/hetzner-amd;
description = "Basic NixOS configuration for AMD based Hetzner VPS.";
};
hyprland = {
path = ./templates/nix-configs/hyprland;
description = "Basic NixOS configuration for clients running Hyprland with standalone Home Manager.";
};
pi4 = {
path = ./templates/nix-configs/pi4;
description = "Basic NixOS configuration for Raspberry Pi 4.";
};
server = {
path = ./templates/nix-configs/server;
description = "Basic NixOS configuration for servers.";
};
vm-uefi = {
path = ./templates/nix-configs/vm-uefi;
description = "Basic NixOS configuration for VMs (UEFI).";
};
microvm = {
path = ./templates/microvm;
description = "MicroVM NixOS configurations";
};
container = {
path = ./templates/container;
description = "Container NixOS configurations";
};
c-hello = {
path = ./templates/dev/c-hello;
description = "C hello world template.";
};
esp-blink = {
path = ./templates/dev/esp-blink;
description = "ESP32 blink template.";
};
flask-hello = {
path = ./templates/dev/flask-hello;
description = "Python Flask hello template.";
};
py-hello = {
path = ./templates/dev/py-hello;
description = "Python hello world template.";
};
rs-hello = {
path = ./templates/dev/rs-hello;
description = "Rust hello world template.";
};
stm32-blink = {
path = ./templates/dev/stm32-blink;
description = "STM32G4 blink template with libopencm3.";
};
};
};
}