Repository: flox/flox

Issue #492: unfree packages can be installed by default and display a warning
Created: 2023-11-29T18:12:26Z
Acceptance Criteria
Given I have an environment freshly flox init
When I flox install vscode (unfree package example)
Then I see a message...
⚠️ The package 'vscode' is not free. Please verify the licensing terms of use.
✅ 'vscode' installed to environment name at /Users/ghudgins/name


Don't put unfree in manifest by default
And When I flox edit
Then I do not see any options related to unfree (we assume lack of the option means unfree is true)
setting allow unfree still works
And When I add options.allow.unfree = false
And I flox install spotify
Then I see an error not allowing installation
❌ ERROR: Failed to build environment.

Package 'spotify' is marked as unfree.

Allow unfree packages by setting 'options.allow.unfree = true' in manifest.toml

Flox search honors the settings of the environment (including implicit defaults)
Given an environment has no options set
When I flox search vscode <-- unfree package
Then I see results
And When I flox search CHOWTape <-- broken package
Then I don't see results
Notes
Trying to install an unfree package prints an ugly Nix error. We should either catch the error and print something nicer or enable unfree packages by default.
> flox install vscode
ERROR: error building environment: warning: unknown setting 'trusted-users'
    error:
           … in the condition of the assert statement

             at /nix/store/l45hwj0x8rpmz64qli38m2j831n82zkw-source/lib/customisation.nix:229:17:

              228|       drvPath = assert condition; drv.drvPath;
              229|       outPath = assert condition; drv.outPath;
                 |                 ^
              230|     };

           … while evaluating the attribute 'handled'

             at /nix/store/l45hwj0x8rpmz64qli38m2j831n82zkw-source/pkgs/stdenv/generic/check-meta.nix:447:7:

              446|       # or, alternatively, just output a warning message.
              447|       handled =
                 |       ^
              448|         {

           (stack trace truncated; use '--show-trace' to show the full trace)

           error: Package ‘vscode-1.78.2’ in /nix/store/l45hwj0x8rpmz64qli38m2j831n82zkw-source/pkgs/applications/editors/vscode/vscode.nix:59 has an unfree license (‘unfree’), refusing to evaluate.

           a) To temporarily allow unfree packages, you can use an environment variable
              for a single invocation of the nix tools.

                $ export NIXPKGS_ALLOW_UNFREE=1

            Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
            (Flake) command, `--impure` must be passed in order to read this
            environment variable.

           b) For `nixos-rebuild` you can set
             { nixpkgs.config.allowUnfree = true; }
           in configuration.nix to override this.

           Alternatively you can configure a predicate to allow specific packages:
             { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
                 "vscode"
               ];
             }

           c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
             { allowUnfree = true; }
           to ~/.config/nixpkgs/config.nix.

Some prior discussion is in https://github.com/flox/product/issues/125

Duplicate issue #679: Unable to install cudatoolkit
Created: 2023-12-20T04:23:59Z
Describe the bug:
I can't install cudatoolkit
Steps to reproduce:

'flox search cuda` # Notice that cudatoolkit is a package
flox install cudatoolkit # Notice it fails
File bug.

Result:
% flox init                                                                                 /tmp/tmp.Hqm00bALHH fedora
✨ Created environment tmp.Hqm00bALHH (x86_64-linux)

Next:
 $ flox search <package>    <- Search for a package
 $ flox install <package>   <- Install a package into an environment
 $ flox activate            <- Enter the environment

% flox search cuda                                                                          /tmp/tmp.Hqm00bALHH fedora
vimPlugins.nvim-treesitter-parsers.cuda  <no description provided>
cudatext                                 Cross-platform code editor
cudatext-gtk                             Cross-platform code editor
cudatext-qt                              Cross-platform code editor
cudatoolkit                              A compiler for NVIDIA GPUs, math libraries, and tools
cudatoolkit_11                           A compiler for NVIDIA GPUs, math libraries, and tools
mathematica-cuda                         Wolfram Mathematica computational software system
tiny-cuda-nn                             Lightning fast C++/CUDA neural network framework
caffeWithCuda                            Deep learning framework
colmapWithCuda                           COLMAP - Structure-From-Motion and Multi-View Stereo pipeline

Showing 10 of 83 results. Use `flox search cuda --all` to see the full list.
Use `flox show <package>` to see available versions
% flox install cudatoolkit                                                                  /tmp/tmp.Hqm00bALHH fedora
ERROR: error building environment:
%


With --debug
 % flox install --debug cudatoolkit                                                          /tmp/tmp.Hqm00bALHH fedora
