feature/flupdt #1

Merged
ahuston-0 merged 14 commits from feature/flupdt into main 2025-03-02 01:01:15 -05:00
10 changed files with 22 additions and 57 deletions
Showing only changes of commit bdc15b2c41 - Show all commits

14
.poetry-git-overlay.nix Normal file
View File

@ -0,0 +1,14 @@
{ pkgs }:
final: prev: {
rad-development-python = prev.rad-development-python.overridePythonAttrs (
_: {
src = pkgs.fetchgit {
url = "https://github.com/RAD-Development/rad-development-python";
rev = "f919535e1eb39b78f77c3c2b8ccee9244fd7fc92";
sha256 = "0vba1d184ks4r78d9z252paxpfwvwq4h9fvhmsavby1rr2dr1976";
};
}
);
}

View File

@ -34,5 +34,6 @@ Until `rad_development_python` (`rdp`) is in PyPI, we use the below steps to
update the lock file when there is an update to `rdp`.
1. Run `poetry lock` to update the poetry reference to GitHub
1. Run `poetry2nix lock` to update the overlay which Poetry2Nix uses
1. Run `poetry2nix lock --out .poetry-git-overlay.nix` to update the overlay
which Poetry2Nix uses
1. Run `nix flake check` to verify that all is building as expected

View File

@ -22,14 +22,15 @@ in
# The pattern of files to run on (default: "" (all))
# see also https://pre-commit.com/#hooks-files
files = "\\.nix$";
# exclude = [".poetry-git-overlay.nix"];
};
## static analysis checks for nix
nil.enable = true;
statix.enable = true;
deadnix = {
enable = true;
# exclude = [".poetry-git-overlay.nix"];
settings = {
exclude = [ "poetry-git-overlay.nix" ];
noUnderscore = true; # ignore variables starting with underscore
# ignore lambda patterns (useful for passing args from ({}@args)
# to other functions)

View File

@ -61,7 +61,7 @@
};
overlay = pkgs.lib.composeExtensions pyOverrides (
import ./poetry-git-overlay.nix { inherit pkgs; }
import ./.poetry-git-overlay.nix { inherit pkgs; }
);
overrides = pkgs.poetry2nix.overrides.withDefaults overlay;

View File

@ -1,39 +1 @@
#!/usr/bin/env python3
"""common."""
import logging
import sys
from subprocess import PIPE, Popen
def configure_logger(level: str = "INFO") -> None:
"""Configure the logger.
Args:
level (str, optional): The logging level. Defaults to "INFO".
"""
logging.basicConfig(
level=level,
datefmt="%Y-%m-%dT%H:%M:%S%z",
format="%(asctime)s %(levelname)s %(filename)s:%(lineno)d - %(message)s",
handlers=[logging.StreamHandler(sys.stdout)],
)
def bash_wrapper(command: str, path: str = ".") -> tuple[str, str, int]:
"""Execute a bash command and capture the output.
Args:
command (str): The bash command to be executed.
path (str): The current working directory, '.' by default
Returns:
Tuple[str, int]: A tuple containing the output of the command (stdout) as a string,
the error output (stderr) as a string (optional), and the return code as an integer.
"""
# This is a acceptable risk
process = Popen(command.split(), stdout=PIPE, stderr=PIPE, cwd=path) # noqa: S603
output, error = process.communicate()
return output.decode(), error.decode(), process.returncode

View File

@ -2,7 +2,7 @@
import logging
from typing import Optional
from flupdt.common import bash_wrapper
from rad_development_python import bash_wrapper
ahuston-0 marked this conversation as resolved Outdated

this should be common.py

this should be common.py
import re
drv_re = re.compile(r".*(/nix/store/.*\.drv).*")

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import json
from flupdt.common import bash_wrapper
from rad_development_python import bash_wrapper
import shutil
import logging
import re

View File

@ -3,7 +3,6 @@
from flupdt.flake_show import get_derivations
from flupdt.cli import parse_inputs
from flupdt.flake_eval import evaluate_output
from flupdt.common import configure_logger
import logging
import rad_development_python as rd
ahuston-0 marked this conversation as resolved Outdated

should be common.py

should be common.py

View File

@ -1,12 +0,0 @@
{ pkgs }:
final: prev: {
rad-development-python = prev.rad-development-python.overridePythonAttrs (_: {
src = pkgs.fetchgit {
url = "https://github.com/RAD-Development/rad-development-python";
rev = "4ee897ab983234eda6f12dfcfd822bffab01f740";
sha256 = "1hxdqnjrznx0c07qn5cdx7p7f7sz2ysydx5l82w0r7rdadj69ik2";
};
});
}

2
poetry.lock generated
View File

@ -852,7 +852,7 @@ poetry = "^1.8.3"
type = "git"
url = "https://github.com/RAD-Development/rad-development-python"
reference = "feature/nix"
resolved_reference = "4ee897ab983234eda6f12dfcfd822bffab01f740"
resolved_reference = "f919535e1eb39b78f77c3c2b8ccee9244fd7fc92"
[[package]]
name = "rapidfuzz"