Last active
October 21, 2020 17:50
-
-
Save manojkarthick/3767b946ad45d5e4a2b5bca257154983 to your computer and use it in GitHub Desktop.
Sample nix derivations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
stdenv.mkDerivation rec { | |
pname = "avro-tools"; | |
version = "1.9.2"; | |
src = fetchurl { | |
url = | |
"https://repo1.maven.org/maven2/org/apache/avro/avro-tools/${version}/${pname}-${version}.jar"; | |
sha256 = "169cv4fjsj69fa2s87gh1i7wk0xzh3l7sx5yyz3cgyjalg4a12n1"; | |
}; | |
dontUnpack = true; | |
buildInputs = [ jre ]; | |
nativeBuildInputs = [ makeWrapper ]; | |
sourceRoot = "."; | |
installPhase = '' | |
mkdir -p $out/bin | |
mkdir -p $out/libexec/avro-tools | |
cp $src $out/libexec/avro-tools/${pname}.jar | |
makeWrapper ${jre}/bin/java $out/bin/avro-tools \ | |
--add-flags "-jar $out/libexec/avro-tools/${pname}.jar" | |
''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
go113Tarball = fetchTarball https://github.com/NixOS/nixpkgs/archive/6148f6360310366708dff42055a0ba0afa963101.tar.gz; | |
pkgs = import <nixpkgs> {}; | |
goAlternate = import go113Tarball {}; | |
drv = pkgs.stdenv.mkDerivation rec { | |
name = "env"; | |
env = pkgs.buildEnv { name = name; paths = buildInputs; }; | |
buildInputs = [ | |
goAlternate.go_1_13 | |
]; | |
shellHook = '' | |
# export PS1="[nix@${name}:\W]\[$(tput sgr0)\] " | |
export PS1="[\[\e[32m\]nix\[\e[m\]@\[\e[31m\]${name}\[\e[m\] \[\e[36m\]\W\[\e[m\]] " | |
bind '"\e\e[C": forward-word' | |
bind '"\e\e[D": backward-word' | |
''; | |
}; | |
in drv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
let | |
wmiPackage = pkgs.writeShellScriptBin "whatsMyIp" '' | |
${pkgs.curl}/bin/curl -sL http://httpbin.org/get | ${pkgs.jq}/bin/jq -r '.origin' | |
''; | |
in | |
stdenv.mkDerivation rec { | |
name = "test-environment"; | |
buildInputs = [ wmiPackage]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sourced from: https://nathan.gs/2019/04/19/using-jekyll-and-nix-to-blog/ | |
with import <nixpkgs> { }; | |
let jekyll_env = bundlerEnv rec { | |
name = "jekyll_env"; | |
inherit ruby; | |
gemfile = ./Gemfile; | |
lockfile = ./Gemfile.lock; | |
gemset = ./gemset.nix; | |
}; | |
in | |
stdenv.mkDerivation rec { | |
name = "nathan.gs"; | |
buildInputs = [ jekyll_env bundler ruby ]; | |
shellHook = '' | |
exec ${jekyll_env}/bin/jekyll serve --watch | |
''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
stdenv.mkDerivation rec { | |
name = "env"; | |
env = buildEnv { name = name; paths = buildInputs; }; | |
buildInputs = [ | |
python36 | |
python36Packages.virtualenv | |
python36Packages.pip | |
]; | |
shellHook = '' | |
# export PS1="[nix@${name}:\W]\[$(tput sgr0)\] " | |
export PS1="[\[\e[32m\]nix\[\e[m\]@\[\e[31m\]${name}\[\e[m\] \[\e[36m\]\W\[\e[m\]] " | |
bind '"\e\e[C": forward-word' | |
bind '"\e\e[D": backward-word' | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment