nixpkgs/pkgs/applications/misc/cura/stable.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

74 lines
2.0 KiB
Nix

{ lib, stdenv, python27Packages, curaengine, makeDesktopItem, fetchurl }:
let
py = python27Packages;
version = "15.04";
in
stdenv.mkDerivation rec {
pname = "cura";
inherit version;
src = fetchurl {
url = "https://github.com/daid/Cura/archive/${version}.tar.gz";
sha256 = "0xbjvzhp8wzq9lnpmcg1fjf7j5h39bj5463sd5c8jzdjl96izizl";
};
desktopItem = makeDesktopItem {
name = "Cura";
exec = "cura";
icon = "cura";
comment = "Cura";
desktopName = "Cura";
genericName = "3D printing host software";
categories = "GNOME;GTK;Utility;";
};
python_deps = with py; [ pyopengl pyserial numpy wxPython30 power setuptools ];
pythonPath = python_deps;
propagatedBuildInputs = python_deps;
buildInputs = [ curaengine py.wrapPython ];
configurePhase = "";
buildPhase = "";
patches = [ ./numpy-cast.patch ];
installPhase = ''
# Install Python code.
site_packages=$out/lib/python2.7/site-packages
mkdir -p $site_packages
cp -r Cura $site_packages/
# Install resources.
resources=$out/share/cura
mkdir -p $resources
cp -r resources/* $resources/
sed -i 's|os.path.join(os.path.dirname(__file__), "../../resources")|"'$resources'"|g' $site_packages/Cura/util/resources.py
# Install executable.
mkdir -p $out/bin
cp Cura/cura.py $out/bin/cura
chmod +x $out/bin/cura
sed -i 's|#!/usr/bin/python|#!/usr/bin/env python|' $out/bin/cura
wrapPythonPrograms
# Make it find CuraEngine.
echo "def getEngineFilename(): return '${curaengine}/bin/CuraEngine'" >> $site_packages/Cura/util/sliceEngine.py
# Install desktop item.
mkdir -p "$out"/share/applications
cp "$desktopItem"/share/applications/* "$out"/share/applications/
mkdir -p "$out"/share/icons
ln -s "$resources/images/c.png" "$out"/share/icons/cura.png
'';
meta = with lib; {
description = "3D printing host software";
homepage = "https://github.com/daid/Cura";
license = licenses.agpl3;
platforms = platforms.linux;
};
}