From f5f5d358b427edee878d3e19b14270714e6cf4a1 Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Mon, 8 Jul 2024 09:20:15 -0400 Subject: [PATCH] Introduce flake.nix for project to build for NixOS (#387) --- flake.lock | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..660c45e --- /dev/null +++ b/flake.lock @@ -0,0 +1,93 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1718727675, + "narHash": "sha256-uFsCwWYI2pUpt0awahSBorDUrUfBhaAiyz+BPTS2MHk=", + "owner": "nix-community", + "repo": "naersk", + "rev": "941ce6dc38762a7cfb90b5add223d584feed299b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-US1tAChvPxT52RV8GksWZS415tTS7PV42KTc2PNDBmc=", + "path": "/nix/store/aa0zsahvyqnvzkicsh29jirm9hwv95pg-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1720244366, + "narHash": "sha256-WrDV0FPMVd2Sq9hkR5LNHudS3OSMmUrs90JUTN+MXpA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "49ee0e94463abada1de470c9c07bfc12b36dcf40", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1718428119, + "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1720318855, + "narHash": "sha256-w3CCVK9LJ5aznXGkO1IyAlbvMNJfyA+dBF7Z1Zwx1LA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "3eed08a074cd2000884a69d448d70da2843f7103", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..12af717 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +# 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 + ]; + + 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 + ''; + }; + + }; + }); + }; +}