nix settings

Allow managing nix.

nix is only available for Linux and MacOS.

pkgs

pkgs allow to install some nix packages (see website).

You need to specify the name of the packages to install.

2 ways to install nix packages:

  • by name, equivalent to:

nix-env -i python3
vscode-anywhere:
    python3:
        enabled: True
        nix:
          pkgs:
            python3:
              enabled: True
  • by attribute (recommended), equivalent to:

nix-env -iA nixpkgs.python3
vscode-anywhere:
    python3:
        enabled: True
        nix:
          pkgs:
            python3:
              enabled: True
              attr: nixpkgs.python3Full

python3 (line 6) is the real name of the package once installed. To retrieve the package name:

nix-instantiate --eval -E '(import <nixpkgs> {}).python3Full.pname'
"python3"

Sometimes pname doesn't exist. In this case, you can use name and remove the version:

nix-instantiate --eval -E '(import <nixpkgs> {}).dotnetPackages.NUnitConsole.pname'
error: attribute 'pname' missing, at (string):1:1
nix-instantiate --eval -E '(import <nixpkgs> {}).dotnetPackages.NUnitConsole.name'
"NUnit.Console-3.0.1"

enabled

True to enable, False to skip (default to False).

attr

attr is not mandatory but allow to specify specific attribute like python3Full.

opts

opts is not mandatory but allows to pass extra args.

Extra args can be arguments described in the Saltstack nix states or can be global Saltstack arguments.

nix is not an official Saltstack states but a custom states written for VSCode-Anywhere.

channel

It uses the -I option of nix-env (man nix-env):

   -I path
       Add a path to the Nix expression search path. This option may be given multiple times. See the NIX_PATH environment variable for information on the semantics of the Nix
       search path. Paths added through -I take precedence over NIX_PATH.

Example:

vscode-anywhere:
    python3:
        enabled: True
        nix:
          pkgs:
            opts:
              install: {}
              update: {}
              uninstall: {}
            python3:
              enabled: True
              attr: nixpkgs.python3Full
              install:
                channel: nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
              update:
                channel: nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
              uninstall: {}

This is equivalent to:

nix-env -iA python3Full -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz

Global packages settings

  • nix:pkgs:opts:global: allow passing arguments to all nix packages when installing, updating, or uninstalling a package

  • nix:pkgs:opts:install: allow passing arguments to all nix packages when installing a package (cf pkg_installed function)

  • nix:pkgs:opts:update: allow passing arguments to all nix packages when updating a package (cf pkg_latest function)

  • nix:pkgs:opts:uninstall: allow passing arguments to all nix packages when uninstalling a package (cf pkg_removed function)

Specific packages settings

  • nix:pkgs:<mypkg>:opts:global: allow passing arguments to <mypkg> nix package when installing, updating, or uninstalling the package

  • nix:pkgs:<mypkg>:opts:install: allow passing arguments to <mypkg> nix packages when installing the package (cf pkg_installed function)

  • nix:pkgs:<mypkg>:opts:update: allow passing arguments to <mypkg> nix packages when updating the package (cf pkg_latest function)

  • nix:pkgs:<mypkg>:opts:uninstall: allow passing arguments to <mypkg> nix packages when uninstalling the package (cf pkg_removed function)

Last updated