Skip to content

Commit

Permalink
Merge pull request #23 from nrdxp/nix-std-ci
Browse files Browse the repository at this point in the history
Nix std ci
  • Loading branch information
nrdxp authored Sep 20, 2023
2 parents f267df8 + ed434ce commit 6004ce9
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# shellcheck disable=SC1090
. "$(fetchurl https://raw.githubusercontent.com/paisano-nix/direnv/main/lib sha256-IgQhKK7UHL1AfCUntJO2KCaIDJQotRnK2qC4Daxk+wI=)"

use env //repo/shells/default
use env //repo/shells/dev
48 changes: 48 additions & 0 deletions .github/_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# yq '. | explode(.)' .github/_ci.yml >| .github/workflows/ci.yml
name: CI For CloudFlare Dynamic DNS client

on:
pull_request:
branches:
- master
push:
branches:
- master

permissions:
contents: read

concurrency:
group: std-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
discover:
outputs:
hits: ${{ steps.discovery.outputs.hits }}
runs-on: ubuntu-latest
steps:
- uses: nixbuild/nix-quick-install-action@v25
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: divnix/std-action/discover@main
id: discovery

packages: &job
needs: discover
name: ${{ matrix.target.jobName }}
runs-on: ubuntu-latest
if: fromJSON(needs.discover.outputs.hits).packages.build != ''
strategy:
matrix:
target: ${{ fromJSON(needs.discover.outputs.hits).packages.build }}
steps:
- uses: nixbuild/nix-quick-install-action@v25
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: divnix/std-action/run@main

shells:
<<: *job
if: fromJSON(needs.discover.outputs.hits).shells.build != ''
strategy:
matrix:
target: ${{ fromJSON(needs.discover.outputs.hits).shells.build }}
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# yq '. | explode(.)' .github/_ci.yml >| .github/workflows/ci.yml
name: CI For CloudFlare Dynamic DNS client
on:
pull_request:
branches:
- master
push:
branches:
- master
permissions:
contents: read
concurrency:
group: std-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
discover:
outputs:
hits: ${{ steps.discovery.outputs.hits }}
runs-on: ubuntu-latest
steps:
- uses: nixbuild/nix-quick-install-action@v25
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: divnix/std-action/discover@main
id: discovery
packages:
needs: discover
name: ${{ matrix.target.jobName }}
runs-on: ubuntu-latest
if: fromJSON(needs.discover.outputs.hits).packages.build != ''
strategy:
matrix:
target: ${{ fromJSON(needs.discover.outputs.hits).packages.build }}
steps:
- uses: nixbuild/nix-quick-install-action@v25
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: divnix/std-action/run@main
shells:
needs: discover
name: ${{ matrix.target.jobName }}
runs-on: ubuntu-latest
steps:
- uses: nixbuild/nix-quick-install-action@v25
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: divnix/std-action/run@main
if: fromJSON(needs.discover.outputs.hits).shells.build != ''
strategy:
matrix:
target: ${{ fromJSON(needs.discover.outputs.hits).shells.build }}
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

Reimplementation of [cloudflare-dyndns](https://github.com/colemickens/cloudflare-dyndns) in [Rust](https://www.rust-lang.org).

## status known issues

* paging is not implemented
* some basic CI should be added

## building

`cargo build`
Expand Down
78 changes: 36 additions & 42 deletions flake.lock

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

28 changes: 19 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
{
description = "A very basic flake for Rust development";
description = "CI framework, devshell, and package for the Cloudflare Dynamic DNS Client";

inputs.std.url = "github:divnix/std/v0.24.0-1";
inputs.std.inputs.nixpkgs.follows = "nixpkgs";
inputs.std.inputs.devshell.follows = "devshell";

inputs.fenix.url = "github:nix-community/fenix";

inputs.crane.url = "github:ipetkov/crane";
inputs.crane.inputs.nixpkgs.follows = "nixpkgs";
inputs.crane.inputs.flake-compat.follows = "";
inputs.crane.inputs.rust-overlay.follows = "";

inputs.std.inputs.devshell.url = "github:numtide/devshell";
inputs.devshell.url = "github:numtide/devshell";
inputs.devshell.inputs.nixpkgs.follows = "nixpkgs";

inputs.nixpkgs.follows = "fenix/nixpkgs";

inputs.nosys.follows = "std/paisano/nosys";

outputs = inputs @ {
self,
std,
nosys,
...
}:
}: let
systems = ["x86_64-linux"];
in
std.growOn {
inherit inputs;
systems = ["x86_64-linux"];
inherit inputs systems;
cellsFrom = ./nix;
cellBlocks = with std.blockTypes; [
(installables "packages")
# Contribution Environment
(devshells "shells")
(installables "packages" {ci.build = true;})
(devshells "shells" {ci.build = true;})
(pkgs "rust")
];
} {
devShells = std.harvest self ["repo" "shells"];
packages = std.harvest self ["bin" "packages"];
};
}
(nosys (inputs // {inherit systems;}) ({self, ...}: {
packages.default = self.packages.cfdyndns;
devShells.default = self.devshells.dev;
}));

nixConfig = {
extra-substituters = [
Expand Down
9 changes: 5 additions & 4 deletions nix/bin/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
inherit (inputs) std self cells;
inherit (inputs.nixpkgs) pkgs;

crane = inputs.crane.lib.overrideToolchain cells.repo.rust.toolchain;
crane = inputs.crane.lib.overrideToolchain cells.repo.rust;
in {
# sane default for a binary package
default = crane.buildPackage {
cfdyndns = crane.buildPackage {
src = std.incl self [
"${self}/Cargo.lock"
"${self}/Cargo.toml"
"${self}/src"
];

buildInputs = [pkgs.openssl pkgs.pkgconfig];
buildInputs = [pkgs.openssl pkgs.pkg-config];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [cells.repo.rust];
meta.description = "CloudFlare Dynamic DNS Client";
};
}
Loading

0 comments on commit 6004ce9

Please sign in to comment.