From 03b2afea2456ccdadfc236936a3b375d9e15e3e6 Mon Sep 17 00:00:00 2001 From: ditsuke Date: Mon, 8 Jul 2024 23:33:43 +0530 Subject: [PATCH] chore: Suggestions from review - Filter out non-source files from llama-scripts flake derivation - Clean up unused closure - Remove scripts devShell --- .devops/nix/devshells.nix | 11 ++++++++--- .devops/nix/package.nix | 14 ++++++-------- .devops/nix/python-scripts.nix | 21 ++++++++++++++++++--- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.devops/nix/devshells.nix b/.devops/nix/devshells.nix index 858c5bea9..b7eed5c74 100644 --- a/.devops/nix/devshells.nix +++ b/.devops/nix/devshells.nix @@ -2,8 +2,13 @@ perSystem = { config, lib, ... }: { - devShells = lib.concatMapAttrs (name: package: { - ${name} = package.passthru.shell; - }) config.packages; + devShells = lib.pipe (config.packages) [ + (lib.concatMapAttrs + (name: package: { + ${name} = package.passthru.shell or null; + })) + (lib.filterAttrs (name: value: value != null)) + ]; }; } + diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 7576bca21..b6548e1bb 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -73,7 +73,6 @@ let ) ", accelerated with ${strings.concatStringsSep ", " suffices}"; executableSuffix = effectiveStdenv.hostPlatform.extensions.executable; - mapToPythonPackages = ps: packages: map (package: ps.${package}) packages; xcrunHost = runCommand "xcrunHost" { } '' mkdir -p $out/bin @@ -121,14 +120,13 @@ effectiveStdenv.mkDerivation (finalAttrs: { filter = name: type: let - noneOf = builtins.all (x: !x); - baseName = baseNameOf name; + any = builtins.any (x: x); + baseName = builtins.baseNameOf name; in - noneOf [ - (lib.hasSuffix ".nix" name) # Ignore *.nix files when computing outPaths - (lib.hasSuffix ".md" name) # Ignore *.md changes whe computing outPaths - (lib.hasPrefix "." baseName) # Skip hidden files and directories - (baseName == "flake.lock") + any [ + (lib.hasSuffix ".py" name) + (baseName == "README.md") + (baseName == "pyproject.toml") ]; src = lib.cleanSource ../../.; }; diff --git a/.devops/nix/python-scripts.nix b/.devops/nix/python-scripts.nix index 119fee99b..4b1a598f8 100644 --- a/.devops/nix/python-scripts.nix +++ b/.devops/nix/python-scripts.nix @@ -23,12 +23,27 @@ in buildPythonPackage ({ pname = "llama-scripts"; - src = ../../.; version = "0.0.0"; pyproject = true; + + # NOTE: The files filtered out here are not visible in the build sandbox, neither + # do they affect the output hash. They can be modified without triggering a rebuild. + src = lib.cleanSourceWith { + filter = + name: type: + let + any = builtins.any (x: x); + baseName = builtins.baseNameOf name; + in + any [ + (lib.hasSuffix ".py" name) + (baseName == "README.md") + (baseName == "pyproject.toml") + ]; + src = lib.cleanSource ../../.; + }; nativeBuildInputs = [ poetry-core ]; - projectDir = ../../.; - propagatedBuildInputs = llama-python-deps; + dependencies = llama-python-deps; passthru = { shell = mkShell {