Switch to Nix Super
This commit is contained in:
parent
aa4552e7d1
commit
aef44bebf7
7 changed files with 35 additions and 211 deletions
31
flake.lock
31
flake.lock
|
@ -120,7 +120,27 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nix-super-unstable": {
|
"nix-super": {
|
||||||
|
"inputs": {
|
||||||
|
"nix": [
|
||||||
|
"nix-super-unstable-repin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1629553905,
|
||||||
|
"narHash": "sha256-HPv17qWWZjq19Ig7RRcJIZXP3AswOKNA6DmIzQBd2tU=",
|
||||||
|
"ref": "master",
|
||||||
|
"rev": "065bf6ab82cb63ee1c3f530110a1c7f9616f947c",
|
||||||
|
"revCount": 9,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.privatevoid.net/max/nix-super"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.privatevoid.net/max/nix-super"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix-super-unstable-repin": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"lowdown-src": "lowdown-src",
|
"lowdown-src": "lowdown-src",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
@ -128,11 +148,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1629453556,
|
"lastModified": 1629716742,
|
||||||
"narHash": "sha256-nlTEYae1JWor8cfazqLy39dzmtSgAttfjZXl3EajnTE=",
|
"narHash": "sha256-H+ISQ6m7YJFNbS1RnW14WAuKNRReEqL6y95UIJPAxAM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nix",
|
"repo": "nix",
|
||||||
"rev": "7a54b10a8a29dadea2bb2c639a15cfec25a4d38c",
|
"rev": "af94b54db3a2be100731a215cb5e95f306471731",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -163,7 +183,8 @@
|
||||||
"deploy-rs": "deploy-rs",
|
"deploy-rs": "deploy-rs",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"naersk": "naersk",
|
"naersk": "naersk",
|
||||||
"nix-super-unstable": "nix-super-unstable",
|
"nix-super": "nix-super",
|
||||||
|
"nix-super-unstable-repin": "nix-super-unstable-repin",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,8 +9,11 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
|
||||||
|
|
||||||
nix-super-unstable.url = "github:NixOS/nix";
|
nix-super.url = "git+https://git.privatevoid.net/max/nix-super";
|
||||||
nix-super-unstable.inputs.nixpkgs.follows = "nixpkgs";
|
nix-super.inputs.nix.follows = "nix-super-unstable-repin";
|
||||||
|
|
||||||
|
nix-super-unstable-repin.url = "github:NixOS/nix";
|
||||||
|
nix-super-unstable-repin.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
home-manager.url = "github:nix-community/home-manager/master";
|
home-manager.url = "github:nix-community/home-manager/master";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, inputs, ... }:
|
||||||
let
|
let
|
||||||
fixPriority = x: if config.services.hydra.enable
|
fixPriority = x: if config.services.hydra.enable
|
||||||
then lib.mkForce x
|
then lib.mkForce x
|
||||||
else x;
|
else x;
|
||||||
in {
|
in {
|
||||||
nix = {
|
nix = {
|
||||||
package = pkgs.nixUnstable;
|
package = inputs.nix-super.defaultPackage.${pkgs.system};
|
||||||
|
|
||||||
extraOptions = fixPriority ''
|
extraOptions = fixPriority ''
|
||||||
experimental-features = nix-command flakes ca-references
|
experimental-features = nix-command flakes ca-references
|
||||||
|
|
|
@ -3,17 +3,7 @@ in with tools;
|
||||||
{ inputs, pkgs, ... }: rec {
|
{ inputs, pkgs, ... }: rec {
|
||||||
deploy-rs = inputs.deploy-rs.packages.x86_64-linux.deploy-rs;
|
deploy-rs = inputs.deploy-rs.packages.x86_64-linux.deploy-rs;
|
||||||
|
|
||||||
nix-super-unstable = let
|
nix-super = inputs.nix-super.defaultPackage.x86_64-linux;
|
||||||
system = "x86_64-linux";
|
|
||||||
pkgs = import inputs.nixpkgs { inherit system;
|
|
||||||
overlays = [
|
|
||||||
inputs.nix-super-unstable.overlay
|
|
||||||
(self: super: rec {
|
|
||||||
nixSuperUnstable = patch-rename-direct super.nix (attrs: "nix-super-unstable-${attrs.version}") "patches/base/nix";
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in pkgs.nixSuperUnstable;
|
|
||||||
|
|
||||||
agenix = inputs.agenix.packages.x86_64-linux.agenix.override { nix = nix-super-unstable; };
|
agenix = inputs.agenix.packages.x86_64-linux.agenix.override { nix = nix-super; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
|
|
||||||
index 4e6bf4a9a..ab672f8be 100644
|
|
||||||
--- a/src/libcmd/installables.cc
|
|
||||||
+++ b/src/libcmd/installables.cc
|
|
||||||
@@ -20,6 +20,10 @@
|
|
||||||
|
|
||||||
namespace nix {
|
|
||||||
|
|
||||||
+const static std::regex attrPathRegex(
|
|
||||||
+ R"((?:[a-zA-Z0-9_"-][a-zA-Z0-9_".-]*))",
|
|
||||||
+ std::regex::ECMAScript);
|
|
||||||
+
|
|
||||||
void completeFlakeInputPath(
|
|
||||||
ref<EvalState> evalState,
|
|
||||||
const FlakeRef & flakeRef,
|
|
||||||
@@ -215,10 +219,19 @@ void completeFlakeRefWithFragment(
|
|
||||||
/* Look for flake output attributes that match the
|
|
||||||
prefix. */
|
|
||||||
try {
|
|
||||||
+ bool isAttrPath = std::regex_match(prefix.begin(), prefix.end(), attrPathRegex);
|
|
||||||
auto hash = prefix.find('#');
|
|
||||||
- if (hash != std::string::npos) {
|
|
||||||
- auto fragment = prefix.substr(hash + 1);
|
|
||||||
- auto flakeRefS = std::string(prefix.substr(0, hash));
|
|
||||||
+ if (isAttrPath || hash != std::string::npos) {
|
|
||||||
+ auto fragment =
|
|
||||||
+ isAttrPath
|
|
||||||
+ ? prefix
|
|
||||||
+ : prefix.substr(hash + 1);
|
|
||||||
+
|
|
||||||
+ auto flakeRefS =
|
|
||||||
+ isAttrPath
|
|
||||||
+ ? std::string("flake:default")
|
|
||||||
+ : std::string(prefix.substr(0, hash));
|
|
||||||
+
|
|
||||||
// FIXME: do tilde expansion.
|
|
||||||
auto flakeRef = parseFlakeRef(flakeRefS, absPath("."));
|
|
||||||
|
|
||||||
@@ -251,7 +264,10 @@ void completeFlakeRefWithFragment(
|
|
||||||
auto attrPath2 = attr->getAttrPath(attr2);
|
|
||||||
/* Strip the attrpath prefix. */
|
|
||||||
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
|
|
||||||
- completions->add(flakeRefS + "#" + concatStringsSep(".", attrPath2));
|
|
||||||
+ if (isAttrPath)
|
|
||||||
+ completions->add(concatStringsSep(".", attrPath2));
|
|
||||||
+ else
|
|
||||||
+ completions->add(flakeRefS + "#" + concatStringsSep(".", attrPath2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -626,7 +642,13 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
|
||||||
std::exception_ptr ex;
|
|
||||||
|
|
||||||
try {
|
|
||||||
- auto [flakeRef, fragment] = parseFlakeRefWithFragment(s, absPath("."));
|
|
||||||
+ bool isAttrPath = std::regex_match(s, attrPathRegex);
|
|
||||||
+
|
|
||||||
+ auto [flakeRef, fragment] =
|
|
||||||
+ isAttrPath
|
|
||||||
+ ? std::make_pair(parseFlakeRef("flake:default", absPath(".")), s)
|
|
||||||
+ : parseFlakeRefWithFragment(s, absPath("."));
|
|
||||||
+
|
|
||||||
result.push_back(std::make_shared<InstallableFlake>(
|
|
||||||
getEvalState(), std::move(flakeRef),
|
|
||||||
fragment == "" ? getDefaultFlakeAttrPaths() : Strings{fragment},
|
|
||||||
diff --git a/src/nix/search.cc b/src/nix/search.cc
|
|
||||||
index 9f864b3a4..b21118ece 100644
|
|
||||||
--- a/src/nix/search.cc
|
|
||||||
+++ b/src/nix/search.cc
|
|
||||||
@@ -30,13 +30,32 @@ std::string hilite(const std::string & s, const std::smatch & m, std::string pos
|
|
||||||
+ std::string(m.suffix());
|
|
||||||
}
|
|
||||||
|
|
||||||
-struct CmdSearch : InstallableCommand, MixJSON
|
|
||||||
+struct CmdSearch : SourceExprCommand, MixJSON
|
|
||||||
{
|
|
||||||
+ std::string _installable{"flake:default"};
|
|
||||||
std::vector<std::string> res;
|
|
||||||
|
|
||||||
CmdSearch()
|
|
||||||
{
|
|
||||||
- expectArgs("regex", &res);
|
|
||||||
+ bool hasInstallable = false;
|
|
||||||
+
|
|
||||||
+ addFlag({
|
|
||||||
+ .longName = "installable",
|
|
||||||
+ .shortName = 'i',
|
|
||||||
+ .description = "Search within this installable",
|
|
||||||
+ .labels = {"installable"},
|
|
||||||
+ .handler = {[this, &hasInstallable](std::string ss) {
|
|
||||||
+ hasInstallable = true;
|
|
||||||
+ _installable = ss;
|
|
||||||
+ }},
|
|
||||||
+ .completer = completePath
|
|
||||||
+ });
|
|
||||||
+
|
|
||||||
+ if (hasInstallable && (file || expr)) {
|
|
||||||
+ throw UsageError("'--installable' cannot be used together with '--file' or '--expr'");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ expectArgs("args", &res);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string description() override
|
|
||||||
@@ -63,6 +82,8 @@ struct CmdSearch : InstallableCommand, MixJSON
|
|
||||||
{
|
|
||||||
settings.readOnlyMode = true;
|
|
||||||
|
|
||||||
+ auto installable = parseInstallable(store, (file || expr) ? "" : _installable);
|
|
||||||
+
|
|
||||||
// Empty search string should match all packages
|
|
||||||
// Use "^" here instead of ".*" due to differences in resulting highlighting
|
|
||||||
// (see #1893 -- libc++ claims empty search string is not in POSIX grammar)
|
|
||||||
diff --git a/tests/flakes.sh b/tests/flakes.sh
|
|
||||||
index 2b7bcdd68..f654b2f36 100644
|
|
||||||
--- a/tests/flakes.sh
|
|
||||||
+++ b/tests/flakes.sh
|
|
||||||
@@ -188,7 +188,7 @@ nix build -o $TEST_ROOT/result flake1#foo
|
|
||||||
[[ -e $TEST_ROOT/result/hello ]]
|
|
||||||
|
|
||||||
# Test defaultPackage.
|
|
||||||
-nix build -o $TEST_ROOT/result flake1
|
|
||||||
+nix build -o $TEST_ROOT/result flake1#
|
|
||||||
[[ -e $TEST_ROOT/result/hello ]]
|
|
||||||
|
|
||||||
nix build -o $TEST_ROOT/result $flake1Dir
|
|
||||||
diff --git a/tests/search.sh b/tests/search.sh
|
|
||||||
index ee3261687..e41963c2d 100644
|
|
||||||
--- a/tests/search.sh
|
|
||||||
+++ b/tests/search.sh
|
|
||||||
@@ -3,23 +3,23 @@ source common.sh
|
|
||||||
clearStore
|
|
||||||
clearCache
|
|
||||||
|
|
||||||
-(( $(nix search -f search.nix '' hello | wc -l) > 0 ))
|
|
||||||
+(( $(nix search -f search.nix hello | wc -l) > 0 ))
|
|
||||||
|
|
||||||
# Check descriptions are searched
|
|
||||||
-(( $(nix search -f search.nix '' broken | wc -l) > 0 ))
|
|
||||||
+(( $(nix search -f search.nix broken | wc -l) > 0 ))
|
|
||||||
|
|
||||||
# Check search that matches nothing
|
|
||||||
-(( $(nix search -f search.nix '' nosuchpackageexists | wc -l) == 0 ))
|
|
||||||
+(( $(nix search -f search.nix nosuchpackageexists | wc -l) == 0 ))
|
|
||||||
|
|
||||||
# Search for multiple arguments
|
|
||||||
-(( $(nix search -f search.nix '' hello empty | wc -l) == 2 ))
|
|
||||||
+(( $(nix search -f search.nix hello empty | wc -l) == 2 ))
|
|
||||||
|
|
||||||
# Multiple arguments will not exist
|
|
||||||
-(( $(nix search -f search.nix '' hello broken | wc -l) == 0 ))
|
|
||||||
+(( $(nix search -f search.nix hello broken | wc -l) == 0 ))
|
|
||||||
|
|
||||||
## Search expressions
|
|
||||||
|
|
||||||
# Check that empty search string matches all
|
|
||||||
-nix search -f search.nix '' |grep -q foo
|
|
||||||
-nix search -f search.nix '' |grep -q bar
|
|
||||||
-nix search -f search.nix '' |grep -q hello
|
|
||||||
+nix search -f search.nix |grep -q foo
|
|
||||||
+nix search -f search.nix |grep -q bar
|
|
||||||
+nix search -f search.nix |grep -q hello
|
|
|
@ -1,15 +0,0 @@
|
||||||
diff --git a/src/nix/profile.cc b/src/nix/profile.cc
|
|
||||||
index 4d275f5..48e9625 100644
|
|
||||||
--- a/src/nix/profile.cc
|
|
||||||
+++ b/src/nix/profile.cc
|
|
||||||
@@ -453,9 +453,8 @@ struct CmdProfileList : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
|
|
||||||
|
|
||||||
for (size_t i = 0; i < manifest.elements.size(); ++i) {
|
|
||||||
auto & element(manifest.elements[i]);
|
|
||||||
- logger->cout("%d %s %s %s", i,
|
|
||||||
+ logger->cout("%03d %s\t%s", i,
|
|
||||||
element.source ? element.source->originalRef.to_string() + "#" + element.source->attrPath : "-",
|
|
||||||
- element.source ? element.source->resolvedRef.to_string() + "#" + element.source->attrPath : "-",
|
|
||||||
concatStringsSep(" ", store->printStorePathSet(element.storePaths)));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
|
|
||||||
index 2f0c468..492a7de 100644
|
|
||||||
--- a/src/nix/flake.cc
|
|
||||||
+++ b/src/nix/flake.cc
|
|
||||||
@@ -574,8 +574,6 @@ struct CmdFlakeCheck : FlakeCommand
|
|
||||||
*attr.value, *attr.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
- else
|
|
||||||
- warn("unknown flake output '%s'", name);
|
|
||||||
|
|
||||||
} catch (Error & e) {
|
|
||||||
e.addTrace(pos, hintfmt("while checking flake output '%s'", name));
|
|
Loading…
Reference in a new issue