Important
snowflake-cli is now in nixpkgs. The newer versions this program will be made available there going forward.
This is a Nix flake that provides snowcli and Snowflake connector python packages that are pinned to a more recent version than what's typically available in nixpkgs.
NOTE: snowflake-cli is being upstreamed to nixpkgs #345810. Once that PR is closed, this repo will start raising deprecation warnings and will be eventually archived.
Flake provides the snowcli
packages and a home-manager
module to configure snowcli in an environment.
Options to run snowcli from this flake:
- Without installing anything:
nix run github:sfc-gh-vtimofeenko/snowcli-nix-flake -- <SNOWCLI FLAGS>
- Install the package in your configuration:
-
Add this flake to the inputs
-
Add
inputs.<snowcli_input_name>.packages.<architecture>.snowcli-2x
to yourenvironment.systemPackages
- or -
add
inputs.<snowcli_input_name>.overlays.default
to your overlays list and addpkgs.snowcli-2x
toenvironment.systemPackages
-
- Add and configure
home-manager
module by importinginputs.<snowcli_input_name>.homeManagerModules.default
and configuring the module
Provided home manager module (src) allows configuring snowcli when it's installed in home-manager environment:
Whether to enable Snowcli.
Type: boolean
Default:
false
Example:
true
Package that provides Snowcli
Type: package
Default:
<derivation snowcli-2.1.2>
Snowcli configuration.
This value is copied to the Nix store in plaintext, so consider using env variables for secrets.
NOTE: connection.default
is used as the default connection by Snowcli.
See doc for more information.
Type: TOML value
Example:
{
connections = {
default = {
account = "account_identifier";
authenticator = "externalbrowser";
database = "some_database";
user = "username";
};
};
}
If using environment variables to manage per-project Snowflake authentication, snow
can be wrapped with an in-line config file to isolate the per-project configuration from the rest of the system.
Wrapper could be defined like this:
{
snowcliWrapped = pkgs.writeShellScript "snow"
''
${lib.getExe snowCli} --config-file <(cat<<EOF
[connections]
[connections.default]
account = "$SF_ACCOUNT"
user = "$SF_USER"
database = "$SF_DB"
schema = "$SF_SCHEMA"
password = "$SF_PASSWORD"
EOF
) $@''; # NOTE: '$@' allows passing all subsequent arguments to the wrapped snowcli
}
snow snowpark init
copies the skeleton directory from Nix store, so the default permissions on the resulting project are read-only. To workaround runchmod -R a+w ./<PROJECT_DIR>
. Then, to update the timestamps on the files:find . -exec touch {} +
TODO