From ee601f60c0d3aa84a3aea6daf6d8708fbd0968a1 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sun, 27 Feb 2022 12:21:01 +0100 Subject: refactor: use subdirectories directly instead of relying on rootSrc The problem with rootSrc is that it changes whenever something (that isn't covered by .gitignore) in the tree changes. This means that after _any_ change all derivations need to be rebuild. By using the subdirectories we need as a starting point instead of the filtered root source, we can avoid this. --- default.nix | 19 +++++++++---------- nix/python-flipdot-gschichtler.nix | 4 ++-- nix/python-flipdots.nix | 4 ++-- nix/warteraum.nix | 9 ++++++--- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/default.nix b/default.nix index 33d10a4..be5d524 100644 --- a/default.nix +++ b/default.nix @@ -6,11 +6,10 @@ let version = import ./nix/version.nix; root = ./.; - sourceName = "flipdot-gschichtler-source"; - rootSrc = builtins.path { - path = root; - name = sourceName; + getSrc = name: builtins.path { + name = builtins.baseNameOf name; + path = root + "/${name}"; filter = gi.gitignoreFilter (builtins.readFile ./.gitignore) root; }; @@ -19,13 +18,13 @@ in rec { warteraum-static = pkgs.pkgsStatic.callPackage ./nix/warteraum.nix { inherit (pkgs.pkgsStatic.llvmPackages) stdenv; - inherit rootSrc sourceName; + inherit getSrc; inherit (python3.pkgs) pytest pytest-randomly requests flipdot-gschichtler; }; warteraum = pkgs.callPackage ./nix/warteraum.nix { inherit (pkgs.llvmPackages_latest) stdenv; - inherit rootSrc sourceName; + inherit getSrc; inherit (python3.pkgs) pytest pytest-randomly requests flipdot-gschichtler; }; @@ -33,7 +32,7 @@ rec { pname = "bahnhofshalle"; inherit version; - src = rootSrc + "/bahnhofshalle"; + src = getSrc "bahnhofshalle"; nativeBuildInputs = [ pkgs.buildPackages.esbuild @@ -53,7 +52,7 @@ rec { pname = "anzeigetafel"; inherit version; - src = rootSrc + "/anzeigetafel"; + src = getSrc "anzeigetafel"; propagatedBuildInputs = [ flipdots flipdot-gschichtler ]; @@ -73,11 +72,11 @@ rec { python3 = pkgs.python3.override { packageOverrides = self: super: { flipdots = self.callPackage ./nix/python-flipdots.nix { - inherit rootSrc; + inherit getSrc; }; flipdot-gschichtler = self.callPackage ./nix/python-flipdot-gschichtler.nix { - inherit rootSrc; + inherit getSrc; }; }; }; diff --git a/nix/python-flipdot-gschichtler.nix b/nix/python-flipdot-gschichtler.nix index a85598d..630a2ce 100644 --- a/nix/python-flipdot-gschichtler.nix +++ b/nix/python-flipdot-gschichtler.nix @@ -1,12 +1,12 @@ { buildPythonPackage, requests -, rootSrc +, getSrc }: buildPythonPackage rec { pname = "flipdot-gschichtler"; version = import ./version.nix; - src = rootSrc + "/clients/py"; + src = getSrc "clients/py"; doCheck = false; diff --git a/nix/python-flipdots.nix b/nix/python-flipdots.nix index 88d1324..6ba0ba3 100644 --- a/nix/python-flipdots.nix +++ b/nix/python-flipdots.nix @@ -1,12 +1,12 @@ { buildPythonPackage, pillow, numpy, flask -, rootSrc +, getSrc }: buildPythonPackage { name = "flipdots"; version = "unstable"; - src = rootSrc + "/third_party/flipdots"; + src = getSrc "third_party/flipdots"; propagatedBuildInputs = [ flask pillow numpy ]; diff --git a/nix/warteraum.nix b/nix/warteraum.nix index af954a7..d1b41ce 100644 --- a/nix/warteraum.nix +++ b/nix/warteraum.nix @@ -1,15 +1,18 @@ { stdenv, lib, scrypt , jq, requests, pytest, pytest-randomly, flipdot-gschichtler, valgrind -, rootSrc, sourceName +, getSrc }: stdenv.mkDerivation rec { pname = "warteraum"; version = import ./version.nix; - sourceRoot = sourceName + "/warteraum"; + src = [ + (getSrc "warteraum") + (getSrc "third_party") + ]; - src = rootSrc; + sourceRoot = "warteraum"; makeFlags = [ "PREFIX=${placeholder "out"}" -- cgit 1.4.1