diff --git a/.gitignore b/.gitignore index 93b3bcee..31276456 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ start.sh dist release cache.json +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..62ec88ad --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1778869304, + "narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d233902339c02a9c334e7e593de68855ad26c4cb", + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..25f57c75 --- /dev/null +++ b/flake.nix @@ -0,0 +1,112 @@ +{ + description = "p2r3-convert - Truly universal browser-based file converter"; + + 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 = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + packages = with pkgs; [ + bun.packages.${system}.bun + git + pkg-config + cairo + pango + gdk-pixbuf + gtk3 + libnotify + libsecret + cups + libdbus + at-spi2-core + xorg.libX11 + xorg.libXrender + xorg.libXtst + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXrandr + xorg.libxkbfile + xorg.libxshmfence + elfutils + ]; + + shellHook = '' + export ELECTRON_SKIP_BINARY_DOWNLOAD=1 + export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 + ''; + }; + + packages.default = pkgs.stdenv.mkDerivation { + pname = "p2r3-convert"; + version = "0.0.0"; + src = self; + + nativeBuildInputs = with pkgs; [ + git + pkg-config + cairo + pango + gdk-pixbuf + gtk3 + libnotify + libsecret + cups + at-spi2-core + libx11 + libxrender + libxtst + libxdamage + libxext + libxfixes + libxrandr + libxkbfile + libxshmfence + elfutils + curl + unzip + cacert + nodejs + ]; + + buildInputs = with pkgs; [ + stdenv.cc.cc + ]; + + buildPhase = '' + export ELECTRON_SKIP_BINARY_DOWNLOAD=1 + export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 + export PUPPETEER_SKIP_DOWNLOAD=1 + export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + + # Work in /tmp since $src is read-only + cd /tmp + rm -rf convert project + git clone --recurse-submodules https://github.com/p2r3/convert.git project + cd project + + # Download and install bun + export BUN_INSTALL="$PWD/bun-install" + curl -fsSL https://bun.sh/install | BUN_INSTALL="$BUN_INSTALL" bash + export PATH="$BUN_INSTALL/bin:$PATH" + + bun --version + bun install --frozen-lockfile + bun run build + ''; + + installPhase = '' + mkdir -p $out + cp -r /tmp/project/dist $out/ + ''; + }; + } + ); +} \ No newline at end of file