diff --git a/.gitignore b/.gitignore index 4cbc9626da..09a452cb7e 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ extras/ /dist/ /data/ datastore/migration/testfiles/ +result docs/venv diff --git a/flake.nix b/flake.nix index 188c475244..3249284a79 100644 --- a/flake.nix +++ b/flake.nix @@ -5,13 +5,100 @@ }; outputs = - { nixpkgs, flake-utils, ... }: + { + nixpkgs, + flake-utils, + ... + }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system}; + + # Common attributes for all components + commonAttrs = { + version = "0.0.0"; + vendorHash = "sha256-0hInlX2yXf9IBW1h9lYeG1pn9v3LtVRoWNJJIiIdPaU="; + }; + + # Common builder function for woodpecker components + mkWoodpeckerComponent = + { + pname, + subPackages ? [ ], + buildTags ? [ ], + nativeBuildInputs ? [ ], + preBuild ? "", + CGO_ENABLED ? "0", + }: + pkgs.buildGoModule ({ + inherit pname; + inherit (commonAttrs) + version + vendorHash + ; + inherit + subPackages + buildTags + nativeBuildInputs + preBuild + CGO_ENABLED + ; + + src = ./.; + + meta = { + mainProgram = pname; + description = "A distributed CI/CD system"; + homepage = "https://woodpecker-ci.org"; + license = pkgs.lib.licenses.asl20; + }; + }); + in { + packages = rec { + cli = mkWoodpeckerComponent { + pname = "woodpecker-cli"; + subPackages = [ "cmd/cli" ]; + }; + + server = mkWoodpeckerComponent { + pname = "woodpecker-server"; + subPackages = [ "cmd/server" ]; + CGO_ENABLED = "1"; + nativeBuildInputs = with pkgs; [ + nodejs_20 + pnpm + gnumake + ]; + preBuild = '' + export HOME=$(mktemp -d) + + cd web + pnpm install --frozen-lockfile + pnpm build + cd .. + + go generate cmd/server/swagger.go + ''; + }; + + agent = mkWoodpeckerComponent { + pname = "woodpecker-agent"; + subPackages = [ "cmd/agent" ]; + }; + + default = pkgs.symlinkJoin { + name = "woodpecker"; + paths = [ + cli + agent + # server # need impure because of pnpm + ]; + }; + }; + devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ # generic @@ -19,6 +106,7 @@ gnutar zip tree + git # frontend nodejs_20