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

Building on NixOS / Nix #2085

Open
Loosetooth opened this issue Sep 17, 2024 · 0 comments
Open

Building on NixOS / Nix #2085

Loosetooth opened this issue Sep 17, 2024 · 0 comments

Comments

@Loosetooth
Copy link

Just creating this issue here, in case anyone else ever wants to build this package on NixOS / Nix.

The 'difficult' part is getting the right dependencies in place in order to build the node-canvas package.

For that, I wrote the following flake.nix file, containing the dependencies.:

{
  description = "Paper.js Development";

  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:
    # Define pkgs as a variable for easier reference
    let
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      devShell = with pkgs; mkShell {
        buildInputs = [
          nodejs_18
          pnpm
          cairo
          pango
          python3
          pkg-config
          libjpeg8
          giflib
          librsvg
        ];
      };
    }
  );
}

To install and build: in the root of the package:

nix develop
pnpm install
pnpm build

Here is my flake.lock file so you can have the exact dependency versions:

{
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1726560853,
        "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1726463316,
        "narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172",
        "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
}

Maintainers: we can add these two files to the root of the repo, then NIX/NixOS users can always build the package.

But feel free to close this issue if that is out of scope :)

Hopefully curious NixOS users can still find this issue to save them some time.

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

1 participant