aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2022-08-17Fix onErrorEelco Dolstra
2022-08-03tests/check.sh: add nix3-build check testFélix Baylac-Jacqué
2022-07-18Merge pull request #6784 from tweag/completion-testThéophane Hufschmitt
Add some tests for the CLI completion
2022-07-14On test failures, print a bash stack traceEelco Dolstra
This makes it easier to identify what command failed. It looks like: follow-paths.sh: test failed at: main in follow-paths.sh:54
2022-07-13Split off 'nix flake check' testsEelco Dolstra
2022-07-13Move flake-searching.sh and make it less dependent on gitEelco Dolstra
2022-07-13Move flake-local-settings.shEelco Dolstra
2022-07-13Move the 'nix bundle' testsEelco Dolstra
Note: these were previously not actually called.
2022-07-13Split off following paths testsEelco Dolstra
2022-07-13Split off 'nix flake init' testsEelco Dolstra
2022-07-13Split off the circular flake import testsEelco Dolstra
2022-07-13Split off the Mercurial flake testsEelco Dolstra
2022-07-13Move flakes tests to a subdirectoryEelco Dolstra
2022-07-13Merge pull request #6797 from edolstra/overrides-checkEelco Dolstra
Simplify the check for overrides on non-existent inputs
2022-07-13tests/flakes.sh: Make sure flake7 is cleanEelco Dolstra
Cherry-picked from the lazy-trees branch, where we no longer write a lock file if any of the inputs is dirty.
2022-07-13Simplify the check for overrides on non-existent inputsEelco Dolstra
2022-07-13Add some more completion testsThéophane Hufschmitt
- Test another command than `build` - Test with two input flakes
2022-07-13Fix the “out of order” completion testThéophane Hufschmitt
`--override-input` id snarky because it takes two arguments, so it doesn't play well when completed in the middle of the CLI (since the argument just after gets interpreted as its second argument). So use `--update-input` instead
2022-07-12Turn error for non-existant follows into a warningMaximilian Bosch
2022-07-12flakes: throw an error if `follows`-declaration for an input is invalidMaximilian Bosch
I recently got fairly confused why the following expression didn't have any effect { description = "Foobar"; inputs.sops-nix = { url = github:mic92/sops-nix; inputs.nixpkgs_22_05.follows = "nixpkgs"; }; } until I found out that the input was called `nixpkgs-22_05` (please note the dash vs. underscore). IMHO it's not a good idea to not throw an error in that case and probably leave end-users rather confused, so I implemented a small check for that which basically checks whether `follows`-declaration from overrides actually have corresponding inputs in the transitive flake. In fact this was done by accident already in our own test-suite where the removal of a `follows` was apparently forgotten[1]. Since the key of the `std::map` that holds the `overrides` is a vector and we have to find the last element of each vector (i.e. the override) this has to be done with a for loop in O(n) complexity with `n` being the total amount of overrides (which shouldn't be that large though). Please note that this doesn't work with nested expressions, i.e. inputs.fenix.inputs.nixpkgs.follows = "..."; which is a known problem[2]. For the expression demonstrated above, an error like this will be thrown: error: sops-nix has a `follows'-declaration for a non-existant input nixpkgs_22_05! [1] 2664a216e57169ec57d7f51be1b8383c1be83fd5 [2] https://github.com/NixOS/nix/issues/5790
2022-07-12Test the tilde expansion for the flake completionThéophane Hufschmitt
Also add a disabled test for when the `--override-input` flag comes *before* the flake ref
2022-07-12Harden the comparisons in the completion testThéophane Hufschmitt
- Don't use `printf` for the expected result, but just use bash's `$' '` litteral strings - Quote the `nix` call result - Invert the order in the comparisons (just because it feels more natural)
2022-07-12Fix the name of the completions testThéophane Hufschmitt
2022-07-12Add some tests for the CLI completionThéophane Hufschmitt
2022-07-05Add builtins.traceVerboseGytis Ivaskevicius
Co-Authored-By: Silvan Mosberger <contact@infinisil.com> Add builtins.traceVerbose tests
2022-07-05Merge pull request #6664 from Ma27/innixshell-backwards-compatThéophane Hufschmitt
nix-shell: restore backwards-compat with old nixpkgs
2022-06-29Merge pull request #6699 from tennox/better-flake-new-error-messageThéophane Hufschmitt
flakes: apply templates partially on conflicts
2022-06-29Merge pull request #6233 from flox/nix-repl-flakesThéophane Hufschmitt
Nix repl flakes
2022-06-29Add some test for `nix flake init` with conflictsThéophane Hufschmitt
2022-06-25Merge pull request #6717 from edolstra/move-flake-registryEelco Dolstra
Fetch flake-registry.json from channels.nixos.org
2022-06-24tests: enable ca-derivations for simple.nix in repl testsTom Bereknyei
2022-06-24Merge pull request #6698 from tweag/forbid-tilde-paths-in-pure-modeThéophane Hufschmitt
Forbid the tilde expansion in pure eval mode
2022-06-23Fetch flake-registry.json from channels.nixos.orgEelco Dolstra
Using fastly is slightly faster, provides some resilience due to a high stale TTL, and allows some usage metrics.
2022-06-22Enable/fix tests in nix-staticEelco Dolstra
pkgsStatic is apparently considered a cross environment, so checkPhase and installCheckPhase are disabled even when we ask for them.
2022-06-22tests/nix-shell: more meaningful testcaseMaximilian Bosch
2022-06-21Forbid the tilde expansion in pure eval modeThéophane Hufschmitt
Fix #6684
2022-06-20Add another test for `--exclude` in `nix search`Fishhh
2022-06-15Merge branch 'master' into nix-repl-flakesTom Bereknyei
2022-06-13nix-shell: restore backwards-compat with old nixpkgsMaximilian Bosch
Basically an attempt to resume fixing #5543 for a breakage introduced earlier[1]. Basically, when evaluating an older `nixpkgs` with `nix-shell` the following error occurs: λ ma27 [~] → nix-shell -I nixpkgs=channel:nixos-18.03 -p nix error: anonymous function at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/default.nix:20:1 called with unexpected argument 'inNixShell' at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/impure.nix:82:1: 81| 82| import ./. (builtins.removeAttrs args [ "system" "platform" ] // { | ^ 83| inherit config overlays crossSystem; This is a problem because one of the main selling points of Nix is that you can evaluate any old Nix expression and still get the same result (which also means that it *still evaluates*). In fact we're deprecating, but not removing a lot of stuff for that reason such as unquoted URLs[2] or `builtins.toPath`. However this property was essentially thrown away here. The change is rather simple: check if `inNixShell` is specified in the formals of an auto-called function. This means that { inNixShell ? false }: builtins.trace inNixShell (with import <nixpkgs> { }; makeShell { name = "foo"; }) will show `trace: true` while args@{ ... }: builtins.trace args.inNixShell (with import <nixpkgs> { }; makeShell { name = "foo"; }) will throw the following error: error: attribute 'inNixShell' missing This is explicitly needed because the function in `pkgs/top-level/impure.nix` of e.g. NixOS 18.03 has an ellipsis[3], but passes the attribute-set on to another lambda with formals that doesn't have an ellipsis anymore (hence the error from above). This was perhaps a mistake, but we can't fix it anymore. This also means that there's AFAICS no proper way to check if the attr-set that's passed to the Nix code via `EvalState::autoCallFunction` is eventually passed to a lambda with formals where `inNixShell` is missing. However, this fix comes with a certain price. Essentially every `shell.nix` that assumes `inNixShell` to be passed to the formals even without explicitly specifying it would break with this[4]. However I think that this is ugly, but preferable: * Nix 2.3 was declared stable by NixOS up until recently (well, it still is as long as 21.11 is alive), so most people might not have even noticed that feature. * We're talking about a way shorter time-span with this change being in the wild, so the fallout should be smaller IMHO. [1] https://github.com/NixOS/nix/commit/9d612c393abc3a73590650d24bcfe2ee57792872 [2] https://github.com/NixOS/rfcs/pull/45#issuecomment-488232537 [3] https://github.com/NixOS/nixpkgs/blob/release-18.03/pkgs/top-level/impure.nix#L75 [4] See e.g. the second expression in this commit-message or the changes for `tests/ca/nix-shell.sh`.
2022-06-13Merge pull request #6027 from Ma27/pure-replEelco Dolstra
repl: `--option pure-eval true` actually enables pure eval mode
2022-06-11fix sourcehut brach/tag resolving regressionGabriel Fontes
nixos/nix#6290 introduced a regex pattern to account for tags when resolving sourcehut refs. nixos/nix#4638 reafactored the code, accidentally treating the pattern as a regular string, causing all non-HEAD ref resolving to break. This fixes the regression and adds more test cases to avoid future breakage.
2022-06-07Merge pull request #6618 from afishhh/search-excludeEelco Dolstra
Add `-e`/`--exclude` flag to `nix search`
2022-06-07Use `grep -c` instead of `grep|wc -l` in some `nix search` testsFishhh
2022-06-07Add tests for `--exclude` flag in `nix search`Fishhh
2022-06-07Merge pull request #6598 from cole-h/update-flake-for-realEelco Dolstra
flake: update to 22.05
2022-06-07Fix 22.05 eval warningsEelco Dolstra
2022-06-02Merge branch 'master' into nix-repl-flakesTom Bereknyei
2022-06-02TypoEelco Dolstra
2022-06-02tests/flakes.sh: Fix some ignored breakageEelco Dolstra
2022-05-31repl: `--option pure-eval true` actually enables pure eval modeMaximilian Bosch
To quote Eelco in #5867: > Unfortunately we can't do > > evalSettings.pureEval.setDefault(false); > > because then we have to do the same in main.cc (where > pureEval is set to true), and that would allow pure-eval > to be disabled globally from nix.conf. Instead, a command should specify that it should be impure by default. Then, `evalSettings.pureEval` will be set to `false;` unless it's overridden by e.g. a CLI flag. In that case it's IMHO OK to be (theoretically) able to override `pure-eval` via `nix.conf` because it doesn't have an effect on commands where `forceImpureByDefault` returns `false` (i.e. everything where pure eval actually matters). Closes #5867