Skip to content

Commit

Permalink
Add option to build project with nix (server=wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Oct 27, 2024
1 parent 57f1d10 commit a3b49fc
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extras/
/dist/
/data/
datastore/migration/testfiles/
result

docs/venv

Expand Down
90 changes: 89 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,108 @@
};

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
];
};
};

devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# generic
gnumake
gnutar
zip
tree
git

# frontend
nodejs_20
Expand Down

0 comments on commit a3b49fc

Please sign in to comment.