2024-04-10 16:26:38 +00:00
|
|
|
{
|
2024-07-05 18:09:52 +00:00
|
|
|
description = "A webserver to create files for tetsing purposes";
|
2024-04-10 16:26:38 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
poetry2nix-lib = {
|
|
|
|
url = "github:nix-community/poetry2nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-11 19:11:05 +00:00
|
|
|
microvm = {
|
|
|
|
url = "github:astro/microvm.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-10 16:26:38 +00:00
|
|
|
};
|
|
|
|
|
2024-04-11 19:11:05 +00:00
|
|
|
outputs = {self, ...} @ inputs: let
|
2024-04-10 16:26:38 +00:00
|
|
|
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
2024-04-11 19:11:05 +00:00
|
|
|
forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems;
|
|
|
|
pkgs = forAllSystems (system: inputs.nixpkgs.legacyPackages.${system});
|
|
|
|
poetry2nix = forAllSystems (system: inputs.poetry2nix-lib.lib.mkPoetry2Nix {pkgs = pkgs.${system};});
|
2024-08-04 22:09:41 +00:00
|
|
|
|
|
|
|
addSetuptools = self: super: list:
|
|
|
|
builtins.listToAttrs (builtins.map (package: {
|
|
|
|
name = "${package}";
|
|
|
|
value = super."${package}".overridePythonAttrs (old: {
|
|
|
|
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [self.setuptools];
|
|
|
|
});
|
|
|
|
})
|
|
|
|
list);
|
2024-04-10 16:26:38 +00:00
|
|
|
in {
|
|
|
|
# `nix build`
|
2024-08-04 17:56:53 +00:00
|
|
|
packages = forAllSystems (system: let
|
|
|
|
mkPackage = {debug ? false}:
|
|
|
|
poetry2nix.${system}.mkPoetryApplication {
|
|
|
|
projectDir = self;
|
|
|
|
checkPhase =
|
|
|
|
if debug
|
2024-08-04 22:17:15 +00:00
|
|
|
then "pyright --warnings testdata && pytest"
|
2024-08-04 17:56:53 +00:00
|
|
|
else "";
|
|
|
|
# doCheck = debug;
|
2024-08-04 22:09:41 +00:00
|
|
|
preferWheels = false;
|
2024-08-04 17:56:53 +00:00
|
|
|
nativeBuildInputs = with pkgs.${system}; [pyright];
|
2024-08-04 22:09:41 +00:00
|
|
|
overrides =
|
|
|
|
poetry2nix.${system}.overrides.withDefaults (self: super:
|
|
|
|
addSetuptools self super ["sqlite-minutils" "fastlite" "python-fasthtml"]);
|
2024-08-04 17:56:53 +00:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
default = mkPackage {debug = false;};
|
|
|
|
debug = mkPackage {debug = true;};
|
2024-04-11 19:11:05 +00:00
|
|
|
vm = self.nixosConfigurations.vm.config.microvm.declaredRunner;
|
|
|
|
});
|
|
|
|
|
|
|
|
# `nix run`
|
|
|
|
apps = forAllSystems (system: {
|
|
|
|
default = {
|
|
|
|
program = "${self.packages.${system}.default}/bin/testdata";
|
|
|
|
type = "app";
|
|
|
|
};
|
2024-04-10 16:26:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
# `nix fmt`
|
|
|
|
formatter = forAllSystems (system: pkgs.${system}.alejandra);
|
|
|
|
|
|
|
|
# `nix develop`
|
|
|
|
devShells = forAllSystems (system: {
|
2024-08-02 20:23:20 +00:00
|
|
|
# Shell for app dependencies.
|
|
|
|
#
|
|
|
|
# nix develop
|
|
|
|
#
|
|
|
|
# Use this shell for developing your app.
|
|
|
|
default = pkgs.${system}.mkShellNoCC {
|
|
|
|
inputsFrom = [self.packages.${system}.default];
|
2024-08-04 17:56:53 +00:00
|
|
|
packages = [self.packages.${system}.default];
|
2024-08-02 20:23:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Shell for poetry.
|
|
|
|
#
|
|
|
|
# nix develop .#poetry
|
|
|
|
#
|
|
|
|
# Use this shell for changes to pyproject.toml and poetry.lock.
|
|
|
|
poetry = pkgs.${system}.mkShellNoCC {
|
|
|
|
packages = [pkgs.${system}.poetry];
|
|
|
|
};
|
2024-04-10 16:26:38 +00:00
|
|
|
});
|
2024-04-11 19:11:05 +00:00
|
|
|
|
|
|
|
# NixOS Module
|
|
|
|
nixosModules.default = import ./nix/module.nix inputs;
|
2024-04-10 16:26:38 +00:00
|
|
|
};
|
|
|
|
}
|