diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.lock b/flake.lock index 2041d58..cdc9f4d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,36 +1,24 @@ { "nodes": { - "naersk": { + "flake-parts": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1721727458, - "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", - "owner": "nix-community", - "repo": "naersk", - "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", + "lastModified": 1736143030, + "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "naersk", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, "nixpkgs": { - "locked": { - "lastModified": 0, - "narHash": "sha256-HP89HZOT0ReIbI7IJZJQoJgxvB2Tn28V6XS3MNKnfLs=", - "path": "/nix/store/lryfc8mhk1czqsa421di2y5nzz5c3b8m-source", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1728492678, "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", @@ -46,27 +34,22 @@ "type": "github" } }, - "root": { - "inputs": { - "naersk": "naersk", - "nixpkgs": "nixpkgs_2", - "rustypasteRepo": "rustypasteRepo" - } - }, - "rustypasteRepo": { - "flake": false, + "nixpkgs-lib": { "locked": { - "lastModified": 1728306155, - "narHash": "sha256-mgB/arakSQu7mC/n7Oal/rsHdVxCD4NEgX7TAsCrCMI=", - "owner": "orhun", - "repo": "rustypaste", - "rev": "561025fca47e63a4356cf8e41669ab823f033717", - "type": "github" + "lastModified": 1735774519, + "narHash": "sha256-CewEm1o2eVAnoqb6Ml+Qi9Gg/EfNAxbRx1lANGVyoLI=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" }, "original": { - "owner": "orhun", - "repo": "rustypaste", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 09bb8cb..e3d17bb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,22 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - naersk.url = "github:nix-community/naersk"; - rustypasteRepo = { - url = "github:orhun/rustypaste"; - flake = false; - }; + flake-parts.url = "github:hercules-ci/flake-parts"; }; outputs = - { - self, - nixpkgs, - naersk, - rustypasteRepo, - }: - let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - naersk' = pkgs.callPackage naersk { }; - rustypaste = naersk'.buildPackage { src = rustypasteRepo; }; - in - { - packages.${system} = { - default = rustypaste; - inherit rustypaste; - }; - overlays.default = final: prev: { inherit (self.packages.${prev.system}) rustypaste; }; + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + + systems = [ "x86_64-linux" ]; + + perSystem = + { pkgs, config, ... }: + { + packages = { + rustypaste = pkgs.callPackage ./pkgs/rustypaste { }; + pineflash = pkgs.callPackage ./pkgs/pineflash { }; + }; + }; }; } diff --git a/pkgs/pineflash/default.nix b/pkgs/pineflash/default.nix new file mode 100644 index 0000000..41209ef --- /dev/null +++ b/pkgs/pineflash/default.nix @@ -0,0 +1,107 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + curl, + pkg-config, + wrapGAppsHook, + atk, + bzip2, + cairo, + gdk-pixbuf, + glib, + gtk3, + libusb, + libxkbcommon, + openssl, + pango, + udev, + vulkan-loader, + zlib, + stdenv, + darwin, + wayland, + autoPatchelfHook, + makeWrapper, + libGL, +}: + +rustPlatform.buildRustPackage rec { + pname = "pineflash"; + version = "82605e4eeb48d25e59361ea42bcb01f02588b6aa"; + + src = fetchFromGitHub { + owner = "Nydragon"; + repo = "PineFlash"; + rev = version; + hash = "sha256-s/yUB0mqXDD+InlWW/cDuk63K/mNZp158CD99RmHZrY="; + fetchSubmodules = true; + }; + + cargoHash = "sha256-DuxKkC3+3Ynct0TAUNB8/O8b1/Cj4FoeUilxhYnSdwk="; + + nativeBuildInputs = [ + curl + pkg-config + wrapGAppsHook + autoPatchelfHook + makeWrapper + ]; + + buildInputs = + [ + atk + bzip2 + cairo + curl + gdk-pixbuf + glib + gtk3 + libusb + libxkbcommon + openssl + pango + udev + vulkan-loader + zlib + ] + ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.CoreFoundation + darwin.apple_sdk.frameworks.CoreGraphics + darwin.apple_sdk.frameworks.CoreServices + darwin.apple_sdk.frameworks.Foundation + darwin.apple_sdk.frameworks.Metal + darwin.apple_sdk.frameworks.QuartzCore + darwin.apple_sdk.frameworks.Security + darwin.apple_sdk.frameworks.SystemConfiguration + ] + ++ lib.optionals stdenv.isLinux [ + wayland + ]; + + patches = [ + # remove when merged: https://github.com/Spagett1/pineflash/pull/86 + ./fix-crash.patch + ]; + + preFixup = '' + wrapProgram $out/bin/pineflash \ + --prefix LD_LIBRARY_PATH : ${ + lib.makeLibraryPath [ + wayland + libGL + libxkbcommon + ] + } \ + --set RUST_SRC_PATH "${rustPlatform.rustLibSrc}" + ''; + + meta = { + description = "A tool to flash ironos to the pinecil soldering iron and possibly other pine64 devices in the future"; + homepage = "https://github.com/Spagett1/PineFlash"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ ]; + mainProgram = "pineflash"; + }; +} diff --git a/pkgs/pineflash/fix-crash.patch b/pkgs/pineflash/fix-crash.patch new file mode 100644 index 0000000..5231b71 --- /dev/null +++ b/pkgs/pineflash/fix-crash.patch @@ -0,0 +1,12 @@ +diff --git a/src/main.rs b/src/main.rs +index bcd4f0c..1395a73 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -529,6 +529,6 @@ fn main() { + }), + ) { + Ok(_) => (), +- Err(error) => panic!("A massive error occured, not sure whats goin on here: \n {}"), ++ Err(error) => panic!("A massive error occured, not sure whats goin on here"), + } + } diff --git a/pkgs/rustypaste/default.nix b/pkgs/rustypaste/default.nix new file mode 100644 index 0000000..1c11eaf --- /dev/null +++ b/pkgs/rustypaste/default.nix @@ -0,0 +1,52 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + openssl, + zstd, + stdenv, + darwin, +}: + +rustPlatform.buildRustPackage rec { + pname = "rustypaste"; + version = "0.16.0"; + + src = fetchFromGitHub { + owner = "orhun"; + repo = "rustypaste"; + rev = "v${version}"; + hash = "sha256-Kv6hmqqGY9SssiT/MYmYCZ71N8CHFTT7K4q7eMdQTQU="; + }; + + cargoHash = "sha256-podM44J7RGpLdPo+yS7clwX6vvvQRllkqPu7UpC/LzI="; + + nativeBuildInputs = [ + pkg-config + ]; + doCheck = false; + buildInputs = + [ + openssl + zstd + ] + ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreFoundation + darwin.apple_sdk.frameworks.CoreServices + darwin.apple_sdk.frameworks.Security + ]; + + env = { + ZSTD_SYS_USE_PKG_CONFIG = true; + }; + + meta = { + description = "A minimal file upload/pastebin service"; + homepage = "https://github.com/orhun/rustypaste"; + changelog = "https://github.com/orhun/rustypaste/blob/${src.rev}/CHANGELOG.md"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ ]; + mainProgram = "rustypaste"; + }; +}