From 372aac6a44e53a15935ed8c3432145828ad13d63 Mon Sep 17 00:00:00 2001 From: linuswck Date: Fri, 20 Dec 2024 15:37:04 +0800 Subject: [PATCH] Reorganize flake.nix - No functional change --- .../linien-client-ssh-port-change.patch | 6 +- fast-servo/linien-server-fast-servo.patch | 6 +- flake.nix | 114 +++++++++++++----- 3 files changed, 89 insertions(+), 37 deletions(-) diff --git a/fast-servo/linien-client-ssh-port-change.patch b/fast-servo/linien-client-ssh-port-change.patch index f92f278..fd3e3b7 100644 --- a/fast-servo/linien-client-ssh-port-change.patch +++ b/fast-servo/linien-client-ssh-port-change.patch @@ -1,7 +1,7 @@ -diff --git a/linien_client/deploy.py b/linien_client/deploy.py +diff --git a/linien-client/linien_client/deploy.py b/linien-client/linien_client/deploy.py index df6683f..7355cc3 100644 ---- a/linien_client/deploy.py -+++ b/linien_client/deploy.py +--- a/linien-client/linien_client/deploy.py ++++ b/linien-client/linien_client/deploy.py @@ -34,7 +34,7 @@ logger.setLevel(logging.DEBUG) diff --git a/fast-servo/linien-server-fast-servo.patch b/fast-servo/linien-server-fast-servo.patch index bdd2136..aa35417 100644 --- a/fast-servo/linien-server-fast-servo.patch +++ b/fast-servo/linien-server-fast-servo.patch @@ -1,7 +1,7 @@ -diff --git a/linien_server/cli.py b/linien_server/cli.py +diff --git a/linien-server/linien_server/cli.py b/linien-server/linien_server/cli.py index 98539b2..7781c74 100644 ---- a/linien_server/cli.py -+++ b/linien_server/cli.py +--- a/linien-server/linien_server/cli.py ++++ b/linien-server/linien_server/cli.py @@ -83,18 +83,9 @@ class LinienServerCLI: else: control = RedPitayaControlService(host=host) diff --git a/flake.nix b/flake.nix index ade6a9e..3a57b89 100644 --- a/flake.nix +++ b/flake.nix @@ -15,11 +15,28 @@ fsbl-support = ./fast-servo/fsbl-support; version = "2.1.0"; - linien-src = pkgs.fetchFromGitHub { - owner = "linien-org"; - repo = "linien"; - rev = "v" + version; - sha256 = "sha256-j6oiP/usLfV5HZtKLcXQ5pHhhxRG05kP2FMwingiWm0="; + linien-src = pkgs.applyPatches { + name = "linien-src"; + src = pkgs.fetchFromGitHub { + owner = "linien-org"; + repo = "linien"; + rev = "v" + version; + sha256 = "sha256-j6oiP/usLfV5HZtKLcXQ5pHhhxRG05kP2FMwingiWm0="; + }; + prePatch = '' + mkdir -p fast_servo/gateware + cp -r ${./fast-servo/linien-gateware}/. fast_servo/gateware + ''; + patches = [ + ./fast-servo/linien-client-ssh-port-change.patch + ./fast-servo/linien-server-fast-servo.patch + ./fast-servo/linien-gateware-fast-servo.patch + ./fast-servo/autolock_pipeline.patch + ./fast-servo/iir_pipeline.patch + ./fast-servo/linien_module_pipeline.patch + ./fast-servo/pid_pipeline.patch + ./fast-servo/pid_err_sig_pipeline.patch + ]; }; patched-not-os = pkgs.applyPatches { @@ -158,6 +175,62 @@ ]; }; + linien-common = pkgs.python3Packages.buildPythonPackage rec { + pname = "linien-common"; + inherit version; + pyproject = true; + + src = linien-src; + + sourceRoot = "${src.name}/linien-common"; + + preBuild = '' + export HOME=$(mktemp -d) + ''; + + nativeBuildInputs = [ pkgs.python3Packages.setuptools ]; + + pythonRelaxDeps = [ "importlib-metadata" ]; + + propagatedBuildInputs = with pkgs.python3Packages; [ + importlib-metadata + numpy + rpyc + scipy + appdirs + ]; + + pythonImportsCheck = [ "linien_common" ]; + }; + + linien-common-armv7l = pkgs-armv7l.python3Packages.buildPythonPackage rec { + pname = "linien-common-armv7l"; + inherit version; + pyproject = true; + + src = linien-src; + + sourceRoot = "${src.name}/linien-common"; + + preBuild = '' + export HOME=$(mktemp -d) + ''; + + nativeBuildInputs = [ pkgs-armv7l.python3Packages.setuptools ]; + + pythonRelaxDeps = [ "importlib-metadata" ]; + + propagatedBuildInputs = with pkgs-armv7l.python3Packages; [ + importlib-metadata + numpy + rpyc + scipy + appdirs + ]; + + pythonImportsCheck = [ "linien_common" ]; + }; + linien-client = pkgs.python3Packages.buildPythonPackage rec { pname = "linien-client"; inherit version; @@ -173,17 +246,12 @@ nativeBuildInputs = [ pkgs.python3Packages.setuptools ]; - patches = [ - ./fast-servo/linien-client-ssh-port-change.patch - ]; - doInstallCheck = false; doCheck = false; propagatedBuildInputs = with pkgs.python3Packages; [ fabric typing-extensions - linien-common - ]; + ] ++ [ linien-common ]; pythonImportsCheck = [ "linien_client" ]; @@ -234,9 +302,6 @@ pyproject = true; sourceRoot = "${src.name}/linien-server"; - patches = [ - ./fast-servo/linien-server-fast-servo.patch - ]; postPatch = '' cp ${fast-servo-gateware}/csrmap.py linien_server/csrmap.py @@ -250,8 +315,8 @@ fire influxdb-client pylpsd - linien-common ] ++ [ + linien-common-armv7l cma pyrp3 ]; @@ -259,19 +324,7 @@ fast-servo-gateware = pkgs.stdenv.mkDerivation rec { name = "fast-servo-gateware"; - inherit (pkgs.python3Packages.linien-common) src; - prePatch = '' - mkdir -p fast_servo/gateware - cp -r ${./fast-servo/linien-gateware}/. fast_servo/gateware - ''; - patches = [ - fast-servo/linien-gateware-fast-servo.patch - fast-servo/autolock_pipeline.patch - fast-servo/iir_pipeline.patch - fast-servo/linien_module_pipeline.patch - fast-servo/pid_pipeline.patch - fast-servo/pid_err_sig_pipeline.patch - ]; + src = linien-src; nativeBuildInputs = [ (pkgs.python3.withPackages(ps: [ migen misoc @@ -585,10 +638,9 @@ in rec { devShell.x86_64-linux = pkgs.mkShell { name = "nix-servo-dev_shell"; - buildInputs = with pkgs.python3Packages; [ - linien-common + buildInputs = with pkgs.python3Packages; [ matplotlib - ] ++ [ linien-client linien-gui ]; + ] ++ [ linien-common linien-client linien-gui ]; }; packages.x86_64-linux = {