-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61a807a
commit f79638a
Showing
3 changed files
with
29 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
From 4ab398fd9629c8ddeec7ca4f43747beac444d2b3 Mon Sep 17 00:00:00 2001 | ||
From 65e47fd58d933b75a2e75777eb36e28873d98be3 Mon Sep 17 00:00:00 2001 | ||
From: isabel <[email protected]> | ||
Date: Mon, 2 Dec 2024 17:48:34 +0000 | ||
Date: Thu, 5 Dec 2024 17:05:38 +0000 | ||
Subject: [PATCH] feat(cli): add callPackage flag | ||
|
||
adds a --call-package or -C cli option to build a package from the cli | ||
|
@@ -11,7 +11,7 @@ based on the work of https://github.com/privatevoid-net/nix-super | |
2 files changed, 22 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/lix/libcmd/command.hh b/lix/libcmd/command.hh | ||
index 0f9ec66e7..1617afb5c 100644 | ||
index 478032116..40ee997db 100644 | ||
--- a/lix/libcmd/command.hh | ||
+++ b/lix/libcmd/command.hh | ||
@@ -111,6 +111,7 @@ struct SourceExprCommand : virtual Args, MixFlakeOptions | ||
|
@@ -23,7 +23,7 @@ index 0f9ec66e7..1617afb5c 100644 | |
SourceExprCommand(); | ||
|
||
diff --git a/lix/libcmd/installables.cc b/lix/libcmd/installables.cc | ||
index 1a51a36d3..ec2df929f 100644 | ||
index 700f5115a..8141d6ab4 100644 | ||
--- a/lix/libcmd/installables.cc | ||
+++ b/lix/libcmd/installables.cc | ||
@@ -165,6 +165,19 @@ SourceExprCommand::SourceExprCommand() | ||
|
@@ -46,7 +46,7 @@ index 1a51a36d3..ec2df929f 100644 | |
} | ||
|
||
MixReadOnlyOption::MixReadOnlyOption() | ||
@@ -426,12 +439,12 @@ Installables SourceExprCommand::parseInstallables( | ||
@@ -428,12 +441,12 @@ Installables SourceExprCommand::parseInstallables( | ||
{ | ||
Installables result; | ||
|
||
|
@@ -58,22 +58,22 @@ index 1a51a36d3..ec2df929f 100644 | |
+ throw UsageError("'--file', '--expr' and '--call-package' are exclusive"); | ||
|
||
// FIXME: backward compatibility hack | ||
- if (file) evalSettings.pureEval.override(false); | ||
+ if (file || callPackageFile) evalSettings.pureEval.override(false); | ||
|
||
auto state = getEvalState(); | ||
auto vFile = state->mem.allocValue(); | ||
@@ -442,6 +455,10 @@ Installables SourceExprCommand::parseInstallables( | ||
- if (file) { | ||
+ if (file || callPackageFile) { | ||
evalSettings.pureEval.override(false); | ||
getEvalState()->paths.allowedPaths.reset(); | ||
} | ||
@@ -447,6 +460,10 @@ Installables SourceExprCommand::parseInstallables( | ||
} | ||
else if (file) | ||
state->evalFile(lookupFileArg(*state, *file), *vFile); | ||
state.evalFile(lookupFileArg(state, *file), *vFile); | ||
+ else if (callPackageFile) { | ||
+ auto & e = state->parseExprFromString(fmt("(import <nixpkgs> {}).callPackage %s {}", CanonPath::fromCwd(*callPackageFile)), CanonPath::fromCwd()); | ||
+ state->eval(e, *vFile); | ||
+ auto & e = state.parseExprFromString(fmt("(import <nixpkgs> {}).callPackage %s {}", CanonPath::fromCwd(*callPackageFile)), CanonPath::fromCwd()); | ||
+ state.eval(e, *vFile); | ||
+ } | ||
else { | ||
auto & e = state->parseExprFromString(*expr, CanonPath::fromCwd()); | ||
state->eval(e, *vFile); | ||
auto & e = state.parseExprFromString(*expr, CanonPath::fromCwd()); | ||
state.eval(e, *vFile); | ||
-- | ||
2.44.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
From 078f184a1cf98bd435370c826eb268081fd47008 Mon Sep 17 00:00:00 2001 | ||
From b89d3ff243691d2b2d108fef9ad5fe931042aed1 Mon Sep 17 00:00:00 2001 | ||
From: isabel <[email protected]> | ||
Date: Wed, 4 Dec 2024 21:49:25 +0000 | ||
Date: Thu, 5 Dec 2024 17:33:24 +0000 | ||
Subject: [PATCH] feat(builtins): pow | ||
--- | ||
lix/libexpr/builtins/pow.md | 5 +++++ | ||
lix/libexpr/meson.build | 1 + | ||
lix/libexpr/primops.cc | 21 +++++++++++++++++++++ | ||
3 files changed, 27 insertions(+) | ||
lix/libexpr/primops.cc | 10 ++++++++++ | ||
3 files changed, 16 insertions(+) | ||
create mode 100644 lix/libexpr/builtins/pow.md | ||
|
||
diff --git a/lix/libexpr/builtins/pow.md b/lix/libexpr/builtins/pow.md | ||
|
@@ -33,10 +33,10 @@ index dcbc12e7d..47442c22c 100644 | |
'builtins/readFile.md', | ||
'builtins/readFileType.md', | ||
diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc | ||
index 7b9ea06cc..ca69a2fe0 100644 | ||
index 328ce250b..45b3589d1 100644 | ||
--- a/lix/libexpr/primops.cc | ||
+++ b/lix/libexpr/primops.cc | ||
@@ -2420,6 +2420,27 @@ static void prim_div(EvalState & state, const PosIdx pos, Value * * args, Value | ||
@@ -2425,6 +2425,16 @@ static void prim_div(EvalState & state, const PosIdx pos, Value * * args, Value | ||
} | ||
} | ||
|
||
|
@@ -45,20 +45,9 @@ index 7b9ea06cc..ca69a2fe0 100644 | |
+ state.forceValue(*args[0], pos); | ||
+ state.forceValue(*args[1], pos); | ||
+ | ||
+ if (args[0]->type() == nFloat || args[1]->type() == nFloat) { | ||
+ NixFloat f1 = state.forceFloat(*args[0], pos, "while evaluating the first operand of the exponentiation"); | ||
+ NixFloat f2 = state.forceFloat(*args[1], pos, "while evaluating the second operand of the exponentiation"); | ||
+ v.mkFloat(std::pow(f1, f2)); | ||
+ } else { | ||
+ auto i1 = state.forceInt(*args[0], pos, "while evaluating the first operand of the exponentiation"); | ||
+ auto i2 = state.forceInt(*args[1], pos, "while evaluating the second operand of the exponentiation"); | ||
+ | ||
+ if (i2 < 0) | ||
+ state.error<EvalError>("negative exponent in %1% ^ %2%", i1, i2).atPos(pos).debugThrow(); | ||
+ | ||
+ auto result = std::pow(i1.value, i2.value); | ||
+ v.mkInt(result); | ||
+ } | ||
+ NixFloat f1 = state.forceFloat(*args[0], pos, "while evaluating the first operand of the exponentiation"); | ||
+ NixFloat f2 = state.forceFloat(*args[1], pos, "while evaluating the second operand of the exponentiation"); | ||
+ v.mkFloat(std::pow(f1, f2)); | ||
+} | ||
+ | ||
static void prim_bitAnd(EvalState & state, const PosIdx pos, Value * * args, Value & v) | ||
|