-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
163 lines (152 loc) · 4.69 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
description = "Flake for a R environment";
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
nix2container.url = "github:nlewo/nix2container";
nix2container.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
flake-utils,
nix2container,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
nix2containerPkgs = nix2container.packages.${system};
imageBuilder =
(import ./nix_package/image.nix {inherit nix2containerPkgs pkgs;})
.builder;
Rpkgs = pkgs;
R-packages = with Rpkgs.rPackages; [
shiny
shinydashboard
shinycssloaders
shinyjs
shinyvalidate
RSQLite
MASS
digest
plotly
DT
igraph
lubridate
vistime
scrm
GenomicRanges
bsicons
uuid
shinyTree
prettyunits
(pkgs.rPackages.buildRPackage {
name = "rutilstimflutre";
src = pkgs.fetchFromGitHub {
owner = "timflutre";
repo = "rutilstimflutre";
rev = "42660be440687c50169acae592cc32e1a11e4255";
sha256 = "sha256-Au1Izpuht83S4oEhq+1fq4cIrOt+48DbsCoxNvdndi4=";
};
propagatedBuildInputs = with pkgs.rPackages; [data_table lme4 Matrix Rcpp];
})
];
R-test-packages = with Rpkgs.rPackages; [
testthat
];
R-dev-packages = with Rpkgs.rPackages; [
languageserver
styler
];
in rec {
devShells.default = pkgs.mkShell {
LOCALE_ARCHIVE =
if "${system}" == "x86_64-linux"
then "${pkgs.glibcLocalesUtf8}/lib/locale/locale-archive"
else "";
LANG = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
R_LIBS_USER = "''"; # to not use users' installed R packages
R_ZIPCMD = "${pkgs.zip}/bin/zip";
TEST_PORT = 3000;
PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
PLANTBREEDGAME_DATA_ROOT = "./data";
nativeBuildInputs = [pkgs.bashInteractive];
shellHook = ''
npm install --ignore-scripts
'';
buildInputs = [
(Rpkgs.rWrapper.override {packages = R-packages ++ R-test-packages ++ R-dev-packages;})
(Rpkgs.rstudioWrapper.override {packages = R-packages ++ R-test-packages ++ R-dev-packages;})
pkgs.pandoc
pkgs.zip
pkgs.nodejs_20
(pkgs.playwright-driver.override {nodejs = pkgs.nodejs_20;})
pkgs.skopeo
];
};
apps = {
default = let
PlantBreedGame = pkgs.writeShellApplication {
name = "PlantBreedGame";
text = ''
Rscript --vanilla -e "shiny::runApp(port = as.numeric(Sys.getenv('TEST_PORT')))"
'';
};
in {
type = "app";
program = "${PlantBreedGame}/bin/PlantBreedGame";
};
test_ui = let
test_ui = pkgs.writeShellApplication {
name = "test_ui";
text = ''
npx playwright test "$@"
'';
};
in {
type = "app";
program = "${test_ui}/bin/test_ui";
};
unit_tests = let
unit_tests = pkgs.writeShellApplication {
name = "unit_tests";
text = ''
Rscript --vanilla ${./tests/testthat.R}
'';
};
in {
type = "app";
program = "${unit_tests}/bin/unit_tests";
};
initialise-data = let
initialise-data = pkgs.writeShellApplication {
name = "initialise-data";
text = ''
make data
'';
};
in {
type = "app";
program = "${initialise-data}/bin/initialise-data";
};
};
packages.plantBreedGame = pkgs.callPackage ./nix_package/default.nix {
inherit pkgs;
R_deps = R-packages;
tests_R_deps = R-test-packages;
src = pkgs.lib.sources.cleanSource ./.;
};
packages.default = packages.plantBreedGame;
images = {
latest = let
in (imageBuilder {
imageName = "plantBreedGame";
plantBreedGame = packages.plantBreedGame;
tag = "latest";
});
};
}
);
}