Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flags to override the lockfile #2943

Closed
wants to merge 2 commits into from

Conversation

CSVdB
Copy link
Contributor

@CSVdB CSVdB commented Jun 12, 2019

Fixes #2837

tests/flakes.sh Outdated
@@ -274,3 +274,5 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake3:sth
mv $flake2Dir.tmp $flake2Dir
mv $nonFlakeDir.tmp $nonFlakeDir
nix build -o $TEST_ROOT/result --flake-registry $registry flake3:xyzzy flake3:fnord

(! nix build -o $TEST_ROOT/result --flake-registry $registry flake3:xyzzy --override-lockfile flake2 flake1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add some tests that succeed? Otherwise we won't notice if --override-lockfile is completely broken :-)

src/nix/build.cc Outdated
@@ -55,6 +55,7 @@ struct CmdBuild : MixDryRun, InstallablesCommand

auto evalState = std::make_shared<EvalState>(searchPath, store);
evalState->addRegistryOverrides(registryOverrides);
evalState->addLockFileOverrides(lockFileOverrides);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be changed to use getEvalState(), then we don't need any special handling in CmdBuild anymore.

.description("override a lockfile value")
.arity(2)
.handler([&](std::vector<std::string> ss) {
lockFileOverrides.insert_or_assign(FlakeRef(ss[0]), FlakeRef(ss[1]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be added to EvalCommand rather than MixEvalArgs. The latter is also used by legacy commands (nix-env etc) which don't implement flake-related stuff.

@CSVdB
Copy link
Contributor Author

CSVdB commented Jun 18, 2019

Fixed

tests/config.nix Outdated
PATH = path;
} // removeAttrs args ["builder" "meta"])
// { meta = args.meta or {}; };
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/config.nix added accidentally again. Feel free to add it to .gitignore.

Copy link
Member

@edolstra edolstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently using --override-lockfile causes the lockfile to be rewritten, which I think is not what we want. Otherwise you would just use --override-flake ... --recreate-lock-file.

For example, in a clone of NixOS/nixos-homepage/flake, I get:

$ /nix build --override-lockfile nixpkgs github:edolstra/nixpkgs/77baa898afa0fab609598a91dc150da825207d27 
... some expected errors ...

$ git diff --staged
diff --git a/flake.lock b/flake.lock
index df97306..5281849 100644
--- a/flake.lock
+++ b/flake.lock
@@ -48,9 +48,9 @@
         "nixpkgs": {
             "id": "nixpkgs",
             "inputs": {},
-            "narHash": "sha256-HQ/wXOy6POACr5BIDoUeFYThgqHxtVfrXVQi95yIljw=",
+            "narHash": "sha256-/BKIFPqT2qqHCvaLXRxoEtMypIL/Hrg95SXGzwZkDmg=",
             "nonFlakeInputs": {},
-            "uri": "github:edolstra/nixpkgs/a0e1f50e6f72e5037d71a0b65c67cf0605349a06"
+            "uri": "github:edolstra/nixpkgs/77baa898afa0fab609598a91dc150da825207d27"
         }
     },
     "nonFlakeInputs": {},

@@ -1,6 +1,7 @@
#pragma once

#include "args.hh"
#include "flake/flakeref.hh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This #include is unnecessary here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can take the import away here and add it to nix/command.hh, where it's needed to define the registry and lockfile overrides in EvalCommand.

@@ -6,6 +6,7 @@
#include "symbol-table.hh"
#include "hash.hh"
#include "config.hh"
#include "flake/flakeref.hh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is necessary here, the FlakeRef concept is used now because registryOverrides are stored in the EvalState.

});

mkFlag()
.longName("override-lockfile")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think --override-lock is a better name, since we're overriding a specific lock, not an entire lockfile.

@CSVdB CSVdB closed this Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants