Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake: improve devshell, add watson package, add github action #12

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
{
});
};
};
}
Loading