add flake config to manage dependencies via nix

This commit is contained in:
Sebastian Wendel 2022-10-31 17:26:02 +01:00
parent d52e194de0
commit d27dfaef49
No known key found for this signature in database
GPG key ID: 1422B7DF78144640
5 changed files with 225 additions and 1 deletions

3
.envrc Normal file
View file

@ -0,0 +1,3 @@
use flake
eval "$shellHook"

3
.gitignore vendored
View file

@ -9,4 +9,5 @@ docs/_*
*.jpg
*.png
*.pyc
*__pycache__*
*__pycache__*
.direnv

151
flake.lock Normal file
View file

@ -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
}

47
flake.nix Normal file
View file

@ -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;};
});
}

22
nix/shell.nix Normal file
View file

@ -0,0 +1,22 @@
{pkgs ? import <nixpkgs> {}}:
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
];
}