Last active
December 7, 2022 10:02
-
-
Save AlexeyRaga/c506005ad0356c025170a4d45db41033 to your computer and use it in GitHub Desktop.
Nix shell with pinned packages
This file contains hidden or 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 | |
# a function that takes a descriptive name and a hash of nixpkgs-unstable to pin | |
# and returns the package from the channel at that version | |
pinned = name: hash: | |
let pinnedPkgs = | |
import | |
(builtins.fetchGit { | |
# Descriptive name to make the store path easier to identify | |
# ... | |
# Or maybe we don't need to do it? Say, we pin multiple packages from the same hash... Don't know :) | |
name = "pinned-${name}"; | |
url = "https://github.com/NixOS/nixpkgs/"; | |
ref = "refs/heads/nixpkgs-unstable"; | |
rev = hash; | |
}) | |
{ }; | |
in builtins.getAttr name pinnedPkgs; | |
# let's say I want to have cabal-install 3.2.0.0. | |
# I find an appropriate hash in https://lazamar.co.uk/nix-versions/ and pin it from that hash | |
cabal-install = (pinned "cabal-install" "2c162d49cd5b979eb66ff1653aecaeaa01690fcc"); | |
in mkShell { | |
shellHook = '' | |
export FOO="bar"; | |
''; | |
buildInputs = [ | |
haskell.compiler.ghc94 | |
haskell-language-server | |
hlint | |
cabal-install | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment