chore: Suggestions from review

- Filter out non-source files from llama-scripts flake derivation
- Clean up unused closure
- Remove scripts devShell
This commit is contained in:
ditsuke 2024-07-08 23:33:43 +05:30
parent 4a71d86d85
commit 03b2afea24
No known key found for this signature in database
GPG key ID: 71B6C31C8A5A9D21
3 changed files with 32 additions and 14 deletions

View file

@ -2,8 +2,13 @@
perSystem = perSystem =
{ config, lib, ... }: { config, lib, ... }:
{ {
devShells = lib.concatMapAttrs (name: package: { devShells = lib.pipe (config.packages) [
${name} = package.passthru.shell; (lib.concatMapAttrs
}) config.packages; (name: package: {
${name} = package.passthru.shell or null;
}))
(lib.filterAttrs (name: value: value != null))
];
}; };
} }

View file

@ -73,7 +73,6 @@ let
) ", accelerated with ${strings.concatStringsSep ", " suffices}"; ) ", accelerated with ${strings.concatStringsSep ", " suffices}";
executableSuffix = effectiveStdenv.hostPlatform.extensions.executable; executableSuffix = effectiveStdenv.hostPlatform.extensions.executable;
mapToPythonPackages = ps: packages: map (package: ps.${package}) packages;
xcrunHost = runCommand "xcrunHost" { } '' xcrunHost = runCommand "xcrunHost" { } ''
mkdir -p $out/bin mkdir -p $out/bin
@ -121,14 +120,13 @@ effectiveStdenv.mkDerivation (finalAttrs: {
filter = filter =
name: type: name: type:
let let
noneOf = builtins.all (x: !x); any = builtins.any (x: x);
baseName = baseNameOf name; baseName = builtins.baseNameOf name;
in in
noneOf [ any [
(lib.hasSuffix ".nix" name) # Ignore *.nix files when computing outPaths (lib.hasSuffix ".py" name)
(lib.hasSuffix ".md" name) # Ignore *.md changes whe computing outPaths (baseName == "README.md")
(lib.hasPrefix "." baseName) # Skip hidden files and directories (baseName == "pyproject.toml")
(baseName == "flake.lock")
]; ];
src = lib.cleanSource ../../.; src = lib.cleanSource ../../.;
}; };

View file

@ -23,12 +23,27 @@ in
buildPythonPackage ({ buildPythonPackage ({
pname = "llama-scripts"; pname = "llama-scripts";
src = ../../.;
version = "0.0.0"; version = "0.0.0";
pyproject = true; 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 ]; nativeBuildInputs = [ poetry-core ];
projectDir = ../../.; dependencies = llama-python-deps;
propagatedBuildInputs = llama-python-deps;
passthru = { passthru = {
shell = mkShell { shell = mkShell {