Introduce flake.nix for project to build for NixOS (#387)

This commit is contained in:
Farid Zakaria 2024-07-08 09:20:15 -04:00 committed by GitHub
parent 5cb9432f21
commit f5f5d358b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 150 additions and 0 deletions

93
flake.lock generated Normal file
View File

@ -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
}

57
flake.nix Normal file
View File

@ -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
'';
};
};
});
};
}