From d27dfaef49bccfb81e4bf30d54252e5b5a7dc7ca Mon Sep 17 00:00:00 2001 From: Sebastian Wendel Date: Mon, 31 Oct 2022 17:26:02 +0100 Subject: [PATCH] add flake config to manage dependencies via nix --- .envrc | 3 + .gitignore | 3 +- flake.lock | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 47 ++++++++++++++++ nix/shell.nix | 22 ++++++++ 5 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6adf7d3 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +use flake + +eval "$shellHook" diff --git a/.gitignore b/.gitignore index 31a98a5..c405d11 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ docs/_* *.jpg *.png *.pyc -*__pycache__* \ No newline at end of file +*__pycache__* +.direnv \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..73ccfe6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,151 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "mach-nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs", + "pypi-deps-db": "pypi-deps-db" + }, + "locked": { + "lastModified": 1654084003, + "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "7e14360bde07dcae32e5e24f366c83272f52923f", + "type": "github" + }, + "original": { + "id": "mach-nix", + "ref": "3.5.0", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1643805626, + "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1664281702, + "narHash": "sha256-haixZ4TJLu1Dciow54wrHrHvlGDVr5sW6MTeAV/ZLuI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7e52b35fe98481a279d89f9c145f8076d049d2b9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1663082609, + "narHash": "sha256-lmCCIu4dj59qbzkGKHQtolhpIEQMeAd2XUbXVPqgPYo=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "60cad1a326df17a8c6cf2bb23436609fdd83024e", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pypi-deps-db": { + "flake": false, + "locked": { + "lastModified": 1643877077, + "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", + "owner": "DavHau", + "repo": "pypi-deps-db", + "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "pypi-deps-db", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "mach-nix": "mach-nix", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ce4c8be --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + description = "Nix PlanktoScope"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + + flake-utils.url = "github:numtide/flake-utils"; + + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + + mach-nix.url = "mach-nix/3.5.0"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + mach-nix, + ... + } @ inputs: + flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux"] (system: let + pkgs = import nixpkgs { + inherit system; + }; + machNix = mach-nix.lib."${system}"; + in rec { + packages = { + planktoscope = machNix.buildPythonPackage { + src = builtins.fetchGit { + url = "https://github.com/PlanktoScope/PlanktoScope"; + ref = "master"; + rev = "d52e194de0604e6fdd41ba2e13de9ab91e7789da"; + }; + extras = []; + }; + }; + devShell = import ./nix/shell.nix {inherit pkgs;}; + }); +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..181e5a9 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,22 @@ +{pkgs ? import {}}: +with pkgs; + mkShell { + name = "planctoscope"; + nativeBuildInputs = with pkgs; [ + alejandra + docker + editorconfig-checker + git + gnumake + hadolint + mdl + nixpkgs-fmt + pre-commit + python310Packages.mkdocs + reuse + rnix-lsp + vscodium-fhs + yaml-language-server + yamllint + ]; + }