artist-alerts/flake.nix

112 lines
3.6 KiB
Nix
Raw Permalink Normal View History

2024-07-06 13:32:14 -07:00
/*
TODO
2024-07-06 14:23:59 -07:00
1. Find and replace "artist-alerts" with your package name for **ALL FILES IN REPOSITORY**
2024-07-06 13:32:14 -07:00
2. Add a flake description that describes the workspace on line 27
3. Add a package description on line 70
4. (optional) uncomment `nativeBuildInputs` and `buildInputs` on lines 43 and 44 if you need openssl
5. (optional) set your project homepage, license, and maintainers list on lines 48-51
6. (optional) uncomment the NixOS module and update it for your needs
7. Delete this comment block
*/
/*
Some utility commands:
- `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>`
2024-07-06 14:23:59 -07:00
- `nix build .#artist-alerts` or `nix build .`
- `nix run .#artist-alerts` or `nix run .`
2024-07-06 13:32:14 -07:00
*/
{
2024-07-06 14:23:59 -07:00
description = "Webservice with subscription features for new artist releases";
2024-07-06 13:32:14 -07:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, rust-overlay }:
let
overlays = [ (import rust-overlay) ];
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system overlays;
};
rustSettings = with pkgs; {
src = ./.;
#nativeBuildInputs = [ pkg-config ];
2024-07-06 18:20:21 -07:00
buildInputs = [ tailwindcss ];
2024-07-06 13:32:14 -07:00
cargoHash = nixpkgs.lib.fakeHash;
};
meta = with nixpkgs.lib; {
#homepage = "https://example.com";
#license = [ licenses.gpl3 ];
platforms = [ system ];
#maintainers = with maintainers; [ ];
};
in {
devShells.${system}.default = with pkgs; mkShell {
packages = [
(pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
})
2024-07-06 18:20:21 -07:00
cargo-watch
2024-07-06 13:32:14 -07:00
cargo-edit
bacon
];
2024-07-06 14:23:59 -07:00
inputsFrom = with self.packages.${system}; [ artist-alerts ];
2024-07-06 13:32:14 -07:00
};
packages.${system} = {
2024-07-06 14:23:59 -07:00
default = self.packages.${system}.artist-alerts;
artist-alerts = pkgs.rustPlatform.buildRustPackage (rustSettings // {
pname = "artist-alerts";
2024-07-06 13:32:14 -07:00
version = "0.1.0";
2024-07-06 14:23:59 -07:00
buildAndTestSubdir = "artist-alerts";
2024-07-06 13:32:14 -07:00
cargoHash = "sha256-+TaGIiKf+Pz2bTABeG8aCZz0/ZTCKl5398+qbas4Nvo=";
meta = meta // {
2024-07-06 14:23:59 -07:00
description = "Webservice with subscription features for new artist releases";
2024-07-06 13:32:14 -07:00
};
});
};
/*
nixosModules.default = { config, ... }: let
lib = nixpkgs.lib;
in {
2024-07-06 14:23:59 -07:00
options.services.artist-alerts = {
enable = lib.mkEnableOption (lib.mdDoc "artist-alerts service");
2024-07-06 13:32:14 -07:00
package = lib.mkOption {
type = lib.types.package;
2024-07-06 14:23:59 -07:00
default = self.packages.${system}.artist-alerts;
defaultText = "pkgs.artist-alerts";
2024-07-06 13:32:14 -07:00
description = lib.mdDoc ''
2024-07-06 14:23:59 -07:00
The artist-alerts package that should be used.
2024-07-06 13:32:14 -07:00
'';
};
port = lib.mkOption {
type = lib.types.port;
default = 8000;
description = lib.mdDoc ''
The port at which to run.
'';
};
};
2024-07-06 14:23:59 -07:00
config.systemd.services.artist-alerts = let
cfg = config.services.artist-alerts;
pkg = self.packages.${system}.artist-alerts;
2024-07-06 13:32:14 -07:00
in lib.mkIf cfg.enable {
description = pkg.meta.description;
after = [ "network.target" ];
wantedBy = [ "network.target" ];
serviceConfig = {
ExecStart = ''
2024-07-06 14:23:59 -07:00
${cfg.package}/bin/artist-alerts --port ${builtins.toString cfg.port}
2024-07-06 13:32:14 -07:00
'';
Restart = "always";
DynamicUser = true;
};
};
};
*/
};
}