Skip to content

Commit

Permalink
Rewrote the version match in flake.nix to return the package version
Browse files Browse the repository at this point in the history
  • Loading branch information
WombatFromHell committed Feb 15, 2025
1 parent ae17f0d commit 024112d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
system: let
pkgs = import nixpkgs {inherit system;};
naersk' = pkgs.callPackage naersk {};
cargoToml = builtins.readFile ./Cargo.toml;
versionMatch = builtins.match ''.*version[[:space:]]*=[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)".*'' cargoToml;
version = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile (pkgs.runCommand "get-version" {
nativeBuildInputs = [pkgs.remarshal pkgs.jq];
} ''
toml2json ${./Cargo.toml} | jq -r '.package.version' > $out
''));
in {
packages = {
veridian-controller = naersk'.buildPackage {
pname = "veridian-controller";
version =
if versionMatch != null
then builtins.elemAt versionMatch 0
else throw "Could not extract version from Cargo.toml. Make sure it contains a line like `version = \"0.1.0\"`.";
inherit version;
src = ./.;
};
default = self.packages.${system}.veridian-controller;
Expand Down

0 comments on commit 024112d

Please sign in to comment.