I’m currently trying to improve the portability of some of my scripts that use dhall-haskell
, which uses Nix build expressions. nix-shell
seems like a great way to do so, but as a Nix neophyte, I’m starting to struggle with the transition from “nixpkgs is out of date” -> “OK, let me just use the Nix expressions in the dhall-haskell repository” -> “… well how do I do that?”
Consider a starting point:
script.sh
:
#! /usr/bin/env bash
dhall version
And an initial attempt to transition to using nix-shell
:
script.sh
:
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.09.tar.gz
#! nix-shell deps.nix -i bash
dhall version
deps.nix
:
with import <nixpkgs> {};
let pinned-dhall = dhall
in runCommand "my-dhall-script" {
buildInputs = [
bash
pinned-dhall
];
} ""
But really, instead of pinned-dhall = dhall
, I should have some kind of derivation, e.g. pinned-dhall = mkDerivation...
with the arguments to mkDerivation
pinned to a specific tag of dhall-haskell
somewhere? Is there an easy/simple way to use the release binaries in a platform-independent way (such that the script will work for both OS X-using colleagues and Linux-using colleagues)?