From 1c54ba1f0a936a8d1e8fdfdb9869861a1c431e81 Mon Sep 17 00:00:00 2001 From: Noon van der Silk Date: Mon, 17 Jun 2024 09:55:31 +0100 Subject: [PATCH] Add nix flake The project can now be run with: ``` nix run . ``` :) --- README.md | 6 +++ flake.lock | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 54 +++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 1ebe06c..6697467 100644 --- a/README.md +++ b/README.md @@ -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 ----- diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c9f3e5e --- /dev/null +++ b/flake.lock @@ -0,0 +1,126 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "mdbook-nixdoc": { + "inputs": { + "nix-github-actions": [ + "pyproject-nix", + "nix-github-actions" + ], + "nixpkgs": [ + "pyproject-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708395692, + "narHash": "sha256-smf0VmxGbjJDZqKvxxG3ZVqubgbVwAWG26wPo+BT/A0=", + "owner": "adisbladis", + "repo": "mdbook-nixdoc", + "rev": "d6a71b114b9221c0b4f20d31b81766d072cc26be", + "type": "github" + }, + "original": { + "owner": "adisbladis", + "repo": "mdbook-nixdoc", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "pyproject-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703863825, + "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-US1tAChvPxT52RV8GksWZS415tTS7PV42KTc2PNDBmc=", + "path": "/nix/store/aa0zsahvyqnvzkicsh29jirm9hwv95pg-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "pyproject-nix": { + "inputs": { + "mdbook-nixdoc": "mdbook-nixdoc", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716218469, + "narHash": "sha256-w2djd2mxQhBIqDhCVSW544vFxGgCFX6vm/cpk1Btzg8=", + "owner": "nix-community", + "repo": "pyproject.nix", + "rev": "298d55c4122a9a2177fd56cb18796d62daf386c5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "pyproject.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pyproject-nix": "pyproject-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f802c32 --- /dev/null +++ b/flake.nix @@ -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; + } + ); +}