add flake for easier build support#694
Conversation
This change adds support for nix flake based builds. This includes a dev shell required for running make targets like code generation or testing, and a package target for the output mgmt binary. We have also .gitignored the default output location, result.
urandom2
left a comment
There was a problem hiding this comment.
no pressure to merge or review this; just got it put together based upon NixOS/nixpkgs#198963
per #610, suggestions for repo level changes are inline, but can be added to this change or broken out as a separate pr; I would suggest integrating nix build into your build process at least to verify that this logic does not break and ossify, but it is not required, and just let me know if you want a hand
| substituteInPlace Makefile --replace "/usr/bin/env " "" | ||
| substituteInPlace lang/Makefile --replace "/usr/bin/env " "" | ||
| substituteInPlace lang/types/Makefile --replace "/usr/bin/env " "" |
There was a problem hiding this comment.
these execute the same change I would suggest: use SHELL = bash and allow make to do PATH based resolution, as this will be more portable than assuming everybody has a /usr/bin/env
| substituteInPlace Makefile --replace "/usr/bin/env " "" | ||
| substituteInPlace lang/Makefile --replace "/usr/bin/env " "" | ||
| substituteInPlace lang/types/Makefile --replace "/usr/bin/env " "" | ||
| substituteInPlace lang/types/Makefile --replace "unset GOCACHE &&" "" |
There was a problem hiding this comment.
I reviewed the linked upstream bug, golang/go#31843, and it is both stale/closed, and I could not trigger it during testing; can we consider it resolved and remove the override?
| }; | ||
| packages.default = let | ||
| pname = "mgmt"; | ||
| version = "0.0.22"; |
There was a problem hiding this comment.
unfortunately, flakes cannot consume version strings from vcs, so you will be required to manually update the string before releases, or just leave the flake as something like unstable-20221107155054 like so:
| version = "0.0.22"; | |
| version = "unstable-${self.lastModifiedDate}"; |
| in { | ||
| devShells.default = pkgs.mkShell { | ||
| inherit buildInputs nativeBuildInputs; | ||
| packages = [pkgs.go]; |
There was a problem hiding this comment.
if there is anything I missed that is useful for testing/debugging/development, we should add it here
| libvirt | ||
| libxml2 | ||
| ]; | ||
| nativeBuildInputs = with pkgs; [ |
There was a problem hiding this comment.
these are dependencies that are called during the build process explicitly
| self, | ||
| }: | ||
| flake-utils.lib.eachDefaultSystem (system: let | ||
| buildInputs = with pkgs; [ |
There was a problem hiding this comment.
these are dependencies that are linked against, think shared libraries
fe2313c to
271a94e
Compare
b8072b2 to
380004b
Compare
See the recommendation in purpleidea#694 (comment)
Use path based SHELL in Makefiles. It was suggested that this is a better solution for make for cases when there is no /usr/bin/env. See: #694 (comment)
37fdda9 to
5f4ae05
Compare
3221a93 to
4ad2b9a
Compare
|
Stale so closing for now. |
This change adds support for nix flake based builds. This includes a dev shell required for running make targets like code generation or testing, and a package target for the output mgmt binary. We have also .gitignored the default output location, result.
Fixes #610