Working Nix flake based on Naersk

This commit is contained in:
Olivier 'reivilibre' 2022-04-02 21:27:25 +01:00
parent 001357c825
commit f335d0daaa
3 changed files with 65 additions and 44 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ qp_web.ron
/rakepacks
/index
qp_indexer.toml
nix_flake/result

View File

@ -1,17 +1,20 @@
{
"nodes": {
"flake-utils": {
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"lastModified": 1648544490,
"narHash": "sha256-EoBDcccV70tfz2LAs5lK0BjC7en5mzUVlgLsd5E6DW4=",
"owner": "nix-community",
"repo": "naersk",
"rev": "e30ef9a5ce9b3de8bb438f15829c50f9525ca730",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
@ -29,10 +32,40 @@
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1648219316,
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},

View File

@ -2,57 +2,44 @@
description = "QuickPeep Search Engine Flake for Nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
# Do we need to declare this ...? nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
outputs = { self, nixpkgs, utils, naersk }:
utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages."${system}";
rustPlatform = pkgs.rust.packages.stable.rustPlatform;
naersk-lib = naersk.lib."${system}";
in rec {
# `nix build`
packages.quickpeep = rustPlatform.buildRustPackage {
packages.quickpeep = naersk-lib.buildPackage {
pname = "quickpeep";
version = "0.1.0";
#src = ./..;
#buildAndTestSubdir = "../quickpeep";
src = builtins.fetchGit {
ref = "main";
rev = "99a4c91ac33301e3d808d2f17498b710725a77e9";
url = "https://bics.ga/reivilibre/quickpeep.git";
};
root = ./..;
buildInputs = with pkgs; [
openssl
pkgconfig
# Needed to generate a dev database
pkgs.sqlx-cli
];
# Generate the dev database
preConfigure = ''
export PATH="${pkgs.sqlx-cli}/bin:$PATH"
cd quickpeep
bash dev_db.sh
'';
nativeBuildInputs = with pkgs; [
# Idea from https://github.com/NixOS/nixpkgs/blob/634141959076a8ab69ca2cca0f266852256d79ee/pkgs/servers/matrix-conduit/default.nix
rustPlatform.bindgenHook
openssl
pkgconfig
pkgs.rust.packages.stable.rustPlatform.bindgenHook
];
#cargoSha256 = pkgs.lib.fakeSha256;
cargoSha256 = "sha256-8J/twLhzs/Coou07Hs7mIiBpwDAPANgXMIwoplWZXRs=";
overrideMain = attrs: {
preConfigure = ''
export PATH="${pkgs.sqlx-cli}/bin:$PATH"
pushd quickpeep
bash dev_db.sh
popd
'';
};
};
defaultPackage = packages.quickpeep;
# `nix run`
apps.quickpeep = flake-utils.lib.mkApp {
apps.quickpeep = utils.lib.mkApp {
drv = packages.quickpeep;
};
defaultApp = apps.quickpeep;