I do all my nixops commands from within a nix shell that pins nixpkgs using NIX_PATH
. Here is an example shell.nix
file:
let
commitRev = "4df3426f5a5e78cef4835897a43abd9e2a092b74"; # 18.03 on 2018-08-22
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs-channels/archive/${commitRev}.tar.gz";
sha256 = "05k5mssiqxffxi45mss9wjns6k76i248rpasa48akdcriry1mp63";
};
pkgs = import nixpkgs { config = {}; };
in
pkgs.mkShell {
buildInputs = [ pkgs.nixops ];
shellHook = ''
export NIX_PATH="nixpkgs=${nixpkgs}:."
'';
}
Note the NIX_PATH includes the current directory, that’s necessary if you want to use <mySystem.nix>
like a lot of nixops command line examples do. The shell also ensures everyone is using the same version of nixops.
This isn’t actually my whole shell.nix file, there are more details here: http://www.ryantm.com/blog/nixops-without-sharing/