testdata/flake.nix
Kristian Krsnik ff8820c80a
Made project structure more modular.
* Project can now be started as a package
* Added unit-tests
2024-08-02 22:23:20 +02:00

67 lines
1.9 KiB
Nix

{
description = "A webserver to create files for tetsing purposes";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
poetry2nix-lib = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {self, ...} @ inputs: let
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: inputs.nixpkgs.legacyPackages.${system});
poetry2nix = forAllSystems (system: inputs.poetry2nix-lib.lib.mkPoetry2Nix {pkgs = pkgs.${system};});
in {
# `nix build`
packages = forAllSystems (system: {
default = poetry2nix.${system}.mkPoetryApplication {
projectDir = self;
checkPhase = "pytest";
};
vm = self.nixosConfigurations.vm.config.microvm.declaredRunner;
});
# `nix run`
apps = forAllSystems (system: {
default = {
program = "${self.packages.${system}.default}/bin/testdata";
type = "app";
};
});
# `nix fmt`
formatter = forAllSystems (system: pkgs.${system}.alejandra);
# `nix develop`
devShells = forAllSystems (system: {
# Shell for app dependencies.
#
# nix develop
#
# Use this shell for developing your app.
default = pkgs.${system}.mkShellNoCC {
inputsFrom = [self.packages.${system}.default];
};
# 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];
};
});
# NixOS Module
nixosModules.default = import ./nix/module.nix inputs;
};
}