forked from hernad/odoonix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
251 lines (180 loc) · 7.24 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#https://ianthehenry.com/posts/how-to-learn-nix/flakes/
{
# # Executed by `nix flake check`
# checks."<system>"."<name>" = derivation;
# # Executed by `nix build .#<name>`
# packages."<system>"."<name>" = derivation;
# # Executed by `nix build .`
# packages."<system>".default = derivation;
description = "odoo nixos developer environment";
inputs = {
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
};
outputs = { self, nixpkgs, ... }@inputs:
let
inherit (self) outputs;
#forAllSystems = nixpkgs.lib.genAttrs [
# https://github.com/NixOS/nixpkgs/issues/44255
#freetype_static = pkgs.freetype.overrideAttrs (oldArgs: { dontDisableStatic = true; });
ft = pkgs.freetype.overrideAttrs (oldArgs: { dontDisableStatic = true; });
lib = pkgs.lib;
#ft = pkgs.freetype;
myConfig = {
allowBroken = true;
permittedInsecurePackages = [
"openssl-1.1.1w"
];
packageOverrides = pkgs: {
python311 = (import ./python311.nix {inherit pkgs lib ft;});
};
};
# https://nixos.org/manual/nixpkgs/unstable/#how-to-override-a-python-package-for-all-python-versions-using-extensions
system = "x86_64-linux";
pkgs = (import nixpkgs {
inherit system;
config = myConfig;
});
stdenv = pkgs.stdenv;
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
];
nixpkgsFor = forAllSystems (system: import nixpkgs
{
inherit system;
config = myConfig;
#overlays = [ self.overlays.default ];
}
);
odoo17 = self.packages.${system}.my-odoo-17;
odoo17-11 = self.packages.${system}.my-odoo-17-11;
odoo16 = self.packages.${system}.my-odoo-16;
python-311 = self.packages.${system}.odoo-python-311;
nginx-start = self.packages.${system}.nginx-start;
my-wkhtmltopdf = self.packages.${system}.my-wkhtmltopdf;
postgresql-start = self.packages.${system}.postgresql-start;
postgresql-stop = self.packages.${system}.postgresql-stop;
odoo-16-start = pkgs.writeShellScriptBin "odoo-16-start" ''
#export PATH=${pkgs.wkhtmltopdf-bin}/bin:$PATH
#echo "PATH=$PATH"
#wkhtmltopdf --version
exec ${odoo16}/bin/odoo -c ${./odoo.conf} "$@"
'';
odoo-17-start = pkgs.writeShellScriptBin "odoo-17-start" ''
exec ${odoo17}/bin/odoo -c ${./odoo.conf} "$@"
'';
odoo-17-11-start = pkgs.writeShellScriptBin "odoo-17-11-start" ''
exec ${odoo17-11}/bin/odoo -c ${./odoo.conf} "$@"
'';
#nginx-start = pkgs.writeShellScriptBin "nginx-start" ''
# exec ${pkgs.nginx}/bin/nginx -c ${./nginx/nginx.conf} "$@"
#'';
odooVersion17 = {
url = null;
version = "17.0";
release = "20240130";
hash = "sha256-0Dqar3CTBaG07LqMs7yykG3uK6FmPC3pJcWVIqZgibo=";
#release = "20240204";
#hash = "sha256-ieAlkbUS5b8j/2wRleLkzkVi0H0s7ZreCHbCjFnyKsA=";
};
odooVersion16 = {
version = "16.0";
release = "hernad-20240210";
hash = "sha256-Wl+/rvfQ3LKTQcchnnWPp9+SHsttc5he02gwlu2EKVM=";
url = "https://download.cloud.out.ba/odoo-16-hernad.zip";
#release = "20240204";
#hash = "sha256-ieAlkbUS5b8j/2wRleLkzkVi0H0s7ZreCHbCjFnyKsA=";
};
in
{
# https://git.sbruder.de/simon/nixpkgs-overlay/src/branch/master/flake.nix
#overlays.default = import ./overlayPython.nix;
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
odoo-python-311 = (import ./odoo-python-311.nix {inherit pkgs;});
nginx-start = import ./nginx_start.nix { inherit stdenv pkgs; };
postgresql-start = import ./postgresql_start.nix { inherit stdenv pkgs; };
postgresql-stop = import ./postgresql_stop.nix { inherit stdenv pkgs; };
my-odoo-16 = import ./odoo.nix { inherit pkgs; odooVersion = odooVersion16; python = python-311; };
my-odoo-17 = import ./odoo.nix { inherit pkgs; odooVersion = odooVersion17; python = python-311; };
odoo-16-start = odoo-16-start;
odoo-17-start = odoo-17-start;
#odoo-17-11-start = odoo-17-11-start;
#default = self.packages.${system}.odoo-start;
#nginx-start = nginx-start;
odoo-python-311-pip = pkgs.python311.withPackages (ps: [
ps.pip
ps.virtualenv
]);
my-wkhtmltopdf = pkgs.wkhtmltopdf-bin;
});
devShells.${system}.default = pkgs.mkShell {
buildInputs = [
nginx-start
odoo-16-start
odoo-17-start
postgresql-start
postgresql-stop
my-wkhtmltopdf
];
shellHook = ''
alias np="scripts/start_nginx_then_local_postgresql.sh"
echo Let’s Nix with nginx !
echo run: nginx-start\&
echo "run: export PGDATA=\$(pwd)/pgdata"
echo "run: postgresql-start / postgresql-stop"
echo "run psql client: psql -h 127.0.0.1 -U postgres -p 15432 postgres"
echo "create odoo in local database: CREATE ROLE odoo WITH LOGIN PASSWORD 'odoo' CREATEDB;"
echo "ako je lokalna postgresql baza napravljena, dovoljno je pokreniti skriptu:"
echo " "
echo "my-wkhtmltopdf: `${my-wkhtmltopdf}/bin/wkhtmltopdf --version`"
echo "set (ln -sf) ./python311 ./odoo16/python311 ./odoo17/python311"
ln -sf ${python-311}/bin/python ./python311
ln -sf ${python-311}/bin/python ./odoo16/python311
ln -sf ${python-311}/bin/python ./odoo17/python311
echo -e "Start nginx and postgresql local server with command: \033[1;32mnp\033[0m"
echo " "
echo "type 'exit' before command 'scripts/nix_shell_odoo.sh'"
'';
};
};
# # Executed by `nix run .#<name>`
# apps."<system>"."<name>" = {
# type = "app";
# program = "<store-path>";
# };
# # Executed by `nix run . -- <args?>`
# apps."<system>".default = { type = "app"; program = "..."; };
#
# # Formatter (alejandra, nixfmt or nixpkgs-fmt)
# formatter."<system>" = derivation;
# # Used for nixpkgs packages, also accessible via `nix build .#<name>`
# legacyPackages."<system>"."<name>" = derivation;
# # Overlay, consumed by other flakes
# overlays."<name>" = final: prev: { };
# # Default overlay
# overlays.default = final: prev: { };
# # Nixos module, consumed by other flakes
# nixosModules."<name>" = { config }: { options = {}; config = {}; };
# # Default module
# nixosModules.default = { config }: { options = {}; config = {}; };
# # Used with `nixos-rebuild switch --flake .#<hostname>`
# # nixosConfigurations."<hostname>".config.system.build.toplevel must be a derivation
# nixosConfigurations."<hostname>" = {};
# # Used by `nix develop .#<name>`
# devShells."<system>"."<name>" = derivation;
# # Used by `nix develop`
# devShells."<system>".default = derivation;
# # Hydra build jobs
# hydraJobs."<attr>"."<system>" = derivation;
# # Used by `nix flake init -t <flake>#<name>`
# templates."<name>" = {
# path = "<store-path>";
# description = "template description goes here?";
# };
# # Used by `nix flake init -t <flake>`
# templates.default = { path = "<store-path>"; description = ""; };
}