Skip to content

Make kodi overrideAttrs and withPackages composable - #209580

Closed
dwagenk wants to merge 3 commits into
NixOS:masterfrom
dwagenk:feature/kodi-override-composable
Closed

dwagenk wants to merge 3 commits into
NixOS:masterfrom
dwagenk:feature/kodi-override-composable

Conversation

@dwagenk

@dwagenk dwagenk commented Jan 7, 2023 •

Copy link
Copy Markdown
Contributor
Description of changes

When using a kodi derivation modified with overrideAttrs and adding extensions to it with withPackages the changes were discarded and the original unmodified kodi derivation was wrapped together with the extensions.
Fix this by switching kodi to use the mkDerivation with finalAttrs pattern (described in #119942 and https://nixos.org/manual/nixpkgs/stable/#mkderivation-recursive-attributes).

Things done

For testing I've assebled a little flake

Test-Flake (expand)

{
  description = "test flake for nixpkgs kodi override";

  inputs = {
    nixpkgs.url = github:nixos/nixpkgs/release-22.11;
    flake-utils.url = "github:numtide/flake-utils";
    nix-flake-tests.url = "github:antifuchs/nix-flake-tests";
  };

  outputs = inputs@{ self, nixpkgs, flake-utils, nix-flake-tests }:
    flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
      let
        pkgs = import nixpkgs
          {
            localSystem = "${system}";
            overlays = [
              (final: prev: {
                kodi = prev.kodi.overrideAttrs (o: {
                  pname = "test-kodi";
                });
              })
            ];
          };
      in
      {
        packages = {
          inherit (pkgs) kodi;
          kodi-with-addons = pkgs.kodi.withPackages (p: [ p.inputstreamhelper ]);
        };
        checks = {
          kodi = nix-flake-tests.lib.check {
            inherit pkgs;
            tests = {
              testNameStartsWithPName = rec {
                expected = "test-kodi-";
                expr = builtins.substring 0 (builtins.stringLength expected)
                  self.packages.${system}.kodi-with-addons.name;
              };
              testAddonGetsLinked = {
                expected = [ ]; # exact match of regex returns empty list
                expr = builtins.match ".*-kodi-inputstreamhelper-.*"
                  self.packages.${system}.kodi-with-addons.postBuild;
              };
            };
          };
        };
      }
    );
}

The resulting kodi-with-addons derivation includes both, the pname changed via overrideAttrs as well as the postBuild wrapping for the inputstream plugin added via withPackages.

Running it is possible, finds the plugin and doesn't have any signs of anything being wrong.

  • Built on #platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.05 Release Notes (or backporting 22.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

This pattern allows for easier overriding of the derivations attributes like
described and discussed in NixOS#119942.

In this context
- adapt the handling of the version and revision handling so overriding it gets
  reflected in the version string that kodi displays in the UI
- make the bundled dependencies available for overriding
Using withPackage on a kodi derivation that was modified with overrideAttrs
lead to the modifications being discarded. With the previous adaptions to the
kodi derivation we can now modify the wrapper that allows using both
overrideAttrs and withPackage to form a custom kodi derivation with plugins.
@ofborg ofborg Bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Jan 7, 2023
@aanderse

Copy link
Copy Markdown
Member

@dwagenk thanks for contributing this. I'll try and get back to it as soon as I can, though I'm going to prioritize getting the new kodi release packaged first. Please be patient with us 🙇‍♂️

@aanderse

Copy link
Copy Markdown
Member

Linking kodi update PR for visibility: #201835

@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict This PR has merge conflicts with the target branch labels Mar 19, 2024
@stale stale Bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@nvmd

nvmd commented Apr 18, 2024

Copy link
Copy Markdown
Member

Proposed changes merged in #304097, thanks!

@nvmd nvmd closed this Apr 18, 2024
@dwagenk

dwagenk commented Apr 18, 2024

Copy link
Copy Markdown
Contributor Author

Oh, wow, thank you for updating and getting this merged! 🎉

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

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants