Skip to content

Commit

Permalink
Merge pull request #482 from imincik/nix-build-all
Browse files Browse the repository at this point in the history
utils: add nix-build-all script
  • Loading branch information
imincik authored May 3, 2024
2 parents ea4d6eb + 26804ea commit 3579988
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
45 changes: 17 additions & 28 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,22 @@
## Building packages

* Build single package
```
```bash
nix build .#<PACKAGE>
```

* Build all packages
```
```bash
nix build .#all-packages
```

* Build a single package and push it to the Geonix binary cache
```
nix build --json .#<PACKAGE> | jq -r '.[].outputs | to_entries[].value' | cachix push geonix
```

* Build all packages and push them to the Geonix binary cache
```
nix build --json .#all-packages | jq -r '.[].outputs | to_entries[].value' | cachix push geonix
```

* Run package passthru tests
```
```bash
nix build -L .#<PACKAGE>.tests.<TEST-NAME>
```

* Run single flake check
```
```bash
nix build -L .#checks.x86_64-linux.<TEST-NAME>
```

Expand All @@ -38,17 +28,17 @@ _To an re-build already built package or to re-run already succeeded tests, use
## Debugging packages

* Explore derivation
```
```bash
nix show-derivation .#<PACKAGE>
```

* Explore package store path content
```
```bash
nix path-info -rsSh .#<PACKAGE> | sort -nk3
```

* Explain package dependencies
```
```bash
nix why-depends .#<PACKAGE> .#<DEPENDENCY>
```

Expand Down Expand Up @@ -78,25 +68,25 @@ utils/pull-nixpkgs.sh <NIXPKGS-DIR>
```

* Visually review changes created by `pull-nixpkgs.sh` script
```
```bash
git diff
```

* Identify related PRs in Nixpkgs
```
```bash
git log -- <PATH-TO-PACKAGE> # list changes to package in nixpkgs
```
```
```bash
gh pr list --web --state all --search <NIXPKGS-COMMIT-HASH> # identify PR related to commit
```

* Optional: generate a reverse patch for changes which are not desired
```
```bash
git diff <CHANGED-FILE> > pkgs/<PACKAGE>/nixpkgs/<PATCH-NAME>.patch
```

* Create separate commit for each change (include Nixpkgs PR URL in commit message)
```
```bash
git commit

<PACKAGE>: <CHANGE-DESCRIPTION>
Expand All @@ -105,14 +95,13 @@ Nixpkgs PR: <NIXPKGS-PR-URL>
```

* Build, test and upload all packages to binary chache
```bash
utils/nix-build-all.sh
```
nix build --json .#all-packages | jq -r '.[].outputs | to_entries[].value' | cachix push geonix

nix flake check
for test in test-qgis test-qgis-ltr test-nixgl; do
nix build --json .#checks.x86_64-linux.$test | jq -r '.[].outputs | to_entries[].value' | cachix push geonix
done
* Push changes to `weekly-update` PR
```bash
git push
```

* Merge `weekly-update` PR (Friday, Saturday)
27 changes: 27 additions & 0 deletions utils/nix-build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Build all packages and upload them to binary cache. Run tests.
# Usage: nix-build-all.sh

set -Eeuo pipefail

nixos_tests=( test-qgis test-qgis-ltr test-nixgl )


# build all packages and upload them to binary chache
echo -e "\nBuilding packages ..."
nix build --json .#all-packages \
| jq -r '.[].outputs | to_entries[].value' \
| cachix push geonix

# run tests
echo -e "\nRunning tests ..."
nix flake check

for test in "${nixos_tests[@]}"; do
nix build --json .#checks.x86_64-linux."$test" \
| jq -r '.[].outputs | to_entries[].value' \
| cachix push geonix
done

echo -e "\nDone."

0 comments on commit 3579988

Please sign in to comment.