mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-09-13 05:55:22 +00:00
Package with nix and add systemd unit example
This commit is contained in:
parent
a63d0df443
commit
e84b13c876
9 changed files with 287 additions and 3 deletions
80
flake.nix
Normal file
80
flake.nix
Normal file
|
@ -0,0 +1,80 @@
|
|||
rec {
|
||||
description = "Blah Chat Server";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
naersk = {
|
||||
url = "github:nix-community/naersk";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
naersk,
|
||||
}:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
eachSystem = lib.genAttrs lib.systems.flakeExposed;
|
||||
|
||||
rev = self.rev or (lib.warn "Git changes are not committed" (self.dirtyRev or "dirty"));
|
||||
in
|
||||
{
|
||||
packages = eachSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
naersk' = pkgs.callPackage naersk { };
|
||||
in
|
||||
rec {
|
||||
default = blahd;
|
||||
blahd = pkgs.callPackage (
|
||||
{
|
||||
pkg-config,
|
||||
openssl,
|
||||
sqlite,
|
||||
}:
|
||||
naersk'.buildPackage rec {
|
||||
pname = "blahd";
|
||||
src = ./.;
|
||||
version = "git-${rev}";
|
||||
CFG_RELEASE = version;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
];
|
||||
buildInputs = [
|
||||
openssl
|
||||
sqlite
|
||||
];
|
||||
|
||||
cargoBuildOptions = opts: opts ++ [
|
||||
"--package=blahd"
|
||||
"--package=blahctl"
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/etc/systemd/system
|
||||
substitute ./blahd/blahd.example.service $out/etc/systemd/system/blahd.service \
|
||||
--replace-fail '/usr/bin/blahd' "$out/bin/blahd"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
inherit description;
|
||||
homepage = "https://github.com/Blah-IM/blahrs";
|
||||
};
|
||||
}
|
||||
) { };
|
||||
}
|
||||
);
|
||||
|
||||
nixosModules = rec {
|
||||
default = blahd;
|
||||
blahd = import ./nix/module.nix {
|
||||
inherit self;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue