diff options
| author | seth <[email protected]> | 2023-09-06 18:51:30 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2023-09-07 11:50:26 -0400 |
| commit | 0f3a367d27c909b803baf0185d0b6e0ade968c3a (patch) | |
| tree | 03b1b04127029289c1356bf2c0597b5aa8a37aec /flake.nix | |
| parent | 8d8dc0896fc8c7f0d2f10087db39cac4e3149c66 (diff) | |
flake: start using flake-parts + add vm test
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 97 |
1 files changed, 26 insertions, 71 deletions
@@ -3,7 +3,11 @@ inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; - pre-commit-hooks = { + parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + pre-commit = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs-stable.follows = "nixpkgs"; @@ -11,76 +15,27 @@ }; outputs = { + parts, + pre-commit, self, - nixpkgs, - pre-commit-hooks, - }: let - version = self.lastModifiedDate; - - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - - forAllSystems = nixpkgs.lib.genAttrs systems; - nixpkgsFor = forAllSystems (system: - import nixpkgs { - inherit system; - overlays = [self.overlays.default]; - }); - - packageFn = pkgs: let - inherit (pkgs) callPackage; - in { - guzzle-api = callPackage ./nix {inherit version;}; - guzzle-api-server = callPackage ./nix/server.nix {}; + ... + } @ inputs: + parts.lib.mkFlake {inherit inputs;} { + imports = [ + pre-commit.flakeModule + ./nix/dev.nix + ./nix/packages.nix + ]; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + perSystem = p: {formatter = p.pkgs.alejandra;}; + + flake.nixosModules.default = import ./nix/module.nix self; }; - in { - checks = forAllSystems (system: let - pkgs = nixpkgsFor.${system}; - in { - pre-commit-check = pre-commit-hooks.lib.${system}.run { - src = ./.; - hooks = { - isort.enable = true; - pylint.enable = true; - yapf = { - enable = true; - name = "yapf"; - entry = "${pkgs.python311Packages.yapf}/bin/yapf -i"; - types = ["file" "python"]; - }; - }; - }; - }); - - devShells = forAllSystems (system: let - pkgs = nixpkgsFor.${system}; - inherit (pkgs) mkShell; - in { - default = mkShell { - inherit (self.checks.${system}.pre-commit-check) shellHook; - packages = with pkgs.python311Packages; [ - python - fastapi - httpx - pydantic - pylint - toml - uvicorn - yapf - ]; - }; - }); - - nixosModules.guzzle_api = import ./nix/module.nix; - - packages = forAllSystems (system: let - pkgs = nixpkgsFor.${system}; - in {inherit (pkgs) guzzle-api guzzle-api-server;}); - - overlays.default = final: _: packageFn final; - }; } |
