Skip to content

Commit

Permalink
feat: nix flake setup
Browse files Browse the repository at this point in the history
Add `flake.nix` (and friends) to help Nix user develop, compile
and use this project.

You can read more about Nix Flakes:

https://www.tweag.io/blog/2020-05-25-flakes/
  • Loading branch information
dpc authored and FriedrichAltheide committed Jun 27, 2023
1 parent 9dcf29c commit 595c94c
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ tags

# End of https://www.toptal.com/developers/gitignore/api/linux,macos,rust,visualstudiocode,vim

# Nix
/result
/.direnv
123 changes: 123 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
description = "Scalable push server for XMPP";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, crane }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
craneLib = crane.lib.${system};

commonArgs = {
src = craneLib.cleanCargoSource ./.;

buildInputs = [
pkgs.openssl
];

nativeBuildInputs = [
pkgs.pkg-config
];
};
in
{
packages.default = craneLib.buildPackage ({
meta = { mainProgram = "fpush"; };
} // commonArgs);

devShells = {
default = pkgs.mkShell {

buildInputs = [ ] ++ commonArgs.buildInputs;
nativeBuildInputs = builtins.attrValues
{
inherit (pkgs) cargo rustc nixpkgs-fmt shellcheck rnix-lsp;
} ++ [
# This is required to prevent a mangled bash shell in nix develop
# see: https://discourse.nixos.org/t/interactive-bash-with-nix-develop-flake/15486
(pkgs.hiPrio pkgs.bashInteractive)

] ++ commonArgs.nativeBuildInputs;
};
};
}
);
}

0 comments on commit 595c94c

Please sign in to comment.