Compare commits

...

10 commits

Author SHA1 Message Date
ec47f4e110 remove newlines after headings 2021-04-10 10:02:01 +02:00
231f1421af remove names 2021-03-14 22:07:17 +01:00
c1e517f5cf update README 2021-03-11 18:25:20 +01:00
0cdc75a4f0 rename folders 2021-03-11 18:23:14 +01:00
5c0bb8fdde add rustfmt 2021-03-11 15:02:57 +01:00
49973291c4 add logging 2021-03-11 13:03:41 +01:00
ee563bb987 add rust_environment 2021-03-11 13:03:19 +01:00
eb17946c21 update README 2021-03-11 10:30:50 +01:00
e26c68f285 move default.nix to shell.nix 2021-03-11 09:37:54 +01:00
b2e0bda97e change Python version to 3 2021-03-06 00:39:18 +01:00
9 changed files with 139 additions and 44 deletions

View file

@ -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
View 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
View 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)"
'';
}

View file

@ -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
View 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)"
'';
}

View file

@ -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
View 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)"
'';
}