diff --git a/Makefile b/Makefile index 77b6995..a958c23 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,18 @@ build_flatpak_arm64: @echo "Build Flatpak package" @$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run build-flatpak-arm64 +build_nix_x64: + @echo "Build Nix package" + @uname -m | grep -Eq 'x86_64|amd64' || { echo "The x64 Nix target requires a native x86_64 host."; exit 1; } + @$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run prepare-nix -- --x64 + @nix-build -A deezer-desktop --argstr pkgVer "$(PKGVER)" --argstr arch "x64" --out-link ./artifacts/x64/nix-result + +build_nix_arm64: + @echo "Build Nix package" + @uname -m | grep -Eq 'arm64|aarch64' || { echo "The arm64 Nix target requires a native arm64 host."; exit 1; } + @$(PACKAGE_MANAGER) $(PACKAGE_MANAGER_SUBDIR_ARG) $(APP_DIR) run prepare-nix -- --arm64 + @nix-build -A deezer-desktop --argstr pkgVer "$(PKGVER)" --argstr arch "arm64" --out-link ./artifacts/arm64/nix-result + #! DEV patch-new: install_deps diff --git a/README.md b/README.md index e184bf9..5ff736a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ It packages the app in a number of formats: - Flatpak, [available on flathub](https://flathub.org/apps/dev.aunetx.deezer) - AppImage - Snapcraft +- Nix [available on NixOS Nixpkgs](https://search.nixos.org/packages?query=deezer-desktop&show=deezer-desktop) - `rpm` (Fedora, Red Hat, CentOS, openSUSE, ...) - `deb` (Debian, Ubuntu, Pop!\_OS, elementary OS, ...) - `tar.xz` to install anywhere else @@ -37,14 +38,15 @@ It packages the app in a number of formats: ### Which package should I choose? -| Method | Best for | How to get it | -| ------------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -| **Flatpak**\* | Sandboxed, auto-updated, works everywhere | [**Install from Flathub**](https://flathub.org/apps/dev.aunetx.deezer) or `flatpak install flathub dev.aunetx.deezer` | -| **Snap**\* | Ubuntu and Snap-based distros | [**Install from the Snap Store**](https://snapcraft.io/deezer-desktop) or `sudo snap install deezer-desktop` | -| **AppImage** | A single portable file, no installation needed | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | -| **`.deb`** | Debian, Ubuntu, Pop!\_OS, elementary OS… | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | -| **`.rpm`** | Fedora, Red Hat, CentOS, openSUSE… | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | -| **`.tar.xz`** | Any other distro. Set up and run | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | +| Method | Best for | How to get it | +| ------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Flatpak**\* | Sandboxed, auto-updated, works everywhere | [**Install from Flathub**](https://flathub.org/apps/dev.aunetx.deezer) or `flatpak install flathub dev.aunetx.deezer` | +| **Snap**\* | Ubuntu and Snap-based distros | [**Install from the Snap Store**](https://snapcraft.io/deezer-desktop) or `sudo snap install deezer-desktop` | +| **AppImage** | A single portable file, no installation needed | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | +| **Nix** | NixOS and other distros using Nix package manager | Add the [Nix version](https://search.nixos.org/packages?query=deezer-desktop&show=deezer-desktop) available in `unstable` and current releases to your configuration or run it once with `nix-shell -p deezer-desktop --run deezer-desktop` | +| **`.deb`** | Debian, Ubuntu, Pop!\_OS, elementary OS… | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | +| **`.rpm`** | Fedora, Red Hat, CentOS, openSUSE… | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | +| **`.tar.xz`** | Any other distro. Set up and run | [Download from the releases page](https://github.com/aunetx/deezer-linux/releases/latest) | All packages for every release are listed on the [**releases page**](https://github.com/aunetx/deezer-linux/releases/latest). @@ -68,6 +70,7 @@ After installing, launch **Deezer** from your applications menu, or from a termi | -------------------- | ------------------------------------------------------------------- | | Flatpak | `flatpak run dev.aunetx.deezer` | | Snap | `deezer-desktop` | +| Nix | `deezer-desktop` | | `.deb` / `.rpm` | `deezer-desktop` | | `.tar.xz` / AppImage | `./deezer-desktop` (from the extracted folder or the AppImage file) | @@ -116,6 +119,7 @@ _\*_ This feature does not work on Flatpak because of strict sandboxing. | tar.xz | ⚠️ | ✅ | | snap | ✅ | ✅ | | flatpak | ✅ | ✅ | +| nix | ✅ | ✅ | ✅ Available ; ⚠️ Not tested ; ❌ Not available ; ⛔ Not planned @@ -238,6 +242,21 @@ To run it, you can use: flatpak run dev.aunetx.deezer ``` +### Nix + +To build the `nix` package, you can use: + +```sh +nix-shell # Temporarily install dependencies from shell.nix in a shell +make install_deps +make build_nix_{arch} +``` + +To run it, you can use: +```sh +./artifacts/{arch}/nix-result/bin/deezer-desktop +``` + ## Contributing If you want to contribute to this project, please read the [contribution guidelines](CONTRIBUTING.md) file. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..4e6ba78 --- /dev/null +++ b/default.nix @@ -0,0 +1,55 @@ +{ + pkgs ? import { config.allowUnfree = true; }, + pkgVer ? "local", + arch ? "x64", + lib ? pkgs.lib, +}: + +let + + src = ./. + "/artifacts/${arch}/linux${lib.optionalString (arch != "x64") "-${arch}"}-unpacked"; + + deezer-desktop = pkgs.stdenv.mkDerivation (finalAttrs: { + pname = "deezer-desktop"; + version = pkgVer; + inherit src; + + nativeBuildInputs = [ + pkgs.makeWrapper + ]; + + dontUnpack = true; + dontBuild = true; + installPhase = '' + runHook preInstall + install -d $out/bin $out/share/deezer-desktop/resources $out/share/applications $out/share/icons/hicolor/scalable/apps + + cp $src/resources/dev.aunetx.deezer.desktop $out/share/applications/ + substituteInPlace $out/share/applications/dev.aunetx.deezer.desktop \ + --replace-fail "run.sh" "deezer-desktop" + cp $src/resources/dev.aunetx.deezer.svg $out/share/icons/hicolor/scalable/apps/ + cp -r $src/resources/{app.asar,linux} $out/share/deezer-desktop/resources/ + + makeWrapper "${pkgs.lib.getExe pkgs.electron}" "$out/bin/deezer-desktop" \ + --inherit-argv0 \ + --add-flags "$out/share/deezer-desktop/resources/app.asar" \ + --set-default ELECTRON_FORCE_IS_PACKAGED 1 \ + --set DZ_RESOURCES_PATH "$out/share/deezer-desktop/resources" + + runHook postInstall + ''; + + meta = { + description = "Unofficial Linux port of the music streaming application"; + homepage = "https://github.com/aunetx/deezer-linux"; + downloadPage = "https://github.com/aunetx/deezer-linux/releases"; + platforms = lib.platforms.linux; + license = lib.licenses.unfree; + mainProgram = "deezer-desktop"; + }; + }); +in +{ + "deezer-desktop" = deezer-desktop; + default = deezer-desktop; +} diff --git a/package-append.json b/package-append.json index 78aa824..0161f65 100644 --- a/package-append.json +++ b/package-append.json @@ -3,6 +3,7 @@ "copy-resources": "mkdir -p resources/linux && cp ../extra/linux/* ./resources/linux", "start": "yarn run copy-resources && electron .", "prepare-flatpak": "electron-builder --linux --dir", + "prepare-nix": "electron-builder --linux --dir", "build-flatpak-x64": "env DEBUG='@malept/flatpak-bundler' electron-builder --x64 --linux flatpak", "build-flatpak-arm64": "env DEBUG='@malept/flatpak-bundler' electron-builder --arm64 --linux flatpak", diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..0d8d9c4 --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +{ + pkgs ? import { }, +}: + +pkgs.mkShell { + buildInputs = with pkgs; [ + gnumake + p7zip + nodejs + jq + wget + ]; +}