feature/flupdt #1
165
.gitignore
vendored
165
.gitignore
vendored
@ -25,3 +25,168 @@ post-diff
|
||||
|
||||
# ruff cache
|
||||
.ruff_cache
|
||||
|
||||
# borrowed from https://github.com/github/gitignore/blob/bfa56dc5d8465f558383f6764e1219b4e983b725/Python.gitignore
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||
.pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
27
README.md
27
README.md
@ -0,0 +1,27 @@
|
||||
# Flake Update Diff Tool
|
||||
|
||||
This is the Nix flake update validator. A tool which is able to evaluate a flake
|
||||
at two points in history, check that everything evaluates, and provide a diff
|
||||
of the two. In its target state, it will provide a similar function to
|
||||
DeterminateSystems' awesome `update-flake-lock` tool, but with `nvd` integration
|
||||
and other bells and whistles that we've come to like.
|
||||
|
||||
## How to Use
|
||||
|
||||
Currently, this only supports locally-stored flakes, although we are planning to
|
||||
add support for `git`-based URLs for usage outside of CI pipelines where the
|
||||
repository is already downloaded.
|
||||
|
||||
``` shell
|
||||
nix run github:RAD-Development/flake-update-diff-tool -- <path to local flake>
|
||||
```
|
||||
|
||||
For use in other nix-based projects, `flpudt` is available as
|
||||
`packages.${system}.flupdt`. Please see our `examples/` folder for common
|
||||
use-cases.
|
||||
|
||||
## Why the name?
|
||||
|
||||
`flupdt` comes from Fl(ake) Up(date) D(iff) T(ool). The cli is also available as
|
||||
`flake-update-diff-tool`, for ease-of-use and those who use screen readers or
|
||||
similar accessibility tools that may not react well to `flupdt`.
|
10
app/main.py
10
app/main.py
@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from app.flake_show import get_derivations
|
||||
|
||||
def main():
|
||||
print(get_derivations("/home/alice/.gitprojects/nix-dotfiles"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
15
checks.nix
15
checks.nix
@ -4,6 +4,9 @@
|
||||
formatter,
|
||||
...
|
||||
}:
|
||||
let
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
@ -43,6 +46,18 @@
|
||||
# toml hooks
|
||||
check-toml.enable = true;
|
||||
|
||||
# markdown hooks
|
||||
mdl = {
|
||||
enable = true;
|
||||
settings.style =
|
||||
(pkgs.writeText ".mdl_style.rb" ''
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
all
|
||||
rule 'MD013', :tables => false
|
||||
'').outPath;
|
||||
};
|
||||
|
||||
# git hooks
|
||||
check-merge-conflicts.enable = true;
|
||||
## prevents committing to main
|
||||
|
@ -70,10 +70,10 @@
|
||||
in
|
||||
rec {
|
||||
packages = {
|
||||
myapp = poetry2nix.mkPoetryApplication poetryConfig // {
|
||||
flupdt = poetry2nix.mkPoetryApplication poetryConfig // {
|
||||
develop = true;
|
||||
};
|
||||
default = self.packages.${system}.myapp;
|
||||
default = self.packages.${system}.flupdt;
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
|
11
flupdt/cli.py
Normal file
11
flupdt/cli.py
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
|
||||
|
||||
def parse_inputs():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"flake_path", metavar="flake-path", help="path to flake to evaluate"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
return args
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
from app.common import bash_wrapper
|
||||
from flupdt.common import bash_wrapper
|
||||
import shutil
|
||||
|
||||
|
13
flupdt/main.py
Normal file
13
flupdt/main.py
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from flupdt.flake_show import get_derivations
|
||||
from flupdt.cli import parse_inputs
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_inputs()
|
||||
print(get_derivations(args.flake_path))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
52
flupdt/model.py
Normal file
52
flupdt/model.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, Table
|
||||
from sqlalchemy.orm import relationship, backref
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
author_publisher = Table(
|
||||
"author_publisher",
|
||||
Base.metadata,
|
||||
Column("author_id", Integer, ForeignKey("author.author_id")),
|
||||
Column("publisher_id", Integer, ForeignKey("publisher.publisher_id")),
|
||||
)
|
||||
|
||||
book_publisher = Table(
|
||||
"book_publisher",
|
||||
Base.metadata,
|
||||
Column("book_id", Integer, ForeignKey("book.book_id")),
|
||||
Column("publisher_id", Integer, ForeignKey("publisher.publisher_id")),
|
||||
)
|
||||
|
||||
|
||||
class Author(Base):
|
||||
__tablename__ = "author"
|
||||
author_id = Column(Integer, primary_key=True)
|
||||
first_name = Column(String)
|
||||
last_name = Column(String)
|
||||
books = relationship("Book", backref=backref("author"))
|
||||
publishers = relationship(
|
||||
"Publisher", secondary=author_publisher, back_populates="authors"
|
||||
)
|
||||
|
||||
|
||||
class Book(Base):
|
||||
__tablename__ = "book"
|
||||
book_id = Column(Integer, primary_key=True)
|
||||
author_id = Column(Integer, ForeignKey("author.author_id"))
|
||||
title = Column(String)
|
||||
publishers = relationship(
|
||||
"Publisher", secondary=book_publisher, back_populates="books"
|
||||
)
|
||||
|
||||
|
||||
class Publisher(Base):
|
||||
__tablename__ = "publisher"
|
||||
publisher_id = Column(Integer, primary_key=True)
|
||||
name = Column(String)
|
||||
authors = relationship(
|
||||
"Author", secondary=author_publisher, back_populates="publishers"
|
||||
)
|
||||
books = relationship("Book", secondary=book_publisher, back_populates="publishers")
|
5
main.py
5
main.py
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from app.flake_show import get_derivations
|
||||
|
||||
print(get_derivations("/home/alice/.gitprojects/nix-dotfiles"))
|
@ -1,17 +1,23 @@
|
||||
[tool.poetry]
|
||||
name = "app"
|
||||
name = "flupdt"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
description = """\
|
||||
Nix flake update diff checker. \
|
||||
Useful for validating and diffing flakes after updates. \
|
||||
Short for fl(ake) up(date) d(iff).\
|
||||
"""
|
||||
authors = ["Alice Huston <aliceghuston@gmail.com>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
packages = [{ include = "flupdt" }]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
sqlalchemy = "^2.0.31"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
main = "app.main:main"
|
||||
flupdt = "flupdt.main:main"
|
||||
flake-update-diff = "flupdt.main:main"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
ruff = "0.5.5"
|
||||
|
@ -31,7 +31,7 @@ let
|
||||
};
|
||||
|
||||
# constructs the application in-place
|
||||
app = pkgs.mkShell { inputsFrom = [ self.packages.${system}.myapp ]; };
|
||||
flupdt = pkgs.mkShell { inputsFrom = [ self.packages.${system}.flupdt ]; };
|
||||
|
||||
# pull in python/poetry dependencies
|
||||
poetry = pkgs.mkShell { packages = [ pkgs.poetry ]; };
|
||||
@ -43,7 +43,7 @@ in
|
||||
inputsFrom = [
|
||||
pre-commit
|
||||
rad-dev
|
||||
app
|
||||
flupdt
|
||||
poetry
|
||||
poetry2nixshell
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user