Skip to content

Commit bec1b4b

Browse files
authored
feat: add openstack to nix (#7519)
* feat: add openstack to nix * fix: note about FSH I since moved away from an FSH into a regular env * refactor: use venvShellHook This is not as robust as the existing hook — it doesn't hash the interpreter, but that's OK.
1 parent 3459cfc commit bec1b4b

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

flake.nix

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# code-owner: @agoose77
2-
# This flake sets up an FSH dev-shell that installs all the required
2+
# This flake sets up a dev-shell that installs all the required
33
# packages for running deployer, and then installs the tool in the virtual environment
44
# It is not best-practice for the nix-way of distributing this code,
55
# but its purpose is to get an environment up and running.
@@ -23,10 +23,18 @@
2323
gdk = pkgs.google-cloud-sdk.withExtraComponents (with pkgs.google-cloud-sdk.components; [
2424
gke-gcloud-auth-plugin
2525
]);
26+
openstack = python.pkgs.toPythonApplication (
27+
python.pkgs.python-openstackclient.overridePythonAttrs (oldAttrs: {
28+
dependencies =
29+
(oldAttrs.dependencies or [])
30+
++ [python.pkgs.python-magnumclient];
31+
})
32+
);
2633
python = pkgs.python313;
2734
packages =
2835
[
2936
python
37+
python.pkgs.venvShellHook
3038
]
3139
++ (with pkgs; [
3240
cmake
@@ -43,46 +51,26 @@
4351
awscli2
4452
azure-cli
4553
terraform
54+
openstack
4655
eksctl
4756
]);
48-
shellHook = ''
49-
# Unset leaky PYTHONPATH
50-
unset PYTHONPATH
51-
52-
__hash=$(echo ${python.interpreter} | sha256sum)
53-
54-
# Setup if not defined ####
55-
if [[ ! -f ".venv/$__hash" ]]; then
56-
__setup_env() {
57-
# Remove existing venv
58-
if [[ -d .venv ]]; then
59-
rm -r .venv
60-
fi
61-
62-
# Stand up new venv
63-
${python.interpreter} -m venv .venv
64-
65-
".venv/bin/python" -m pip install -e ".[dev]"
66-
67-
# Add a marker that marks this venv as "ready"
68-
touch ".venv/$__hash"
69-
}
70-
71-
__setup_env
72-
fi
73-
###########################
74-
75-
# Activate venv
76-
source .venv/bin/activate
77-
'';
7857
env = lib.optionalAttrs pkgs.stdenv.isLinux {
7958
# Python uses dynamic loading for certain libraries.
8059
# We'll set the linker path instead of patching RPATH
8160
LD_LIBRARY_PATH = lib.makeLibraryPath pkgs.pythonManylinuxPackages.manylinux2014;
8261
};
8362
in {
8463
devShell = pkgs.mkShell {
85-
inherit env packages shellHook;
64+
inherit env packages;
65+
66+
venvDir = "./.venv";
67+
postShellHook = ''
68+
unset SOURCE_DATE_EPOCH PYTHONPATH
69+
'';
70+
postVenvCreation = ''
71+
unset SOURCE_DATE_EPOCH PYTHONPATH
72+
pip install -e ".[dev]"
73+
'';
8674
};
8775
});
8876
}

0 commit comments

Comments
 (0)