##// END OF EJS Templates
nix: Add `sourcesOverrides` argument to shell.nix to set the vcs server path in jenkins.
Martin Bornhold -
r1133:69363678 default
parent child Browse files
Show More
@@ -1,81 +1,83 b''
1 { pkgs ? (import <nixpkgs> {})
1 { pkgs ? (import <nixpkgs> {})
2 , pythonPackages ? "python27Packages"
2 , pythonPackages ? "python27Packages"
3 , doCheck ? true
3 , doCheck ? true
4 , sourcesOverrides ? {}
4 , doDevelopInstall ? true
5 , doDevelopInstall ? true
5 }:
6 }:
6
7
7 let
8 let
8 sources = pkgs.config.rc.sources or {};
9 # Get sources from config and update them with overrides.
10 sources = (pkgs.config.rc.sources or {}) // sourcesOverrides;
9
11
10 enterprise-ce = import ./default.nix {
12 enterprise-ce = import ./default.nix {
11 inherit pkgs pythonPackages doCheck;
13 inherit pkgs pythonPackages doCheck;
12 };
14 };
13
15
14 ce-pythonPackages = enterprise-ce.pythonPackages;
16 ce-pythonPackages = enterprise-ce.pythonPackages;
15
17
16 # This method looks up a path from `pkgs.config.rc.sources` and returns a
18 # This method looks up a path from `pkgs.config.rc.sources` and returns a
17 # shell script which does a `python setup.py develop` installation of it. If
19 # shell script which does a `python setup.py develop` installation of it. If
18 # no path is found it will return an empty string.
20 # no path is found it will return an empty string.
19 optionalDevelopInstall = attributeName:
21 optionalDevelopInstall = attributeName:
20 let
22 let
21 path = pkgs.lib.attrByPath [attributeName] null sources;
23 path = pkgs.lib.attrByPath [attributeName] null sources;
22 doIt = doDevelopInstall && path != null;
24 doIt = doDevelopInstall && path != null;
23 in
25 in
24 pkgs.lib.optionalString doIt (
26 pkgs.lib.optionalString doIt (
25 builtins.trace "Develop install of ${attributeName} from ${path}" ''
27 builtins.trace "Develop install of ${attributeName} from ${path}" ''
26 echo "Develop install of '${attributeName}' from '${path}' [BEGIN]"
28 echo "Develop install of '${attributeName}' from '${path}' [BEGIN]"
27 pushd ${path}
29 pushd ${path}
28 python setup.py develop --prefix $tmp_path --allow-hosts ""
30 python setup.py develop --prefix $tmp_path --allow-hosts ""
29 popd
31 popd
30 echo "Develop install of '${attributeName}' from '${path}' [DONE]"
32 echo "Develop install of '${attributeName}' from '${path}' [DONE]"
31 '');
33 '');
32
34
33 # This method looks up a path from `pkgs.config.rc.sources` and imports the
35 # This method looks up a path from `pkgs.config.rc.sources` and imports the
34 # default.nix file if it exists. It returns the list of build inputs. If no
36 # default.nix file if it exists. It returns the list of build inputs. If no
35 # path is found it will return an empty list.
37 # path is found it will return an empty list.
36 optionalDevelopInstallBuildInputs = attributeName:
38 optionalDevelopInstallBuildInputs = attributeName:
37 let
39 let
38 path = pkgs.lib.attrByPath [attributeName] null sources;
40 path = pkgs.lib.attrByPath [attributeName] null sources;
39 nixFile = "${path}/default.nix";
41 nixFile = "${path}/default.nix";
40 doIt = doDevelopInstall && path != null && pkgs.lib.pathExists "${nixFile}";
42 doIt = doDevelopInstall && path != null && pkgs.lib.pathExists "${nixFile}";
41 derivate = import "${nixFile}" {
43 derivate = import "${nixFile}" {
42 inherit doCheck pkgs pythonPackages;
44 inherit doCheck pkgs pythonPackages;
43 };
45 };
44 in
46 in
45 pkgs.lib.lists.optionals doIt derivate.propagatedNativeBuildInputs;
47 pkgs.lib.lists.optionals doIt derivate.propagatedNativeBuildInputs;
46
48
47 developInstalls = [ "rhodecode-vcsserver" ];
49 developInstalls = [ "rhodecode-vcsserver" ];
48
50
49 in enterprise-ce.override (attrs: {
51 in enterprise-ce.override (attrs: {
50 # Avoid that we dump any sources into the store when entering the shell and
52 # Avoid that we dump any sources into the store when entering the shell and
51 # make development a little bit more convenient.
53 # make development a little bit more convenient.
52 src = null;
54 src = null;
53
55
54 buildInputs =
56 buildInputs =
55 attrs.buildInputs ++
57 attrs.buildInputs ++
56 pkgs.lib.lists.concatMap optionalDevelopInstallBuildInputs developInstalls ++
58 pkgs.lib.lists.concatMap optionalDevelopInstallBuildInputs developInstalls ++
57 (with ce-pythonPackages; [
59 (with ce-pythonPackages; [
58 bumpversion
60 bumpversion
59 invoke
61 invoke
60 ipdb
62 ipdb
61 ]);
63 ]);
62
64
63 # Somewhat snappier setup of the development environment
65 # Somewhat snappier setup of the development environment
64 # TODO: think of supporting a stable path again, so that multiple shells
66 # TODO: think of supporting a stable path again, so that multiple shells
65 # can share it.
67 # can share it.
66 preShellHook = enterprise-ce.linkNodeAndBowerPackages + ''
68 preShellHook = enterprise-ce.linkNodeAndBowerPackages + ''
67 # Custom prompt to distinguish from other dev envs.
69 # Custom prompt to distinguish from other dev envs.
68 export PS1="\n\[\033[1;32m\][CE-shell:\w]$\[\033[0m\] "
70 export PS1="\n\[\033[1;32m\][CE-shell:\w]$\[\033[0m\] "
69
71
70 # Setup a temporary directory.
72 # Setup a temporary directory.
71 tmp_path=$(mktemp -d)
73 tmp_path=$(mktemp -d)
72 export PATH="$tmp_path/bin:$PATH"
74 export PATH="$tmp_path/bin:$PATH"
73 export PYTHONPATH="$tmp_path/${ce-pythonPackages.python.sitePackages}:$PYTHONPATH"
75 export PYTHONPATH="$tmp_path/${ce-pythonPackages.python.sitePackages}:$PYTHONPATH"
74 mkdir -p $tmp_path/${ce-pythonPackages.python.sitePackages}
76 mkdir -p $tmp_path/${ce-pythonPackages.python.sitePackages}
75
77
76 # Develop installations
78 # Develop installations
77 python setup.py develop --prefix $tmp_path --allow-hosts ""
79 python setup.py develop --prefix $tmp_path --allow-hosts ""
78 echo "Additional develop installs"
80 echo "Additional develop installs"
79 '' + pkgs.lib.strings.concatMapStrings optionalDevelopInstall developInstalls;
81 '' + pkgs.lib.strings.concatMapStrings optionalDevelopInstall developInstalls;
80
82
81 })
83 })
General Comments 0
You need to be logged in to leave comments. Login now