Skip to content

add flake.nix for reproducible builds and NixOS#2444

Open
randomizedcoder wants to merge 2 commits intoperformancecopilot:mainfrom
randomizedcoder:flake.nix
Open

add flake.nix for reproducible builds and NixOS#2444
randomizedcoder wants to merge 2 commits intoperformancecopilot:mainfrom
randomizedcoder:flake.nix

Conversation

@randomizedcoder
Copy link
Contributor

Add comprehensive Nix packaging support for PCP 7.0.5, enabling reproducible
builds via Nix flakes and preparing for inclusion in nixpkgs.

New files:

  • flake.nix: Main Nix flake with package definition, dev shell, and VM test
  • flake.lock: Pinned nixpkgs and flake-utils versions
  • nix/vm-test.nix: NixOS VM integration test for pmcd daemon
  • nix/patches/gnumakefile-nix-fixes.patch: Remove ownership flags, fix
      tmpfiles path, exclude qa from build
  • nix/patches/tmpdir-portability.patch: Use ${TMPDIR:-/tmp} instead of
      hardcoded /var/tmp for sandbox compatibility
  • nix/patches/configure-ar-portable.patch: Portable ar fallback (not
      applied, available for upstream)
  • docs/HowTos/nix/index.rst: Comprehensive documentation explaining Nix
      packaging, technical details, and future improvements

Features enabled by default (Linux):

  • Core PCP tools, libraries, and PMDAs
  • Python3 and Perl language bindings
  • BPF/BCC kernel tracing PMDAs
  • Systemd integration
  • SNMP, device mapper, and service discovery

The flake provides:

  • nix build: Build PCP package with split outputs (out, man, doc)
  • nix develop: Development shell with build dependencies and PCP logo
  • nix build .#checks.x86_64-linux.vm-test: NixOS VM integration test

Technical fixes for Nix sandbox:

  • Patch /var/tmp to ${TMPDIR:-/tmp} for sandbox compatibility
  • Remove install ownership flags (handled by NixOS module)
  • Fix broken symlinks with double /nix/store prefix
  • Override systemd paths from pkg-config
  • Export AR for configure script

Documentation ./docs/HowTos/nix/index.rst includes explanations of why Nix
packaging can be challenging (non-FHS paths, sandboxed builds, pure
environment) and how these constraints help expose portability issues in
build systems.

Copy link
Member

@kmcdonell kmcdonell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@randomizedcoder Could I suggest you separate the 2 portability patches as a separate PR? I'm happy for those to proceed immediately.
Then you're left with just the one nix-specific patch and the associated nix life-support changes.
For the latter, my only (nit) issue is adding result* to the top-level .gitignore ... can that be more targeted, or does the nix build leave result* files all over the place?

@randomizedcoder
Copy link
Contributor Author

G'day Ken,

Thanks for the feedback.

I'm actually from Melbourne also!

Is this what you meant? #2445

Thanks,
Dave

@kmcdonell
Copy link
Member

@randomizedcoder I'm assuming we need to drive #2445 to completion, and then circle back with a rebased set of changes here?
Do you agree?

kmcdonell added a commit to kmcdonell/pcp that referenced this pull request Jan 31, 2026
- $tmp in our scripts are for transient files, they never need to
  survive a reboot, so /tmp is a better match than /var/tmp
- /tmp is often a tmpfs these days which provides a potential
  reduction in disk i/o
- $TMPDIR provides a standard way of locating *all* these temporary
  files someplace else, e.g. for a container or sandbox environment
- consistently uses tmp=${TMPDIR:-/tmp}/<script>-$$ for a script
  named <script> to avoid concurrent execution clashes and to help
  identify corpses in /tmp

This pre-empts point 2. in PR performancecopilot#2445 and the similar changes in
PR performancecopilot#2444.
@randomizedcoder
Copy link
Contributor Author

Continuing to work on getting flake.nix working well.

Just added pull request for "ar"

#2479

Will assess this pull request, if/when 2479 is merged

@randomizedcoder
Copy link
Contributor Author

@kmcdonell

I've also updated this flake.nix branch now that TMPDIR has been improved, and I'm assuming the AR pull request 2479 gets merged.

190a1a1

nix does build correctly

Thanks,
Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants