From c96f0a29aeace349aa1f6b5761d6c977c4fe363f Mon Sep 17 00:00:00 2001 From: ihaveahax Date: Sat, 10 Feb 2024 21:23:36 -0600 Subject: [PATCH] add nix flake and stuff --- .gitignore | 2 ++ default.nix | 6 +++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 21 ++++++++++++++++ haccrypto.nix | 18 ++++++++++++++ ninfs.nix | 20 ++++++++++++++++ ninfs/__main__.py | 5 ++++ 7 files changed, 133 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 haccrypto.nix create mode 100644 ninfs.nix diff --git a/.gitignore b/.gitignore index 45c9039..9ed66f0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ __pycache__/ *.pyd # dll and dylib are not here, since libcrypto needs to be included Thumbs.db +result +result-* diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..dcd4dd5 --- /dev/null +++ b/default.nix @@ -0,0 +1,6 @@ +{ pkgs ? import {} }: + +rec { + haccrypto = pkgs.python3Packages.callPackage ./haccrypto.nix {}; + ninfs = pkgs.python3Packages.callPackage ./ninfs.nix { haccrypto = haccrypto; }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..307d633 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1707451808, + "narHash": "sha256-UwDBUNHNRsYKFJzyTMVMTF5qS4xeJlWoeyJf+6vvamU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "442d407992384ed9c0e6d352de75b69079904e4e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..718672b --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + description = "ninfs"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = inputs@{ self, nixpkgs, flake-utils }: + + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; in { + + packages = rec { + haccrypto = pkgs.python3Packages.callPackage ./haccrypto.nix {}; + ninfs = pkgs.python3Packages.callPackage ./ninfs.nix { haccrypto = haccrypto; }; + default = ninfs; + }; + } + ); +} diff --git a/haccrypto.nix b/haccrypto.nix new file mode 100644 index 0000000..c23e758 --- /dev/null +++ b/haccrypto.nix @@ -0,0 +1,18 @@ +{ lib, buildPythonPackage, pythonOlder, fetchPypi }: + +buildPythonPackage rec { + pname = "haccrypto"; + version = "0.1.3"; + format = "setuptools"; + + disabled = pythonOlder "3.6"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-PHkAxy0lq7SsdQlKSq2929Td8UDFVMleCYnq2t1xg44="; + }; + + pythonImportsCheck = [ + "haccrypto" + ]; +} diff --git a/ninfs.nix b/ninfs.nix new file mode 100644 index 0000000..3e2f66a --- /dev/null +++ b/ninfs.nix @@ -0,0 +1,20 @@ +{ lib, callPackage, buildPythonApplication, fetchPypi, pyctr, pycryptodomex, pypng, tkinter, setuptools, fusepy, haccrypto, pip }: + +buildPythonApplication rec { + pname = "ninfs"; + version = "2.0a11"; + format = "setuptools"; + + srcs = builtins.path { path = ./.; name = "ninfs"; }; + + propagatedBuildInputs = [ + pyctr + pycryptodomex + pypng + tkinter + setuptools # missing from requirements.txt + fusepy # despite ninfs including its own copy of fuse.py, it can't find it for some reason + pip + haccrypto + ]; +} diff --git a/ninfs/__main__.py b/ninfs/__main__.py index b4194db..08183fa 100755 --- a/ninfs/__main__.py +++ b/ninfs/__main__.py @@ -7,6 +7,11 @@ from os.path import dirname, realpath from sys import argv, exit, path +if 'nix_run_setup' in argv: + # I don't understand why this gets called with nix build! + print('nix build is calling me!') + exit(0) + # path fun times path.insert(0, dirname(realpath(__file__)))