-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Johann Bahl
committed
Aug 27, 2023
1 parent
c35d3ad
commit 08c74d8
Showing
11 changed files
with
170 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ tags | |
vagrant/.vagrant | ||
.pytest_cache | ||
share/ | ||
/venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Add nix flake support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
{ | ||
pkgs ? import <nixpkgs> {}, | ||
poetry2nix ? pkgs.poetry2nix, | ||
lzo ? pkgs.lzo, | ||
... | ||
}: | ||
poetry2nix.mkPoetryApplication { | ||
projectDir = ./.; | ||
overrides = poetry2nix.overrides.withDefaults (self: super: { | ||
python-lzo = super.python-lzo.overrideAttrs (old: { | ||
buildInputs = [ lzo ]; | ||
}); | ||
}); | ||
} | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
inputs.flake-compat = { | ||
url = "github:edolstra/flake-compat"; | ||
flake = false; | ||
}; | ||
|
||
outputs = { self, nixpkgs, ... }: | ||
let | ||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; | ||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); | ||
poetryOverrides = pkgs: [ | ||
# https://github.com/nix-community/poetry2nix/pull/899#issuecomment-1620306977 | ||
pkgs.poetry2nix.defaultPoetryOverrides | ||
(self: super: { | ||
python-lzo = super.python-lzo.overrideAttrs (old: { | ||
buildInputs = (old.buildInputs or []) ++ [ pkgs.lzo ]; | ||
}); | ||
scriv = super.scriv.overrideAttrs (old: { | ||
buildInputs = (old.buildInputs or []) ++ [ super.setuptools ]; | ||
}); | ||
consulate-fc-nix-test = super.consulate-fc-nix-test.overrideAttrs (old: { | ||
buildInputs = (old.buildInputs or []) ++ [ super.setuptools super.setuptools-scm ]; | ||
}); | ||
}) | ||
]; | ||
poetryEnv = pkgs: pkgs.poetry2nix.mkPoetryEnv { | ||
projectDir = self; | ||
python = pkgs.python310; | ||
overrides = poetryOverrides pkgs; | ||
editablePackageSources = { | ||
backy = ./src; | ||
}; | ||
}; | ||
in | ||
{ | ||
packages = forAllSystems (system: { | ||
default = pkgs.${system}.poetry2nix.mkPoetryApplication { | ||
projectDir = self; | ||
doCheck = true; | ||
python = pkgs.${system}.python310; | ||
overrides = poetryOverrides pkgs.${system}; | ||
}; | ||
|
||
venv = poetryEnv pkgs.${system}; | ||
}); | ||
|
||
devShells = forAllSystems (system: { | ||
default = pkgs.${system}.mkShellNoCC { | ||
BACKY_CMD = "backy"; | ||
packages = with pkgs.${system}; [ | ||
(poetryEnv pkgs.${system}) | ||
poetry | ||
]; | ||
}; | ||
}); | ||
|
||
checks = forAllSystems (system: { | ||
pytest = pkgs.${system}.runCommand "pytest" { | ||
nativeBuildInputs = [ (poetryEnv pkgs.${system}) ]; | ||
} '' | ||
export BACKY_CMD=backy | ||
cd ${self} | ||
pytest -vv -p no:cacheprovider --no-cov | ||
touch $out | ||
''; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
{ | ||
pkgs ? import <nixpkgs> {}, | ||
... | ||
}: | ||
pkgs.mkShell { | ||
buildInputs = [ pkgs.lzo ]; | ||
packages = [ pkgs.poetry ]; | ||
shellHook = '' | ||
# check if `poetry env info --path`/bin/activate exists | ||
POETRY_ENV_PATH=$(poetry env info --path)/bin/activate | ||
if [ -f $POETRY_ENV_PATH ]; then | ||
source $POETRY_ENV_PATH | ||
else | ||
echo "Run \`poetry install\` to install dependencies first" | ||
fi | ||
''; | ||
} | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).shellNix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters