From 7c66ecd5866041a6c80a7ff8ca7236e8d4c807dc Mon Sep 17 00:00:00 2001 From: Niklas Mohrin Date: Sun, 13 Oct 2024 00:45:25 +0200 Subject: [PATCH] remove flake-parts --- flake.lock | 37 ++----------------------- flake.nix | 80 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 48 insertions(+), 69 deletions(-) diff --git a/flake.lock b/flake.lock index 2bc34f1a3..803a309e8 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1722555600, - "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -73,18 +55,6 @@ "type": "github" } }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1722555339, - "narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" - } - }, "poetry2nix": { "inputs": { "flake-utils": "flake-utils", @@ -111,11 +81,11 @@ }, "process-compose-flake": { "locked": { - "lastModified": 1724606023, - "narHash": "sha256-rdGeNa/lCS8E1lXzPqgl+vZUUvnbEZT11Bqkx5jfYug=", + "lastModified": 1727723765, + "narHash": "sha256-/3az0h2Zp02bjJQKliR0PEQiT+FMLOR1GumhH42jA4w=", "owner": "Platonic-Systems", "repo": "process-compose-flake", - "rev": "f6ce9481df9aec739e4e06b67492401a5bb4f0b1", + "rev": "22f2aeb7e0b88006d1d27065f8422f2790d99e47", "type": "github" }, "original": { @@ -126,7 +96,6 @@ }, "root": { "inputs": { - "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", "poetry2nix": "poetry2nix", "process-compose-flake": "process-compose-flake", diff --git a/flake.nix b/flake.nix index 35e9199b9..c923f81ba 100644 --- a/flake.nix +++ b/flake.nix @@ -8,19 +8,23 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - flake-parts.url = "github:hercules-ci/flake-parts"; process-compose-flake.url = "github:Platonic-Systems/process-compose-flake"; services-flake.url = "github:juspay/services-flake"; }; - outputs = { self, flake-parts, ... }@inputs: - flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ - inputs.process-compose-flake.flakeModule - ]; + outputs = { self, nixpkgs, ... }@inputs: + let + lib = nixpkgs.lib; systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; - perSystem = { self', inputs', pkgs, lib, system, ... }: { - devShells = rec { + forAllSystems = lib.genAttrs systems; + pkgsFor = lib.genAttrs systems (system: import nixpkgs { inherit system; }); + in + { + devShells = forAllSystems (system: + let + pkgs = pkgsFor.${system}; + in + rec { evap = pkgs.callPackage ./nix/shell.nix { python3 = pkgs.python310; poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }; @@ -29,35 +33,41 @@ }; evap-dev = evap.override { poetry-groups = [ "dev" ]; }; default = evap-dev; - }; + }); - # Start with `nix run .#services` - process-compose = - let - make = only-databases: import ./nix/services.nix { - inherit pkgs only-databases; - inherit (inputs) services-flake; - inherit (self'.devShells.evap.passthru) poetry-env; - }; - in - { - services = make true; - services-full = make false; + packages = forAllSystems (system: + let + pkgs = pkgsFor.${system}; + make-process-compose = only-databases: (import inputs.process-compose-flake.lib { inherit pkgs; }).makeProcessCompose { + modules = [ + inputs.services-flake.processComposeModules.default + (import + ./nix/services.nix + { + inherit pkgs only-databases; + inherit (inputs) services-flake; + inherit (self.devShells.${system}.evap.passthru) poetry-env; + }) + ]; }; + in + { + services = make-process-compose true; + services-full = make-process-compose false; - packages.wait-for-pc = - let - pc = lib.getExe self'.packages.services; - in - pkgs.writeShellApplication { - name = "wait-for-pc"; - runtimeInputs = [ pkgs.jq ]; - text = '' - while [ "$(${pc} process list -o json 2>/dev/null | jq '.[] |= .is_ready == "Ready" or .status == "Completed" or .status == "Disabled" | all')" != "true" ]; do - sleep 1 - done - ''; - }; - }; + wait-for-pc = + let + pc = lib.getExe self.packages.${system}.services; + in + pkgs.writeShellApplication { + name = "wait-for-pc"; + runtimeInputs = [ pkgs.jq ]; + text = '' + while [ "$(${pc} process list -o json 2>/dev/null | jq '.[] |= .is_ready == "Ready" or .status == "Completed" or .status == "Disabled" | all')" != "true" ]; do + sleep 1 + done + ''; + }; + }); }; }