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 Simple Nix Flake #7656

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,25 @@ jobs:
cat config.vars
VALGRIND=0 poetry run pytest tests/ -vvv -n ${PYTEST_PAR} ${PYTEST_OPTS}

check-flake:
name: Check Nix Flake
runs-on: ubuntu-20.04
strategy:
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v8
- name: Install Nix
uses: cachix/install-nix-action@V27
with:
nix_path: nixpkgs=channel:nixos-24.05
- name: Check flake
run: nix flake check .?submodules=1#

gather:
# A dummy task that depends on the full matrix of tests, and
# signals successful completion. Used for the PR status to pass
Expand All @@ -540,6 +559,7 @@ jobs:
- integration-valgrind
- integration-sanitizers
- min-btc-support
- check-flake
steps:
- name: Complete
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ release/
SHA256SUMS-*
doc/.doc_version
autogenerate-examples-status.log

# Ignore nix outputs
result
result-[0-9]*
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.08.1
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ clean: obsclean

PYLNS=client proto testing
# See doc/contribute-to-core-lightning/contributor-workflow.md
update-py-versions: update-pyln-versions update-clnrest-version update-wss-proxy-version update-poetry-lock
update-versions: update-pyln-versions update-clnrest-version update-wss-proxy-version update-poetry-lock update-dot-version

update-pyln-versions: $(PYLNS:%=update-pyln-version-%)

Expand Down Expand Up @@ -754,6 +754,10 @@ update-reckless-version:
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
@sed -i "s/__VERSION__ = '\([.-z]*\)'/__VERSION__ = '$(NEW_VERSION)'/" tools/reckless

update-dot-version:
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
echo $(NEW_VERSION) > .version

update-mocks: $(ALL_TEST_PROGRAMS:%=update-mocks/%.c)

$(ALL_TEST_PROGRAMS:%=update-mocks/%.c): $(ALL_GEN_HEADERS) $(EXTERNAL_LIBS) libccan.a ccan/ccan/cdump/tools/cdump-enumstr config.vars
Expand Down
12 changes: 6 additions & 6 deletions doc/contribute-to-core-lightning/release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Here's a checklist for the release process.
2. Look through outstanding issues, to identify any problems that might be necessary to fixup before the release. Good candidates are reports of the project not building on different architectures or crashes.
3. Identify a good lead for each outstanding issue, and ask them about a fix timeline.
4. Create a milestone for the _next_ release on Github, and go though open issues and PRs and mark accordingly.
5. Ask (via email) the most significant contributor who has not already named a release to name the release (use
5. Ask (via email) the most significant contributor who has not already named a release to name the release (use
`devtools/credit --verbose v<PREVIOUS-VERSION>` to find this contributor). CC previous namers and team.

## Preparing for -rc1

1. Check that `CHANGELOG.md` is well formatted, ordered in areas, covers all signficant changes, and sub-ordered approximately by user impact & coolness.
2. Use `devtools/changelog.py` to collect the changelog entries from pull request commit messages and merge them into the manually maintained `CHANGELOG.md`. This does API queries to GitHub, which are severely
2. Use `devtools/changelog.py` to collect the changelog entries from pull request commit messages and merge them into the manually maintained `CHANGELOG.md`. This does API queries to GitHub, which are severely
ratelimited unless you use an API token: set the `GH_TOKEN` environment variable to a Personal Access Token from <https://github.com/settings/tokens>
3. Create a new CHANGELOG.md heading to `v<VERSION>rc1`, and create a link at the bottom. Note that you should exactly copy the date and name format from a previous release, as the `build-release.sh` script relies on this.
4. Update the contrib/pyln package versions: `make update-py-versions NEW_VERSION=<VERSION>`
4. Update the package versions: `make update-versions NEW_VERSION=<VERSION>`
5. Create a PR with the above.

## Releasing -rc1
Expand All @@ -47,7 +47,7 @@ Here's a checklist for the release process.
## Releasing -rc2, ..., -rcN

1. Update CHANGELOG.md by changing rc(N-1) to rcN. Update the changelog list with information from newly merged PRs also.
2. Update the contrib/pyln package versions: `make update-py-versions NEW_VERSION=<VERSION>`
2. Update the package versions: `make update-versions NEW_VERSION=<VERSION>`
3. Add a PR with the rcN.
4. Tag it `git pull && git tag -s v<VERSION>rcN && git push --tags`
5. Draft a new `v<VERSION>rcN` pre-release on Github, upload reproducible builds, SHA256SUMS and SHA256SUMS.asc.
Expand All @@ -71,9 +71,9 @@ Here's a checklist for the release process.
- Build reproducible Ubuntu-v18.04, Ubuntu-v20.04, Ubuntu-v22.04 images. Follow [link](https://docs.corelightning.org/docs/repro#building-using-the-builder-image) for manually Building Ubuntu Images.
- Build Docker images for amd64 and arm64v8. Follow [link](https://docs.corelightning.org/docs/docker-images) for more details on Docker publishing.
- Create and sign checksums. Follow [link](https://docs.corelightning.org/docs/repro#co-signing-the-release-manifest) for manually signing the release.
6. The tarballs may be owned by root, so revert ownership if necessary:
6. The tarballs may be owned by root, so revert ownership if necessary:
`sudo chown ${USER}:${USER} *${VERSION}*`
7. Upload the resulting files to github and save as a draft.
7. Upload the resulting files to github and save as a draft.
(<https://github.com/ElementsProject/lightning/releases/>)
8. Send `SHA256SUMS` & `SHA256SUMS.asc` files to the rest of the team to check and sign the release.
9. Team members can verify the release with the help of `build-release.sh`:
Expand Down
20 changes: 18 additions & 2 deletions doc/developers-guide/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,24 @@ Clean up the lightning directories:
destroy_ln
```



## Using Polar

[Polar](https://lightningpolar.com/) offers a one-click setup of Lightning Network for local app development & testing.

## Using Nix

Install [Nix](https://nixos.org/download/)

Update git submodules `git submodule update --init --recursive`.

The entry point is `flake.nix` in the root of the project, where the inputs and outputs are defined.

`nix develop` will create the default shell env with the build and runtime dependencies of the cln package. Then you can call `make` manually and the project will compile as usual.

`nix develop .#rust` will create a shell env for developing rust.

`nix build .?submodules=1` will build the default package (cln).

`nix flake check .?submodules=1` will build the cln and rust packages. Rust tests are run during the build. There are also checks to run cargo audit and nixfmt.

If you have nix installed you can use `nix run "git+https://github.com/hashrelay/lightning?ref=flake&submodules=1#lightningd"` to run lightningd without having to manually clone the repo. This make use of the flake output apps.
126 changes: 126 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
description = "Core Lightning (CLN): A specification compliant Lightning Network implementation in C";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";

flake-parts.url = "github:hercules-ci/flake-parts";

crane.url = "github:ipetkov/crane";

treefmt-nix.url = "github:numtide/treefmt-nix";

advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};

outputs =
inputs@{
self,
nixpkgs,
flake-parts,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.treefmt-nix.flakeModule
./nix/pkgs/flake-module.nix
./nix/checks/flake-module.nix
./nix/shells.nix
./nix/treefmt.nix
];
perSystem =
{
config,
pkgs,
self',
system,
...
}:
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (final: prev: { craneLib = (inputs.crane.mkLib pkgs); }) ];
};
apps = {
lightningd = {
program = "${self'.packages.cln}/bin/lightningd";
};
lightning-cli = {
program = "${self'.packages.cln}/bin/lightning-cli";
};
lightning-hsmtool = {
program = "${self'.packages.cln}/bin/lightning-hsmtool";
};
reckless = {
program = "${self'.packages.cln}/bin/reckless";
};
};
};
};
}
20 changes: 20 additions & 0 deletions nix/checks/flake-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ inputs, self, ... }:
{
perSystem =
{ pkgs, config, ... }:
let
advisory-db = inputs.advisory-db;
in
{
checks = {
cln = config.packages.cln;
cln-postgres = config.packages.cln-postgres;
rust = config.packages.rust;
cargo-audit = pkgs.craneLib.cargoAudit {
src = ../../.;
inherit advisory-db;
};
formatting = config.treefmt.build.check self;
};
};
}
Loading
Loading