Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Last active Jul 1, 2022
Embed
What would you like to do?
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1655624069,
"narHash": "sha256-7g1zwTdp35GMTERnSzZMWJ7PG3QdDE8VOX3WsnOkAtM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0d68d7c857fe301d49cdcd56130e0beea4ecd5aa",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python3.withPackages (ps: with ps; [ selenium ]);
simplenet = ps: ps.callPackage ./simplenet.nix { };
pythonWithSimplenet = pkgs.python3.withPackages (ps: [ (simplenet ps) ]);
in
{
packages.${system} = {
output1 = pkgs.writeScriptBin "myscript" ''
echo foo
'';
output2 = pkgs.writeScriptBin "myscript" ./myscript.sh;
output3 = pkgs.writeScriptBin "myscript" ''
export PATH=${pkgs.lib.makeBinPath [ pkgs.hello ]}:$PATH
${./run-hello.sh}
'';
output4 =
let
tmpPyScript = pkgs.writeTextFile {
name = "tmp-py-script";
text = ''
print("foo from python")
'';
};
in
pkgs.writeScriptBin "run-python" ''
${python}/bin/python ${tmpPyScript}
'';
runner = pkgs.writeShellApplication
{
name = "runme";
checkPhase = ":";
runtimeInputs = [pythonWithSimplenet];
text = ''
"${pythonWithSimplenet}/bin/python" ${./foo.py}
'';
};
};
};
}
# foo.py
import sys
import simplenet
print(sys.executable)
print(simplenet.__version__)
#!/usr/bin/env bash
echo foo2
{ lib
, buildPythonPackage
, fetchPypi
, numpy
, build
}:
buildPythonPackage rec {
pname = "simplenet";
version = "0.1.4";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-lW5LXjDO6CxvoGzvDr8jmQhg7DG5XLbTYi0mifuofwk=";
};
propagatedBuildInputs = [
numpy
];
patches = [
./simplenet.patch
];
buildPhase = ''
${build}/bin/pyproject-build --no-isolation
'';
doCheck = false;
meta = with lib; {
homepage = "https://github.com/n8henrie/simplenet";
description = "A simple neural network in Python ";
license = licenses.mit;
maintainers = [ ];
};
}
--- a/setup.cfg 2022-07-01 13:59:18.009491094 +0700
+++ b/setup.cfg 2022-07-01 13:59:31.423435045 +0700
@@ -24,3 +24,3 @@ include_package_data = True
install_requires =
- numpy==1.22.4
+ numpy~=1.21.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment