Skip to content

Commit

Permalink
Merge pull request #4 from jurraca/flakify
Browse files Browse the repository at this point in the history
Flakify
  • Loading branch information
fjahr authored Nov 29, 2023
2 parents 9d1c2e8 + 1a1c396 commit 9959db5
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "nix-build"
name: "nix build"

on:
push:
Expand All @@ -13,5 +13,5 @@ jobs:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix-build
nix_path: nixpkgs=channel:nixos-23.11
- run: nix build
36 changes: 19 additions & 17 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
{ pkgs ? import <nixpkgs> { } }:

{
pkgs,
rpki-client-src,
rpki-openbsd-src,
}:
# build the package
pkgs.stdenv.mkDerivation rec {
name = "rpki-client";
version = "8.2";

src = pkgs.fetchFromGitHub {
owner = "rpki-client";
repo = "rpki-client-portable";
rev = version;
hash = "sha256-oErUjZn/a/Ka70+Z8Wb2L7UIulGPjF81bYAQ2wPvWfo=";
};
version = "8.6";

openbsd_src = pkgs.fetchFromGitHub {
owner = "rpki-client";
repo = "rpki-client-openbsd";
rev = "rpki-client-8.2";
hash = "sha256-zC3vbQLLWgImS+lYNWbHzkLrZTJvgPfH+W+FiSnH8Aw=";
};
src = rpki-client-src;

# Dependencies required at build time
buildInputs = with pkgs; [
libressl
expat
automake
autoconf
libtool
rsync
zlib
];

# Prepare the source directory before configuring and building.
# In this case, we set up the openbsd directory, which rpki-client-portable expects,
# with the rpki-openbsd-src attribute we set up as a flake input.
unpackPhase = ''
mkdir -p openbsd
cp -R ${openbsd_src}/* openbsd
cp -R ${rpki-openbsd-src}/* openbsd
cp -R ${src}/* .
chmod 700 -R .
'';

# Configure with the given scripts, but point to our nix-specific $out directory
configurePhase = ''
./autogen.sh
./configure --prefix=$out
'';

# The default buildPhase for stdenv.mkDerivation is "make"
# which is what the project wants in this case.
# So we don't need to modify the buildPhase.
}
97 changes: 97 additions & 0 deletions flake.lock

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

45 changes: 45 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
description = "RPKI Client v8.6";

# To build the package, run "nix build" in the current directory.
# This will build the rpki-client binary and put it in 'result/bin/'.

inputs = {
# We pin to a set nixpkgs version
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
# A lib to help build packages for multiple target systems
utils.url = "github:numtide/flake-utils";
# The RPKI portable client source, pinned to a specific version
rpki-client-src = {
url = "github:rpki-client/rpki-client-portable/aa554ab91add82bb68de00d323e02c9d20621aee"; # v8.6
flake = false;
};
# The openbsd shim of rpki-client-portable, which gets pulled into rpki-client at build time
# Since Nix can't fetch external sources (or access the Internet) at build time, we pull it in explicitly.
# See https://github.com/rpki-client/rpki-client-portable/blob/master/update.sh
rpki-openbsd-src = {
url = "github:rpki-client/rpki-client-openbsd/082ed00f2b1f8b1b578b2bc9eae84a5fc1923d68"; # v8.6
flake = false;
};
};

outputs = {
self,
nixpkgs,
utils,
rpki-client-src,
rpki-openbsd-src,
}:
# Read as: for each system, use nixpkgs and run the default.nix build instructions with these args.
utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
rpki-client = import ./default.nix {inherit pkgs rpki-client-src rpki-openbsd-src;};
in rec {
# This exposes a package under the namespace rpki-client.defaultPackage.<system>
defaultPackage = rpki-client;

# To run locally without cloning this repo, create a `cachedir` locally to hold RPKI data.
# Then run "nix run github:fjahr/rpki-client-nix -- -d cachedir"
apps.rpki-client = utils.lib.mkApp {drv = rpki-client;};
});
}

0 comments on commit 9959db5

Please sign in to comment.