[DEBUG] [flox::config] `$FLOX_CONFIG_HOME` not set, using "/home/stahnma/.config/flox/"
[DEBUG] [flox::commands] Metrics collection disabled
[DEBUG] [flox::utils::init] no default user nix.conf found - weird
[DEBUG] [flox::utils::init::metrics] Attempting to read own UUID from file
[DEBUG] [flox::commands::environment] installing packages [cudatoolkit] to Unspecified
[DEBUG] [flox_rust_sdk::models::environment] looking for .flox: starting_path=/tmp/tmp.Hqm00bALHH/.flox
[DEBUG] [flox_rust_sdk::models::environment] .flox found: path=/tmp/tmp.Hqm00bALHH/.flox
[DEBUG] [flox::commands] detected concrete environment type: path
[DEBUG] [flox_rust_sdk::models::environment::path_environment] attempting to open .flox directory: /tmp/tmp.Hqm00bALHH/.flox
⠁ Installing packages to environment tmp.Hqm00bALHH at /tmp/tmp.Hqm00bALHH...                                           [DEBUG] [flox_rust_sdk::models::manifest] attempting to insert packages into manifest
[DEBUG] [flox_rust_sdk::models::manifest] package newly installed: id=cudatoolkit, path=cudatoolkit
⠁ Installing packages to environment tmp.Hqm00bALHH at /tmp/tmp.Hqm00bALHH...                                           [DEBUG] [flox_rust_sdk::models::environment::core_environment] transaction: making temporary environment in /home/stahnma/.cache/flox/process/.tmp0waJIE/.tmpmIScLb
[DEBUG] [flox_rust_sdk::models::environment::core_environment] transaction: updating manifest
[DEBUG] [flox_rust_sdk::models::environment::core_environment] writing new manifest to /home/stahnma/.cache/flox/process/.tmp0waJIE/.tmpmIScLb/manifest.toml
[DEBUG] [flox_rust_sdk::models::environment::core_environment] transaction: building environment
[DEBUG] [flox_rust_sdk::models::environment::core_environment] no existing lockfile found
[DEBUG] [flox_rust_sdk::models::environment] global manifest path is /home/stahnma/.config/flox/global-manifest.toml
[DEBUG] [flox_rust_sdk::models::environment::core_environment] locking manifest with command: "/nix/store/676hygvwdx2ckbc14nrlyaziwy8nxiws-flox-pkgdb-0.1.0/bin/pkgdb" "manifest" "lock" "--ga-registry" "--global-manifest" "/home/stahnma/.config/flox/global-manifest.toml" "--manifest" "/home/stahnma/.cache/flox/process/.tmp0waJIE/.tmpmIScLb/manifest.toml"
⠙ Installing packages to environment tmp.Hqm00bALHH at /tmp/tmp.Hqm00bALHH...                                           [DEBUG] [flox_rust_sdk::models::environment::core_environment] generated lockfile, writing to /home/stahnma/.cache/flox/process/.tmp0waJIE/.tmpmIScLb/manifest.lock
[DEBUG] [flox_rust_sdk::models::environment::core_environment] building environment: system=x86_64-linux, lockfilePath=/home/stahnma/.cache/flox/process/.tmp0waJIE/.tmpmIScLb/manifest.lock
[DEBUG] [flox_rust_sdk::models::environment::core_environment] building environment with command: "/nix/store/676hygvwdx2ckbc14nrlyaziwy8nxiws-flox-pkgdb-0.1.0/bin/pkgdb" "buildenv" "{\"lockfile-version\":0,\"manifest\":{\"install\":{\"cudatoolkit\":{\"path\":\"cudatoolkit\"}},\"registry\":{\"defaults\":{\"subtrees\":null},\"inputs\":{\"nixpkgs\":{\"from\":{\"owner\":\"NixOS\",\"ref\":\"release-23.05\",\"repo\":\"nixpkgs\",\"type\":\"github\"},\"subtrees\":[\"legacyPackages\"]}},\"priority\":[\"nixpkgs\"]}},\"packages\":{\"x86_64-linux\":{\"cudatoolkit\":{\"attr-path\":[\"legacyPackages\",\"x86_64-linux\",\"cudatoolkit\"],\"info\":{\"broken\":false,\"license\":null,\"pname\":\"cudatoolkit\",\"unfree\":true,\"version\":\"11.7.0\"},\"input\":{\"attrs\":{\"lastModified\":1702882221,\"narHash\":\"sha256-L/uOrBqkGsa45EvQk4DLq/aR6JeomW+7Mwe0mC/dVUM=\",\"owner\":\"NixOS\",\"repo\":\"nixpkgs\",\"rev\":\"25fef6e30d8ad48f47a8411ccfe986d8baed8a15\",\"type\":\"github\"},\"fingerprint\":\"0bba17e4e0d149b3e3612d69653fa6970af2e167f228b939168c9ae65f320cf7\",\"url\":\"github:NixOS/nixpkgs/25fef6e30d8ad48f47a8411ccfe986d8baed8a15\"},\"priority\":5}}},\"registry\":{\"defaults\":{\"subtrees\":null},\"inputs\":{\"nixpkgs\":{\"from\":{\"lastModified\":1702882221,\"narHash\":\"sha256-L/uOrBqkGsa45EvQk4DLq/aR6JeomW+7Mwe0mC/dVUM=\",\"owner\":\"NixOS\",\"repo\":\"nixpkgs\",\"rev\":\"25fef6e30d8ad48f47a8411ccfe986d8baed8a15\",\"type\":\"github\"},\"subtrees\":[\"legacyPackages\"]}},\"priority\":[\"nixpkgs\"]}}"
[ERROR] [flox] error building environment:
 %

Expected:
I have cudatoolkit installed into the environment, or helpful error messages.
📓  FWIW, cudaPackages.cudatoolkit also has the same error.
Screenshots/terminal output (if relevant):
** flox Version (run flox --version if possible): **
Version: 0.3.6-168-g2d8d41c

Closing comment (2023-12-20T17:42:46Z): duplicate of #492