nixpkgs/pkgs/misc/moonfire-nvr/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

86 lines
1.9 KiB
Nix

{ lib
, stdenv
, rustPlatform
, buildNpmPackage
, fetchFromGitHub
, pkg-config
, ncurses
, sqlite
, testers
, moonfire-nvr
, darwin
}:
let
pname = "moonfire-nvr";
version = "0.7.7";
src = fetchFromGitHub {
owner = "scottlamb";
repo = "moonfire-nvr";
rev = "v${version}";
hash = "sha256-+7VahlS+NgaO2knP+xqdlZnNEfjz8yyF/VmjWf77KXI=";
};
ui = buildNpmPackage {
inherit version src;
pname = "${pname}-ui";
sourceRoot = "${src.name}/ui";
npmDepsHash = "sha256-IpZWgMo6Y3vRn9h495ifMB3tQxobLeTLC0xXS1vrKLA=";
installPhase = ''
runHook preInstall
cp -r build $out
runHook postInstall
'';
};
in rustPlatform.buildRustPackage {
inherit pname version src;
sourceRoot = "${src.name}/server";
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"coded-0.2.0-pre" = "sha256-ICDvLFCsiPCzAzf3nrRhH/McNPVQz1+uVOmj6Uc5teg=";
"hashlink-0.8.1" = "sha256-h7DEapTVy0SSTaOV9rCkdH3em4A9+PS0k1QQh1+0P4c=";
"mp4-0.9.2" = "sha256-mJZJDzD8Ep9c+4QusyBtRoqAArHK9SLdFxG1AR7JydE=";
};
};
nativeBuildInputs = [
pkg-config
];
buildInputs = [
ncurses
sqlite
] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
Security
]);
postInstall = ''
mkdir -p $out/lib/ui
ln -s ${ui} $out/lib/ui
'';
doCheck = false;
passthru = {
inherit ui;
tests.version = testers.testVersion {
inherit version;
package = moonfire-nvr;
command = "moonfire-nvr --version";
};
};
meta = with lib; {
description = "Moonfire NVR, a security camera network video recorder";
homepage = "https://github.com/scottlamb/moonfire-nvr";
changelog = "https://github.com/scottlamb/moonfire-nvr/releases/tag/v${version}";
license = licenses.gpl3Only;
maintainers = with maintainers; [ gaelreyrol ];
mainProgram = "moonfire-nvr";
};
}