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

brickstore: init at 0-unstable-2024-05-02 #309937

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

jrobinson-uk
Copy link
Contributor

Description of changes

Created a new package deviation for building the popular offline Lego store inventory tool Brickstore.
First version begins at v2024.5.2, see release notes

Things done

Built on local system and tested through last 2 package releases

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

I would like to support by reviewing pull requests but would like to see this pull request through to ensure I understand the process

Add a 👍 reaction to pull requests you find important.

@DontEatOreo
Copy link
Member

DontEatOreo commented May 7, 2024

Thanks for making a PR! You will need to rebase so you can comply with the Commit Conventions

In your case please squash d49b7d3 7fed93b 9d16a5f into bb280d1 and reword bb280d1 to brickstore: init at 0-unstable-2024-05-02

As well adding yourself as maintainer should be separate commit and in your case should be titled maintainers: add legojames

EDIT: Please move your package to pkgs/by-name (https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/README.md) and reword your PR title to brickstore: init at 0-unstable-2024-05-02

@DontEatOreo
Copy link
Member

I'm not exactly sure how package this but I think this will set you in the right direction.

{
  lib,
  stdenv,
  qt6,
  libsForQt5,
  fetchFromGitHub,
  gst_all_1,
  cmake,
  libglvnd,
  tbb,
  ninja,
  pkg-config,
}:
let
  inherit (libsForQt5) qcoro;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "brickstore";
  version = "0-unstable-2024-05-02";

  src = fetchFromGitHub {
    owner = "rgriebl";
    repo = finalAttrs.pname;
    rev = "v2024.5.2";
    hash = "sha256-Bu9oNbZm3lx/CfYAReHyWe/kW+kaefDWeBtWLHOCORU=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    cmake
    libglvnd
    ninja
    pkg-config
    qcoro
    qt6.qtdoc
    qt6.qtdeclarative
    qt6.qtimageformats
    qt6.qtmultimedia
    qt6.qtquick3d
    qt6.qtquicktimeline
    qt6.qtshadertools
    qt6.qttools
    qt6.qtwayland
    qt6.wrapQtAppsHook
    tbb
  ];

  preConfigure = ''
    # deletes line https://github.com/rgriebl/brickstore/blob/1e62a8bdf7da848a0033b8647d3711d95a3afd8d/cmake/BuildQCoro.cmake#L21
    # This isn't good but not sure how to do it via substituteInPlace
    sed -i '/^)$/d' cmake/BuildQCoro.cmake

    substituteInPlace cmake/BuildQCoro.cmake \
      --replace-fail 'FetchContent_Declare(' ' ' \
      --replace-fail '    qcoro' ' ' \
      --replace-fail '    GIT_REPOSITORY https://github.com/danvratil/qcoro.git' ' ' \
      --replace-fail '    GIT_TAG        v''${QCORO_VERSION}' ' ' \
      --replace-fail 'FetchContent_GetProperties(qcoro)' ' ' \
      --replace-fail 'FetchContent_Populate(qcoro)' ' ' \
      --replace-fail \
        'add_subdirectory(''${qcoro_SOURCE_DIR} ''${qcoro_BINARY_DIR} EXCLUDE_FROM_ALL)' \
        'add_subdirectory(${qcoro.src} ${qcoro}bin/qcoro)'
  '';

  qtWrapperArgs = [
    ''
      --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : ${
        lib.makeLibraryPath [
          gst_all_1.gstreamer
          gst_all_1.gst-plugins-base
          gst_all_1.gst-plugins-good
          gst_all_1.gst-plugins-bad
          gst_all_1.gst-plugins-ugly
          gst_all_1.gst-libav
        ]
      }
    ''
  ];

  meta = {
    changelog = "https://github.com/rgriebl/brickstore/blob/main/CHANGELOG.md";
    description = "BrickLink offline management tool";
    homepage = "https://www.brickstore.dev/";
    license = lib.licenses.gpl3Plus;
    longDescription = ''
      BrickStore is a BrickLink offline management tool.
      It is multi-platform (Windows, macOS and Linux as well as iOS and Android),
      multilingual (currently English, German, Spanish, Swedish and French), fast and stable.
    '';
    maintainers = with lib.maintainers; [ legojames ];
    platforms = lib.platforms.linux;
  };
})

@jrobinson-uk
Copy link
Contributor Author

I'm not exactly sure how package this but I think this will set you in the right direction.

{
  lib,
  stdenv,
  qt6,
  libsForQt5,
  fetchFromGitHub,
  gst_all_1,
  cmake,
  libglvnd,
  tbb,
  ninja,
  pkg-config,
}:
let
  inherit (libsForQt5) qcoro;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "brickstore";
  version = "0-unstable-2024-05-02";

  src = fetchFromGitHub {
    owner = "rgriebl";
    repo = finalAttrs.pname;
    rev = "v2024.5.2";
    hash = "sha256-Bu9oNbZm3lx/CfYAReHyWe/kW+kaefDWeBtWLHOCORU=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    cmake
    libglvnd
    ninja
    pkg-config
    qcoro
    qt6.qtdoc
    qt6.qtdeclarative
    qt6.qtimageformats
    qt6.qtmultimedia
    qt6.qtquick3d
    qt6.qtquicktimeline
    qt6.qtshadertools
    qt6.qttools
    qt6.qtwayland
    qt6.wrapQtAppsHook
    tbb
  ];

  preConfigure = ''
    # deletes line https://github.com/rgriebl/brickstore/blob/1e62a8bdf7da848a0033b8647d3711d95a3afd8d/cmake/BuildQCoro.cmake#L21
    # This isn't good but not sure how to do it via substituteInPlace
    sed -i '/^)$/d' cmake/BuildQCoro.cmake

    substituteInPlace cmake/BuildQCoro.cmake \
      --replace-fail 'FetchContent_Declare(' ' ' \
      --replace-fail '    qcoro' ' ' \
      --replace-fail '    GIT_REPOSITORY https://github.com/danvratil/qcoro.git' ' ' \
      --replace-fail '    GIT_TAG        v''${QCORO_VERSION}' ' ' \
      --replace-fail 'FetchContent_GetProperties(qcoro)' ' ' \
      --replace-fail 'FetchContent_Populate(qcoro)' ' ' \
      --replace-fail \
        'add_subdirectory(''${qcoro_SOURCE_DIR} ''${qcoro_BINARY_DIR} EXCLUDE_FROM_ALL)' \
        'add_subdirectory(${qcoro.src} ${qcoro}bin/qcoro)'
  '';

  qtWrapperArgs = [
    ''
      --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : ${
        lib.makeLibraryPath [
          gst_all_1.gstreamer
          gst_all_1.gst-plugins-base
          gst_all_1.gst-plugins-good
          gst_all_1.gst-plugins-bad
          gst_all_1.gst-plugins-ugly
          gst_all_1.gst-libav
        ]
      }
    ''
  ];

  meta = {
    changelog = "https://github.com/rgriebl/brickstore/blob/main/CHANGELOG.md";
    description = "BrickLink offline management tool";
    homepage = "https://www.brickstore.dev/";
    license = lib.licenses.gpl3Plus;
    longDescription = ''
      BrickStore is a BrickLink offline management tool.
      It is multi-platform (Windows, macOS and Linux as well as iOS and Android),
      multilingual (currently English, German, Spanish, Swedish and French), fast and stable.
    '';
    maintainers = with lib.maintainers; [ legojames ];
    platforms = lib.platforms.linux;
  };
})

Is this to replace my patch approach? I took that approach as I thought I read something that said that downloading addtional requirements should be done using nixos helper tools like fetchFromGithub

@DontEatOreo
Copy link
Member

Your older commits had a patch file, but it was just a duplicate of the default.nix file with the .patch extension (As seen in d49b7d3). There was no actual patch in that commit, so I don't know what your original approach was. After looking at the project, I found that only cmake/BuildQCoro.cmake was trying to download something from GitHub and I just got rid of that logic and patch the path for qcoro

I noticed you were downloading qcoro with fetchFromGitHub to patch the source code. This isn't needed as qcoro is already packaged in nixpkgs

I was able to build the package on x86_64-linux and run the GUI program, but I don't know how to use it. So I don't know if everything is working correctly. Please let me know if there are any issues.

@jrobinson-uk
Copy link
Contributor Author

brickstore: init at 0-unstable-2024-05-02

I've never had to rebase before, I've tried git rebase -i master and squashed the relevant commits but it leads to merge conflicts from other parts of nix-pkgs.

Would like to figure it out but would it be easier to close this pull, re-clone my fork and start again?

@DontEatOreo
Copy link
Member

Would like to figure it out but would it be easier to close this pull, re-clone my fork and start again?

No need, we can solve the issue here! Let me show you how.

You will need to checkout the branch add-brickstore-package. Afterwards, you will need to rebase the last 5 commits by running: git rebase -i HEAD~5. After that, you will have a list of the 5 commits, and you will just need to replace the pick word at the start with the appropriate one:

In your case this is how the rebase file should look like before saving it:

pick 9d16a5fb3c26 Last Sync: 2024-05-07 21:00:42 (Xen)
squash 7fed93b6e68f brickstore: init at 2024.5.2 https://github.com/rgriebl/brickstore/releases/tag/v2024.5.2
squash d49b7d30f35a brickstore: v2024.5.2 Adding no-download patch to ensure qcoro is fetched and built via fetchFromGitHub
squash bb280d1bc875 brickstore: v2024.5.2 Fixing editorconfig issue
squash 796ab14da982 Last Sync: 2024-05-08 09:00:41 (Xen)

This will squash from 796ab14 to 7fed93b into 9d16a5f

After that, you will need to "softly reset" the commit by running git reset --soft HEAD~1. Then you can unstage all files except the maintainers one. After that, you will just make a commit to add yourself to the maintainer list and word it as maintainers: add legojames. Finally, commit the package with the title brickstore: init at 0-unstable-2024-05-02.

@jrobinson-uk
Copy link
Contributor Author

git rebase -i HEAD~5

I get fatal: invalid upstream 'HEAD-5'

@DontEatOreo
Copy link
Member

That's because you typed - instead of ~

@jrobinson-uk
Copy link
Contributor Author

jrobinson-uk commented May 9, 2024

brickstore: init at 0-unstable-2024-05-02

I'm an idiot.

Think I've done all that and now just need to push changes, which in turn requires a pull. Do I need to merge, rebase or fast-forward.

hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only

I'm guessing merge?

@DontEatOreo
Copy link
Member

No worries! Run git reflog. This will open up a log of the git commands you've done. Afterwards, you just need to find which line was the one before the merge conflict and then copy the "HEAD." It will look something like this: HEAD@{X}. After that, you will just need to run git reset --hard HEAD@{X}, which allows you to essentially "go back in time" and redo the rebase again, and then you can force push the changes.

@DontEatOreo
Copy link
Member

I see you're struggling a bit, but no worries! So make sure to run git reflog and take a close look at which line was the one before all the extra commits, the one where you had your original 5 commits, then just do git reset --hard HEAD@{X} (X being whatever number you need based on your local history) and start the rebase again, you don't need to make any extra commits.

@jrobinson-uk
Copy link
Contributor Author

git reflog

Thanks, I think that's HEAD{742} based on this:

d49b7d30f35a HEAD@{741}: commit: brickstore: v2024.5.2
7fed93b6e68f HEAD@{742}: commit: brickstore: init at 2024.5.2

@DontEatOreo
Copy link
Member

It's a bit hard for me to tell exactly, but it seems that HEAD@{742} is the one. After resetting to it, take a look at your git log and squash any extra commits into your initial commit. Then "softly reset" the commit, then commit the maintainer file, and then your package, after that make sure to force push your changes.

@jrobinson-uk
Copy link
Contributor Author

brickstore: init at 0-unstable-2024-05-02

I think I've done that now 🤞 , thanks for the help in getting this far

@DontEatOreo
Copy link
Member

Almost correct! Reset again but carefully rebase, as to not pick up anyone else commits

@jrobinson-uk
Copy link
Contributor Author

Almost correct! Reset again but carefully rebase, as to not pick up anyone else commits

Is that just down to the number of commits in the HEAD~5 bit I thought is was just viewing the last 5, but is it actually "include last 5 commits"?

@DontEatOreo
Copy link
Member

DontEatOreo commented May 9, 2024

When I was originally asking you to run that command, there were 5 commits, hence the HEAD~5. The numbering starts from 1, where 1 is the latest commit (as HEAD~1), and as you increment the number, you go further down the commit history

EDIT: You can read further about HEAD on https://git-scm.com/docs/gitglossary#def_HEAD

@jrobinson-uk
Copy link
Contributor Author

When I was originally asking you to run that command, there were 5 commits, hence the HEAD~5. The numbering starts from 1, where 1 is the latest commit (as HEAD~1), and as you increment the number, you go further down the commit history

EDIT: You can read further about HEAD on https://git-scm.com/docs/gitglossary#def_HEAD

Think it's done

@jrobinson-uk jrobinson-uk changed the title Add bricktore package brickstore: init at 0-unstable-2024-05-02 May 10, 2024
@DontEatOreo
Copy link
Member

@jrobinson-uk
Copy link
Contributor Author

@DontEatOreo
Copy link
Member

If you have commits pkg-name: oh, forgot to insert whitespace: squash commits in this case. Use git rebase -i. See Squashing Commits for additional information.

Please rebase and squash the other commits into e28daba

@DontEatOreo
Copy link
Member

Result of nixpkgs-review pr 309937 run on x86_64-linux 1

1 package built:
  • brickstore

@DontEatOreo
Copy link
Member

LGTM, Thank you for sticking with the PR, even though I know it was a bit challenging!

@jrobinson-uk
Copy link
Contributor Author

LGTM, Thank you for sticking with the PR, even though I know it was a bit challenging!

Yay, thanks you so much for the support, I learnt a lot (slowly) and feel more confident about adding packages going forward.

What happens next with this PR, how does this become installable from nixpkgs for other users?

@DontEatOreo DontEatOreo added the backport release-23.11 Backport PR automatically label May 10, 2024
@DontEatOreo
Copy link
Member

Somebody with commit access has to merge it, so there are a couple of scenarios:

For future PR's that haven't been reviewed yet, you can ask on https://discourse.nixos.org/t/prs-ready-for-review/3032 or if you have Matrix account you can ask here too: https://app.element.io/#/room/#review-requests:nixos.org 1

I added a backport label, which will automatically create a backport PR that will "back port" the program to nixpkgs unstable. You can track the progress here: https://nixpk.gs/pr-tracker.html?pr=309937

When it gets merged into master, you can skip waiting for the backport to be merged, by temporarily installing the package with nix profile install github:NixOS/nixpkgs/master#brickstore2 and after it arrives in the channel (or inputs if you use flakes), you can remove it from the profile.

And final note to save time and effort for both yourself and reviewers, please take a careful look again at CONTRIBUTING.md so there is less back and forth, and future PR can get merged faster!

Wishing you luck for any future PRs!

Footnotes

  1. If it takes too long for it to be merged, you can also post in the review requests channels as well.

  2. You will need to have the new nix3 commands enabled for this, though:
    https://nixos.org/manual/nix/stable/contributing/experimental-features.html?highlight=experimental-features
    https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-profile

Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Hi,

Thanks for your PR. I've left some comments, let me know if this is clear enough.

''
];

meta = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing meta.mainProgram


src = fetchFromGitHub {
owner = "rgriebl";
repo = finalAttrs.pname;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use this.

repo = pname; is nice for DRY but creates a binding that goes too far.

See further information about this here: nix-community/nixpkgs-lint#21

@DontEatOreo DontEatOreo added backport release-24.05 Backport PR automatically and removed backport release-23.11 Backport PR automatically labels Jun 1, 2024
@drupol
Copy link
Contributor

drupol commented Jun 6, 2024

Please rebase your branch on top of the latest commit from master and it's good for me.

@drupol
Copy link
Contributor

drupol commented Jun 6, 2024

Nope... this PR shouldn't contain any merge commit.

Copy link
Member

@DontEatOreo DontEatOreo left a comment

Choose a reason for hiding this comment

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

LGTM!

In the future, when you have merge conflict on a PR, you can checkout master then pull with a rebase (make sure to update your fork master first) and then do a git rebase on your local branch.

git checkout master
# you can add `origin master` to be very explicit
git pull --rebase
git checkout add-bricktore-package
git rebase master

Then resolve any conflict

pkgs/by-name/br/brickstore/package.nix Outdated Show resolved Hide resolved
Removing redundant comments
@drupol drupol merged commit de98620 into NixOS:master Jun 7, 2024
23 of 25 checks passed
Copy link
Contributor

github-actions bot commented Jun 7, 2024

Successfully created backport PR for release-24.05:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants