Compare commits
No commits in common. "ec47f4e1102fa3eaef38d1f9411e8eb7bb731015" and "5f1789a18443a88e4855d688834b1c9df81f70ce" have entirely different histories.
ec47f4e110
...
5f1789a184
9 changed files with 44 additions and 139 deletions
5
README.md
Normal file
5
README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# nix_virtualenvs
|
||||||
|
|
||||||
|
This is a repository for different virtual environments, which can be used with the **Nix** package manager.
|
||||||
|
|
||||||
|
Just copy the content of the desired folder to your project, add your required packages to the `*.txt` file and run `nix-shell`.
|
||||||
34
README.org
34
README.org
|
|
@ -1,34 +0,0 @@
|
||||||
* nix_environments
|
|
||||||
|
|
||||||
This is a set of various environments which can be used with the *Nix* package manager.
|
|
||||||
|
|
||||||
Copy the =shell.nix= file from the desired folder into your project and run ~nix-shell~.
|
|
||||||
This will drop you into a virtual environment with all requirements fulfilled.
|
|
||||||
Please check below how the virtual environments work and how to add environment specific packages.
|
|
||||||
|
|
||||||
If you need more Nix packages in your environent, enhance the list ~buildInputs~ in the file =shell.nix=.
|
|
||||||
|
|
||||||
** node
|
|
||||||
|
|
||||||
This environment does the following:
|
|
||||||
|
|
||||||
1. Create a directory =.npm/bin= if not existent
|
|
||||||
2. Add the =.npm/bin= directory to the ~$PATH~ variable
|
|
||||||
3. Upgrade npm to the latest version
|
|
||||||
4. If the file =global_packages.txt= is present, install the packages via npm into the =.npm= directory
|
|
||||||
5. Run ~npm install~ if a file =package.json= is present
|
|
||||||
|
|
||||||
** python
|
|
||||||
|
|
||||||
This environment does the following:
|
|
||||||
|
|
||||||
1. Create a new python virtualenv in the folder =.venv= if not existent
|
|
||||||
2. Source the virtual environment
|
|
||||||
3. Upgrade pip to the latest version
|
|
||||||
4. If present, install the packages from the file =requirements.txt= via pip
|
|
||||||
|
|
||||||
** rust
|
|
||||||
|
|
||||||
This environment does the following:
|
|
||||||
|
|
||||||
1. Run ~cargo build~ if =Cargo.toml= is present
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
pkgs.mkShell {
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
nodejs
|
|
||||||
];
|
|
||||||
shellHook = ''
|
|
||||||
function log_header {
|
|
||||||
echo -ne "==> \e[32m\e[1m$1\e[0m\n"
|
|
||||||
}
|
|
||||||
function log_subheader {
|
|
||||||
echo -ne "--> \e[33m\e[1m$1\e[0m\n"
|
|
||||||
}
|
|
||||||
function log {
|
|
||||||
echo -ne " $1\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
log_header "node_environment"
|
|
||||||
mkdir -p .npm/bin
|
|
||||||
export PATH=$PWD/.npm/bin:$PATH
|
|
||||||
log_subheader "upgrading npm"
|
|
||||||
npm install -g npm --prefix $PWD/.npm
|
|
||||||
echo ""
|
|
||||||
if [ -s global_packages.txt ]; then
|
|
||||||
log_subheader "found global_packages.txt, installing packages"
|
|
||||||
cat global_packages.txt | xargs npm install -g --prefix $PWD/.npm
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
if [ -s package.json ]; then
|
|
||||||
log_subheader "found package.json, running 'npm install'"
|
|
||||||
npm install
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
log_header "package versions"
|
|
||||||
log "node $(node --version)"
|
|
||||||
log "npm $(npm --version)"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
19
node_environment/default.nix
Normal file
19
node_environment/default.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "myNodeEnv";
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
nodejs
|
||||||
|
];
|
||||||
|
src = null;
|
||||||
|
shellHook = ''
|
||||||
|
mkdir -p .npm
|
||||||
|
if [ -s global_packages.txt ]; then
|
||||||
|
cat global_packages.txt | xargs npm install -g --prefix $PWD/.npm
|
||||||
|
fi
|
||||||
|
if [ -s package.json ]; then
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
export PATH=$PWD/.npm/bin:$PATH
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
pkgs.mkShell {
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
python3
|
|
||||||
python3Packages.virtualenv
|
|
||||||
];
|
|
||||||
shellHook = ''
|
|
||||||
function log_header {
|
|
||||||
echo -ne "==> \e[32m\e[1m$1\e[0m\n"
|
|
||||||
}
|
|
||||||
function log_subheader {
|
|
||||||
echo -ne "--> \e[33m\e[1m$1\e[0m\n"
|
|
||||||
}
|
|
||||||
function log {
|
|
||||||
echo -ne " $1\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
log_header "python_environment"
|
|
||||||
if [ ! -d .venv ]; then
|
|
||||||
python -m venv .venv
|
|
||||||
fi
|
|
||||||
source .venv/bin/activate
|
|
||||||
log_subheader "upgrading pip"
|
|
||||||
pip install --upgrade pip
|
|
||||||
echo ""
|
|
||||||
if [ -s requirements.txt ]; then
|
|
||||||
log_subheader "found requirements.txt, installing packages"
|
|
||||||
pip install -r requirements.txt
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
log_header "package versions"
|
|
||||||
log "$(python --version)"
|
|
||||||
log "$(pip --version)"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
20
python_environment/default.nix
Normal file
20
python_environment/default.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "myPythonEnv";
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
python38Full
|
||||||
|
python38Packages.virtualenv
|
||||||
|
];
|
||||||
|
src = null;
|
||||||
|
shellHook = ''
|
||||||
|
if [ ! -d .venv ]; then
|
||||||
|
python -m venv .venv
|
||||||
|
fi
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
if [ -s requirements.txt ]; then
|
||||||
|
pip install -r requirements.txt
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
pkgs.mkShell {
|
|
||||||
NIX_ENFORCE_PURITY=0;
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
cargo
|
|
||||||
rustc
|
|
||||||
rustfmt
|
|
||||||
];
|
|
||||||
shellHook = ''
|
|
||||||
function log_header {
|
|
||||||
echo -ne "==> \e[32m\e[1m$1\e[0m\n"
|
|
||||||
}
|
|
||||||
function log_subheader {
|
|
||||||
echo -ne "--> \e[33m\e[1m$1\e[0m\n"
|
|
||||||
}
|
|
||||||
function log {
|
|
||||||
echo -ne " $1\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
log_header "rust_environment"
|
|
||||||
if [ -s Cargo.toml ]; then
|
|
||||||
log_subheader "found Cargo.toml, running 'cargo-build'"
|
|
||||||
cargo build
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
log_header "package versions"
|
|
||||||
log "$(rustc --version)"
|
|
||||||
log "$(cargo --version)"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue