From 6a1311508609bbca6388417d3aa444a648a4b93b Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Sun, 7 Jul 2024 22:12:49 -0700 Subject: [PATCH] Introduce flake.nix for project Create flake.nix for the project so that we can reproducibly build this project using Nix software and on NixOS machines. --- flake.nix | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ae6f068 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.12) +{ + # Flake inputs + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + naersk.url = "github:nix-community/naersk"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + # Flake outputs that other flakes can use + outputs = { + self, + nixpkgs, + naersk, + rust-overlay, + }: let + supportedSystems = ["x86_64-linux" "aarch64-linux"]; + forEachSupportedSystem = f: + nixpkgs.lib.genAttrs supportedSystems (system: + f rec { + pkgs = import nixpkgs { + inherit system; + overlays = [rust-overlay.overlays.default]; + }; + naersk' = pkgs.callPackage naersk {}; + }); + in { + packages = forEachSupportedSystem ({ + pkgs, + naersk', + }: { + default = naersk'.buildPackage { + src = ./.; + nativeBuildInputs = with pkgs; [ + perl + jq + openconnect + libsoup + webkitgtk + pkg-config + tree + ]; + + overrideMain = {...}: { + postPatch = '' + substituteInPlace crates/gpapi/src/lib.rs \ + --replace-fail /usr/bin/gpclient $out/bin/gpclient \ + --replace-fail /usr/bin/gpservice $out/bin/gpservice \ + --replace-fail /usr/bin/gpgui-helper $out/bin/gpgui-helper \ + --replace-fail /usr/bin/gpgui $out/bin/gpgui \ + --replace-fail /usr/bin/gpauth $out/bin/gpauth + ''; + }; + + }; + }); + }; +}