Skip to content

Commit

Permalink
Merge pull request #12 from pub-solar/flake/add-requirements
Browse files Browse the repository at this point in the history
flake: improve devshell, add watson package, add github action
  • Loading branch information
b12f authored Nov 25, 2024
2 parents 8fc0424 + 5e651e2 commit 0669f8b
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 65 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Nix Flake Build

on:
push:
branches:
- main
pull_request:

jobs:
nix-flake-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: nixbuild/nix-quick-install-action@v29

- name: build watson
run: nix build '.#watson-td'

- name: run watson
run: ./result/bin/watson
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ pip-log.txt
*.sublime-workspace
*.swp
*.sw[po]

# nix related files

/result
49 changes: 22 additions & 27 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 69 additions & 38 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,51 +1,82 @@
{
description = "Watson devenv";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

inputs.devshell.url = "github:numtide/devshell";
inputs.devshell.inputs.nixpkgs.follows = "nixpkgs";

outputs = {self, nixpkgs, systems, devshell }:
let
eachSystem = nixpkgs.lib.genAttrs (import systems);
# Nixpkgs instantiated for system types in nix-systems
nixpkgsFor = eachSystem (system:
import nixpkgs {
inherit system;
overlays = [
devshell.overlays.default
];
}
);
in
{
devShells = eachSystem (system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.devshell.mkShell {
# Add additional packages you'd like to be available in your devshell
# PATH here
devshell.packages = with pkgs; [
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs@{ self, ... }:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

perSystem =
args@{ pkgs, config, system, ... }: {
packages = {
watson-td = pkgs.python3Packages.buildPythonPackage {
name = "watson-td";
src = ./.;
propagatedBuildInputs = with pkgs.python3Packages; [
# requirements
click
click-didyoumean
requests
arrow

# requirements-dev
flake8
py
pytest
pytest-datafiles
pytest-mock
pytest-runner
];
postInstall = ''
installShellCompletion --bash --name watson watson.completion
installShellCompletion --zsh --name _watson watson.zsh-completion
installShellCompletion --fish watson.fish
'';
nativeCheckInputs = with pkgs.python3Packages; [ pytestCheckHook pytest-mock mock pytest-datafiles ];
nativeBuildInputs = [ pkgs.installShellFiles ];
};
};

devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
gnumake
virtualenv
(pkgs.python3.withPackages (p: [
# select Python packages here
yaml-language-server
(python3.withPackages (p: [
# LSP support
p.python-lsp-ruff
p.python-lsp-server
p.python-lsp-server.optional-dependencies

# pip
p.pip

# requirements
p.click
p.click-didyoumean
p.requests
p.arrow

# requirements-dev
p.flake8
p.py
p.pytest
p.pytest-datafiles
p.pytest-mock
p.pytest-runner
]))
];
};
});

packages = eachSystem (system:
let
pkgs = nixpkgsFor.${system};
in
{
});
};
};
}

0 comments on commit 0669f8b

Please sign in to comment.