dream2nix
dream2nix copied to clipboard
document ```Alternatively `nix run` the .lock attribute of your package.```
using the ml example
following the bash command works, but im interested in how to
nix run
the .lock attribute of your package.
[lizelive@reese:/tmp/experment.a9d]$ nix run --impure #someproject.lock
warning: Git tree '/tmp/experment.a9d' is dirty
error:
… while calling the 'head' builtin
at /nix/store/g68f5abh3xhcz8xsdlfw7wkgkkcx3nwy-source/lib/attrsets.nix:820:11:
819| || pred here (elemAt values 1) (head values) then
820| head values
| ^
821| else
… while evaluating the attribute 'value'
at /nix/store/g68f5abh3xhcz8xsdlfw7wkgkkcx3nwy-source/lib/modules.nix:807:9:
806| in warnDeprecation opt //
807| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
808| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: The lock file ./lock.json
for drv-parts module 'someproject' is missing.
To create or update the lock file, run:
bash -c $(nix-build /nix/store/9g39yk3ic1iqgn8b34cqsyn0g5gfvcw6-refresh.drv --no-link)/bin/refresh
Alternatively `nix run` the .lock attribute of your package.
nix run --impure #someproject.lock
Ah, that's confusing. The packages name is "someproject", but if you take a look at nix flake show
you'll see that the attribute is named 'default', so
nix run .#default.lock
should work (and does on my machine). No need to use --impure as nix run commands are impure anyways.
We could add an option 'paths.flakeAttrPath' which, when set, would improve the error message to be more specific.
I think in this specific case it might suffice to rename the packages attribute from default to "myproject" which could arguably be less confusing. What would you think of that?
Hm, that would imply modifying the flake. Currently all the single-package examples share the exact same flake.nix and I like to keep it that way to simplify maintenance.
Maybe the confusing part is that the lock update script is not a separate flake output itself that can be discovered by nix flake show. We could add an app to all the flakes, which iterates over all packages and updates them. Or a dream2nix devShell wirh a cmdline tool that is capable of doing that