Created
January 4, 2022 08:42
-
-
Save ckiee/f86ed075bb8aa839a55fff00d9307205 to your computer and use it in GitHub Desktop.
Get the default value of a NixOS option
This file contains 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
# $ nix-instantiate --eval option.nix --argstr path services.journald.enableHttpGateway | |
# false | |
{ path }: | |
let | |
pkgs = import <nixpkgs> { }; | |
evalConfig = import "${<nixpkgs>}/nixos/lib/eval-config.nix"; | |
inherit (pkgs) lib; | |
in (evalConfig { | |
modules = [ | |
({ config, ... }: { | |
options.cookie = lib.mkOption { default = null; }; | |
config.cookie = lib.getAttrFromPath (lib.splitString "." path) config; | |
config._module.check = false; | |
config.fileSystems."/".device = "/fake"; | |
config.boot.loader.grub.devices = [ "/fake" ]; | |
}) | |
]; | |
}).config.cookie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment