Show More
@@ -1,153 +1,138 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 | { pkgs ? (import <nixpkgs> {}) |
|
7 | { pkgs ? (import <nixpkgs> {}) | |
8 | , pythonPackages ? "python27Packages" |
|
8 | , pythonPackages ? "python27Packages" | |
9 | , pythonExternalOverrides ? self: super: {} |
|
9 | , pythonExternalOverrides ? self: super: {} | |
10 | , doCheck ? true |
|
10 | , doCheck ? true | |
11 | }: |
|
11 | }: | |
12 |
|
12 | |||
13 | let pkgs_ = pkgs; in |
|
13 | let pkgs_ = pkgs; in | |
14 |
|
14 | |||
15 | let |
|
15 | let | |
16 | pkgs = pkgs_.overridePackages (self: super: { |
|
16 | pkgs = pkgs_.overridePackages (self: super: { | |
17 | # Override subversion derivation to |
|
17 | # Override subversion derivation to | |
18 | # - activate python bindings |
|
18 | # - activate python bindings | |
19 | subversion = let |
|
19 | subversion = let | |
20 | subversionWithPython = super.subversion.override { |
|
20 | subversionWithPython = super.subversion.override { | |
21 | httpSupport = true; |
|
21 | httpSupport = true; | |
22 | pythonBindings = true; |
|
22 | pythonBindings = true; | |
23 | python = self.python27Packages.python; |
|
23 | python = self.python27Packages.python; | |
24 | }; |
|
24 | }; | |
25 | in pkgs.lib.overrideDerivation subversionWithPython (oldAttrs: { |
|
25 | in pkgs.lib.overrideDerivation subversionWithPython (oldAttrs: { | |
26 | patches = (oldAttrs.patches or []) ++ |
|
26 | patches = (oldAttrs.patches or []) ++ | |
27 | pkgs.lib.optionals pkgs.stdenv.isDarwin [ |
|
27 | pkgs.lib.optionals pkgs.stdenv.isDarwin [ | |
28 | # johbo: "import svn.client" fails on darwin currently. |
|
28 | # johbo: "import svn.client" fails on darwin currently. | |
29 | ./pkgs/subversion-1.9.4-darwin.patch |
|
29 | ./pkgs/subversion-1.9.4-darwin.patch | |
30 | ]; |
|
30 | ]; | |
31 | }); |
|
31 | }); | |
32 | }); |
|
32 | }); | |
33 |
|
33 | |||
34 | inherit (pkgs.lib) fix extends; |
|
34 | inherit (pkgs.lib) fix extends; | |
35 |
|
35 | |||
36 | basePythonPackages = with builtins; if isAttrs pythonPackages |
|
36 | basePythonPackages = with builtins; if isAttrs pythonPackages | |
37 | then pythonPackages |
|
37 | then pythonPackages | |
38 | else getAttr pythonPackages pkgs; |
|
38 | else getAttr pythonPackages pkgs; | |
39 |
|
39 | |||
40 | elem = builtins.elem; |
|
40 | elem = builtins.elem; | |
41 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
41 | basename = path: with pkgs.lib; last (splitString "/" path); | |
42 | startsWith = prefix: full: let |
|
42 | startsWith = prefix: full: let | |
43 | actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; |
|
43 | actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; | |
44 | in actualPrefix == prefix; |
|
44 | in actualPrefix == prefix; | |
45 |
|
45 | |||
46 | src-filter = path: type: with pkgs.lib; |
|
46 | src-filter = path: type: with pkgs.lib; | |
47 | let |
|
47 | let | |
48 | ext = last (splitString "." path); |
|
48 | ext = last (splitString "." path); | |
49 | in |
|
49 | in | |
50 | !elem (basename path) [ |
|
50 | !elem (basename path) [ | |
51 | ".git" ".hg" "__pycache__" ".eggs" "node_modules" |
|
51 | ".git" ".hg" "__pycache__" ".eggs" "node_modules" | |
52 | "build" "data" "tmp"] && |
|
52 | "build" "data" "tmp"] && | |
53 | !elem ext ["egg-info" "pyc"] && |
|
53 | !elem ext ["egg-info" "pyc"] && | |
54 | !startsWith "result" path; |
|
54 | !startsWith "result" path; | |
55 |
|
55 | |||
56 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; |
|
56 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; | |
57 |
|
57 | |||
58 | pythonGeneratedPackages = self: basePythonPackages.override (a: { |
|
58 | pythonGeneratedPackages = self: basePythonPackages.override (a: { | |
59 | inherit self; |
|
59 | inherit self; | |
60 | }) |
|
60 | }) | |
61 | // (scopedImport { |
|
61 | // (scopedImport { | |
62 | self = self; |
|
62 | self = self; | |
63 | super = basePythonPackages; |
|
63 | super = basePythonPackages; | |
64 | inherit pkgs; |
|
64 | inherit pkgs; | |
65 | inherit (pkgs) fetchurl fetchgit; |
|
65 | inherit (pkgs) fetchurl fetchgit; | |
66 | } ./pkgs/python-packages.nix); |
|
66 | } ./pkgs/python-packages.nix); | |
67 |
|
67 | |||
68 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { |
|
68 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { | |
69 | inherit |
|
69 | inherit | |
70 | basePythonPackages |
|
70 | basePythonPackages | |
71 | pkgs; |
|
71 | pkgs; | |
72 | }; |
|
72 | }; | |
73 |
|
73 | |||
74 | version = builtins.readFile ./vcsserver/VERSION; |
|
74 | version = builtins.readFile ./vcsserver/VERSION; | |
75 |
|
75 | |||
76 | pythonLocalOverrides = self: super: { |
|
76 | pythonLocalOverrides = self: super: { | |
77 | rhodecode-vcsserver = super.rhodecode-vcsserver.override (attrs: { |
|
77 | rhodecode-vcsserver = super.rhodecode-vcsserver.override (attrs: { | |
78 | inherit |
|
78 | inherit | |
79 | doCheck |
|
79 | doCheck | |
80 | version; |
|
80 | version; | |
81 | name = "rhodecode-vcsserver-${version}"; |
|
81 | name = "rhodecode-vcsserver-${version}"; | |
82 | releaseName = "RhodeCodeVCSServer-${version}"; |
|
82 | releaseName = "RhodeCodeVCSServer-${version}"; | |
83 | src = rhodecode-vcsserver-src; |
|
83 | src = rhodecode-vcsserver-src; | |
84 |
|
84 | |||
85 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ ([ |
|
85 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ ([ | |
86 | pkgs.git |
|
86 | pkgs.git | |
87 | pkgs.subversion |
|
87 | pkgs.subversion | |
88 | ]); |
|
88 | ]); | |
89 |
|
89 | |||
90 | # TODO: johbo: Make a nicer way to expose the parts. Maybe |
|
90 | # TODO: johbo: Make a nicer way to expose the parts. Maybe | |
91 | # pkgs/default.nix? |
|
91 | # pkgs/default.nix? | |
92 | passthru = { |
|
92 | passthru = { | |
93 | pythonPackages = self; |
|
93 | pythonPackages = self; | |
94 | }; |
|
94 | }; | |
95 |
|
95 | |||
96 | # Somewhat snappier setup of the development environment |
|
|||
97 | # TODO: move into shell.nix |
|
|||
98 | # TODO: think of supporting a stable path again, so that multiple shells |
|
|||
99 | # can share it. |
|
|||
100 | shellHook = '' |
|
|||
101 | # Set locale |
|
|||
102 | export LC_ALL="en_US.UTF-8" |
|
|||
103 |
|
||||
104 | tmp_path=$(mktemp -d) |
|
|||
105 | export PATH="$tmp_path/bin:$PATH" |
|
|||
106 | export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH" |
|
|||
107 | mkdir -p $tmp_path/${self.python.sitePackages} |
|
|||
108 | python setup.py develop --prefix $tmp_path --allow-hosts "" |
|
|||
109 | ''; |
|
|||
110 |
|
||||
111 | # Add VCSServer bin directory to path so that tests can find 'vcsserver'. |
|
96 | # Add VCSServer bin directory to path so that tests can find 'vcsserver'. | |
112 | preCheck = '' |
|
97 | preCheck = '' | |
113 | export PATH="$out/bin:$PATH" |
|
98 | export PATH="$out/bin:$PATH" | |
114 | ''; |
|
99 | ''; | |
115 |
|
100 | |||
116 | postInstall = '' |
|
101 | postInstall = '' | |
117 | echo "Writing meta information for rccontrol to nix-support/rccontrol" |
|
102 | echo "Writing meta information for rccontrol to nix-support/rccontrol" | |
118 | mkdir -p $out/nix-support/rccontrol |
|
103 | mkdir -p $out/nix-support/rccontrol | |
119 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version |
|
104 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version | |
120 | echo "DONE: Meta information for rccontrol written" |
|
105 | echo "DONE: Meta information for rccontrol written" | |
121 |
|
106 | |||
122 | ln -s ${self.pyramid}/bin/* $out/bin/ |
|
107 | ln -s ${self.pyramid}/bin/* $out/bin/ | |
123 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
108 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |
124 |
|
109 | |||
125 | # Symlink version control utilities |
|
110 | # Symlink version control utilities | |
126 | # |
|
111 | # | |
127 | # We ensure that always the correct version is available as a symlink. |
|
112 | # We ensure that always the correct version is available as a symlink. | |
128 | # So that users calling them via the profile path will always use the |
|
113 | # So that users calling them via the profile path will always use the | |
129 | # correct version. |
|
114 | # correct version. | |
130 | ln -s ${pkgs.git}/bin/git $out/bin |
|
115 | ln -s ${pkgs.git}/bin/git $out/bin | |
131 | ln -s ${self.mercurial}/bin/hg $out/bin |
|
116 | ln -s ${self.mercurial}/bin/hg $out/bin | |
132 | ln -s ${pkgs.subversion}/bin/svn* $out/bin |
|
117 | ln -s ${pkgs.subversion}/bin/svn* $out/bin | |
133 |
|
118 | |||
134 | for file in $out/bin/*; do |
|
119 | for file in $out/bin/*; do | |
135 | wrapProgram $file \ |
|
120 | wrapProgram $file \ | |
136 | --set PATH $PATH \ |
|
121 | --set PATH $PATH \ | |
137 | --set PYTHONPATH $PYTHONPATH \ |
|
122 | --set PYTHONPATH $PYTHONPATH \ | |
138 | --set PYTHONHASHSEED random |
|
123 | --set PYTHONHASHSEED random | |
139 | done |
|
124 | done | |
140 | ''; |
|
125 | ''; | |
141 |
|
126 | |||
142 | }); |
|
127 | }); | |
143 | }; |
|
128 | }; | |
144 |
|
129 | |||
145 | # Apply all overrides and fix the final package set |
|
130 | # Apply all overrides and fix the final package set | |
146 | myPythonPackages = |
|
131 | myPythonPackages = | |
147 | (fix |
|
132 | (fix | |
148 | (extends pythonExternalOverrides |
|
133 | (extends pythonExternalOverrides | |
149 | (extends pythonLocalOverrides |
|
134 | (extends pythonLocalOverrides | |
150 | (extends pythonOverrides |
|
135 | (extends pythonOverrides | |
151 | pythonGeneratedPackages)))); |
|
136 | pythonGeneratedPackages)))); | |
152 |
|
137 | |||
153 | in myPythonPackages.rhodecode-vcsserver |
|
138 | in myPythonPackages.rhodecode-vcsserver |
@@ -1,18 +1,36 b'' | |||||
1 | { pkgs ? import <nixpkgs> {} |
|
1 | { pkgs ? import <nixpkgs> {} | |
2 | , doCheck ? false |
|
2 | , doCheck ? false | |
3 | }: |
|
3 | }: | |
4 |
|
4 | |||
5 | let |
|
5 | let | |
6 | vcsserver = import ./default.nix { |
|
6 | vcsserver = import ./default.nix { | |
7 | inherit |
|
7 | inherit | |
8 | doCheck |
|
8 | doCheck | |
9 | pkgs; |
|
9 | pkgs; | |
10 | }; |
|
10 | }; | |
11 |
|
11 | |||
|
12 | vcs-pythonPackages = vcsserver.pythonPackages; | |||
|
13 | ||||
12 | in vcsserver.override (attrs: { |
|
14 | in vcsserver.override (attrs: { | |
13 |
|
15 | |||
14 | # Avoid that we dump any sources into the store when entering the shell and |
|
16 | # Avoid that we dump any sources into the store when entering the shell and | |
15 | # make development a little bit more convenient. |
|
17 | # make development a little bit more convenient. | |
16 | src = null; |
|
18 | src = null; | |
17 |
|
19 | |||
|
20 | # Somewhat snappier setup of the development environment | |||
|
21 | # TODO: think of supporting a stable path again, so that multiple shells | |||
|
22 | # can share it. | |||
|
23 | postShellHook = '' | |||
|
24 | # Set locale | |||
|
25 | export LC_ALL="en_US.UTF-8" | |||
|
26 | ||||
|
27 | # Custom prompt to distinguish from other dev envs. | |||
|
28 | export PS1="\n\[\033[1;32m\][VCS-shell:\w]$\[\033[0m\] " | |||
|
29 | ||||
|
30 | tmp_path=$(mktemp -d) | |||
|
31 | export PATH="$tmp_path/bin:$PATH" | |||
|
32 | export PYTHONPATH="$tmp_path/${vcs-pythonPackages.python.sitePackages}:$PYTHONPATH" | |||
|
33 | mkdir -p $tmp_path/${vcs-pythonPackages.python.sitePackages} | |||
|
34 | python setup.py develop --prefix $tmp_path --allow-hosts "" | |||
|
35 | ''; | |||
18 | }) |
|
36 | }) |
General Comments 0
You need to be logged in to leave comments.
Login now