Show More
@@ -1,185 +1,183 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 rhodecode-vcsserver |
|
3 | # This shall be as lean as possible, just producing the rhodecode-vcsserver | |
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 | args@ |
|
7 | args@ | |
8 | { pythonPackages ? "python27Packages" |
|
8 | { pythonPackages ? "python27Packages" | |
9 | , pythonExternalOverrides ? self: super: {} |
|
9 | , pythonExternalOverrides ? self: super: {} | |
10 | , doCheck ? false |
|
10 | , doCheck ? false | |
11 | , ... |
|
11 | , ... | |
12 | }: |
|
12 | }: | |
13 |
|
13 | |||
14 | let pkgs_ = (import <nixpkgs> {}); in |
|
14 | let pkgs_ = (import <nixpkgs> {}); in | |
15 |
|
15 | |||
16 | let |
|
16 | let | |
17 |
|
17 | |||
18 | # TODO: Currently we ignore the passed in pkgs, instead we should use it |
|
18 | pkgs = args.pkgs or (import <nixpkgs> { | |
19 | # somehow as a base and apply overlays to it. |
|
|||
20 | pkgs = import <nixpkgs> { |
|
|||
21 | overlays = [ |
|
19 | overlays = [ | |
22 | (import ./pkgs/overlays.nix) |
|
20 | (import ./pkgs/overlays.nix) | |
23 | ]; |
|
21 | ]; | |
24 | inherit (pkgs_) |
|
22 | inherit (pkgs_) | |
25 | system; |
|
23 | system; | |
26 | }; |
|
24 | }); | |
27 |
|
25 | |||
28 | # Works with the new python-packages, still can fallback to the old |
|
26 | # Works with the new python-packages, still can fallback to the old | |
29 | # variant. |
|
27 | # variant. | |
30 | basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( |
|
28 | basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( | |
31 | self: basePythonPackages.override (a: { inherit self; })); |
|
29 | self: basePythonPackages.override (a: { inherit self; })); | |
32 |
|
30 | |||
33 | # Evaluates to the last segment of a file system path. |
|
31 | # Evaluates to the last segment of a file system path. | |
34 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
32 | basename = path: with pkgs.lib; last (splitString "/" path); | |
35 |
|
33 | |||
36 | # source code filter used as arugment to builtins.filterSource. |
|
34 | # source code filter used as arugment to builtins.filterSource. | |
37 | src-filter = path: type: with pkgs.lib; |
|
35 | src-filter = path: type: with pkgs.lib; | |
38 | let |
|
36 | let | |
39 | ext = last (splitString "." path); |
|
37 | ext = last (splitString "." path); | |
40 | in |
|
38 | in | |
41 | !builtins.elem (basename path) [ |
|
39 | !builtins.elem (basename path) [ | |
42 | ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" |
|
40 | ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" | |
43 | "bower_components" "node_modules" |
|
41 | "bower_components" "node_modules" | |
44 | "build" "data" "result" "tmp"] && |
|
42 | "build" "data" "result" "tmp"] && | |
45 | !builtins.elem ext ["egg-info" "pyc"] && |
|
43 | !builtins.elem ext ["egg-info" "pyc"] && | |
46 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, |
|
44 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, | |
47 | # it would still be good to restore it since we want to ignore "result-*". |
|
45 | # it would still be good to restore it since we want to ignore "result-*". | |
48 | !hasPrefix "result" path; |
|
46 | !hasPrefix "result" path; | |
49 |
|
47 | |||
50 | sources = |
|
48 | sources = | |
51 | let |
|
49 | let | |
52 | inherit (pkgs.lib) all isString attrValues; |
|
50 | inherit (pkgs.lib) all isString attrValues; | |
53 | sourcesConfig = pkgs.config.rc.sources or {}; |
|
51 | sourcesConfig = pkgs.config.rc.sources or {}; | |
54 | in |
|
52 | in | |
55 | # Ensure that sources are configured as strings. Using a path |
|
53 | # Ensure that sources are configured as strings. Using a path | |
56 | # would result in a copy into the nix store. |
|
54 | # would result in a copy into the nix store. | |
57 | assert all isString (attrValues sourcesConfig); |
|
55 | assert all isString (attrValues sourcesConfig); | |
58 | sourcesConfig; |
|
56 | sourcesConfig; | |
59 |
|
57 | |||
60 | version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION"; |
|
58 | version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION"; | |
61 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; |
|
59 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; | |
62 |
|
60 | |||
63 | pythonLocalOverrides = self: super: { |
|
61 | pythonLocalOverrides = self: super: { | |
64 | rhodecode-vcsserver = |
|
62 | rhodecode-vcsserver = | |
65 | let |
|
63 | let | |
66 | releaseName = "RhodeCodeVCSServer-${version}"; |
|
64 | releaseName = "RhodeCodeVCSServer-${version}"; | |
67 | in super.rhodecode-vcsserver.override (attrs: { |
|
65 | in super.rhodecode-vcsserver.override (attrs: { | |
68 | inherit |
|
66 | inherit | |
69 | doCheck |
|
67 | doCheck | |
70 | version; |
|
68 | version; | |
71 |
|
69 | |||
72 | name = "rhodecode-vcsserver-${version}"; |
|
70 | name = "rhodecode-vcsserver-${version}"; | |
73 | releaseName = releaseName; |
|
71 | releaseName = releaseName; | |
74 | src = rhodecode-vcsserver-src; |
|
72 | src = rhodecode-vcsserver-src; | |
75 | dontStrip = true; # prevent strip, we don't need it. |
|
73 | dontStrip = true; # prevent strip, we don't need it. | |
76 |
|
74 | |||
77 | # expose following attributed outside |
|
75 | # expose following attributed outside | |
78 | passthru = { |
|
76 | passthru = { | |
79 | pythonPackages = self; |
|
77 | pythonPackages = self; | |
80 | }; |
|
78 | }; | |
81 |
|
79 | |||
82 | propagatedBuildInputs = |
|
80 | propagatedBuildInputs = | |
83 | attrs.propagatedBuildInputs or [] ++ [ |
|
81 | attrs.propagatedBuildInputs or [] ++ [ | |
84 | pkgs.git |
|
82 | pkgs.git | |
85 | pkgs.subversion |
|
83 | pkgs.subversion | |
86 | ]; |
|
84 | ]; | |
87 |
|
85 | |||
88 | # set some default locale env variables |
|
86 | # set some default locale env variables | |
89 | LC_ALL = "en_US.UTF-8"; |
|
87 | LC_ALL = "en_US.UTF-8"; | |
90 | LOCALE_ARCHIVE = |
|
88 | LOCALE_ARCHIVE = | |
91 | if pkgs.stdenv.isLinux |
|
89 | if pkgs.stdenv.isLinux | |
92 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" |
|
90 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" | |
93 | else ""; |
|
91 | else ""; | |
94 |
|
92 | |||
95 | # Add bin directory to path so that tests can find 'vcsserver'. |
|
93 | # Add bin directory to path so that tests can find 'vcsserver'. | |
96 | preCheck = '' |
|
94 | preCheck = '' | |
97 | export PATH="$out/bin:$PATH" |
|
95 | export PATH="$out/bin:$PATH" | |
98 | ''; |
|
96 | ''; | |
99 |
|
97 | |||
100 | # custom check phase for testing |
|
98 | # custom check phase for testing | |
101 | checkPhase = '' |
|
99 | checkPhase = '' | |
102 | runHook preCheck |
|
100 | runHook preCheck | |
103 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver |
|
101 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver | |
104 | runHook postCheck |
|
102 | runHook postCheck | |
105 | ''; |
|
103 | ''; | |
106 |
|
104 | |||
107 | postCheck = '' |
|
105 | postCheck = '' | |
108 | echo "Cleanup of vcsserver/tests" |
|
106 | echo "Cleanup of vcsserver/tests" | |
109 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests |
|
107 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests | |
110 | ''; |
|
108 | ''; | |
111 |
|
109 | |||
112 | postInstall = '' |
|
110 | postInstall = '' | |
113 | echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol" |
|
111 | echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol" | |
114 | mkdir -p $out/nix-support/rccontrol |
|
112 | mkdir -p $out/nix-support/rccontrol | |
115 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version |
|
113 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version | |
116 | echo "DONE: vcsserver meta information for rccontrol written" |
|
114 | echo "DONE: vcsserver meta information for rccontrol written" | |
117 |
|
115 | |||
118 | mkdir -p $out/etc |
|
116 | mkdir -p $out/etc | |
119 | cp configs/production.ini $out/etc |
|
117 | cp configs/production.ini $out/etc | |
120 | echo "DONE: saved vcsserver production.ini into $out/etc" |
|
118 | echo "DONE: saved vcsserver production.ini into $out/etc" | |
121 |
|
119 | |||
122 | # python based programs need to be wrapped |
|
120 | # python based programs need to be wrapped | |
123 | mkdir -p $out/bin |
|
121 | mkdir -p $out/bin | |
124 | ln -s ${self.python}/bin/python $out/bin/ |
|
122 | ln -s ${self.python}/bin/python $out/bin/ | |
125 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
123 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |
126 | ln -s ${self.pyramid}/bin/prequest $out/bin/ |
|
124 | ln -s ${self.pyramid}/bin/prequest $out/bin/ | |
127 | ln -s ${self.pyramid}/bin/pserve $out/bin/ |
|
125 | ln -s ${self.pyramid}/bin/pserve $out/bin/ | |
128 |
|
126 | |||
129 | # Symlink version control utilities |
|
127 | # Symlink version control utilities | |
130 | # We ensure that always the correct version is available as a symlink. |
|
128 | # We ensure that always the correct version is available as a symlink. | |
131 | # So that users calling them via the profile path will always use the |
|
129 | # So that users calling them via the profile path will always use the | |
132 | # correct version. Wrapping is required so those can "import" |
|
130 | # correct version. Wrapping is required so those can "import" | |
133 | # vcsserver python hooks. |
|
131 | # vcsserver python hooks. | |
134 |
|
132 | |||
135 | ln -s ${pkgs.git}/bin/git $out/bin |
|
133 | ln -s ${pkgs.git}/bin/git $out/bin | |
136 | ln -s ${self.mercurial}/bin/hg $out/bin |
|
134 | ln -s ${self.mercurial}/bin/hg $out/bin | |
137 | ln -s ${pkgs.subversion}/bin/svn* $out/bin |
|
135 | ln -s ${pkgs.subversion}/bin/svn* $out/bin | |
138 |
|
136 | |||
139 | echo "DONE: created symlinks into $out/bin" |
|
137 | echo "DONE: created symlinks into $out/bin" | |
140 | DEPS="$out/bin/*" |
|
138 | DEPS="$out/bin/*" | |
141 |
|
139 | |||
142 | # wrap only dependency scripts, they require to have full PYTHONPATH set |
|
140 | # wrap only dependency scripts, they require to have full PYTHONPATH set | |
143 | # to be able to import all packages |
|
141 | # to be able to import all packages | |
144 | for file in $DEPS; |
|
142 | for file in $DEPS; | |
145 | do |
|
143 | do | |
146 | wrapProgram $file \ |
|
144 | wrapProgram $file \ | |
147 | --prefix PATH : $PATH \ |
|
145 | --prefix PATH : $PATH \ | |
148 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
146 | --prefix PYTHONPATH : $PYTHONPATH \ | |
149 | --set PYTHONHASHSEED random |
|
147 | --set PYTHONHASHSEED random | |
150 | done |
|
148 | done | |
151 |
|
149 | |||
152 | echo "DONE: vcsserver binary wrapping" |
|
150 | echo "DONE: vcsserver binary wrapping" | |
153 |
|
151 | |||
154 | ''; |
|
152 | ''; | |
155 |
|
153 | |||
156 | }); |
|
154 | }); | |
157 | }; |
|
155 | }; | |
158 |
|
156 | |||
159 | basePythonPackages = with builtins; |
|
157 | basePythonPackages = with builtins; | |
160 | if isAttrs pythonPackages then |
|
158 | if isAttrs pythonPackages then | |
161 | pythonPackages |
|
159 | pythonPackages | |
162 | else |
|
160 | else | |
163 | getAttr pythonPackages pkgs; |
|
161 | getAttr pythonPackages pkgs; | |
164 |
|
162 | |||
165 | pythonGeneratedPackages = import ./pkgs/python-packages.nix { |
|
163 | pythonGeneratedPackages = import ./pkgs/python-packages.nix { | |
166 | inherit pkgs; |
|
164 | inherit pkgs; | |
167 | inherit (pkgs) fetchurl fetchgit fetchhg; |
|
165 | inherit (pkgs) fetchurl fetchgit fetchhg; | |
168 | }; |
|
166 | }; | |
169 |
|
167 | |||
170 | pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { |
|
168 | pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { | |
171 | inherit pkgs basePythonPackages; |
|
169 | inherit pkgs basePythonPackages; | |
172 | }; |
|
170 | }; | |
173 |
|
171 | |||
174 |
|
172 | |||
175 | # Apply all overrides and fix the final package set |
|
173 | # Apply all overrides and fix the final package set | |
176 | myPythonPackagesUnfix = with pkgs.lib; |
|
174 | myPythonPackagesUnfix = with pkgs.lib; | |
177 | (extends pythonExternalOverrides |
|
175 | (extends pythonExternalOverrides | |
178 | (extends pythonLocalOverrides |
|
176 | (extends pythonLocalOverrides | |
179 | (extends pythonVCSServerOverrides |
|
177 | (extends pythonVCSServerOverrides | |
180 | (extends pythonGeneratedPackages |
|
178 | (extends pythonGeneratedPackages | |
181 | basePythonPackagesUnfix)))); |
|
179 | basePythonPackagesUnfix)))); | |
182 |
|
180 | |||
183 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); |
|
181 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); | |
184 |
|
182 | |||
185 | in myPythonPackages.rhodecode-vcsserver |
|
183 | in myPythonPackages.rhodecode-vcsserver |
@@ -1,67 +1,66 b'' | |||||
1 | # This file contains the adjustments which are desired for a development |
|
1 | # This file contains the adjustments which are desired for a development | |
2 | # environment. |
|
2 | # environment. | |
3 |
|
3 | |||
4 | { pkgs ? (import <nixpkgs> {}) |
|
4 | { pkgs ? (import <nixpkgs> {}) | |
5 | , pythonPackages ? "python27Packages" |
|
5 | , pythonPackages ? "python27Packages" | |
6 | , doCheck ? false |
|
6 | , doCheck ? false | |
7 | }: |
|
7 | }: | |
8 |
|
8 | |||
9 | let |
|
9 | let | |
10 |
|
10 | |||
11 | vcsserver = import ./default.nix { |
|
11 | vcsserver = import ./default.nix { | |
12 | inherit |
|
12 | inherit | |
13 | pkgs |
|
|||
14 | doCheck; |
|
13 | doCheck; | |
15 | }; |
|
14 | }; | |
16 |
|
15 | |||
17 | vcs-pythonPackages = vcsserver.pythonPackages; |
|
16 | vcs-pythonPackages = vcsserver.pythonPackages; | |
18 |
|
17 | |||
19 | in vcsserver.override (attrs: { |
|
18 | in vcsserver.override (attrs: { | |
20 | # Avoid that we dump any sources into the store when entering the shell and |
|
19 | # Avoid that we dump any sources into the store when entering the shell and | |
21 | # make development a little bit more convenient. |
|
20 | # make development a little bit more convenient. | |
22 | src = null; |
|
21 | src = null; | |
23 |
|
22 | |||
24 | # Add dependencies which are useful for the development environment. |
|
23 | # Add dependencies which are useful for the development environment. | |
25 | buildInputs = |
|
24 | buildInputs = | |
26 | attrs.buildInputs ++ |
|
25 | attrs.buildInputs ++ | |
27 | (with vcs-pythonPackages; [ |
|
26 | (with vcs-pythonPackages; [ | |
28 | ipdb |
|
27 | ipdb | |
29 | ]); |
|
28 | ]); | |
30 |
|
29 | |||
31 | # place to inject some required libs from develop installs |
|
30 | # place to inject some required libs from develop installs | |
32 | propagatedBuildInputs = |
|
31 | propagatedBuildInputs = | |
33 | attrs.propagatedBuildInputs ++ |
|
32 | attrs.propagatedBuildInputs ++ | |
34 | []; |
|
33 | []; | |
35 |
|
34 | |||
36 |
|
35 | |||
37 | # Make sure we execute both hooks |
|
36 | # Make sure we execute both hooks | |
38 | shellHook = '' |
|
37 | shellHook = '' | |
39 | runHook preShellHook |
|
38 | runHook preShellHook | |
40 | runHook postShellHook |
|
39 | runHook postShellHook | |
41 | ''; |
|
40 | ''; | |
42 |
|
41 | |||
43 | preShellHook = '' |
|
42 | preShellHook = '' | |
44 | echo "Entering VCS-Shell" |
|
43 | echo "Entering VCS-Shell" | |
45 |
|
44 | |||
46 | # Custom prompt to distinguish from other dev envs. |
|
45 | # Custom prompt to distinguish from other dev envs. | |
47 | export PS1="\n\[\033[1;32m\][VCS-shell:\w]$\[\033[0m\] " |
|
46 | export PS1="\n\[\033[1;32m\][VCS-shell:\w]$\[\033[0m\] " | |
48 |
|
47 | |||
49 | # Set locale |
|
48 | # Set locale | |
50 | export LC_ALL="en_US.UTF-8" |
|
49 | export LC_ALL="en_US.UTF-8" | |
51 |
|
50 | |||
52 | # Setup a temporary directory. |
|
51 | # Setup a temporary directory. | |
53 | tmp_path=$(mktemp -d) |
|
52 | tmp_path=$(mktemp -d) | |
54 | export PATH="$tmp_path/bin:$PATH" |
|
53 | export PATH="$tmp_path/bin:$PATH" | |
55 | export PYTHONPATH="$tmp_path/${vcs-pythonPackages.python.sitePackages}:$PYTHONPATH" |
|
54 | export PYTHONPATH="$tmp_path/${vcs-pythonPackages.python.sitePackages}:$PYTHONPATH" | |
56 | mkdir -p $tmp_path/${vcs-pythonPackages.python.sitePackages} |
|
55 | mkdir -p $tmp_path/${vcs-pythonPackages.python.sitePackages} | |
57 |
|
56 | |||
58 | # Develop installation |
|
57 | # Develop installation | |
59 | echo "[BEGIN]: develop install of rhodecode-vcsserver" |
|
58 | echo "[BEGIN]: develop install of rhodecode-vcsserver" | |
60 | python setup.py develop --prefix $tmp_path --allow-hosts "" |
|
59 | python setup.py develop --prefix $tmp_path --allow-hosts "" | |
61 | ''; |
|
60 | ''; | |
62 |
|
61 | |||
63 | postShellHook = '' |
|
62 | postShellHook = '' | |
64 |
|
63 | |||
65 | ''; |
|
64 | ''; | |
66 |
|
65 | |||
67 | }) |
|
66 | }) |
General Comments 0
You need to be logged in to leave comments.
Login now