|
| 1 | +{ |
| 2 | + description = |
| 3 | + "This flake builds the Ory CLI using Nix's buildGoModule Function."; |
| 4 | + |
| 5 | + inputs = { |
| 6 | + nixpkgs.url = "nixpkgs/nixos-unstable"; |
| 7 | + flake-utils.url = "github:numtide/flake-utils"; |
| 8 | + # The Ory CLI is not a flake, so we have to use the Github input and build it ourselves. |
| 9 | + ory-cli = { |
| 10 | + type = "github"; |
| 11 | + owner = "ory"; |
| 12 | + repo = "cli"; |
| 13 | + ref = "v0.2.2"; |
| 14 | + flake = false; |
| 15 | + }; |
| 16 | + }; |
| 17 | + |
| 18 | + outputs = { self, nixpkgs, flake-utils, ory-cli }: |
| 19 | + # Use the flake-utils lib to easily create a multi-system flake |
| 20 | + flake-utils.lib.eachDefaultSystem (system: |
| 21 | + let |
| 22 | + # Define some variables that we want to use in our package build. You'll want to update version and `ref` above to use a different version of Ory. |
| 23 | + version = "0.2.2"; |
| 24 | + in { |
| 25 | + packages = let |
| 26 | + pkgs = import nixpkgs{inherit system;}; |
| 27 | + pname = "ory"; |
| 28 | + name = "ory-${version}"; |
| 29 | + in { |
| 30 | + # Build the Ory CLI using Nix's buildGoModuleFunction |
| 31 | + ory-cli = pkgs.buildGoModule { |
| 32 | + inherit version; |
| 33 | + inherit pname; |
| 34 | + inherit name; |
| 35 | + |
| 36 | + # Path to the source code we want to build. In this case, it's the `ory-cli` input we defined above. |
| 37 | + src = ory-cli; |
| 38 | + |
| 39 | + # This was in the Makefile in the Ory repo, not sure if it's required |
| 40 | + tags = [ "sqlite"]; |
| 41 | + |
| 42 | + doCheck = false; |
| 43 | + |
| 44 | + # If the vendor folder is not checked in, we have to provide a hash for the vendor folder. Nix requires this to ensure the vendor folder is reproducible, and matches what we expect. |
| 45 | + vendorSha256 = "sha256-J9jyeLIT+1pFnHOUHrzmblVCJikvY05Sw9zMz5qaDOk="; |
| 46 | + |
| 47 | + # The Go Mod is named `cli` by default, so we rename it to `ory`. |
| 48 | + postInstall = '' |
| 49 | + mv $out/bin/cli $out/bin/ory |
| 50 | + ''; |
| 51 | + }; |
| 52 | + }; |
| 53 | + |
| 54 | + # Set Ory as the default package output for this flake |
| 55 | + defaultPackage = self.packages.ory-cli; |
| 56 | + } |
| 57 | + ); |
| 58 | +} |
| 59 | + |
0 commit comments