Skip to content

Commit

Permalink
chore: Suggestions from review
Browse files Browse the repository at this point in the history
- Filter out non-source files from llama-scripts flake derivation
- Clean up unused closure
- Remove scripts devShell
  • Loading branch information
ditsuke committed Jul 8, 2024
1 parent 665d143 commit 5493dd8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
11 changes: 8 additions & 3 deletions .devops/nix/devshells.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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))
];
};
}

14 changes: 6 additions & 8 deletions .devops/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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
Expand Down Expand Up @@ -125,14 +124,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 ../../.;
};
Expand Down
21 changes: 18 additions & 3 deletions .devops/nix/python-scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5493dd8

Please sign in to comment.