Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into lazy-trees
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Nov 22, 2024
2 parents 355cb56 + feb4668 commit 250813a
Show file tree
Hide file tree
Showing 56 changed files with 689 additions and 521 deletions.
50 changes: 34 additions & 16 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
---
name: Bug report
about: Create a report to help us improve
about: Report unexpected or incorrect behaviour
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
## Describe the bug

A clear and concise description of what the bug is.
<!--
A clear and concise description of what the bug is.
If you have a problem with a specific package or NixOS,
you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues.
If you have a problem with a specific package or NixOS,
you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues.
-->

**Steps To Reproduce**
## Steps To Reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
<!--
Example:
**Expected behavior**
1. Clone this repository: ...
2. Run `nix-... ...`
3. Observe unexpected behaviour
-->

A clear and concise description of what you expected to happen.
## Expected behavior

**`nix-env --version` output**
<!-- A clear and concise description of what you expected to happen. -->

**Additional context**
## Metadata

Add any other context about the problem here.
<!-- Please insert the output of running `nix-env --version` below this line -->

**Priorities**
## Additional context

<!-- Add any other context about the problem here. -->

## Checklist

<!-- make sure this issue is not redundant or obsolete -->

- [ ] checked [latest Nix manual] \([source])
- [ ] checked [open bug issues and pull requests] for possible duplicates

[latest Nix manual]: https://nixos.org/manual/nix/unstable/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug

---

Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
35 changes: 25 additions & 10 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
---
name: Feature request
about: Suggest an idea for this project
about: Suggest a new feature
title: ''
labels: feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
## Is your feature request related to a problem?

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
## Proposed solution

**Additional context**
Add any other context or screenshots about the feature request here.
<!-- A clear and concise description of what you want to happen. -->

**Priorities**
## Alternative solutions

<!-- A clear and concise description of any alternative solutions or features you've considered. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->

## Checklist

<!-- make sure this issue is not redundant or obsolete -->

- [ ] checked [latest Nix manual] \([source])
- [ ] checked [open feature issues and pull requests] for possible duplicates

[latest Nix manual]: https://nixos.org/manual/nix/unstable/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open feature issues and pull requests]: https://github.com/NixOS/nix/labels/feature

---

Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
17 changes: 14 additions & 3 deletions .github/ISSUE_TEMPLATE/installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@ assignees: ''

<details><summary>Output</summary>

```log
<!-- paste console output inside the below code block -->

<!-- paste console output here and remove this comment -->
```log
```

</details>

## Priorities
## Checklist

<!-- make sure this issue is not redundant or obsolete -->

- [ ] checked [latest Nix manual] \([source])
- [ ] checked [open installer issues and pull requests] for possible duplicates

[latest Nix manual]: https://nixos.org/manual/nix/unstable/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open installer issues and pull requests]: https://github.com/NixOS/nix/labels/installer

---

Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/missing_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ assignees: ''
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open documentation issues and pull requests]: https://github.com/NixOS/nix/labels/documentation

## Priorities
---

Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
8 changes: 5 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ so you understand the process and the expectations.
-->

# Motivation
## Motivation

<!-- Briefly explain what the change is about and why it is desirable. -->

# Context
## Context

<!-- Provide context. Reference open issues if available. -->

<!-- Non-trivial change: Briefly outline the implementation strategy. -->
Expand All @@ -29,7 +31,7 @@ so you understand the process and the expectations.

<!-- Large change: Provide instructions to reviewers how to read the diff. -->

# Priorities and Process
---

Add :+1: to [pull requests you find important](https://github.com/NixOS/nix/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc).

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ jobs:
path: flake-regressions/tests
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix build --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
22 changes: 22 additions & 0 deletions build-utils-meson/common/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is only conditional to work around
# https://github.com/mesonbuild/meson/issues/13293. It should be
# unconditional.
if not (host_machine.system() == 'windows' and cxx.get_id() == 'gcc')
deps_private += dependency('threads')
endif

add_project_arguments(
'-Wdeprecated-copy',
'-Werror=suggest-override',
'-Werror=switch',
'-Werror=switch-enum',
'-Werror=unused-result',
'-Wignored-qualifiers',
'-Wimplicit-fallthrough',
'-Wno-deprecated-declarations',
language : 'cpp',
)

if get_option('buildtype') not in ['debug']
add_project_arguments('-O3', language : 'cpp')
endif
11 changes: 0 additions & 11 deletions build-utils-meson/diagnostics/meson.build

This file was deleted.

6 changes: 0 additions & 6 deletions build-utils-meson/threads/meson.build

This file was deleted.

18 changes: 18 additions & 0 deletions doc/manual/rl-next/nix-copy-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
synopsis: "`nix copy` supports `--profile` and `--out-link`"
prs: [11657]
---

The `nix copy` command now has flags `--profile` and `--out-link`, similar to `nix build`. `--profile` makes a profile point to the
top-level store path, while `--out-link` create symlinks to the top-level store paths.

For example, when updating the local NixOS system profile from a NixOS system closure on a remote machine, instead of
```
# nix copy --from ssh://server $path
# nix build --profile /nix/var/nix/profiles/system $path
```
you can now do
```
# nix copy --from ssh://server --profile /nix/var/nix/profiles/system $path
```
The advantage is that this avoids a time window where *path* is not a garbage collector root, and so could be deleted by a concurrent `nix store gc` process.
33 changes: 27 additions & 6 deletions doc/manual/source/command-ref/nix-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ All options not listed here are passed to `nix-store
cleared before the interactive shell is started, so you get an
environment that more closely corresponds to the “real” Nix build. A
few variables, in particular `HOME`, `USER` and `DISPLAY`, are
retained.
retained. Note that the shell used to run commands is obtained from
[`NIX_BUILD_SHELL`](#env-NIX_BUILD_SHELL) / `<nixpkgs>` from
`NIX_PATH`, and therefore not affected by `--pure`.

- `--packages` / `-p` *packages*

Expand All @@ -112,11 +114,30 @@ All options not listed here are passed to `nix-store

# Environment variables

- `NIX_BUILD_SHELL`

Shell used to start the interactive environment. Defaults to the
`bash` found in `<nixpkgs>`, falling back to the `bash` found in
`PATH` if not found.
- <span id="env-NIX_BUILD_SHELL">[`NIX_BUILD_SHELL`](#env-NIX_BUILD_SHELL)</span>

Shell used to start the interactive environment.
Defaults to the `bash` from `bashInteractive` found in `<nixpkgs>`, falling back to the `bash` found in `PATH` if not found.

> **Note**
>
> The shell obtained using this method may not necessarily be the same as any shells requested in *path*.
<!-- -->

> **Example
>
> Despite `--pure`, this invocation will not result in a fully reproducible shell environment:
>
> ```nix
> #!/usr/bin/env -S nix-shell --pure
> let
> pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/854fdc68881791812eddd33b2fed94b954979a8e.tar.gz") {};
> in
> pkgs.mkShell {
> buildInputs = pkgs.bashInteractive;
> }
> ```
{{#include ./env-common.md}}
Expand Down
49 changes: 40 additions & 9 deletions src/libcmd/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,41 +179,45 @@ BuiltPathsCommand::BuiltPathsCommand(bool recursive)

void BuiltPathsCommand::run(ref<Store> store, Installables && installables)
{
BuiltPaths paths;
BuiltPaths rootPaths, allPaths;

if (all) {
if (installables.size())
throw UsageError("'--all' does not expect arguments");
// XXX: Only uses opaque paths, ignores all the realisations
for (auto & p : store->queryAllValidPaths())
paths.emplace_back(BuiltPath::Opaque{p});
rootPaths.emplace_back(BuiltPath::Opaque{p});
allPaths = rootPaths;
} else {
paths = Installable::toBuiltPaths(getEvalStore(), store, realiseMode, operateOn, installables);
rootPaths = Installable::toBuiltPaths(getEvalStore(), store, realiseMode, operateOn, installables);
allPaths = rootPaths;

if (recursive) {
// XXX: This only computes the store path closure, ignoring
// intermediate realisations
StorePathSet pathsRoots, pathsClosure;
for (auto & root : paths) {
for (auto & root : rootPaths) {
auto rootFromThis = root.outPaths();
pathsRoots.insert(rootFromThis.begin(), rootFromThis.end());
}
store->computeFSClosure(pathsRoots, pathsClosure);
for (auto & path : pathsClosure)
paths.emplace_back(BuiltPath::Opaque{path});
allPaths.emplace_back(BuiltPath::Opaque{path});
}
}

run(store, std::move(paths));
run(store, std::move(allPaths), std::move(rootPaths));
}

StorePathsCommand::StorePathsCommand(bool recursive)
: BuiltPathsCommand(recursive)
{
}

void StorePathsCommand::run(ref<Store> store, BuiltPaths && paths)
void StorePathsCommand::run(ref<Store> store, BuiltPaths && allPaths, BuiltPaths && rootPaths)
{
StorePathSet storePaths;
for (auto & builtPath : paths)
for (auto & builtPath : allPaths)
for (auto & p : builtPath.outPaths())
storePaths.insert(p);

Expand Down Expand Up @@ -245,7 +249,7 @@ void MixProfile::updateProfile(const StorePath & storePath)
{
if (!profile)
return;
auto store = getStore().dynamic_pointer_cast<LocalFSStore>();
auto store = getDstStore().dynamic_pointer_cast<LocalFSStore>();
if (!store)
throw Error("'--profile' is not supported for this Nix store");
auto profile2 = absPath(*profile);
Expand Down Expand Up @@ -365,4 +369,31 @@ void MixEnvironment::setEnviron()
return;
}

void createOutLinks(const std::filesystem::path & outLink, const BuiltPaths & buildables, LocalFSStore & store)
{
for (const auto & [_i, buildable] : enumerate(buildables)) {
auto i = _i;
std::visit(
overloaded{
[&](const BuiltPath::Opaque & bo) {
auto symlink = outLink;
if (i)
symlink += fmt("-%d", i);
store.addPermRoot(bo.path, absPath(symlink.string()));
},
[&](const BuiltPath::Built & bfd) {
for (auto & output : bfd.outputs) {
auto symlink = outLink;
if (i)
symlink += fmt("-%d", i);
if (output.first != "out")
symlink += fmt("-%s", output.first);
store.addPermRoot(output.second, absPath(symlink.string()));
}
},
},
buildable.raw());
}
}

}
Loading

0 comments on commit 250813a

Please sign in to comment.