Skip to content

Commit

Permalink
Fix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Oct 24, 2023
1 parent d7ea328 commit 1c77644
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
27 changes: 17 additions & 10 deletions checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
, self ? (import ./compat.nix).flake
}:

let
rev = "0.1.0+ci";
in
{
nix-alien-ci = pkgs.callPackage ./nix-alien.nix {
ci = true;
inherit rev;
nix-index = self.inputs.nix-index-database.packages.${pkgs.system}.nix-index-with-db;
nixpkgs-input = self.inputs.nix-index-database.inputs.nixpkgs.sourceInfo;
};
inherit (self.outputs.packages.${pkgs.system}) nix-alien nix-index-update;

nix-index-update-ci = pkgs.callPackage ./nix-index-update.nix { };
check-py-files = pkgs.runCommand "check-py-files"
{
src = ./.;
nativeBuildInputs = with pkgs; [
python3.pkgs.black
python3.pkgs.mypy
ruff
];
} ''
touch $out
export PYLINTHOME="$(mktemp -d)"
export RUFF_CACHE_DIR="$(mktemp -d)"
black --check $src/nix_alien
mypy --ignore-missing-imports $src/nix_alien
ruff check $src/nix_alien
'';

check-nix-files = pkgs.runCommand "check-nix-files"
{
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
default = self.outputs.packages.${system}.nix-alien;
};

checks = import ./checks.nix { inherit pkgs; };
checks = import ./checks.nix { inherit pkgs self; };

apps =
let
Expand All @@ -43,6 +43,6 @@
nix-index-update = mkApp { drv = self.outputs.packages.${system}.nix-index-update; };
};

devShells.default = import ./shell.nix { inherit pkgs; };
devShells.default = import ./shell.nix { inherit pkgs self; };
}));
}
20 changes: 5 additions & 15 deletions nix-alien.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{ lib
, fzf
, nix-index
, nixpkgs-src
, nixpkgs-src ? {
lastModifiedDate = "19700101000000";
rev = "nixpkgs-unstable";
narHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}
, python3
, ruff
, rev ? null
, dev ? false
, ci ? false
}:

assert dev -> !ci;
let
version = if (rev != null) then rev else "dev";
deps = (lib.importTOML ./pyproject.toml).project.dependencies;
Expand Down Expand Up @@ -56,19 +57,8 @@ python3.pkgs.buildPythonApplication {

nativeCheckInputs = with python3.pkgs; [
pytestCheckHook
] ++ lib.optionals ci [
black
mypy
ruff
];

preCheck = lib.optionalString ci ''
export PYLINTHOME="$(mktemp -d)"
black --check ./nix_alien
mypy --ignore-missing-imports ./nix_alien
ruff check ./nix_alien
'';

meta = with lib; {
description = "Run unpatched binaries on Nix/NixOS";
homepage = "https://github.com/thiagokokada/nix-alien";
Expand Down
10 changes: 8 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{ pkgs ? (import ./compat.nix).pkgs }:
{ pkgs ? (import ./compat.nix).pkgs
, self ? (import ./compat.nix).flake
}:

let
inherit (pkgs) python3 callPackage;
nix-alien = python3.pkgs.toPythonModule (callPackage ./nix-alien.nix { dev = true; });
nix-alien = python3.pkgs.toPythonModule (callPackage ./nix-alien.nix {
dev = true;
nix-index = self.inputs.nix-index-database.packages.${pkgs.system}.nix-index-with-db;
nixpkgs-src = self.inputs.nix-index-database.inputs.nixpkgs.sourceInfo;
});
python-with-packages = python3.withPackages (ps: with ps; [
black
mypy
Expand Down

0 comments on commit 1c77644

Please sign in to comment.