Skip to content

Instantly share code, notes, and snippets.

@samueldr
Last active August 27, 2020 21:10
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 samueldr/f5ddf064917f2535bc3e9ffa66354c80 to your computer and use it in GitHub Desktop.
Save samueldr/f5ddf064917f2535bc3e9ffa66354c80 to your computer and use it in GitHub Desktop.
# nix-build test.nix --arg config '{ my.option = "foobar!"; }' && cat result
{ pkgs ? import <nixpkgs> {}
, config ? {}
}:
let
inherit (pkgs) lib;
eval = config: lib.evalModules {
modules = [
{
options = with lib; {
my = {
option = mkOption {
type = types.str;
default = "hi";
};
};
};
}
config
];
};
in
pkgs.writeText "config.json" (builtins.toJSON (eval config).config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment