Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup sbomnix nix package #142

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions nix/checks.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0
{lib, ...}: {
{
lib,
self,
...
}: {
perSystem = {
self',
pkgs,
Expand All @@ -15,30 +19,35 @@
pkgs.runCommandLocal "reuse-lint" {
nativeBuildInputs = [pkgs.reuse];
} ''
cd ${../.}
cd ${self.outPath}
reuse lint
touch $out
'';
pycodestyle =
pkgs.runCommandLocal "pycodestyle" {
nativeBuildInputs = [pkgs.python3.pkgs.pycodestyle];
} ''
cd ${../.}
pycodestyle --max-line-length 90 $(find . -name "*.py" ! -path "*venv*" ! -path "*eggs*")
cd ${self.outPath}
pycodestyle --max-line-length 90 $(find . -name "*.py")
touch $out
'';
pylint =
pkgs.runCommandLocal "pylint" {
nativeBuildInputs = [self'.packages.python pkgs.python3.pkgs.pylint];
nativeBuildInputs = [self'.devShells.default.nativeBuildInputs];
} ''
cd ${../.}
cd ${self.outPath}
export HOME=/tmp
pylint --enable=useless-suppression --fail-on=I0021 --disable=duplicate-code -rn $(find . -name "*.py" ! -path "*venv*" ! -path "*eggs*")
pylint \
$(find . -name "*.py") \
--reports n \
--enable=useless-suppression \
--fail-on=useless-suppression \
--disable=duplicate-code
touch $out
'';
}
//
# merge in the package derivations to force a build of all packages during a `nix flake check`
# Force a build of all packages during a `nix flake check`
(with lib; mapAttrs' (n: nameValuePair "package-${n}") self'.packages);
};
}
30 changes: 7 additions & 23 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,13 @@
...
}: {
devShells.default = pkgs.mkShell rec {
name = "sbomnix-dev-shell";

packages =
(with pkgs; [
black
coreutils
csvkit
curl
gnugrep
gnused
graphviz
grype
gzip
nix
nix-visualize
pylint
reuse
vulnix
])
++ (with self'.packages; [
python # that python with all sbomnix [dev-]dependencies
]);

name = "sbomnix-devshell";
packages = with self'.packages; [
pkgs.python3.pkgs.pylint # for running pylint manually in devshell
pkgs.black # for running black manually in devshell
sbomnix.propagatedBuildInputs
sbomnix.nativeBuildInputs
];
# Add the repo root to PYTHONPATH, so invoking entrypoints (and them being
# able to find the python packages in the repo) becomes possible.
# `pytest.ini` already sets this for invoking `pytest`
Expand Down
49 changes: 16 additions & 33 deletions nix/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
...
}: let
pp = pkgs.python3Packages;
prefix_path = with pkgs; [
git
graphviz
grype
nix
nix-visualize
vulnix
];
in {
packages = rec {
default = sbomnix;
Expand All @@ -19,6 +27,13 @@

src = lib.cleanSource ../.;

nativeCheckInputs = with pp;
[
jsonschema
pytest
]
++ prefix_path;

propagatedBuildInputs = with pp; [
beautifulsoup4
colorlog
Expand All @@ -40,41 +55,9 @@
pythonImportsCheck = ["sbomnix"];

makeWrapperArgs = [
"--prefix PATH : ${lib.makeBinPath (with pkgs; [
git
nix
graphviz
nix-visualize
vulnix
grype
])}"
"--prefix PATH : ${lib.makeBinPath prefix_path}"
];
};
# a python with all python packages imported by sbomnix itself
python = pkgs.python3.withPackages (
ps: (with ps; [
beautifulsoup4
colorlog
dfdiskcache
filelock
graphviz
numpy
packageurl-python
packaging
pandas
reuse
requests
requests-cache
requests-ratelimiter
setuptools
tabulate
venvShellHook

# dev dependencies
jsonschema
pytest
])
);
};
};
}
Loading