Skip to content

Instantly share code, notes, and snippets.

@dhess
Created October 15, 2018 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhess/3995f7e4ee054803c38c286b8f980465 to your computer and use it in GitHub Desktop.
Save dhess/3995f7e4ee054803c38c286b8f980465 to your computer and use it in GitHub Desktop.
{ pkgs, ... }:
let
# This is a neat trick that clever taught me on #nixos. Here we
# re-import nixpkgs (using our fixed nixpkgs via pkgs.path) and
# force the system to be x86_64-linux, which in turn causes this
# derivation always to be built on x86_64-linux, regardless of the
# system it was intended to be built for (as long as we use
# nixpkgs.x instead of pkgs.x in the derivation!).
#
# We do this because dhall-nix doesn't build on aarch64-linux due to
# GHC currently being unsupported on that arch; and Nixpkgs will
# attempt to build any config that's needed on an aarch64-linux on
# an aarch64-linux... unless we use this trick.
#
# This is effectively equivalent to Debian's "all"
# pseudo-architecture.
nixpkgs = import pkgs.path { system = "x86_64-linux"; };
state =
let
drv = nixpkgs.stdenv.mkDerivation {
name = "foo.nix";
src = ./.;
buildCommand = ''
dhall-to-nix <<< $src/foo.dhall > $out
'';
buildInputs = [ nixpkgs.dhall-nix ];
};
in
import "${drv}";
in
state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment