Skip to content

Instantly share code, notes, and snippets.

@knedlsepp
Last active June 15, 2020 16:40
Show Gist options
  • Save knedlsepp/3dcb222306326d80999ff600e4a52bb9 to your computer and use it in GitHub Desktop.
Save knedlsepp/3dcb222306326d80999ff600e4a52bb9 to your computer and use it in GitHub Desktop.
How to pin a nix version in a default.nix file. (Override the pinned version via: nix-shell --arg nixpkgs '<nixpkgs>')
{nixpkgs ? null}:
let
sysPkg = import <nixpkgs> { };
pinnedPkg = sysPkg.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "cf62a27a326a9cdbb01d627b1faaea3a0d5e886c";
sha256 = "1q74ciqq5r17vidw2025x8idsncz9k7w60warrij4q7piaffgvd7";
};
pkgs = if nixpkgs==null then
import pinnedPkg {}
else
import nixpkgs {};
in with pkgs; stdenv.mkDerivation rec {
name = "ProjectA-1.0.0";
src = ./.;
buildInputs = [ pkgs.python ];
installPhase= ''
sed -i -e "s|python|`which python`" bin/serve
mkdir -p $out/bin
cp bin/* $out/bin
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment