Files
nixos-core/flake.nix
T
kiskaadee 61a2798d4f build(nix): unify Python dev environment via .venv symlink and add pyright to scripts/test
- Extract shared pythonEnv in flake.nix and symlink .venv in devShell
  shellHook so IDEs, terminal, and Nix checks share one Python 3.14 env.
- Add pyright static type checking to scripts/test and align pre-commit
  with the unified Nix environment.
- Remove personal domain from flake.nix description and ignore .venv.
2026-10-15 19:27:30 -05:00

67 lines
1.5 KiB
Nix

{
description = "Homelab Core — Turnkey Declarative NixOS Appliance";
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, sops-nix, ... }@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
pyyaml
types-pyyaml
pytest
pydantic
]);
in
{
nixosConfigurations.server = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [
./nixos/configuration.nix
sops-nix.nixosModules.sops
];
};
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
pythonEnv
pyright
ruff
];
shellHook = ''
git config core.hooksPath .githooks 2>/dev/null || true
if [ -d .venv ] && [ ! -L .venv ]; then
rm -rf .venv
fi
ln -sfn ${pythonEnv} .venv
'';
};
checks.${system} = {
test-suite = pkgs.runCommand "core-tests" {
nativeBuildInputs = with pkgs; [
git
pythonEnv
ruff
];
} ''
mkdir -p $out
cp -r ${self} source
chmod -R u+w source
cd source
HOME=/tmp ruff check --no-cache .
HOME=/tmp pytest -o cache_dir=/tmp/.pytest_cache tests/
'';
};
};
}