From 90c83b4694150bdcfe4fcac1c55fcfdef17c3612 Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 26 Jan 2024 05:43:47 -0500 Subject: initial commit --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d1fc45 --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +# procfile-nix + +A library + [flake-parts](https://flake.parts/) module that helps you manage procfiles and background jobs with [overmind](https://github.com/DarthSim/overmind)! + +## Usage + +Regardless of if you use the library or flakeModule, you will be putting a package into your development shells. +Following this, the name you gave the Procfile will be avalible as a command while will setup all of your processes. + +Example: + +```shell +$ nix develop +$ myprocfile +``` + +You can also send the command to run in the background like so: `myprocfile &` + +## Usage (library) + +First, put this in your `flake.nix`: + +```nix +{ + inputs = { + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + procfile-nix = { + url = "github:getchoo/procfile-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { nixpkgs, procfile-nix, ... }: let + systems = [ "x86_64-linux" "aarch64-linux" ]; + + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + in { + devShells = forAllSystems ({ + lib, + pkgs, + system, + ... + }: let + procfile = procfile-nix.lib.${system}.mkProcfileRunner { + name = "daemons"; + procGroup = { + redis = lib.getExe' pkgs.redis "redis-server"; + }; + }; + in { + default = pkgs.mkShell { + packages = [ procfile ]; + }; + }); + }; +} +``` + +Then run `nix develop`, `daemons &`, and you're good to go! + +## Usage (flakeModule) + +```nix +{ + + inputs = { + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + procfile-nix = { + url = "github:getchoo/procfile-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-linux" ]; + + imports = [ inputs.procfile-nix.flakeModule ]; + + perSystem = { + config, + lib, + pkgs, + ... + }: { + procfiles.daemons.processes = { + redis = lib.getExe' pkgs.redis "redis-server"; + }; + + devShells.default = pkgs.mkShell { + packages = [ config.procfiles.daemons.package ]; + }; + }; + }; +} +``` + +Similar to the last example, `nix develop` and `daemons &` may be run to start your Procfile -- cgit v1.2.3