-
Notifications
You must be signed in to change notification settings - Fork 3
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
Added nix support #100
base: main
Are you sure you want to change the base?
Added nix support #100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# An example package with dependencies defined via pyproject.toml | ||
{ | ||
config, | ||
lib, | ||
dream2nix, | ||
... | ||
}: let | ||
pyproject = lib.importTOML (config.mkDerivation.src + /pyproject.toml); | ||
in { | ||
imports = [ | ||
dream2nix.modules.dream2nix.pip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dream2nix is according to their own webpages still heavily in development and not yet ready for productive use. Hence, I would want to avoid using it in ARTIST without further stabilization (c.f. https://github.com/nix-community/dream2nix) |
||
]; | ||
|
||
deps = {nixpkgs, ...}: { | ||
python = nixpkgs.python3; | ||
hatch = nixpkgs.hatch; | ||
hatchling = nixpkgs.python3.pkgs.hatchling; | ||
}; | ||
|
||
inherit (pyproject.project) name version; | ||
|
||
mkDerivation = { | ||
src = lib.cleanSourceWith { | ||
src = lib.cleanSource ./.; | ||
filter = name: type: | ||
!(builtins.any (x: x) [ | ||
(lib.hasSuffix ".nix" name) | ||
(lib.hasPrefix "." (builtins.baseNameOf name)) | ||
(lib.hasSuffix "flake.lock" name) | ||
]); | ||
}; | ||
}; | ||
|
||
buildPythonPackage = { | ||
pyproject = true; | ||
build-system = [ config.deps.python.pkgs.hatchling ]; | ||
pythonImportsCheck = [ | ||
"artist" | ||
]; | ||
}; | ||
|
||
#paths.lockFile = "lock.${config.deps.stdenv.system}.json"; | ||
pip = { | ||
# Setting editables.$pkg to a relative or absolute path, as a string, will | ||
# link this path as an editable install to .dream2nix/editables in | ||
# devShells. The root package is always installed as editable. | ||
# editables.charset-normalizer = "/home/my-user/src/charset-normalizer"; | ||
|
||
requirementsList = | ||
pyproject.build-system.requires | ||
or [] | ||
++ pyproject.project.dependencies or []; | ||
flattenDependencies = true; | ||
|
||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
# This example flake.nix is pretty generic and the same for all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is again a generic header from some template or generator - adjustments for ARTIST would be necessary |
||
# examples, except when they define devShells or extra packages. | ||
description = "Dream2nix example flake"; | ||
|
||
# We import the latest commit of dream2nix main branch and instruct nix to | ||
# re-use the nixpkgs revision referenced by dream2nix. | ||
# This is what we test in CI with, but you can generally refer to any | ||
# recent nixpkgs commit here. | ||
inputs = { | ||
dream2nix.url = "github:nix-community/dream2nix"; | ||
nixpkgs.follows = "dream2nix/nixpkgs"; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
dream2nix, | ||
nixpkgs, | ||
}: let | ||
# A helper that helps us define the attributes below for | ||
# all systems we care about. | ||
eachSystem = nixpkgs.lib.genAttrs [ | ||
"aarch64-darwin" | ||
"aarch64-linux" | ||
"x86_64-darwin" | ||
"x86_64-linux" | ||
]; | ||
in { | ||
packages = eachSystem (system: { | ||
# For each system, we define our default package | ||
# by passing in our desired nixpkgs revision plus | ||
# any dream2nix modules needed by it. | ||
default = dream2nix.lib.evalModules { | ||
packageSets.nixpkgs = nixpkgs.legacyPackages.${system}; | ||
modules = [ | ||
# Import our actual package definiton as a dream2nix module from ./default.nix | ||
./default.nix | ||
{ | ||
# Aid dream2nix to find the project root. This setup should also works for mono | ||
# repos. If you only have a single project, the defaults should be good enough. | ||
paths.projectRoot = ./.; | ||
# can be changed to ".git" or "flake.nix" to get rid of .project-root | ||
paths.projectRootFile = "flake.nix"; | ||
paths.package = ./.; | ||
} | ||
]; | ||
}; | ||
}); | ||
devShells = eachSystem (system: let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
artist = self.packages.${system}.default; | ||
python = artist.config.deps.python; | ||
in { | ||
default = pkgs.mkShell { | ||
# inherit from the dream2nix generated dev shell | ||
inputsFrom = [artist.devShell]; | ||
packages = [ | ||
python.pkgs.python-lsp-server | ||
python.pkgs.python-lsp-ruff | ||
python.pkgs.pylsp-mypy | ||
python.pkgs.ipython | ||
pkgs.hatch | ||
pkgs.ruff | ||
pkgs.black | ||
]; | ||
}; | ||
}); | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a left over generic statement from a template or generator and should be adjusted