Skip to content

Commit

Permalink
feat(nix, ci/pr): add OS configuration package and build it on pull-r…
Browse files Browse the repository at this point in the history
…equests

`nix building` a derivation that pulls in all existing darwin/nixos
configurations seemed the simplest option here.
  • Loading branch information
steveej committed May 30, 2024
1 parent b1f02c7 commit c5ba519
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ on:
push:
branches: [develop]


jobs:
lints:
name: Build
runs-on: ubuntu-22.04
os-configurations:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-13]
name: OS configurations
runs-on: ${{ matrix.os }}
permissions:
id-token: "write"
contents: "read"
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
# - name: Run `nix build`
# run: nix build .
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- run: |
nix build .#build-os-configurations
ls -lha result/
40 changes: 32 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@

tx5.url = "github:holochain/tx5/tx5-signal-srv-v0.0.8-alpha";
tx5.flake = false;
sbd.url =
"github:holochain/sbd/sbd-server-v0.0.4-alpha"
;
sbd.url = "github:holochain/sbd/sbd-server-v0.0.4-alpha";
sbd.flake = false;

holochain-versions.url = "github:holochain/holochain?dir=versions/weekly";
Expand Down Expand Up @@ -134,6 +132,7 @@
inputs',
pkgs,
lib,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
Expand Down Expand Up @@ -210,11 +209,36 @@
'';
};

packages = {
nomad = inputs'.nixpkgs.legacyPackages.nomad_1_6;

nixos-anywhere = inputs'.nixos-anywhere.packages.default;
};
packages =
{
# nomad = pkgs.nomad_1_6;

nixos-anywhere = inputs'.nixos-anywhere.packages.default;
}
// (
let
mkOsConfigCheck = osConfigs: let
filteredBySystem = lib.filterAttrs (key: value: value.pkgs.system == system) osConfigs;
asStrings = lib.mapAttrsToList (key: value: builtins.trace "evaluating ${key} (${value.pkgs.system})..." "ln -s ${value.config.system.build.toplevel} $out/") filteredBySystem;
in
pkgs.stdenv.mkDerivation {
name = "check-osconfigurations";
phases = "installPhase";
installPhase = "mkdir $out;" + builtins.concatStringsSep "\n" asStrings;
};
in {
build-os-configurations =
if pkgs.stdenv.isLinux
then
mkOsConfigCheck (builtins.removeAttrs self.nixosConfigurations [
# too big for current CI structure and rarely used
"vm-nixcache"
])
else if pkgs.stdenv.isDarwin
then mkOsConfigCheck self.nixosConfigurations
else throw "unexpected case";
}
);
};
flake = {
# The usual flake attributes can be defined here, including system-
Expand Down

0 comments on commit c5ba519

Please sign in to comment.