This repository has been archived by the owner on May 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
flake.nix
96 lines (90 loc) · 2.88 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
description = "clickbait-classifier is an example text classifier";
inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
flake-compat.url = github:edolstra/flake-compat;
flake-compat.flake = false;
nix-filter.url = github:numtide/nix-filter;
poetry2nix.url = github:nix-community/poetry2nix;
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
poetry2nix.inputs.flake-utils.follows = "flake-utils";
};
outputs = { ... }@inputs:
inputs.flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [
inputs.poetry2nix.overlay
];
pkgs = import inputs.nixpkgs {
inherit system overlays;
};
developerEnv = pkgs.poetry2nix.mkPoetryEnv
{
projectDir = ./.;
python = pkgs.python3;
extraPackages = (ps: [
ps.pip
]);
preferWheels = true;
};
packagedApp = pkgs.poetry2nix.mkPoetryApplication {
projectDir = ./.;
python = pkgs.python3;
preferWheels = true;
};
programs.classifier = pkgs.writeShellScript "main.sh" ''
${packagedApp.dependencyEnv}/bin/python -m clickbait_classifier.classifier
'';
programs.interactive = pkgs.writeShellScript "main.sh" ''
${packagedApp.dependencyEnv}/bin/python -m clickbait_classifier.interactive
'';
in
rec {
packages = rec {
clickbait-classifier = packagedApp;
default = clickbait-classifier;
};
apps = rec {
classifier = {
type = "app";
program = "${programs.classifier}";
};
interactive = {
type = "app";
program = "${programs.interactive}";
};
default = classifier;
};
devShells = rec {
default = pkgs.mkShell {
buildInputs = [
pkgs.libxml2
pkgs.libxslt
pkgs.zlib
pkgs.pkg-config
];
packages = [
pkgs.python3
pkgs.poetry
developerEnv
## other tools
pkgs.just
pkgs.rnix-lsp
pkgs.nixpkgs-fmt
];
shellHook = ''
# The path to this repository
if [ -z $WORKSPACE_ROOT ]; then
shell_nix=" ''${IN_LORRI_SHELL:-$(pwd)/shell.nix}"
workspace_root=$(dirname "$shell_nix")
export WORKSPACE_ROOT="$workspace_root"
fi
export TOOLCHAIN_ROOT="$WORKSPACE_ROOT/.toolchain"
'';
};
};
}
);
}