Skip to content

Commit

Permalink
Add nix flake (#8)
Browse files Browse the repository at this point in the history
The project can now be run with:

```
nix run .
```

:)
  • Loading branch information
silky authored Jun 19, 2024
1 parent 3b5c444 commit 2f88a8b
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ I would recommend installing it via [pipx](https://pipx.pypa.io/stable/):
$ pipx install alga
```

Or, via [Nix flakes](https://nixos.org/):

```shell
nix run github:Tenzer/alga
```


Setup
-----
Expand Down
126 changes: 126 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
inputs = {
pyproject-nix.url = "github:nix-community/pyproject.nix";
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";

flake-utils.url = "github:numtide/flake-utils";
};

outputs = { nixpkgs, pyproject-nix, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (nixpkgs) lib;
project = pyproject-nix.lib.project.loadPoetryPyproject {
projectRoot = ./.;
};

overlay = _: prev: {
python3 = prev.python3.override {
packageOverrides = _: p: {
cfgs = p.buildPythonPackage rec {
version = "0.13.0";
pname = "cfgs";
format = "pyproject";
nativeBuildInputs = with p.pythonPackages; [
poetry-core
];
src = p.fetchPypi {
inherit version pname;
hash = "sha256-zvR+Z/BRJ4Pug+JMwvOeWyO11MoMMrvXIb1k9IY2Zn4=";
};
};
};
};
};

pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };
python = pkgs.python3;
in
{
devShells.default =
let
arg = project.renderers.withPackages { inherit python; };
pythonEnv = python.withPackages arg;
in pkgs.mkShell {
packages = [ pythonEnv ];
};

packages.default =
let
attrs = project.renderers.buildPythonPackage { inherit python; };
in python.pkgs.buildPythonPackage attrs;
}
);
}

0 comments on commit 2f88a8b

Please sign in to comment.