cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.39k stars 330 forks source link

`copyToRoot` does not work with files #1334

Open thoward27 opened 3 months ago

thoward27 commented 3 months ago

Describe the bug

I am trying to follow the example under Running Artifacts to generate a container for a small Loco.rs project. Unfortunately, I am unable to get anything to copy to the container, let along files built from an existing process.

To reproduce

https://gist.github.com/thoward27/467399b4aed4a88f775f492b67576f18

$ devenv container run prod
• Building prod container ...
• Using Cachix: devenv
warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error:
       error: builder for '/nix/store/isx9vvyb8s7mv4780mix8ajwk04v0bhz-devenv-container-home.drv' failed with exit code 1;
       last 2 log lines:
       > cp: missing destination file operand after '/nix/store/wnamk406k3qfz9qphiqs962hw31p4wwg-devenv-container-home/env/'
       > Try 'cp --help' for more information.
       For full logs, run 'nix log /nix/store/isx9vvyb8s7mv4780mix8ajwk04v0bhz-devenv-container-home.drv'.
error:
       error: 1 dependencies of derivation '/nix/store/s1iy2ns51ylwlkl99b4idsvqnyjv56a7-closure-graph.json.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/h3fck2gciar5aydmflk0pr1nxbxjfd2v-perms.json.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/mkzfg439svblpm27nj04cdkkpwx02r4x-rewrites.json.drv' failed to build
error:
       error: 3 dependencies of derivation '/nix/store/8b73q4knfd2pcqbqh3m66c83gi2krp9v-layers.json.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/myvwmicifgbrm9slmikn3ygw8bpxxw2k-closure-graph.json.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/4zpspac9gwpkhs2bysp8gl48yjg3ylxc-nix-database.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/rd9sq77263mypsl18acam97khjfda9f5-closure-graph.json.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/i9ggmgmhdv4h23k4icgwaahisxqvihic-perms.json.drv' failed to build
error:
       error: 1 dependencies of derivation '/nix/store/cxsiyikncja789xsz6zqc915lh82hxgm-rewrites.json.drv' failed to build
error:
       error: 4 dependencies of derivation '/nix/store/q7mdgmkgraj5f9jxhpgg1w5v8j55a22p-layers.json.drv' failed to build
error:
       error: 2 dependencies of derivation '/nix/store/69k5dsymwsdcmsjkld21rfaaga8bv19a-image-foobar-prod.json.drv' failed to build

✖ Command produced the following output:

✔ Building prod container in 2.3s.
Error:   × Command `/nix/store/4rfdww731kjc2yill1c17k1i94kwrp64-nix-2.21-devenv/bin/nix --show-trace
  │ --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-
  │ dirty false --option eval-cache false --keep-going --max-jobs 4 build --print-out-paths --no-
  │ link .#devenv.containers.prod.derivation --option extra-substituters https://devenv.cachix.org --option extra-
  │ trusted-public-keys devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=` failed with with exit
  │ code 1

Version

$ devenv version
devenv 1.0.7 (x86_64-linux)

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.39, NixOS, 24.05 (Uakari), 24.05.2780.53e81e790209`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.4`
 - channels(root): `"nixos-24.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

I think this is because mkHome is using cp -R ${path}/* $out${homeDir}/

ppenguin commented 2 months ago

Can confirm this bug. Additionally, you can only refer to files that are staged to the git repo (just like with normal flakes), which I think is a problem because you normally don't check in artefacts in git, so kind of a catch 22. More on that here

spost-qipath commented 1 week ago

This "can't copyToRoot an untracked file" kinda makes the whole "running artifacts" functionality pretty broken, doesn't it? Is there an example of that working end-to-end?