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

ocp.nix (help wanted) #110

Open
coderofsalvation opened this issue Mar 1, 2024 · 3 comments
Open

ocp.nix (help wanted) #110

coderofsalvation opened this issue Mar 1, 2024 · 3 comments

Comments

@coderofsalvation
Copy link

I didn't find ocp in https://search.nixos.org which is fine, because I can just run it via wine.
However, I still tried to come up with a nix-file to build it, but I got stuck on libancient (which is the only lib which is not in the nix-repos).

If you are a nix-developer and you're reading this...then you're very welcome to help out to complete this nix-definition:

https://gist.github.com/coderofsalvation/00434e3c0dad50a4d7086821a80ff882

@mywave82
Copy link
Owner

mywave82 commented Mar 2, 2024

It would probably be more clean to add two packages, libancient as a separate package, and then ocp that depends on libancient.

Probably should add alsa-lib as a dependency also.

@jicksaw
Copy link

jicksaw commented Apr 7, 2024

Here's a flake I made:

flake.nix
{
  description = "Open Cubic Player";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
  flake-utils.lib.eachDefaultSystem (system:
  let
    pkgs = nixpkgs.legacyPackages.${system};
    patched-libdiscid = pkgs.libdiscid.overrideAttrs {
      patches = [
        (pkgs.fetchpatch {
          # Without this patch, ocp will give the runtime error:
          #   undefined symbol: discid_get_id
          # Only affects libdiscid v0.6.3 & v0.6.4 (current)
          name = "fix-missing-libdir.patch";
          url = "https://github.com/metabrainz/libdiscid/commit/b89c14599fd8798eef64431bb05e8705aaaea683.diff";
          hash = "sha256-jqIliHBQrb3Mm8EBZgpfWci23/d5gK0af3yi21hYr44=";
        })
      ];
    };
  in
  {
    devShells = rec {
      ocp = pkgs.mkShell {
        inputsFrom = [ self.packages.${system}.ocp ];
      };
      default = ocp;
    };
    packages = rec {
      libancient = pkgs.stdenv.mkDerivation {
        name = "libancient";
        src = pkgs.fetchFromGitHub {
          owner = "temisu";
          repo = "ancient";
          rev = "v2.1.1";
          hash = "sha256-94YQO+tUcHtmSwOKn5lkSqXwCkDOb0Kcg5aZV7Bxgdc=";
        };
        nativeBuildInputs = with pkgs; [
          autoreconfHook
          pkg-config
          autoconf-archive
        ];
      };
      ocp = pkgs.stdenv.mkDerivation {
        name = "ocp";
        src = pkgs.fetchFromGitHub {
          owner = "mywave82";
          repo = "opencubicplayer";
          rev = "v0.2.109";
          fetchSubmodules = true;
          hash = "sha256-5jWDcZQzBne2XGKtXn25eQ4dg3GfHfOCHEBFZgY1S28=";
        };
        nativeBuildInputs = with pkgs; [
          pkg-config
          hexdump
          perl
        ];
        buildInputs = with pkgs; [
          self.packages.${system}.libancient
          patched-libdiscid

          # Situation with alsa plugins is messy
          # On non-NixOS this probably needs an override to find libasound_module_pcm_pipewire.so
          # https://github.com/NixOS/nixpkgs/pull/277180
          alsa-lib-with-plugins

          cjson
          desktop-file-utils
          freetype
          flac
          ncurses
          SDL2
          xa
          libgme
          libmad
          libjpeg
          libpng
          libvorbis
          shared-mime-info
          bzip2
          zlib
        ];
        configureFlags = [
          "--with-builtin=core"
          "--with-unifont-otf=${pkgs.unifont}/share/fonts/opentype/unifont.otf"
          "--with-unifont-upper-otf=${pkgs.unifont_upper}/share/fonts/opentype/unifont_upper.otf"
          "--without-unifont-csur-ttf"
          "--without-unifont-csur-otf"
          "--without-update-desktop-database"
        ];
      };
      default = ocp;
    };
  });
}
flake.lock
{
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1710146030,
        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1712163089,
        "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs"
      }
    },
    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

@coderofsalvation
Copy link
Author

thanks! trying it right now

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

No branches or pull requests

3 participants