##// END OF EJS Templates
merge with default
super-admin -
r4903:98004a1b merge default
parent child Browse files
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,52 +1,53 b''
1 # top level files
1 # top level files
2
2
3 include MANIFEST.in
3 include MANIFEST.in
4 include README.rst
4 include README.rst
5 include CHANGES.rst
5 include CHANGES.rst
6 include LICENSE.txt
6 include LICENSE.txt
7
7
8 include rhodecode/VERSION
8 include rhodecode/VERSION
9
9
10 # docs
10 # docs
11 recursive-include docs *
11 recursive-include docs *
12
12
13 # all config files
13 # all config files
14 recursive-include configs *
14 recursive-include configs *
15
15
16 # translations
16 # translations
17 recursive-include rhodecode/i18n *
17 recursive-include rhodecode/i18n *
18
18
19 # non-python core stuff
19 # non-python core stuff
20 recursive-include rhodecode *.cfg
20 recursive-include rhodecode *.cfg
21 recursive-include rhodecode *.json
21 recursive-include rhodecode *.json
22 recursive-include rhodecode *.ini_tmpl
22 recursive-include rhodecode *.ini_tmpl
23 recursive-include rhodecode *.sh
23 recursive-include rhodecode *.sh
24 recursive-include rhodecode *.mako
24 recursive-include rhodecode *.mako
25
25
26 # 502 page
26 # 502 page
27 include rhodecode/public/502.html
27 include rhodecode/public/502.html
28
28
29 # robots
29 # robots
30 include rhodecode/public/robots.txt
30 include rhodecode/public/robots.txt
31
31
32 # images, css
32 # images, css
33 include rhodecode/public/css/*.css
33 include rhodecode/public/css/*.css
34 include rhodecode/public/images/*.*
34 include rhodecode/public/images/*.*
35 include rhodecode/public/images/ee_features/*.*
35 include rhodecode/public/images/ee_features/*.*
36
36
37 # sound files
37 # sound files
38 include rhodecode/public/sounds/*.mp3
38 include rhodecode/public/sounds/*.mp3
39 include rhodecode/public/sounds/*.wav
39 include rhodecode/public/sounds/*.wav
40
40
41 # fonts
41 # fonts
42 recursive-include rhodecode/public/fonts/RCIcons *
42 recursive-include rhodecode/public/fonts/RCIcons *
43
43
44 # js
44 # js
45 recursive-include rhodecode/public/js *
45 recursive-include rhodecode/public/js *
46
46
47 # templates
47 # templates
48 recursive-include rhodecode/templates *
48 recursive-include rhodecode/templates *
49
49
50 # skip any tests files
50 # skip any tests files
51 recursive-exclude result *
51 recursive-exclude rhodecode/tests *
52 recursive-exclude rhodecode/tests *
52
53
@@ -1,98 +1,135 b''
1 .DEFAULT_GOAL := help
2
1
3 # set by: PATH_TO_OUTDATED_PACKAGES=/some/path/outdated_packages.py
2 # set by: PATH_TO_OUTDATED_PACKAGES=/some/path/outdated_packages.py
4 OUTDATED_PACKAGES = ${PATH_TO_OUTDATED_PACKAGES}
3 OUTDATED_PACKAGES = ${PATH_TO_OUTDATED_PACKAGES}
5
4
6 NODE_PATH=./node_modules
5 NODE_PATH=./node_modules
7 WEBPACK=./node_binaries/webpack
6 WEBPACK=./node_binaries/webpack
8 GRUNT=./node_binaries/grunt
7 GRUNT=./node_binaries/grunt
9
8
10 .PHONY: clean
9 .PHONY: clean
11 clean: ## full clean
10 ## Cleanup compiled and cache py files
11 clean:
12 make test-clean
12 make test-clean
13 find . -type f \( -iname '*.c' -o -iname '*.pyc' -o -iname '*.so' -o -iname '*.orig' \) -exec rm '{}' ';'
13 find . -type f \( -iname '*.c' -o -iname '*.pyc' -o -iname '*.so' -o -iname '*.orig' \) -exec rm '{}' ';'
14
14
15
15
16 .PHONY: test
16 .PHONY: test
17 test: ## run test-clean and tests
17 ## run test-clean and tests
18 test:
18 make test-clean
19 make test-clean
19 make test-only
20 make test-only
20
21
21
22
22 .PHONY:test-clean
23 .PHONY:test-clean
23 test-clean: ## run test-clean and tests
24 ## run test-clean and tests
25 test-clean:
24 rm -rf coverage.xml htmlcov junit.xml pylint.log result
26 rm -rf coverage.xml htmlcov junit.xml pylint.log result
25 find . -type d -name "__pycache__" -prune -exec rm -rf '{}' ';'
27 find . -type d -name "__pycache__" -prune -exec rm -rf '{}' ';'
26 find . -type f \( -iname '.coverage.*' \) -exec rm '{}' ';'
28 find . -type f \( -iname '.coverage.*' \) -exec rm '{}' ';'
27
29
28
30
29 .PHONY: test-only
31 .PHONY: test-only
30 test-only: ## run tests
32 ## Run tests only without cleanup
33 test-only:
31 PYTHONHASHSEED=random \
34 PYTHONHASHSEED=random \
32 py.test -x -vv -r xw -p no:sugar \
35 py.test -x -vv -r xw -p no:sugar \
33 --cov=rhodecode --cov-report=term-missing --cov-report=html \
36 --cov-report=term-missing --cov-report=html \
34 rhodecode
37 --cov=rhodecode rhodecode
35
36
38
37 .PHONY: test-only-mysql
39 .PHONY: test-only-mysql
38 test-only-mysql: ## run tests against mysql
40 ## run tests against mysql
41 test-only-mysql:
39 PYTHONHASHSEED=random \
42 PYTHONHASHSEED=random \
40 py.test -x -vv -r xw -p no:sugar \
43 py.test -x -vv -r xw -p no:sugar \
41 --cov=rhodecode --cov-report=term-missing --cov-report=html \
44 --cov-report=term-missing --cov-report=html \
42 --ini-config-override='{"app:main": {"sqlalchemy.db1.url": "mysql://root:qweqwe@localhost/rhodecode_test?charset=utf8"}}' \
45 --ini-config-override='{"app:main": {"sqlalchemy.db1.url": "mysql://root:qweqwe@localhost/rhodecode_test?charset=utf8"}}' \
43 rhodecode
46 --cov=rhodecode rhodecode
44
47
45
48
46 .PHONY: test-only-postgres
49 .PHONY: test-only-postgres
47 test-only-postgres: ## run tests against postgres
50 ## run tests against postgres
51 test-only-postgres:
48 PYTHONHASHSEED=random \
52 PYTHONHASHSEED=random \
49 py.test -x -vv -r xw -p no:sugar \
53 py.test -x -vv -r xw -p no:sugar \
50 --cov=rhodecode --cov-report=term-missing --cov-report=html \
54 --cov-report=term-missing --cov-report=html \
51 --ini-config-override='{"app:main": {"sqlalchemy.db1.url": "postgresql://postgres:qweqwe@localhost/rhodecode_test"}}' \
55 --ini-config-override='{"app:main": {"sqlalchemy.db1.url": "postgresql://postgres:qweqwe@localhost/rhodecode_test"}}' \
52 rhodecode
56 --cov=rhodecode rhodecode
53
57
54 .PHONY: docs
58 .PHONY: docs
55 docs: ## build docs
59 ## build docs
60 docs:
56 (cd docs; nix-build default.nix -o result; make clean html)
61 (cd docs; nix-build default.nix -o result; make clean html)
57
62
58
63
59 .PHONY: docs-clean
64 .PHONY: docs-clean
60 docs-clean: ## Cleanup docs
65 ## Cleanup docs
66 docs-clean:
61 (cd docs; make clean)
67 (cd docs; make clean)
62
68
63
69
64 .PHONY: docs-cleanup
70 .PHONY: docs-cleanup
65 docs-cleanup: ## Cleanup docs
71 ## Cleanup docs
72 docs-cleanup:
66 (cd docs; make cleanup)
73 (cd docs; make cleanup)
67
74
68
75
69 .PHONY: web-build
76 .PHONY: web-build
70 web-build: ## Build static/js
77 ## Build JS packages static/js
78 web-build:
71 NODE_PATH=$(NODE_PATH) $(GRUNT)
79 NODE_PATH=$(NODE_PATH) $(GRUNT)
72
80
73
81
74 .PHONY: generate-pkgs
75 generate-pkgs: ## generate new python packages
76 nix-shell pkgs/shell-generate.nix --command "pip2nix generate --licenses"
77
78
79 .PHONY: pip-packages
82 .PHONY: pip-packages
80 pip-packages: ## show outdated packages
83 ## show outdated packages
84 pip-packages:
81 python ${OUTDATED_PACKAGES}
85 python ${OUTDATED_PACKAGES}
82
86
83
87
84 .PHONY: generate-js-pkgs
88 .PHONY: sdist
85 generate-js-pkgs: ## generate js packages
89 ## Build sdist
86 rm -rf node_modules && \
90 sdist:
87 nix-shell pkgs/shell-generate.nix --command "node2nix --input package.json -o pkgs/node-packages.nix -e pkgs/node-env.nix -c pkgs/node-default.nix -d --flatten --nodejs-8" && \
91 python setup.py sdist
88 sed -i -e 's/http:\/\//https:\/\//g' pkgs/node-packages.nix
89
92
90
93
91 .PHONY: generate-license-meta
94 # Default command on calling make
92 generate-license-meta: ## Generate license metadata
95 .DEFAULT_GOAL := show-help
93 nix-build pkgs/license-generate.nix -o result-license && \
94 cat result-license/licenses.json | python -m json.tool > rhodecode/config/licenses.json
95
96
96 .PHONY: help
97 .PHONY: show-help
97 help:
98 show-help:
98 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}'
99 @echo "$$(tput bold)Available rules:$$(tput sgr0)"
100 @echo
101 @sed -n -e "/^## / { \
102 h; \
103 s/.*//; \
104 :doc" \
105 -e "H; \
106 n; \
107 s/^## //; \
108 t doc" \
109 -e "s/:.*//; \
110 G; \
111 s/\\n## /---/; \
112 s/\\n/ /g; \
113 p; \
114 }" ${MAKEFILE_LIST} \
115 | LC_ALL='C' sort --ignore-case \
116 | awk -F '---' \
117 -v ncol=$$(tput cols) \
118 -v indent=19 \
119 -v col_on="$$(tput setaf 6)" \
120 -v col_off="$$(tput sgr0)" \
121 '{ \
122 printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
123 n = split($$2, words, " "); \
124 line_length = ncol - indent; \
125 for (i = 1; i <= n; i++) { \
126 line_length -= length(words[i]) + 1; \
127 if (line_length <= 0) { \
128 line_length = ncol - indent - length(words[i]) - 1; \
129 printf "\n%*s ", -indent, " "; \
130 } \
131 printf "%s ", words[i]; \
132 } \
133 printf "\n"; \
134 }'
135
@@ -1,296 +1,302 b''
1 # Nix environment for the community edition
1 # Nix environment for the community edition
2 #
2 #
3 # This shall be as lean as possible, just producing the enterprise-ce
3 # This shall be as lean as possible, just producing the enterprise-ce
4 # derivation. For advanced tweaks to pimp up the development environment we use
4 # derivation. For advanced tweaks to pimp up the development environment we use
5 # "shell.nix" so that it does not have to clutter this file.
5 # "shell.nix" so that it does not have to clutter this file.
6 #
6 #
7 # Configuration, set values in "~/.nixpkgs/config.nix".
7 # Configuration, set values in "~/.nixpkgs/config.nix".
8 # example
8 # example
9 # {
9 # {
10 # # Thoughts on how to configure the dev environment
10 # # Thoughts on how to configure the dev environment
11 # rc = {
11 # rc = {
12 # codeInternalUrl = "https://usr:token@code.rhodecode.com/internal";
12 # codeInternalUrl = "https://usr:token@code.rhodecode.com/internal";
13 # sources = {
13 # sources = {
14 # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver";
14 # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver";
15 # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce";
15 # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce";
16 # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee";
16 # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee";
17 # };
17 # };
18 # };
18 # };
19 # }
19 # }
20
20
21 args@
21 args@
22 { system ? builtins.currentSystem
22 { system ? builtins.currentSystem
23 , pythonPackages ? "python27Packages"
23 , pythonPackages ? "python27Packages"
24 , pythonExternalOverrides ? self: super: {}
24 , pythonExternalOverrides ? self: super: {}
25 , doCheck ? false
25 , doCheck ? false
26 , ...
26 , ...
27 }:
27 }:
28
28
29 let
29 let
30 pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; });
30 pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; });
31 in
31 in
32
32
33 let
33 let
34 pkgs = import <nixpkgs> {
34 pkgs = import <nixpkgs> {
35 overlays = [
35 overlays = [
36 (import ./pkgs/overlays.nix)
36 (import ./pkgs/overlays.nix)
37 ];
37 ];
38 inherit
38 inherit
39 (pkgs_)
39 (pkgs_)
40 system;
40 system;
41 };
41 };
42
42
43 # Works with the new python-packages, still can fallback to the old
43 # Works with the new python-packages, still can fallback to the old
44 # variant.
44 # variant.
45 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
45 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
46 self: basePythonPackages.override (a: { inherit self; }));
46 self: basePythonPackages.override (a: { inherit self; }));
47
47
48 # Evaluates to the last segment of a file system path.
48 # Evaluates to the last segment of a file system path.
49 basename = path: with pkgs.lib; last (splitString "/" path);
49 basename = path: with pkgs.lib; last (splitString "/" path);
50 startsWith = prefix: full: let
51 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
52 in actualPrefix == prefix;
50
53
51 # source code filter used as arugment to builtins.filterSource.
54 # source code filter used as arugment to builtins.filterSource.
52 src-filter = path: type: with pkgs.lib;
55 src-filter = path: type: with pkgs.lib;
53 let
56 let
54 ext = last (splitString "." path);
57 ext = last (splitString "." path);
58 parts = last (splitString "/" path);
55 in
59 in
56 !builtins.elem (basename path) [
60 !builtins.elem (basename path) [
57 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
61 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
58 "node_modules" "node_binaries"
62 "node_modules" "node_binaries"
59 "build" "data" "result" "tmp"] &&
63 "build" "data" "result" "tmp"] &&
60 !builtins.elem ext ["egg-info" "pyc"] &&
64 !builtins.elem ext ["egg-info" "pyc"] &&
61 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
65 !startsWith "result" (basename path);
62 # it would still be good to restore it since we want to ignore "result-*".
63 !hasPrefix "result" path;
64
66
65 sources =
67 sources =
66 let
68 let
67 inherit
69 inherit
68 (pkgs.lib)
70 (pkgs.lib)
69 all
71 all
70 isString
72 isString
71 attrValues;
73 attrValues;
74
72 sourcesConfig = pkgs.config.rc.sources or {};
75 sourcesConfig = pkgs.config.rc.sources or {};
73 in
76 in
74 # Ensure that sources are configured as strings. Using a path
77 # Ensure that sources are configured as strings. Using a path
75 # would result in a copy into the nix store.
78 # would result in a copy into the nix store.
76 assert all isString (attrValues sourcesConfig);
79 assert all isString (attrValues sourcesConfig);
77 sourcesConfig;
80 sourcesConfig;
78
81
82 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
79 version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION";
83 version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION";
80 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
81
84
82 nodeEnv = import ./pkgs/node-default.nix {
85 nodeEnv = import ./pkgs/node-default.nix {
83 inherit
86 inherit
84 pkgs
87 pkgs
85 system;
88 system;
86 };
89 };
87 nodeDependencies = nodeEnv.shell.nodeDependencies;
90 nodeDependencies = nodeEnv.shell.nodeDependencies;
88
91
89 rhodecode-testdata-src = sources.rhodecode-testdata or (
92 rhodecode-testdata-src = sources.rhodecode-testdata or (
90 pkgs.fetchhg {
93 pkgs.fetchhg {
91 url = "https://code.rhodecode.com/upstream/rc_testdata";
94 url = "https://code.rhodecode.com/upstream/rc_testdata";
92 rev = "v0.10.0";
95 rev = "v0.10.0";
93 sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0";
96 sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0";
94 });
97 });
95
98
96 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
99 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
97 inherit
100 inherit
98 doCheck
101 doCheck
99 pkgs
102 pkgs
100 pythonPackages;
103 pythonPackages;
101 };
104 };
102
105
103 pythonLocalOverrides = self: super: {
106 pythonLocalOverrides = self: super: {
104 rhodecode-enterprise-ce =
107 rhodecode-enterprise-ce =
105 let
108 let
106 linkNodePackages = ''
109 linkNodePackages = ''
107 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
110 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
108
111
109 echo "[BEGIN]: Link node packages and binaries"
112 echo "[BEGIN]: Link node packages and binaries"
110 # johbo: Linking individual packages allows us to run "npm install"
113 # johbo: Linking individual packages allows us to run "npm install"
111 # inside of a shell to try things out. Re-entering the shell will
114 # inside of a shell to try things out. Re-entering the shell will
112 # restore a clean environment.
115 # restore a clean environment.
113 rm -fr node_modules
116 rm -fr node_modules
114 mkdir node_modules
117 mkdir node_modules
115 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
118 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
116 export NODE_PATH=./node_modules
119 export NODE_PATH=./node_modules
117
120
118 rm -fr node_binaries
121 rm -fr node_binaries
119 mkdir node_binaries
122 mkdir node_binaries
120 ln -s ${nodeDependencies}/bin/* node_binaries/
123 ln -s ${nodeDependencies}/bin/* node_binaries/
121 echo "[DONE ]: Link node packages and binaries"
124 echo "[DONE ]: Link node packages and binaries"
122 '';
125 '';
123
126
124 releaseName = "RhodeCodeEnterpriseCE-${version}";
127 releaseName = "RhodeCodeEnterpriseCE-${version}";
128 pythonWithEnv =
129 self.python.buildEnv.override {
130 extraLibs = [ ] ++ self.rhodecode-enterprise-ce.propagatedBuildInputs;
131 ignoreCollisions = true;
132 #--set PYTHONHASHSEED random TODO
133 };
125 in super.rhodecode-enterprise-ce.override (attrs: {
134 in super.rhodecode-enterprise-ce.override (attrs: {
126 inherit
135 inherit
127 doCheck
136 doCheck
128 version;
137 version;
129
138
130 name = "rhodecode-enterprise-ce-${version}";
139 name = "rhodecode-enterprise-ce-${version}";
131 releaseName = releaseName;
140 releaseName = releaseName;
132 src = rhodecode-enterprise-ce-src;
141 src = rhodecode-enterprise-ce-src;
133 dontStrip = true; # prevent strip, we don't need it.
142 dontStrip = true; # prevent strip, we don't need it.
134
143
135 # expose following attributed outside
144 # expose following attributed outside
136 passthru = {
145 passthru = {
137 inherit
146 inherit
138 rhodecode-testdata
147 rhodecode-testdata
139 linkNodePackages
148 linkNodePackages
140 myPythonPackagesUnfix
149 myPythonPackagesUnfix
141 pythonLocalOverrides
150 pythonLocalOverrides
142 pythonCommunityOverrides;
151 pythonCommunityOverrides;
143
152
144 pythonPackages = self;
153 pythonPackages = self;
154 rc_pkgs = pkgs;
145 };
155 };
146
156
147 buildInputs =
157 buildInputs =
148 attrs.buildInputs or [] ++ [
158 attrs.buildInputs or [] ++ [
149 rhodecode-testdata
159 rhodecode-testdata
150 ];
160 ];
151
161
152 #NOTE: option to inject additional propagatedBuildInputs
162 #NOTE: option to inject additional propagatedBuildInputs
153 propagatedBuildInputs =
163 propagatedBuildInputs =
154 attrs.propagatedBuildInputs or [] ++ [
164 attrs.propagatedBuildInputs or [] ++ [
155
165
156 ];
166 ];
167
168 preBuild = ''
169 export NIX_PATH=nixpkgs=${pkgs.path}
170 export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
157
171
158 LC_ALL = "en_US.UTF-8";
172 echo "[BEGIN]: Building frontend assets"
159 LOCALE_ARCHIVE =
173 ${linkNodePackages}
160 if pkgs.stdenv.isLinux
174 make web-build
161 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
175 rm -fr node_modules
162 else "";
176 rm -fr node_binaries
177 echo "[DONE ]: Building frontend assets"
178 '';
163
179
164 # Add bin directory to path so that tests can find 'rhodecode'.
180 # Add bin directory to path so that tests can find 'rhodecode'.
165 preCheck = ''
181 preCheck = ''
182 echo "Expanding PATH with $out/bin directory"
166 export PATH="$out/bin:$PATH"
183 export PATH="$out/bin:$PATH"
167 '';
184 '';
168
185
169 # custom check phase for testing
186 # custom check phase for testing
170 checkPhase = ''
187 checkPhase = ''
171 runHook preCheck
188 runHook preCheck
172 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode
189 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode
173 runHook postCheck
190 runHook postCheck
174 '';
191 '';
175
192
176 postCheck = ''
193 postCheck = ''
177 echo "Cleanup of rhodecode/tests"
194 echo "Cleanup of rhodecode/tests"
178 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
195 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
179 '';
196 '';
180
197
181 preBuild = ''
182 echo "[BEGIN]: Building frontend assets"
183 ${linkNodePackages}
184 make web-build
185 rm -fr node_modules
186 rm -fr node_binaries
187 echo "[DONE ]: Building frontend assets"
188 '';
189
190 postInstall = ''
198 postInstall = ''
191 # check required files
199 # check required files
192 STATIC_CHECK="/robots.txt /502.html
200 STATIC_CHECK="/robots.txt /502.html
193 /js/scripts.min.js /js/rhodecode-components.js
201 /js/scripts.min.js /js/rhodecode-components.js
194 /css/style.css /css/style-polymer.css /css/style-ipython.css"
202 /css/style.css /css/style-polymer.css /css/style-ipython.css"
195
203
196 for file in $STATIC_CHECK;
204 for file in $STATIC_CHECK;
197 do
205 do
198 if [ ! -f rhodecode/public/$file ]; then
206 if [ ! -f rhodecode/public/$file ]; then
199 echo "Missing $file"
207 echo "Missing $file"
200 exit 1
208 exit 1
201 fi
209 fi
202 done
210 done
203
211
204 echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol"
212 echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol"
205 mkdir -p $out/nix-support/rccontrol
213 mkdir -p $out/nix-support/rccontrol
206 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
214 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
207 echo "[DONE ]: enterprise-ce meta information for rccontrol written"
215 echo "[DONE ]: enterprise-ce meta information for rccontrol written"
208
216
209 mkdir -p $out/etc
217 mkdir -p $out/etc
210 cp configs/production.ini $out/etc
218 cp configs/production.ini $out/etc
211 echo "[DONE ]: saved enterprise-ce production.ini into $out/etc"
219 echo "[DONE ]: saved enterprise-ce production.ini into $out/etc"
212
220
221 echo "saving env in $out/etc/env_vars.txt"
222 touch $out/etc/env_vars.txt
223 echo "# RhodeCode build env vars" >> $out/etc/env_vars.txt
224 echo "LOCALE_ARCHIVE=\"${pkgs.glibcLocales}/lib/locale/locale-archive\"" >> $out/etc/env_vars.txt
225 echo "LC_ALL=\"en_US.UTF-8\"" >> $out/etc/env_vars.txt
226
213 cp -Rf rhodecode/config/rcextensions $out/etc/rcextensions.tmpl
227 cp -Rf rhodecode/config/rcextensions $out/etc/rcextensions.tmpl
214 echo "[DONE ]: saved enterprise-ce rcextensions into $out/etc/rcextensions.tmpl"
228 echo "[DONE ]: saved enterprise-ce rcextensions into $out/etc/rcextensions.tmpl"
215
229
216 # python based programs need to be wrapped
230 # python based programs need to be wrapped
217 mkdir -p $out/bin
231 mkdir -p $out/bin
218
232
233 # expose python
234 ln -s ${pythonWithEnv}/bin/python $out/bin/
235
219 # required binaries from dependencies
236 # required binaries from dependencies
220 ln -s ${self.supervisor}/bin/supervisorctl $out/bin/
237 ln -s ${pythonWithEnv}/bin/supervisorctl $out/bin/
221 ln -s ${self.supervisor}/bin/supervisord $out/bin/
238 ln -s ${pythonWithEnv}/bin/supervisord $out/bin/
222 ln -s ${self.pastescript}/bin/paster $out/bin/
239 ln -s ${pythonWithEnv}/bin/paster $out/bin/
223 ln -s ${self.channelstream}/bin/channelstream $out/bin/
240 ln -s ${pythonWithEnv}/bin/channelstream $out/bin/
224 ln -s ${self.celery}/bin/celery $out/bin/
241 ln -s ${pythonWithEnv}/bin/celery $out/bin/
225 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
242 ln -s ${pythonWithEnv}/bin/gunicorn $out/bin/
226 ln -s ${self.pyramid}/bin/prequest $out/bin/
243 ln -s ${pythonWithEnv}/bin/prequest $out/bin/
227 ln -s ${self.pyramid}/bin/pserve $out/bin/
244 ln -s ${pythonWithEnv}/bin/pserve $out/bin/
228
245
229 echo "[DONE ]: created symlinks into $out/bin"
246 echo "[DONE ]: created symlinks into $out/bin"
230 DEPS="$out/bin/supervisorctl \
247 DEPS="
231 $out/bin/supervisord \
248 "
232 $out/bin/paster \
233 $out/bin/channelstream \
234 $out/bin/celery \
235 $out/bin/gunicorn \
236 $out/bin/prequest \
237 $out/bin/pserve"
238
249
239 # wrap only dependency scripts, they require to have full PYTHONPATH set
250 # wrap only dependency scripts, they require to have full PYTHONPATH set
240 # to be able to import all packages
251 # to be able to import all packages
241 for file in $DEPS;
252 for file in $DEPS;
242 do
253 do
243 wrapProgram $file \
254 wrapProgram $file \
244 --prefix PATH : $PATH \
255 --prefix PATH : $PATH \
245 --prefix PYTHONPATH : $PYTHONPATH \
256 --prefix PYTHONPATH : $PYTHONPATH \
246 --set PYTHONHASHSEED random
257 --set PYTHONHASHSEED random
247 done
258 done
248
259
249 echo "[DONE ]: enterprise-ce binary wrapping"
260 echo "[DONE ]: enterprise-ce binary wrapping"
250
261
251 # rhodecode-tools don't need wrapping
262 # rhodecode-tools don't need wrapping
252 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
263 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
253
264
254 # expose sources of CE
255 ln -s $out $out/etc/rhodecode_enterprise_ce_source
256
257 # expose static files folder
265 # expose static files folder
258 cp -Rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/public/ $out/etc/static
266 cp -Rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/public/ $out/etc/static
259 chmod 755 -R $out/etc/static
267 chmod 755 -R $out/etc/static
260
268
269 # expose sources of rhodecode-enterprise-ce
270 ln -s $out $out/etc/rhodecode_enterprise_ce_source
261 '';
271 '';
272
262 });
273 });
274 };
263
275
264 };
265
276
266 basePythonPackages = with builtins;
277 basePythonPackages = with builtins;
267 if isAttrs pythonPackages then
278 if isAttrs pythonPackages then
268 pythonPackages
279 pythonPackages
269 else
280 else
270 getAttr pythonPackages pkgs;
281 getAttr pythonPackages pkgs;
271
282
272 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
283 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
273 inherit
284 inherit pkgs;
274 pkgs;
285 inherit (pkgs) fetchurl fetchgit fetchhg;
275 inherit
276 (pkgs)
277 fetchurl
278 fetchgit
279 fetchhg;
280 };
286 };
281
287
282 pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix {
288 pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix {
283 inherit pkgs basePythonPackages;
289 inherit pkgs basePythonPackages;
284 };
290 };
285
291
286 # Apply all overrides and fix the final package set
292 # Apply all overrides and fix the final package set
287 myPythonPackagesUnfix = with pkgs.lib;
293 myPythonPackagesUnfix = with pkgs.lib;
288 (extends pythonExternalOverrides
294 (extends pythonExternalOverrides
289 (extends pythonLocalOverrides
295 (extends pythonLocalOverrides
290 (extends pythonCommunityOverrides
296 (extends pythonCommunityOverrides
291 (extends pythonGeneratedPackages
297 (extends pythonGeneratedPackages
292 basePythonPackagesUnfix))));
298 basePythonPackagesUnfix))));
293
299
294 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
300 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
295
301
296 in myPythonPackages.rhodecode-enterprise-ce
302 in myPythonPackages.rhodecode-enterprise-ce
@@ -1,62 +1,62 b''
1 {
1 {
2 "name": "rhodecode-enterprise",
2 "name": "rhodecode-enterprise",
3 "version": "2.0.0",
3 "version": "4.19.0",
4 "private": true,
4 "private": true,
5 "description" : "RhodeCode JS packaged",
5 "description" : "RhodeCode JS packaged",
6 "license": "SEE LICENSE IN LICENSE.txt",
6 "license": "SEE LICENSE IN LICENSE.txt",
7 "repository" : {
7 "repository" : {
8 "type" : "hg",
8 "type" : "hg",
9 "url" : "https://code.rhodecode.com/rhodecode-enterprise-ce"
9 "url" : "https://code.rhodecode.com/rhodecode-enterprise-ce"
10 },
10 },
11 "devDependencies": {
11 "devDependencies": {
12 "appenlight-client": "git+https://git@github.com/AppEnlight/appenlight-client-js.git#0.5.1",
12 "appenlight-client": "git+https://git@github.com/AppEnlight/appenlight-client-js.git#0.5.1",
13 "clipboard": "^2.0.1",
13 "clipboard": "^2.0.1",
14 "exports-loader": "^0.6.4",
14 "exports-loader": "^0.6.4",
15 "favico.js": "^0.3.10",
15 "favico.js": "^0.3.10",
16 "dropzone": "^5.5.0",
16 "dropzone": "^5.5.0",
17 "grunt": "^0.4.5",
17 "grunt": "^0.4.5",
18 "grunt-cli": "^1.3.1",
18 "grunt-cli": "^1.3.1",
19 "grunt-contrib-concat": "^0.5.1",
19 "grunt-contrib-concat": "^0.5.1",
20 "grunt-contrib-copy": "^1.0.0",
20 "grunt-contrib-copy": "^1.0.0",
21 "grunt-contrib-jshint": "^0.12.0",
21 "grunt-contrib-jshint": "^0.12.0",
22 "grunt-contrib-less": "^1.1.0",
22 "grunt-contrib-less": "^1.1.0",
23 "grunt-contrib-watch": "^0.6.1",
23 "grunt-contrib-watch": "^0.6.1",
24 "grunt-webpack": "^3.1.3",
24 "grunt-webpack": "^3.1.3",
25 "grunt-contrib-uglify": "^4.0.1",
25 "grunt-contrib-uglify": "^4.0.1",
26 "sweetalert2": "^9.10.12",
26 "sweetalert2": "^9.10.12",
27 "jquery": "1.11.3",
27 "jquery": "1.11.3",
28 "mark.js": "8.11.1",
28 "mark.js": "8.11.1",
29 "jshint": "^2.9.1-rc3",
29 "jshint": "^2.9.1-rc3",
30 "moment": "^2.18.1",
30 "moment": "^2.18.1",
31 "mousetrap": "^1.6.1",
31 "mousetrap": "^1.6.1",
32 "qrious": "^4.0.2",
32 "qrious": "^4.0.2",
33 "sticky-sidebar": "3.3.1",
33 "sticky-sidebar": "3.3.1",
34 "waypoints": "4.0.1",
34 "waypoints": "4.0.1",
35 "webpack": "4.23.1",
35 "webpack": "4.23.1",
36 "webpack-cli": "3.1.2",
36 "webpack-cli": "3.1.2",
37 "babel-core": "^6.26.3",
37 "babel-core": "^6.26.3",
38 "babel-loader": "^7.1.2",
38 "babel-loader": "^7.1.2",
39 "babel-plugin-transform-object-rest-spread": "^6.26.0",
39 "babel-plugin-transform-object-rest-spread": "^6.26.0",
40 "babel-preset-env": "^1.6.0",
40 "babel-preset-env": "^1.6.0",
41 "copy-webpack-plugin": "^4.4.2",
41 "copy-webpack-plugin": "^4.4.2",
42 "css-loader": "^0.28.11",
42 "css-loader": "^0.28.11",
43 "html-loader": "^0.4.4",
43 "html-loader": "^0.4.4",
44 "html-webpack-plugin": "^3.2.0",
44 "html-webpack-plugin": "^3.2.0",
45 "imports-loader": "^0.7.1",
45 "imports-loader": "^0.7.1",
46 "polymer-webpack-loader": "^2.0.1",
46 "polymer-webpack-loader": "^2.0.1",
47 "style-loader": "^0.21.0",
47 "style-loader": "^0.21.0",
48 "webpack-uglify-js-plugin": "^1.1.9",
48 "webpack-uglify-js-plugin": "^1.1.9",
49 "raw-loader": "1.0.0-beta.0",
49 "raw-loader": "1.0.0-beta.0",
50 "ts-loader": "^1.3.3",
50 "ts-loader": "^1.3.3",
51 "@webcomponents/webcomponentsjs": "^2.0.0",
51 "@webcomponents/webcomponentsjs": "^2.0.0",
52 "@polymer/polymer": "^3.0.0",
52 "@polymer/polymer": "^3.0.0",
53 "@polymer/paper-button": "^3.0.0",
53 "@polymer/paper-button": "^3.0.0",
54 "@polymer/paper-spinner": "^3.0.0",
54 "@polymer/paper-spinner": "^3.0.0",
55 "@polymer/paper-tooltip": "^3.0.0",
55 "@polymer/paper-tooltip": "^3.0.0",
56 "@polymer/paper-toast": "^3.0.0",
56 "@polymer/paper-toast": "^3.0.0",
57 "@polymer/paper-toggle-button": "^3.0.0",
57 "@polymer/paper-toggle-button": "^3.0.0",
58 "@polymer/iron-ajax": "^3.0.0",
58 "@polymer/iron-ajax": "^3.0.0",
59 "@polymer/iron-autogrow-textarea": "^3.0.0",
59 "@polymer/iron-autogrow-textarea": "^3.0.0",
60 "@polymer/iron-a11y-keys": "^3.0.0"
60 "@polymer/iron-a11y-keys": "^3.0.0"
61 }
61 }
62 }
62 }
@@ -1,17 +1,25 b''
1 { pkgs
1 { pkgs
2 , pythonPackages
2 , pythonPackages
3 }:
3 }:
4
4
5 rec {
5 rec {
6 pip2nix-src = pkgs.fetchzip {
6 pip2nix-src = pkgs.fetchzip {
7 url = https://github.com/johbo/pip2nix/archive/51e6fdae34d0e8ded9efeef7a8601730249687a6.tar.gz;
7 url = https://github.com/johbo/pip2nix/archive/51e6fdae34d0e8ded9efeef7a8601730249687a6.tar.gz;
8 sha256 = "02a4jjgi7lsvf8mhrxsd56s9a3yg20081rl9bgc2m84w60v2gbz2";
8 sha256 = "02a4jjgi7lsvf8mhrxsd56s9a3yg20081rl9bgc2m84w60v2gbz2";
9 };
9 };
10
10
11 pip2nix = import pip2nix-src {
11 pip2nix = import pip2nix-src {
12 inherit
12 inherit
13 pkgs
13 pkgs
14 pythonPackages;
14 pythonPackages;
15 };
15 };
16
16
17 pip-tools = pythonPackages.pip-tools;
18
19 setuptools = pythonPackages.setuptools;
20
21 wheel = pythonPackages.wheel;
22
23 pip = pythonPackages.pip;
24
17 }
25 }
@@ -1,17 +1,17 b''
1 # This file has been generated by node2nix 1.6.0. Do not edit!
1 # This file has been generated by node2nix 1.8.0. Do not edit!
2
2
3 {pkgs ? import <nixpkgs> {
3 {pkgs ? import <nixpkgs> {
4 inherit system;
4 inherit system;
5 }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-8_x"}:
5 }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
6
6
7 let
7 let
8 nodeEnv = import ./node-env.nix {
8 nodeEnv = import ./node-env.nix {
9 inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
9 inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
10 inherit nodejs;
10 inherit nodejs;
11 libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
11 libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
12 };
12 };
13 in
13 in
14 import ./node-packages.nix {
14 import ./node-packages.nix {
15 inherit (pkgs) fetchurl fetchgit;
15 inherit (pkgs) fetchurl fetchgit;
16 inherit nodeEnv;
16 inherit nodeEnv;
17 } No newline at end of file
17 }
@@ -1,542 +1,542 b''
1 # This file originates from node2nix
1 # This file originates from node2nix
2
2
3 {stdenv, nodejs, python2, utillinux, libtool, runCommand, writeTextFile}:
3 {stdenv, nodejs, python2, utillinux, libtool, runCommand, writeTextFile}:
4
4
5 let
5 let
6 python = if nodejs ? python then nodejs.python else python2;
6 python = if nodejs ? python then nodejs.python else python2;
7
7
8 # Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
8 # Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
9 tarWrapper = runCommand "tarWrapper" {} ''
9 tarWrapper = runCommand "tarWrapper" {} ''
10 mkdir -p $out/bin
10 mkdir -p $out/bin
11
11
12 cat > $out/bin/tar <<EOF
12 cat > $out/bin/tar <<EOF
13 #! ${stdenv.shell} -e
13 #! ${stdenv.shell} -e
14 $(type -p tar) "\$@" --warning=no-unknown-keyword
14 $(type -p tar) "\$@" --warning=no-unknown-keyword --delay-directory-restore
15 EOF
15 EOF
16
16
17 chmod +x $out/bin/tar
17 chmod +x $out/bin/tar
18 '';
18 '';
19
19
20 # Function that generates a TGZ file from a NPM project
20 # Function that generates a TGZ file from a NPM project
21 buildNodeSourceDist =
21 buildNodeSourceDist =
22 { name, version, src, ... }:
22 { name, version, src, ... }:
23
23
24 stdenv.mkDerivation {
24 stdenv.mkDerivation {
25 name = "node-tarball-${name}-${version}";
25 name = "node-tarball-${name}-${version}";
26 inherit src;
26 inherit src;
27 buildInputs = [ nodejs ];
27 buildInputs = [ nodejs ];
28 buildPhase = ''
28 buildPhase = ''
29 export HOME=$TMPDIR
29 export HOME=$TMPDIR
30 tgzFile=$(npm pack | tail -n 1) # Hooks to the pack command will add output (https://docs.npmjs.com/misc/scripts)
30 tgzFile=$(npm pack | tail -n 1) # Hooks to the pack command will add output (https://docs.npmjs.com/misc/scripts)
31 '';
31 '';
32 installPhase = ''
32 installPhase = ''
33 mkdir -p $out/tarballs
33 mkdir -p $out/tarballs
34 mv $tgzFile $out/tarballs
34 mv $tgzFile $out/tarballs
35 mkdir -p $out/nix-support
35 mkdir -p $out/nix-support
36 echo "file source-dist $out/tarballs/$tgzFile" >> $out/nix-support/hydra-build-products
36 echo "file source-dist $out/tarballs/$tgzFile" >> $out/nix-support/hydra-build-products
37 '';
37 '';
38 };
38 };
39
39
40 includeDependencies = {dependencies}:
40 includeDependencies = {dependencies}:
41 stdenv.lib.optionalString (dependencies != [])
41 stdenv.lib.optionalString (dependencies != [])
42 (stdenv.lib.concatMapStrings (dependency:
42 (stdenv.lib.concatMapStrings (dependency:
43 ''
43 ''
44 # Bundle the dependencies of the package
44 # Bundle the dependencies of the package
45 mkdir -p node_modules
45 mkdir -p node_modules
46 cd node_modules
46 cd node_modules
47
47
48 # Only include dependencies if they don't exist. They may also be bundled in the package.
48 # Only include dependencies if they don't exist. They may also be bundled in the package.
49 if [ ! -e "${dependency.name}" ]
49 if [ ! -e "${dependency.name}" ]
50 then
50 then
51 ${composePackage dependency}
51 ${composePackage dependency}
52 fi
52 fi
53
53
54 cd ..
54 cd ..
55 ''
55 ''
56 ) dependencies);
56 ) dependencies);
57
57
58 # Recursively composes the dependencies of a package
58 # Recursively composes the dependencies of a package
59 composePackage = { name, packageName, src, dependencies ? [], ... }@args:
59 composePackage = { name, packageName, src, dependencies ? [], ... }@args:
60 ''
60 builtins.addErrorContext "while evaluating node package '${packageName}'" ''
61 DIR=$(pwd)
61 DIR=$(pwd)
62 cd $TMPDIR
62 cd $TMPDIR
63
63
64 unpackFile ${src}
64 unpackFile ${src}
65
65
66 # Make the base dir in which the target dependency resides first
66 # Make the base dir in which the target dependency resides first
67 mkdir -p "$(dirname "$DIR/${packageName}")"
67 mkdir -p "$(dirname "$DIR/${packageName}")"
68
68
69 if [ -f "${src}" ]
69 if [ -f "${src}" ]
70 then
70 then
71 # Figure out what directory has been unpacked
71 # Figure out what directory has been unpacked
72 packageDir="$(find . -maxdepth 1 -type d | tail -1)"
72 packageDir="$(find . -maxdepth 1 -type d | tail -1)"
73
73
74 # Restore write permissions to make building work
74 # Restore write permissions to make building work
75 find "$packageDir" -type d -print0 | xargs -0 chmod u+x
75 find "$packageDir" -type d -exec chmod u+x {} \;
76 chmod -R u+w "$packageDir"
76 chmod -R u+w "$packageDir"
77
77
78 # Move the extracted tarball into the output folder
78 # Move the extracted tarball into the output folder
79 mv "$packageDir" "$DIR/${packageName}"
79 mv "$packageDir" "$DIR/${packageName}"
80 elif [ -d "${src}" ]
80 elif [ -d "${src}" ]
81 then
81 then
82 # Get a stripped name (without hash) of the source directory.
82 # Get a stripped name (without hash) of the source directory.
83 # On old nixpkgs it's already set internally.
83 # On old nixpkgs it's already set internally.
84 if [ -z "$strippedName" ]
84 if [ -z "$strippedName" ]
85 then
85 then
86 strippedName="$(stripHash ${src})"
86 strippedName="$(stripHash ${src})"
87 fi
87 fi
88
88
89 # Restore write permissions to make building work
89 # Restore write permissions to make building work
90 chmod -R u+w "$strippedName"
90 chmod -R u+w "$strippedName"
91
91
92 # Move the extracted directory into the output folder
92 # Move the extracted directory into the output folder
93 mv "$strippedName" "$DIR/${packageName}"
93 mv "$strippedName" "$DIR/${packageName}"
94 fi
94 fi
95
95
96 # Unset the stripped name to not confuse the next unpack step
96 # Unset the stripped name to not confuse the next unpack step
97 unset strippedName
97 unset strippedName
98
98
99 # Include the dependencies of the package
99 # Include the dependencies of the package
100 cd "$DIR/${packageName}"
100 cd "$DIR/${packageName}"
101 ${includeDependencies { inherit dependencies; }}
101 ${includeDependencies { inherit dependencies; }}
102 cd ..
102 cd ..
103 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
103 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
104 '';
104 '';
105
105
106 pinpointDependencies = {dependencies, production}:
106 pinpointDependencies = {dependencies, production}:
107 let
107 let
108 pinpointDependenciesFromPackageJSON = writeTextFile {
108 pinpointDependenciesFromPackageJSON = writeTextFile {
109 name = "pinpointDependencies.js";
109 name = "pinpointDependencies.js";
110 text = ''
110 text = ''
111 var fs = require('fs');
111 var fs = require('fs');
112 var path = require('path');
112 var path = require('path');
113
113
114 function resolveDependencyVersion(location, name) {
114 function resolveDependencyVersion(location, name) {
115 if(location == process.env['NIX_STORE']) {
115 if(location == process.env['NIX_STORE']) {
116 return null;
116 return null;
117 } else {
117 } else {
118 var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
118 var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
119
119
120 if(fs.existsSync(dependencyPackageJSON)) {
120 if(fs.existsSync(dependencyPackageJSON)) {
121 var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
121 var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
122
122
123 if(dependencyPackageObj.name == name) {
123 if(dependencyPackageObj.name == name) {
124 return dependencyPackageObj.version;
124 return dependencyPackageObj.version;
125 }
125 }
126 } else {
126 } else {
127 return resolveDependencyVersion(path.resolve(location, ".."), name);
127 return resolveDependencyVersion(path.resolve(location, ".."), name);
128 }
128 }
129 }
129 }
130 }
130 }
131
131
132 function replaceDependencies(dependencies) {
132 function replaceDependencies(dependencies) {
133 if(typeof dependencies == "object" && dependencies !== null) {
133 if(typeof dependencies == "object" && dependencies !== null) {
134 for(var dependency in dependencies) {
134 for(var dependency in dependencies) {
135 var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
135 var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
136
136
137 if(resolvedVersion === null) {
137 if(resolvedVersion === null) {
138 process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
138 process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
139 } else {
139 } else {
140 dependencies[dependency] = resolvedVersion;
140 dependencies[dependency] = resolvedVersion;
141 }
141 }
142 }
142 }
143 }
143 }
144 }
144 }
145
145
146 /* Read the package.json configuration */
146 /* Read the package.json configuration */
147 var packageObj = JSON.parse(fs.readFileSync('./package.json'));
147 var packageObj = JSON.parse(fs.readFileSync('./package.json'));
148
148
149 /* Pinpoint all dependencies */
149 /* Pinpoint all dependencies */
150 replaceDependencies(packageObj.dependencies);
150 replaceDependencies(packageObj.dependencies);
151 if(process.argv[2] == "development") {
151 if(process.argv[2] == "development") {
152 replaceDependencies(packageObj.devDependencies);
152 replaceDependencies(packageObj.devDependencies);
153 }
153 }
154 replaceDependencies(packageObj.optionalDependencies);
154 replaceDependencies(packageObj.optionalDependencies);
155
155
156 /* Write the fixed package.json file */
156 /* Write the fixed package.json file */
157 fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
157 fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
158 '';
158 '';
159 };
159 };
160 in
160 in
161 ''
161 ''
162 node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
162 node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
163
163
164 ${stdenv.lib.optionalString (dependencies != [])
164 ${stdenv.lib.optionalString (dependencies != [])
165 ''
165 ''
166 if [ -d node_modules ]
166 if [ -d node_modules ]
167 then
167 then
168 cd node_modules
168 cd node_modules
169 ${stdenv.lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
169 ${stdenv.lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
170 cd ..
170 cd ..
171 fi
171 fi
172 ''}
172 ''}
173 '';
173 '';
174
174
175 # Recursively traverses all dependencies of a package and pinpoints all
175 # Recursively traverses all dependencies of a package and pinpoints all
176 # dependencies in the package.json file to the versions that are actually
176 # dependencies in the package.json file to the versions that are actually
177 # being used.
177 # being used.
178
178
179 pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
179 pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
180 ''
180 ''
181 if [ -d "${packageName}" ]
181 if [ -d "${packageName}" ]
182 then
182 then
183 cd "${packageName}"
183 cd "${packageName}"
184 ${pinpointDependencies { inherit dependencies production; }}
184 ${pinpointDependencies { inherit dependencies production; }}
185 cd ..
185 cd ..
186 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
186 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
187 fi
187 fi
188 '';
188 '';
189
189
190 # Extract the Node.js source code which is used to compile packages with
190 # Extract the Node.js source code which is used to compile packages with
191 # native bindings
191 # native bindings
192 nodeSources = runCommand "node-sources" {} ''
192 nodeSources = runCommand "node-sources" {} ''
193 tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
193 tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
194 mv node-* $out
194 mv node-* $out
195 '';
195 '';
196
196
197 # Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty)
197 # Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty)
198 addIntegrityFieldsScript = writeTextFile {
198 addIntegrityFieldsScript = writeTextFile {
199 name = "addintegrityfields.js";
199 name = "addintegrityfields.js";
200 text = ''
200 text = ''
201 var fs = require('fs');
201 var fs = require('fs');
202 var path = require('path');
202 var path = require('path');
203
203
204 function augmentDependencies(baseDir, dependencies) {
204 function augmentDependencies(baseDir, dependencies) {
205 for(var dependencyName in dependencies) {
205 for(var dependencyName in dependencies) {
206 var dependency = dependencies[dependencyName];
206 var dependency = dependencies[dependencyName];
207
207
208 // Open package.json and augment metadata fields
208 // Open package.json and augment metadata fields
209 var packageJSONDir = path.join(baseDir, "node_modules", dependencyName);
209 var packageJSONDir = path.join(baseDir, "node_modules", dependencyName);
210 var packageJSONPath = path.join(packageJSONDir, "package.json");
210 var packageJSONPath = path.join(packageJSONDir, "package.json");
211
211
212 if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored
212 if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored
213 console.log("Adding metadata fields to: "+packageJSONPath);
213 console.log("Adding metadata fields to: "+packageJSONPath);
214 var packageObj = JSON.parse(fs.readFileSync(packageJSONPath));
214 var packageObj = JSON.parse(fs.readFileSync(packageJSONPath));
215
215
216 if(dependency.integrity) {
216 if(dependency.integrity) {
217 packageObj["_integrity"] = dependency.integrity;
217 packageObj["_integrity"] = dependency.integrity;
218 } else {
218 } else {
219 packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
219 packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
220 }
220 }
221
221
222 packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
222 if(dependency.resolved) {
223 packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided
224 } else {
225 packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
226 }
227
228 if(dependency.from !== undefined) { // Adopt from property if one has been provided
229 packageObj["_from"] = dependency.from;
230 }
231
223 fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
232 fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
224 }
233 }
225
234
226 // Augment transitive dependencies
235 // Augment transitive dependencies
227 if(dependency.dependencies !== undefined) {
236 if(dependency.dependencies !== undefined) {
228 augmentDependencies(packageJSONDir, dependency.dependencies);
237 augmentDependencies(packageJSONDir, dependency.dependencies);
229 }
238 }
230 }
239 }
231 }
240 }
232
241
233 if(fs.existsSync("./package-lock.json")) {
242 if(fs.existsSync("./package-lock.json")) {
234 var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
243 var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
235
244
236 if(packageLock.lockfileVersion !== 1) {
245 if(packageLock.lockfileVersion !== 1) {
237 process.stderr.write("Sorry, I only understand lock file version 1!\n");
246 process.stderr.write("Sorry, I only understand lock file version 1!\n");
238 process.exit(1);
247 process.exit(1);
239 }
248 }
240
249
241 if(packageLock.dependencies !== undefined) {
250 if(packageLock.dependencies !== undefined) {
242 augmentDependencies(".", packageLock.dependencies);
251 augmentDependencies(".", packageLock.dependencies);
243 }
252 }
244 }
253 }
245 '';
254 '';
246 };
255 };
247
256
248 # Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
257 # Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
249 reconstructPackageLock = writeTextFile {
258 reconstructPackageLock = writeTextFile {
250 name = "addintegrityfields.js";
259 name = "addintegrityfields.js";
251 text = ''
260 text = ''
252 var fs = require('fs');
261 var fs = require('fs');
253 var path = require('path');
262 var path = require('path');
254
263
255 var packageObj = JSON.parse(fs.readFileSync("package.json"));
264 var packageObj = JSON.parse(fs.readFileSync("package.json"));
256
265
257 var lockObj = {
266 var lockObj = {
258 name: packageObj.name,
267 name: packageObj.name,
259 version: packageObj.version,
268 version: packageObj.version,
260 lockfileVersion: 1,
269 lockfileVersion: 1,
261 requires: true,
270 requires: true,
262 dependencies: {}
271 dependencies: {}
263 };
272 };
264
273
265 function augmentPackageJSON(filePath, dependencies) {
274 function augmentPackageJSON(filePath, dependencies) {
266 var packageJSON = path.join(filePath, "package.json");
275 var packageJSON = path.join(filePath, "package.json");
267 if(fs.existsSync(packageJSON)) {
276 if(fs.existsSync(packageJSON)) {
268 var packageObj = JSON.parse(fs.readFileSync(packageJSON));
277 var packageObj = JSON.parse(fs.readFileSync(packageJSON));
269 dependencies[packageObj.name] = {
278 dependencies[packageObj.name] = {
270 version: packageObj.version,
279 version: packageObj.version,
271 integrity: "sha1-000000000000000000000000000=",
280 integrity: "sha1-000000000000000000000000000=",
272 dependencies: {}
281 dependencies: {}
273 };
282 };
274 processDependencies(path.join(filePath, "node_modules"), dependencies[packageObj.name].dependencies);
283 processDependencies(path.join(filePath, "node_modules"), dependencies[packageObj.name].dependencies);
275 }
284 }
276 }
285 }
277
286
278 function processDependencies(dir, dependencies) {
287 function processDependencies(dir, dependencies) {
279 if(fs.existsSync(dir)) {
288 if(fs.existsSync(dir)) {
280 var files = fs.readdirSync(dir);
289 var files = fs.readdirSync(dir);
281
290
282 files.forEach(function(entry) {
291 files.forEach(function(entry) {
283 var filePath = path.join(dir, entry);
292 var filePath = path.join(dir, entry);
284 var stats = fs.statSync(filePath);
293 var stats = fs.statSync(filePath);
285
294
286 if(stats.isDirectory()) {
295 if(stats.isDirectory()) {
287 if(entry.substr(0, 1) == "@") {
296 if(entry.substr(0, 1) == "@") {
288 // When we encounter a namespace folder, augment all packages belonging to the scope
297 // When we encounter a namespace folder, augment all packages belonging to the scope
289 var pkgFiles = fs.readdirSync(filePath);
298 var pkgFiles = fs.readdirSync(filePath);
290
299
291 pkgFiles.forEach(function(entry) {
300 pkgFiles.forEach(function(entry) {
292 if(stats.isDirectory()) {
301 if(stats.isDirectory()) {
293 var pkgFilePath = path.join(filePath, entry);
302 var pkgFilePath = path.join(filePath, entry);
294 augmentPackageJSON(pkgFilePath, dependencies);
303 augmentPackageJSON(pkgFilePath, dependencies);
295 }
304 }
296 });
305 });
297 } else {
306 } else {
298 augmentPackageJSON(filePath, dependencies);
307 augmentPackageJSON(filePath, dependencies);
299 }
308 }
300 }
309 }
301 });
310 });
302 }
311 }
303 }
312 }
304
313
305 processDependencies("node_modules", lockObj.dependencies);
314 processDependencies("node_modules", lockObj.dependencies);
306
315
307 fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2));
316 fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2));
308 '';
317 '';
309 };
318 };
310
319
311 # Builds and composes an NPM package including all its dependencies
320 prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
312 buildNodePackage =
313 { name
314 , packageName
315 , version
316 , dependencies ? []
317 , buildInputs ? []
318 , production ? true
319 , npmFlags ? ""
320 , dontNpmInstall ? false
321 , bypassCache ? false
322 , preRebuild ? ""
323 , dontStrip ? true
324 , unpackPhase ? "true"
325 , buildPhase ? "true"
326 , ... }@args:
327
328 let
321 let
329 forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
322 forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
330 extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
331 in
323 in
332 stdenv.mkDerivation ({
324 ''
333 name = "node-${name}-${version}";
334 buildInputs = [ tarWrapper python nodejs ]
335 ++ stdenv.lib.optional (stdenv.isLinux) utillinux
336 ++ stdenv.lib.optional (stdenv.isDarwin) libtool
337 ++ buildInputs;
338
339 inherit dontStrip; # Stripping may fail a build for some package deployments
340 inherit dontNpmInstall preRebuild unpackPhase buildPhase;
341
342 compositionScript = composePackage args;
343 pinpointDependenciesScript = pinpointDependenciesOfPackage args;
344
345 passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
346
347 installPhase = ''
348 # Create and enter a root node_modules/ folder
349 mkdir -p $out/lib/node_modules
350 cd $out/lib/node_modules
351
352 # Compose the package and all its dependencies
353 source $compositionScriptPath
354
355 # Pinpoint the versions of all dependencies to the ones that are actually being used
325 # Pinpoint the versions of all dependencies to the ones that are actually being used
356 echo "pinpointing versions of dependencies..."
326 echo "pinpointing versions of dependencies..."
357 source $pinpointDependenciesScriptPath
327 source $pinpointDependenciesScriptPath
358
328
359 # Patch the shebangs of the bundled modules to prevent them from
329 # Patch the shebangs of the bundled modules to prevent them from
360 # calling executables outside the Nix store as much as possible
330 # calling executables outside the Nix store as much as possible
361 patchShebangs .
331 patchShebangs .
362
332
363 # Deploy the Node.js package by running npm install. Since the
333 # Deploy the Node.js package by running npm install. Since the
364 # dependencies have been provided already by ourselves, it should not
334 # dependencies have been provided already by ourselves, it should not
365 # attempt to install them again, which is good, because we want to make
335 # attempt to install them again, which is good, because we want to make
366 # it Nix's responsibility. If it needs to install any dependencies
336 # it Nix's responsibility. If it needs to install any dependencies
367 # anyway (e.g. because the dependency parameters are
337 # anyway (e.g. because the dependency parameters are
368 # incomplete/incorrect), it fails.
338 # incomplete/incorrect), it fails.
369 #
339 #
370 # The other responsibilities of NPM are kept -- version checks, build
340 # The other responsibilities of NPM are kept -- version checks, build
371 # steps, postprocessing etc.
341 # steps, postprocessing etc.
372
342
373 export HOME=$TMPDIR
343 export HOME=$TMPDIR
374 cd "${packageName}"
344 cd "${packageName}"
375 runHook preRebuild
345 runHook preRebuild
376
346
377 ${stdenv.lib.optionalString bypassCache ''
347 ${stdenv.lib.optionalString bypassCache ''
378 if [ ! -f package-lock.json ]
348 ${stdenv.lib.optionalString reconstructLock ''
379 then
349 if [ -f package-lock.json ]
380 echo "No package-lock.json file found, reconstructing..."
350 then
381 node ${reconstructPackageLock}
351 echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
382 fi
352 echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
353 rm package-lock.json
354 else
355 echo "No package-lock.json file found, reconstructing..."
356 fi
357
358 node ${reconstructPackageLock}
359 ''}
383
360
384 node ${addIntegrityFieldsScript}
361 node ${addIntegrityFieldsScript}
385 ''}
362 ''}
386
363
387 npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
364 npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
388
365
389 if [ "$dontNpmInstall" != "1" ]
366 if [ "''${dontNpmInstall-}" != "1" ]
390 then
367 then
391 # NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
368 # NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
392 rm -f npm-shrinkwrap.json
369 rm -f npm-shrinkwrap.json
393
370
394 npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
371 npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
395 fi
372 fi
373 '';
374
375 # Builds and composes an NPM package including all its dependencies
376 buildNodePackage =
377 { name
378 , packageName
379 , version
380 , dependencies ? []
381 , buildInputs ? []
382 , production ? true
383 , npmFlags ? ""
384 , dontNpmInstall ? false
385 , bypassCache ? false
386 , reconstructLock ? false
387 , preRebuild ? ""
388 , dontStrip ? true
389 , unpackPhase ? "true"
390 , buildPhase ? "true"
391 , ... }@args:
392
393 let
394 extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
395 in
396 stdenv.mkDerivation ({
397 name = "node_${name}-${version}";
398 buildInputs = [ tarWrapper python nodejs ]
399 ++ stdenv.lib.optional (stdenv.isLinux) utillinux
400 ++ stdenv.lib.optional (stdenv.isDarwin) libtool
401 ++ buildInputs;
402
403 inherit nodejs;
404
405 inherit dontStrip; # Stripping may fail a build for some package deployments
406 inherit dontNpmInstall preRebuild unpackPhase buildPhase;
407
408 compositionScript = composePackage args;
409 pinpointDependenciesScript = pinpointDependenciesOfPackage args;
410
411 passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
412
413 installPhase = ''
414 # Create and enter a root node_modules/ folder
415 mkdir -p $out/lib/node_modules
416 cd $out/lib/node_modules
417
418 # Compose the package and all its dependencies
419 source $compositionScriptPath
420
421 ${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
396
422
397 # Create symlink to the deployed executable folder, if applicable
423 # Create symlink to the deployed executable folder, if applicable
398 if [ -d "$out/lib/node_modules/.bin" ]
424 if [ -d "$out/lib/node_modules/.bin" ]
399 then
425 then
400 ln -s $out/lib/node_modules/.bin $out/bin
426 ln -s $out/lib/node_modules/.bin $out/bin
401 fi
427 fi
402
428
403 # Create symlinks to the deployed manual page folders, if applicable
429 # Create symlinks to the deployed manual page folders, if applicable
404 if [ -d "$out/lib/node_modules/${packageName}/man" ]
430 if [ -d "$out/lib/node_modules/${packageName}/man" ]
405 then
431 then
406 mkdir -p $out/share
432 mkdir -p $out/share
407 for dir in "$out/lib/node_modules/${packageName}/man/"*
433 for dir in "$out/lib/node_modules/${packageName}/man/"*
408 do
434 do
409 mkdir -p $out/share/man/$(basename "$dir")
435 mkdir -p $out/share/man/$(basename "$dir")
410 for page in "$dir"/*
436 for page in "$dir"/*
411 do
437 do
412 ln -s $page $out/share/man/$(basename "$dir")
438 ln -s $page $out/share/man/$(basename "$dir")
413 done
439 done
414 done
440 done
415 fi
441 fi
416
442
417 # Run post install hook, if provided
443 # Run post install hook, if provided
418 runHook postInstall
444 runHook postInstall
419 '';
445 '';
420 } // extraArgs);
446 } // extraArgs);
421
447
422 # Builds a development shell
448 # Builds a development shell
423 buildNodeShell =
449 buildNodeShell =
424 { name
450 { name
425 , packageName
451 , packageName
426 , version
452 , version
427 , src
453 , src
428 , dependencies ? []
454 , dependencies ? []
429 , buildInputs ? []
455 , buildInputs ? []
430 , production ? true
456 , production ? true
431 , npmFlags ? ""
457 , npmFlags ? ""
432 , dontNpmInstall ? false
458 , dontNpmInstall ? false
433 , bypassCache ? false
459 , bypassCache ? false
460 , reconstructLock ? false
434 , dontStrip ? true
461 , dontStrip ? true
435 , unpackPhase ? "true"
462 , unpackPhase ? "true"
436 , buildPhase ? "true"
463 , buildPhase ? "true"
437 , ... }@args:
464 , ... }@args:
438
465
439 let
466 let
440 forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
441
442 extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
467 extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
443
468
444 nodeDependencies = stdenv.mkDerivation ({
469 nodeDependencies = stdenv.mkDerivation ({
445 name = "node-dependencies-${name}-${version}";
470 name = "node-dependencies-${name}-${version}";
446
471
447 buildInputs = [ tarWrapper python nodejs ]
472 buildInputs = [ tarWrapper python nodejs ]
448 ++ stdenv.lib.optional (stdenv.isLinux) utillinux
473 ++ stdenv.lib.optional (stdenv.isLinux) utillinux
449 ++ stdenv.lib.optional (stdenv.isDarwin) libtool
474 ++ stdenv.lib.optional (stdenv.isDarwin) libtool
450 ++ buildInputs;
475 ++ buildInputs;
451
476
452 inherit dontStrip; # Stripping may fail a build for some package deployments
477 inherit dontStrip; # Stripping may fail a build for some package deployments
453 inherit dontNpmInstall unpackPhase buildPhase;
478 inherit dontNpmInstall unpackPhase buildPhase;
454
479
455 includeScript = includeDependencies { inherit dependencies; };
480 includeScript = includeDependencies { inherit dependencies; };
456 pinpointDependenciesScript = pinpointDependenciesOfPackage args;
481 pinpointDependenciesScript = pinpointDependenciesOfPackage args;
457
482
458 passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
483 passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
459
484
460 installPhase = ''
485 installPhase = ''
461 mkdir -p $out/${packageName}
486 mkdir -p $out/${packageName}
462 cd $out/${packageName}
487 cd $out/${packageName}
463
488
464 source $includeScriptPath
489 source $includeScriptPath
465
490
466 # Create fake package.json to make the npm commands work properly
491 # Create fake package.json to make the npm commands work properly
467 cp ${src}/package.json .
492 cp ${src}/package.json .
468 chmod 644 package.json
493 chmod 644 package.json
469 ${stdenv.lib.optionalString bypassCache ''
494 ${stdenv.lib.optionalString bypassCache ''
470 if [ -f ${src}/package-lock.json ]
495 if [ -f ${src}/package-lock.json ]
471 then
496 then
472 cp ${src}/package-lock.json .
497 cp ${src}/package-lock.json .
473 fi
498 fi
474 ''}
499 ''}
475
500
476 # Pinpoint the versions of all dependencies to the ones that are actually being used
501 # Go to the parent folder to make sure that all packages are pinpointed
477 echo "pinpointing versions of dependencies..."
478 cd ..
502 cd ..
479 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
503 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
480
504
481 source $pinpointDependenciesScriptPath
505 ${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
482 cd ${packageName}
483
484 # Patch the shebangs of the bundled modules to prevent them from
485 # calling executables outside the Nix store as much as possible
486 patchShebangs .
487
488 export HOME=$PWD
489
506
490 ${stdenv.lib.optionalString bypassCache ''
507 # Expose the executables that were installed
491 if [ ! -f package-lock.json ]
492 then
493 echo "No package-lock.json file found, reconstructing..."
494 node ${reconstructPackageLock}
495 fi
496
497 node ${addIntegrityFieldsScript}
498 ''}
499
500 npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
501
502 ${stdenv.lib.optionalString (!dontNpmInstall) ''
503 # NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
504 rm -f npm-shrinkwrap.json
505
506 npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
507 ''}
508
509 cd ..
508 cd ..
510 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
509 ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
511
510
512 mv ${packageName} lib
511 mv ${packageName} lib
513 ln -s $out/lib/node_modules/.bin $out/bin
512 ln -s $out/lib/node_modules/.bin $out/bin
514 '';
513 '';
515 } // extraArgs);
514 } // extraArgs);
516 in
515 in
517 stdenv.mkDerivation {
516 stdenv.mkDerivation {
518 name = "node-shell-${name}-${version}";
517 name = "node-shell-${name}-${version}";
519
518
520 buildInputs = [ python nodejs ] ++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
519 buildInputs = [ python nodejs ] ++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
521 buildCommand = ''
520 buildCommand = ''
522 mkdir -p $out/bin
521 mkdir -p $out/bin
523 cat > $out/bin/shell <<EOF
522 cat > $out/bin/shell <<EOF
524 #! ${stdenv.shell} -e
523 #! ${stdenv.shell} -e
525 $shellHook
524 $shellHook
526 exec ${stdenv.shell}
525 exec ${stdenv.shell}
527 EOF
526 EOF
528 chmod +x $out/bin/shell
527 chmod +x $out/bin/shell
529 '';
528 '';
530
529
531 # Provide the dependencies in a development shell through the NODE_PATH environment variable
530 # Provide the dependencies in a development shell through the NODE_PATH environment variable
532 inherit nodeDependencies;
531 inherit nodeDependencies;
533 shellHook = stdenv.lib.optionalString (dependencies != []) ''
532 shellHook = stdenv.lib.optionalString (dependencies != []) ''
534 export NODE_PATH=$nodeDependencies/lib/node_modules
533 export NODE_PATH=${nodeDependencies}/lib/node_modules
534 export PATH="${nodeDependencies}/bin:$PATH"
535 '';
535 '';
536 };
536 };
537 in
537 in
538 {
538 {
539 buildNodeSourceDist = stdenv.lib.makeOverridable buildNodeSourceDist;
539 buildNodeSourceDist = stdenv.lib.makeOverridable buildNodeSourceDist;
540 buildNodePackage = stdenv.lib.makeOverridable buildNodePackage;
540 buildNodePackage = stdenv.lib.makeOverridable buildNodePackage;
541 buildNodeShell = stdenv.lib.makeOverridable buildNodeShell;
541 buildNodeShell = stdenv.lib.makeOverridable buildNodeShell;
542 }
542 }
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now