I’m just beginning to learn nix so glad to have this place to asks questions in. Thanks for reading!
I’m watching this video: Reading Nix Expression Zimbatm (NixCon 2019) - YouTube
At the 37min37sec mark the presenter seems to show what a configuration.nix file will be evaluated to using nix-instantiate. The command he runs is: nix-instantiate --eval configuration.nix --strict --json
, and then he sees a json result. However, when I do the same locally I see this:
> nix-instantiate --eval --strict --json configuration.nix
error: cannot convert a function to JSON
> nix-instantiate --eval --strict configuration.nix
<LAMBDA>
Is this due to version differences of nix-instantiate? My version is:
> nix-instantiate --version
nix-instantiate (Nix) 2.3.4
How can I get the same thing done so that I can see what my configuration.nix evaluates to?
In case it matters, my configuration.nix currently looks like this:
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.luks.devices = {
nixos = {
device="/dev/disk/by-uuid/fcd53ef1-31ef-485e-a3e4-cc5b345c14c3";
preLVM=true;
};
};
# Start dropbox automatically. From <https://discourse.nixos.org/t/using-dropbox-on-nixos/387/5>
# this failed... 2020.05.02
# it seems to have worked actually!
systemd.user.services.dropbox = {
description = "Dropbox";
after = [ "xembedsniproxy.service" ];
wants = [ "xembedsniproxy.service" ];
wantedBy = [ "graphical-session.target" ];
environment = {
QT_PLUGIN_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtPluginPrefix;
QML2_IMPORT_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtQmlPrefix;
};
serviceConfig = {
ExecStart = "${pkgs.dropbox.out}/bin/dropbox";
ExecReload = "${pkgs.coreutils.out}/bin/kill -HUP $MAINPID";
KillMode = "control-group"; # upstream recommends process
Restart = "on-failure";
PrivateTmp = true;
ProtectSystem = "full";
Nice = 10;
};
};
networking.hostName = "nixos-dell";
networking.networkmanager.enable = true;
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
networking.interfaces.wlp59s0.useDHCP = true;
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "no";
};
# Set your time zone.
time.timeZone = "Europe/Oslo";
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
# Terminal
wget
neovim
tmux
zsh
oh-my-zsh
git
ripgrep
yakuake
tree
xclip
# Browser
vivaldi
firefox
# Dev
docker
docker-compose
idea.pycharm-professional
# Other
dropbox
slack
openconnect
spectacle
anki
];
nixpkgs.config = {
allowUnfree = true;
# Build Vivaldi with the proprietary stuff needed to play media
vivaldi = {
proprietaryCodecs = true;
enableWideVine = true;
};
};
# Enable docker, ref https://github.com/NixOS/nixpkgs/issues/6616
virtualisation.docker.enable = true;
# Enable zsh and oh-my-zsh
programs.zsh.enable = true;
programs.zsh.ohMyZsh.enable = true;
programs.zsh.interactiveShellInit = ''
export ZSH=${pkgs.oh-my-zsh}/share/oh-my-zsh/
# Customize your oh-my-zsh options here
ZSH_THEME="agnoster"
plugins=(git docker ssh-agent)
source $ZSH/oh-my-zsh.sh
'';
programs.zsh.promptInit = ""; # Clear this to avoid a conflict with oh-my-zsh
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# pinentryFlavor = "gnome3";
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
sound.enable = true;
hardware.pulseaudio.enable = true;
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver.layout = "us";
services.xserver.xkbOptions = "eurosign:e";
# Enable touchpad support.
services.xserver.libinput.enable = true;
# Enable the KDE Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.stian = {
isNormalUser = true;
shell = pkgs.zsh;
extraGroups = [
"wheel" # Enable ‘sudo’ for the user.
"docker"
];
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "20.03"; # Did you read the comment?
}