Compare commits
10 commits
5f1789a184
...
ec47f4e110
| Author | SHA1 | Date | |
|---|---|---|---|
| ec47f4e110 | |||
| 231f1421af | |||
| c1e517f5cf | |||
| 0cdc75a4f0 | |||
| 5c0bb8fdde | |||
| 49973291c4 | |||
| ee563bb987 | |||
| eb17946c21 | |||
| e26c68f285 | |||
| b2e0bda97e |
9 changed files with 139 additions and 44 deletions
|
|
@ -1,5 +0,0 @@
|
|||
# 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
Normal file
34
README.org
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
* 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
|
||||
38
node/shell.nix
Normal file
38
node/shell.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{ 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)"
|
||||
'';
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
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
|
||||
'';
|
||||
}
|
||||
36
python/shell.nix
Normal file
36
python/shell.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ 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)"
|
||||
'';
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
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
|
||||
'';
|
||||
}
|
||||
31
rust/shell.nix
Normal file
31
rust/shell.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{ 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