mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
Merge pull request #45 from fn3x/main
feat(nix): added modules and shell
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# default.nix - for backwards compatibility with nix-build
|
||||
(import (
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/master.tar.gz";
|
||||
sha256 = "0yqfa6rx8md81bcn4szfp0hjq2f3h9i8zjzhqqyfqdkrj5559nmw";
|
||||
}
|
||||
) {
|
||||
src = ./.;
|
||||
}).defaultNix
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1770197578,
|
||||
"narHash": "sha256-AYqlWrX09+HvGs8zM6ebZ1pwUqjkfpnv8mewYwAo+iM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "00c21e4c93d963c50d4c0c89bfa84ed6e0694df2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ];
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (system: {
|
||||
default = nixpkgs.legacyPackages.${system}.callPackage ./nix/package.nix { };
|
||||
});
|
||||
|
||||
apps = forAllSystems (system: {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.default}/bin/idescriptor";
|
||||
};
|
||||
});
|
||||
|
||||
devShells = forAllSystems (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
pkg-config
|
||||
go
|
||||
qt6.wrapQtAppsHook
|
||||
copyDesktopItems
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
qt6.qtbase
|
||||
qt6.qtdeclarative
|
||||
qt6.qtmultimedia
|
||||
qt6.qtserialport
|
||||
qt6.qtpositioning
|
||||
qt6.qtlocation
|
||||
lxqt.qtermwidget
|
||||
qrencode
|
||||
libheif
|
||||
libde265
|
||||
x265
|
||||
libirecovery
|
||||
libssh
|
||||
ffmpeg
|
||||
pugixml
|
||||
avahi
|
||||
avahi-compat
|
||||
libimobiledevice
|
||||
libirecovery
|
||||
libplist
|
||||
usbmuxd
|
||||
libzip
|
||||
openssl
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
|
||||
"-DPACKAGE_MANAGER_MANAGED=ON"
|
||||
"-DPACKAGE_MANAGER_HINT=nix"
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
nixosModules.default = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.programs.idescriptor;
|
||||
idescriptorPkg = self.packages.${pkgs.system}.default;
|
||||
in
|
||||
{
|
||||
imports = [ ./nix/nixos-module.nix ];
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.idescriptor.package = lib.mkDefault idescriptorPkg;
|
||||
};
|
||||
};
|
||||
|
||||
homeManagerModules.default = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.programs.idescriptor;
|
||||
idescriptorPkg = self.packages.${pkgs.system}.default;
|
||||
in
|
||||
{
|
||||
imports = [ ./nix/hm-module.nix ];
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.idescriptor.package = lib.mkDefault idescriptorPkg;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.programs.idescriptor;
|
||||
in
|
||||
{
|
||||
options.programs.idescriptor = {
|
||||
enable = mkEnableOption "iDescriptor program";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
defaultText = literalExpression "pkgs.idescriptor";
|
||||
description = "The iDescriptor package to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.programs.idescriptor;
|
||||
in
|
||||
{
|
||||
options.programs.idescriptor = {
|
||||
enable = mkEnableOption "iDescriptor program";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
defaultText = literalExpression "pkgs.idescriptor";
|
||||
description = "The iDescriptor package to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
};
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "idescriptor";
|
||||
version = "0.2.0";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "iDescriptor";
|
||||
repo = "iDescriptor";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-p6iJP4duesUiYEH8pgGgX5GOdaOhaAegPPphBaXU4VM=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
goModules = (pkgs.stdenv.mkDerivation {
|
||||
name = "${pname}-${version}-go-modules";
|
||||
inherit src;
|
||||
|
||||
nativeBuildInputs = with pkgs; [ go ];
|
||||
|
||||
configurePhase = ''
|
||||
export GOPATH="$TMPDIR/go"
|
||||
export GOCACHE="$TMPDIR/go-cache"
|
||||
export HOME="$TMPDIR"
|
||||
cd lib/ipatool-go
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
go mod download
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r --reflink=auto $GOPATH/pkg/mod $out/
|
||||
'';
|
||||
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = "sha256-CmthXlyxbWRqAY4gFLshx7VGAdbQlySm4y6mWFdxdUI=";
|
||||
});
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
pkg-config
|
||||
go
|
||||
qt6.wrapQtAppsHook
|
||||
libimobiledevice
|
||||
libirecovery
|
||||
usbmuxd
|
||||
copyDesktopItems
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
qt6.qtbase
|
||||
qt6.qtdeclarative
|
||||
qt6.qtmultimedia
|
||||
qt6.qtserialport
|
||||
qt6.qtpositioning
|
||||
qt6.qtlocation
|
||||
qt6.qtwayland
|
||||
lxqt.qtermwidget
|
||||
qrencode
|
||||
libheif
|
||||
libde265
|
||||
x265
|
||||
libssh
|
||||
ffmpeg
|
||||
pugixml
|
||||
avahi
|
||||
avahi-compat
|
||||
libplist
|
||||
libzip
|
||||
openssl
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
|
||||
"-DPACKAGE_MANAGER_MANAGED=ON"
|
||||
"-DPACKAGE_MANAGER_HINT=nix"
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
export HOME=$TMPDIR
|
||||
export GOCACHE=$TMPDIR/go-cache
|
||||
export GOPATH=$TMPDIR/go
|
||||
|
||||
# Copy Go modules to writable location
|
||||
mkdir -p $GOPATH/pkg
|
||||
cp -r --reflink=auto ${goModules}/mod $GOPATH/pkg/
|
||||
chmod -R +w $GOPATH/pkg/mod
|
||||
|
||||
export GOMODCACHE=$GOPATH/pkg/mod
|
||||
export GOPROXY=off
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(pkgs.makeDesktopItem {
|
||||
name = "iDescriptor";
|
||||
exec = "iDescriptor";
|
||||
icon = "idescriptor";
|
||||
desktopName = "iDescriptor";
|
||||
comment = "Cross-platform iDevice management tool";
|
||||
categories = [ "System" "Utility" ];
|
||||
})
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
# Install icon
|
||||
install -Dm644 $src/resources/icons/app-icon/icon.png \
|
||||
$out/share/icons/hicolor/256x256/apps/idescriptor.png
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Free, open-source, cross-platform iDevice management tool";
|
||||
homepage = "https://github.com/iDescriptor/iDescriptor";
|
||||
license = licenses.agpl3Only;
|
||||
maintainers = [ fn3x ];
|
||||
platforms = platforms.unix;
|
||||
mainProgram = "iDescriptor";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user