I’m trying to generate a YAML file from a Dhall expression in Nix. The Dhall file that I pass to dhall-to-yaml
is shown below and I will refer to it as “dhall source”
let Alacritty =
https://raw.githubusercontent.com/cideM/dhall-alacritty/master/linux.dhall sha256:c9cf010f9ef1a7da4590d70571c1fa5114743f9096b8387b180bfb02f5cdffb1
let mono = ./mono.dhall with size = 12.0
in Alacritty.Config::{
, font = mono
, shell = Some { program = "/usr/bin/fish", args = [ "-l" ] }
, colors = ./papercolor.dhall
, key_bindings = ./keys_common.dhall
}
with window.decorations = Alacritty.Window.Decoration.full
with window.dynamic_padding = True
with window.padding = { x = +10, y = +10 }
I made sure that everything in the dhall-alacritty
dependency has a sha256 for the Dhall Prelude, so that I can use buildDhallPackage
to load these things into the cache.
Here’s the Nix code
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
prelude = pkgs.dhallPackages.buildDhallPackage {
name = "dhall-lang-prelude";
code = "${sources.dhall-lang}/Prelude/package.dhall";
};
# Fix in source
preludeMap = pkgs.dhallPackages.buildDhallPackage {
name = "dhall-lang-prelude";
code = "${sources.dhall-lang}/Prelude/Map/Type";
};
linux = pkgs.dhallPackages.buildDhallPackage {
name = "dhall-alacritty";
code = "${sources.dhall-alacritty}/linux.dhall";
dependencies = [
prelude
preludeMap
];
};
# config = pkgs.dhallPackages.buildDhallPackage {
# name = "alacritty_linux";
# code = ./src/linux.dhall;
# dependencies = [
# linux
# ];
# };
in derivation {
name = "alacritty_linux.yml";
builder = "${pkgs.bash}/bin/bash";
args = [ ./builder.sh ];
dhalljson = pkgs.haskellPackages.dhall-json;
coreutils = pkgs.coreutils;
inherit linux;
# inherit config;
src = ./src;
system = builtins.currentSystem;
}
The idea is to use that derivation in Home Manager to generate an alacritty.yml
file. The problem is that if I uncomment alacritty_linux
it complains about missing ./mono.dhall
. So in other words, the dhall source file expects other files to be available in the same folder. If I run this file through buildDhallPackage
it ends up in the Nix store, without the rest of the sources. But if I comment out the call to buildDhallPackage
, my cache doesn’t have the necessary dependencies, it tries to make an HTTP call and that fails for obvious reasons in the Nix builder.
I’m missing a piece of the puzzle here and I don’t know what it is. My idea is that I should uncomment the commented out lines, and then pass inherit config
to derivation
but while also adding the necessary, local (~ relative) sources to name = "alacritty_linux"