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

Add first build information in section of working with local files #1025

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions source/tutorials/working-with-local-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,31 @@ One way to fix this is to use [`unions`](https://nixos.org/manual/nixpkgs/stable

Create a file set containing a union of the files to exclude (`fs.unions [ ... ]`), and subtract it (`difference`) from the complete directory (`./.`):

```{code-block} nix
```{code-block} diff
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't always have to make it a difference. There's no firm rule, but I tried making it a diff where it's a small change - in order to highlight that - and have a full file, like here, where it's essentially a new thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

11c9f26
Ok, I remove code defferences and change the description of PR.

:caption: build.nix
sourceFiles =
fs.difference
./.
(fs.unions [
(fs.maybeMissing ./result)
./default.nix
./build.nix
./npins
]);
- sourceFiles = fs.difference ./. (fs.maybeMissing ./result);
+ sourceFiles =
+ fs.difference
+ ./.
+ (fs.unions [
+ (fs.maybeMissing ./result)
+ ./default.nix
+ ./build.nix
+ ./npins
+ ]);
```

This will work as expected.

```
$ nix-build
trace: /home/user/fileset
trace: - hello.txt (regular)
trace: - world.txt (regular)
this derivation will be built:
/nix/store/gr2hw3gdjc28fmv0as1ikpj7lya4r51f-fileset.drv
...
/nix/store/ckn40y7hgqphhbhyrq64h9r6rvdh973r-fileset
```

Changing any of the excluded files now doesn't necessarily cause a new build anymore:
Expand Down