Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Mob moss work on packaging flarum #23

Closed
wants to merge 24 commits into from
Closed

Conversation

albertchae
Copy link
Contributor

@albertchae albertchae commented Jul 21, 2023

Currently this is a draft PR just for communication on #10

The rest of the files (composer-env.nix, default.nix, php-packages.nix) are the output of composer2nix

composerEnv.buildPackage {
inherit packages devPackages noDev;
name = "flarum-flarum";
src = composerEnv.filterSrc ./.;
Copy link
Contributor Author

@albertchae albertchae Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems to be written assuming that this nix expression will be evaluated in the project repo, but because it's in ngipkgs, we end up copying only composer.lock and the vendor directory into the nix store. As far as we know, we can't just replace this with fetchFromGitHub because the flarum/flarum and flarum/framework repos do not have a composer.lock checked in.

So we were thinking we could get around this by using fetchFromGitHub and then copying our composer.lock on top of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is what I feared. composer2nix makes a few assumptions here that we can't work around without ripping open the whole thing. @infinisil is still working on file set combinators, but we may get enough of it into Nixpkgs for you to use.

@@ -0,0 +1,35 @@
{ stdenv, fetchFromGitHub, php, phpPackages, ... }:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore this file for now, this is a mix of a default.nix we were handwriting plus trying to copy in some of the autogenerated nix code from composer2nix

@albertchae albertchae mentioned this pull request Jul 21, 2023
inherit (phpPackages) composer;

filterSrc = src:
builtins.filterSource (path: type: type != "directory" || (baseNameOf path != ".git" && baseNameOf path != ".git" && baseNameOf path != ".svn")) src;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is generic, and while usually I'd say that stuff should be part of composer2nix and just be imported, you can actually trick it into doing what you want with something along these lines:

Suggested change
builtins.filterSource (path: type: type != "directory" || (baseNameOf path != ".git" && baseNameOf path != ".git" && baseNameOf path != ".svn")) src;
let
flarum-src = builtins.fetchTarball ...;
# hardcode flarum source here. not great
filtered-src = builtins.filterSource (path: type: type != "directory" || (baseNameOf path != ".git" && baseNameOf path != ".git" && baseNameOf path != ".svn")) flarum-src;
# combine what with what's actually in this source tree
in pkgs.symlinkJoin [ src filtered-src ];

Obviously this is fugly, but it doesn't make any sense to touch the generated sources file. I'm sure you'll find a more reasonable workaround.

No idea if this will actually work with symlinks.

composerEnv.buildPackage {
inherit packages devPackages noDev;
name = "flarum-flarum";
src = composerEnv.filterSrc ./.;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is what I feared. composer2nix makes a few assumptions here that we can't work around without ripping open the whole thing. @infinisil is still working on file set combinators, but we may get enough of it into Nixpkgs for you to use.

jleightcap and others added 8 commits July 24, 2023 17:27
commit 670a5c4
Author: Jack Leightcap <jack.leightcap@trailofbits.com>
Date:   Thu Jul 20 20:13:08 2023 -0400

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/php-packages.nix

commit 29f6b9c
Author: Albert Chae <albertchae@users.noreply.github.com>
Date:   Thu Jul 20 16:55:51 2023 -0700

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/default.nix.bak

commit 743fcc3
Author: Jack Leightcap <jack.leightcap@trailofbits.com>
Date:   Thu Jul 20 19:35:17 2023 -0400

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/php-packages.nix

commit 084ed40
Author: Jack Leightcap <jack.leightcap@trailofbits.com>
Date:   Thu Jul 20 18:24:17 2023 -0400

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/composer-env.nix

commit 3faa9a6
Author: Albert Chae <albertchae@users.noreply.github.com>
Date:   Thu Jul 20 15:06:24 2023 -0700

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/default.nix

commit efcd4b2
Author: Jason Odoom <jasonodoom@gmail.com>
Date:   Thu Jul 20 17:56:57 2023 -0400

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/default.nix

commit 8645907
Author: Dominic Mills <dominic.millz27@gmail.com>
Date:   Thu Jul 20 16:38:57 2023 -0500

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/default.nix

commit 7649658
Author: Anish Lakhwara <anish+git@lakhwara.com>
Date:   Thu Jul 20 14:27:08 2023 -0700

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/default.nix

commit 5cca401
Author: Jack Leightcap <jack.leightcap@trailofbits.com>
Date:   Thu Jul 20 17:16:08 2023 -0400

    mob next [ci-skip] [ci skip] [skip ci]

    lastFile:pkgs/flarum/default.nix

commit 2f38aa2
Author: Jack Leightcap <jack.leightcap@trailofbits.com>
Date:   Thu Jul 20 17:07:20 2023 -0400

    mob start [ci-skip] [ci skip] [skip ci]

Co-authored-by: Jason Odoom <jasonodoom@gmail.com>
Co-authored-by: Anish Lakhwara <anish+git@lakhwara.com>
Co-authored-by: Dominic Mills <dominic.millz27@gmail.com>
Co-authored-by: Albert Chae <albertchae@users.noreply.github.com>
Signed-off-by: Jack Leightcap <jack.leightcap@trailofbits.com>
Signed-off-by: Jack Leightcap <jack.leightcap@trailofbits.com>
Signed-off-by: Jack Leightcap <jack.leightcap@trailofbits.com>
copy installPhase build script from closed PR NixOS/nixpkgs#96869

fix typo
Signed-off-by: Jack Leightcap <jack.leightcap@trailofbits.com>
@albertchae albertchae deleted the moss-flarum branch August 3, 2023 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: mobleted
Development

Successfully merging this pull request may close these issues.

6 participants