nix-darwin
nix-darwin copied to clipboard
Is there a way to "evaluate" my configuration?
I was looking for a way to "evaluate" my configuration, to basically get a nix record out of my flake with all the configuration I've set:
# Example configuration
{
description = "Example Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nix-darwin, nixpkgs }:
let
configuration = { pkgs, ... }: {
environment.systemPackages = [
pkgs.vim
pkgs.neovim
];
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# nix.package = pkgs.nix;
# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
programs.fish.enable = true;
# Set Git commit hash for darwin-version.
system.configurationRevision = self.rev or self.dirtyRev or null;
system.defaults.dock.autohide = true;
system.defaults.dock.showhidden = true;
system.stateVersion = 4;
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "x86_64-darwin";
};
in
{
darwinConfigurations."simple" = nix-darwin.lib.darwinSystem {
modules = [ configuration ];
};
};
}
nix do the thing .#darwinConfigurations
{
simple = {
system = {
configuration = ...
};
};
}
Is this possible?
nix build ~/.nixpkgs#darwinConfigurations."${HOSTNAME}".system
at least that's what I do: https://github.com/kubukoz/nix-config/blob/65496c3f3ff50076eed9b523462606dc2cbee34d/compare.sh
I want the nix object/record, not the built artifacts (directory tree).
If you want to explore it, you can do nix repl .#darwinConfigurations.simple.config
I don't think a nix-darwin/NixOS configuration object is fully serializable, see: https://discourse.nixos.org/t/print-flake-system-configuration-as-json/14199/4