Skip to content

Conversation

@urandom2
Copy link

@urandom2 urandom2 commented Nov 7, 2022

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

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.
Copy link
Author

@urandom2 urandom2 left a comment

Choose a reason for hiding this comment

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

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

Comment on lines +46 to +48
substituteInPlace Makefile --replace "/usr/bin/env " ""
substituteInPlace lang/Makefile --replace "/usr/bin/env " ""
substituteInPlace lang/types/Makefile --replace "/usr/bin/env " ""
Copy link
Author

Choose a reason for hiding this comment

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

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 &&" ""
Copy link
Author

Choose a reason for hiding this comment

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

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";
Copy link
Author

Choose a reason for hiding this comment

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

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:

Suggested change
version = "0.0.22";
version = "unstable-${self.lastModifiedDate}";

in {
devShells.default = pkgs.mkShell {
inherit buildInputs nativeBuildInputs;
packages = [pkgs.go];
Copy link
Author

Choose a reason for hiding this comment

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

if there is anything I missed that is useful for testing/debugging/development, we should add it here

libvirt
libxml2
];
nativeBuildInputs = with pkgs; [
Copy link
Author

Choose a reason for hiding this comment

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

these are dependencies that are called during the build process explicitly

self,
}:
flake-utils.lib.eachDefaultSystem (system: let
buildInputs = with pkgs; [
Copy link
Author

Choose a reason for hiding this comment

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

these are dependencies that are linked against, think shared libraries

@purpleidea purpleidea force-pushed the master branch 4 times, most recently from fe2313c to 271a94e Compare December 4, 2023 02:35
@purpleidea purpleidea force-pushed the master branch 3 times, most recently from b8072b2 to 380004b Compare November 23, 2024 06:25
karpfediem added a commit to karpfediem/mgmt that referenced this pull request Mar 21, 2025
purpleidea pushed a commit that referenced this pull request Mar 22, 2025
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)
@purpleidea purpleidea force-pushed the master branch 2 times, most recently from 37fdda9 to 5f4ae05 Compare October 2, 2025 07:05
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.

Package for Nixos

1 participant