commit e3b01366509a3058aff8cb4a67cb195fc0109f8b Author: Jonas Rabenstein Date: Tue Sep 30 12:07:41 2025 +0200 initial commit diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d554105 --- /dev/null +++ b/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1759036355, + "narHash": "sha256-0m27AKv6ka+q270dw48KflE0LwQYrO7Fm4/2//KCVWg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e9f00bd893984bc8ce46c895c3bf7cac95331127", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-24.11": { + "locked": { + "lastModified": 1751274312, + "narHash": "sha256-/bVBlRpECLVzjV19t5KMdMFWSwKLtb5RyXdjz3LJT+g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "50ab793786d9de88ee30ec4e4c24fb4236fc2674", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-24.11": "nixpkgs-24.11" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..175f861 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + description = "Jetperch tools"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + inputs."nixpkgs-24.11".url = "github:nixos/nixpkgs/nixos-24.11"; + + outputs = { self, nixpkgs, ... }@inputs: let + lib = nixpkgs.lib; + + scan = root: pkg: let + path = ./. + "/${root}"; + entries = lib.optionalAttrs (builtins.pathExists path) (builtins.readDir path); + in lib.attrsets.foldlAttrs (acc: name: value: acc // lib.optionalAttrs (builtins.pathExists ("${./.}/${root}/${name}/default.nix")) { + ${name} = pkg name (import "${./.}/${root}/${name}/default.nix"); + }) {} entries; + + overlay = final: prev: let + all = packages final; + python3 = prev.python3.override { + self = python3; + packageOverrides = pself: psuper: { + watchdog = psuper.watchdog; + }; + }; + in { inherit python3; } // all; + + packages = pkgs: scan "package" (name: pkg: (pkgs.extend overlay).callPackage pkg { jetperch = self; inherit name; }); + in { + packages = builtins.mapAttrs (_: packages) nixpkgs.legacyPackages; + }; +} diff --git a/package/current.nix b/package/current.nix new file mode 100644 index 0000000..ca048da --- /dev/null +++ b/package/current.nix @@ -0,0 +1,4 @@ +{ + lib, + versions, +}: diff --git a/package/joulescope-driver/default.nix b/package/joulescope-driver/default.nix new file mode 100644 index 0000000..273bf14 --- /dev/null +++ b/package/joulescope-driver/default.nix @@ -0,0 +1,29 @@ +let + v."1.10.0" = "sha256-deMxbLHnD1jDvQaAzhGiCF1vt11IpF6Ao2OF6zJuJ9A="; +in { + callPackage, + jetperch, + name ? "joulescope-driver", + version ? "1.10.0", + hash ? v.${version} or "", + stdenv, + #dependencies + cmake, + udev, +}: stdenv.mkDerivation { + pname = name; + version = version; + src = callPackage ../source.nix { + repo = "joulescope_driver"; + inherit version; + inherit hash; + }; + + postPatch = '' + echo 'install(TARGETS jsdrv DESTINATION lib)' >>CMakeLists.txt + ''; + + nativeBuildInputs = [ cmake ]; + hardeningDisable = [ "format" ]; + buildInputs = [ udev.dev ]; +} diff --git a/package/pyjls/default.nix b/package/pyjls/default.nix new file mode 100644 index 0000000..692560b --- /dev/null +++ b/package/pyjls/default.nix @@ -0,0 +1,18 @@ +let + v."0.15.0" = "sha256-lr23f8YDF/7f/dAJIiZdy69lzcnO0HRkbYS/GkOYwfo="; +in { + callPackage, + jetperch, + name ? "pyjls", + version ? "0.15.0", + hash ? v.${version} or "", +}: callPackage ../python.nix { + inherit name; + inherit jetperch; + inherit version; + inherit hash; + repo = "jls"; + pydeps = py: with py; [ + numpy + ]; +} diff --git a/package/pyjoulescope-driver/default.nix b/package/pyjoulescope-driver/default.nix new file mode 100644 index 0000000..546a04c --- /dev/null +++ b/package/pyjoulescope-driver/default.nix @@ -0,0 +1,33 @@ +let + v."1.10.0" = "sha256-deMxbLHnD1jDvQaAzhGiCF1vt11IpF6Ao2OF6zJuJ9A="; +in { + callPackage, + jetperch, + name ? "pyjoulescope-driver", + version ? "1.10.0", + hash ? v.${version} or "", + udev, +}: (callPackage ../python.nix { + inherit name; + inherit jetperch; + inherit version; + inherit hash; + repo = "joulescope_driver"; + pydeps = py: with py; [ + numpy + requests + psutil + ]; +} +).overrideAttrs (final: prev: { + nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [ + [ udev udev.dev ] + ]; + NIX_CFLAGS_COMPILE = (prev.NIX_CFLAGS_COMPILE or []) ++ [ + "-I${udev.dev}/include" + ]; + NIX_LDFLAGS = (prev.NIX_LDFLAGS or []) ++ [ + "-L${udev}/lib" + ]; + dontUseCmakeConfigure = true; +}) diff --git a/package/pyjoulescope-ui/default.nix b/package/pyjoulescope-ui/default.nix new file mode 100644 index 0000000..fc7a02f --- /dev/null +++ b/package/pyjoulescope-ui/default.nix @@ -0,0 +1,38 @@ +let + v."1.3.9" = "sha256-9UDZxeuSsaWreoFq6hhRub+72IvDavN5Y2tfgpBUwTE="; +in { + callPackage, + jetperch, + name ? "pyjoulescope-ui", + version ? "1.3.9", + hash ? v.${version} or "", + + # dependencies + pyjoulescope-driver, + pyjls, + ... +}: callPackage ../python.nix { + inherit name; + inherit jetperch; + inherit version; + inherit hash; + repo = "pyjoulescope_ui"; + pydeps = py: with py; [ + numpy + polib + pyside6 + psutil + pyjls + pyopengl + pyqtgraph + pyside6-qtads + python-dateutil + qtpy + requests + appnope + fs + markdown + watchdog + pyjoulescope-driver + ]; +} diff --git a/package/python.nix b/package/python.nix new file mode 100644 index 0000000..4a0277c --- /dev/null +++ b/package/python.nix @@ -0,0 +1,36 @@ +{ + callPackage, + python3Packages, + + name, + repo ? name, + version, + hash, + pydeps ? (_: []), + + ... +}: let + source = callPackage ./source.nix { + inherit repo; + inherit version; + inherit hash; + }; +in python3Packages.buildPythonPackage { + pname = name; + inherit version; + + src = callPackage ./source.nix { + inherit repo; + inherit version; + inherit hash; + }; + + build-system = [ python3Packages.setuptools ]; + pyproject = true; + + dependencies = let + common = with python3Packages; [ + cython + ]; + in common ++ pydeps python3Packages; +} diff --git a/package/source.nix b/package/source.nix new file mode 100644 index 0000000..038f9c8 --- /dev/null +++ b/package/source.nix @@ -0,0 +1,12 @@ +{ + fetchFromGitHub, + repo, + version, + hash ? "", + owner ? "jetperch", +}: fetchFromGitHub { + owner = owner; + repo = repo; + tag = "v${version}"; + inherit hash; +}