Merge pull request 'nix' (#1) from nix into master
All checks were successful
gitea-physics/pyewjn/pipeline/head This commit looks good

Reviewed-on: #1
This commit is contained in:
Deepak Mallubhotla 2022-06-07 23:27:10 +00:00
commit 68f3451531
3 changed files with 182 additions and 6 deletions

26
do.sh
View File

@ -4,30 +4,56 @@
set -Eeuo pipefail # -e "Automatic exit from bash shell script on error" -u "Treat unset variables and parameters as errors" set -Eeuo pipefail # -e "Automatic exit from bash shell script on error" -u "Treat unset variables and parameters as errors"
checknix() {
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
echo "In an interactive nix env."
else
echo "Using poetry as runner, no nix detected."
fi
}
build() { build() {
echo "I am ${FUNCNAME[0]}ing" echo "I am ${FUNCNAME[0]}ing"
poetry build poetry build
} }
fmt() { fmt() {
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
black .
else
poetry run black . poetry run black .
fi
find . -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \; find . -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
} }
test() { test() {
echo "I am ${FUNCNAME[0]}ing" echo "I am ${FUNCNAME[0]}ing"
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
flake8 pyewjn tests
mypy pyewjn
pytest --benchmark-disable
else
poetry run flake8 pyewjn tests poetry run flake8 pyewjn tests
poetry run mypy pyewjn poetry run mypy pyewjn
poetry run pytest --benchmark-disable poetry run pytest --benchmark-disable
fi
} }
benchmark() { benchmark() {
echo "I am ${FUNCNAME[0]}ing" echo "I am ${FUNCNAME[0]}ing"
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
pytest --benchmark-only
else
poetry run pytest --benchmark-only poetry run pytest --benchmark-only
fi
} }
htmlcov() { htmlcov() {
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
pytest --cov-report=html
else
poetry run pytest --cov-report=html poetry run pytest --cov-report=html
fi
} }
release() { release() {

95
flake.lock generated Normal file
View File

@ -0,0 +1,95 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1648854265,
"narHash": "sha256-e/RlfodBOMr2SH9diDPYMraTWvhOWSSsXDQikHFdUvM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e194871435cad8ffb1d64b64fb7df3b2b8a10088",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e194871435cad8ffb1d64b64fb7df3b2b8a10088",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1654366296,
"narHash": "sha256-7XkmwoaM9cI2Qk0KJmSM15oW7KYpDWCFeUWOoDa1OKI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f1a49956529e0fe9a7fe7efb2f60a80f11c9f81f",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"poetry2nix": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1648808959,
"narHash": "sha256-1KZuZ0yJ4j1cWvOvnyyy36xCTcG9+sNe2FDHOHnErQM=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "99c79568352799af09edaeefc858d337e6d9c56f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "99c79568352799af09edaeefc858d337e6d9c56f",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix"
}
}
},
"root": "root",
"version": 7
}

55
flake.nix Normal file
View File

@ -0,0 +1,55 @@
{
description = "Application packaged using poetry2nix";
inputs.flake-utils.url = "github:numtide/flake-utils?rev=0f8662f1319ad6abf89b3380dd2722369fc51ade";
inputs.nixpkgs.url = "github:NixOS/nixpkgs?rev=e194871435cad8ffb1d64b64fb7df3b2b8a10088";
inputs.poetry2nix.url = "github:nix-community/poetry2nix?rev=99c79568352799af09edaeefc858d337e6d9c56f";
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
{
# Nixpkgs overlay providing the application
overlay = nixpkgs.lib.composeManyExtensions [
poetry2nix.overlay
(final: prev: {
# The application
pyewjn = prev.poetry2nix.mkPoetryApplication {
overrides = [
prev.poetry2nix.defaultPoetryOverrides
];
projectDir = ./.;
};
pyewjnEnv = prev.poetry2nix.mkPoetryEnv {
overrides = [
prev.poetry2nix.defaultPoetryOverrides
];
projectDir = ./.;
};
})
];
} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in
{
apps = {
pyewjn = pkgs.pyewjn;
};
defaultApp = pkgs.pyewjn;
devShell = pkgs.mkShell {
buildInputs = [
pkgs.poetry
pkgs.pyewjnEnv
pkgs.pyewjn
];
shellHook = ''
export DO_NIX_CUSTOM=1
'';
packages = [ pkgs.nodejs-16_x ];
};
}));
}