vroom vroom

This commit is contained in:
Peder Bergebakken Sundt 2023-08-17 20:39:22 +02:00
parent 1497e3e679
commit 59fffe853a
4 changed files with 73 additions and 121 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
__pycache__ __pycache__
config.py config.py
*.socket *.socket
result
result-*

View File

@ -1,89 +1,24 @@
{ {
"nodes": { "nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1661621241, "lastModified": 1692174805,
"narHash": "sha256-qUsCgbZNM9b8yOV2XWB//0/qUduDAnbB9WFXr8XzWB0=", "narHash": "sha256-xmNPFDi/AUMIxwgOH/IVom55Dks34u1g7sFKKebxUm0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f214afa5fb6452900e27776735db21f5092261b8", "rev": "caac0eb6bdcad0b32cb2522e03e4002c8975c62e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1661621241,
"narHash": "sha256-qUsCgbZNM9b8yOV2XWB//0/qUduDAnbB9WFXr8XzWB0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f214afa5fb6452900e27776735db21f5092261b8",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"poetry2nix": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1661298951,
"narHash": "sha256-R4zRiXIYic14aNJGuWvBZBblyt6I0GNzgBEQAXhchf4=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "e1e95bbf61be2d150613f5e0560d70c4b316ba4a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix"
} }
} }
}, },

111
flake.nix
View File

@ -1,55 +1,70 @@
{ {
description = "A REST API for managing a MPV instance over via a RPC socket"; description = "A REST API for managing a MPV instance over via a RPC socket";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.poetry2nix.url = "github:nix-community/poetry2nix";
outputs = { self, nixpkgs, flake-utils, poetry2nix }: outputs = {
{ self,
# Nixpkgs overlay providing the application nixpkgs,
overlay = nixpkgs.lib.composeManyExtensions [ ...
poetry2nix.overlay } @ inputs:
(final: prev: { let
# The application forSystems = systems: f: nixpkgs.lib.genAttrs systems (system: f rec {
grzegorz = prev.poetry2nix.mkPoetryApplication { inherit system;
projectDir = ./.; pkgs = nixpkgs.legacyPackages.${system};
}; lib = nixpkgs.legacyPackages.${system}.lib;
}) });
]; forAllSystems = forSystems [
} // (flake-utils.lib.eachDefaultSystem (system: "x86_64-linux"
let "aarch64-linux"
pkgs = import nixpkgs { #"riscv64-linux"
inherit system; ];
overlays = [ self.overlay ]; in {
};
entrypoint = pkgs.writeShellApplication {
name = "grzegorz-run";
runtimeInputs = [
pkgs.grzegorz
pkgs.mpv
];
text = ''
SPIS_MEG=()
if test -z "$*"; then
>&2 echo "DEBUG: No args provided, running with defaults...."
SPIS_MEG=("--host" "::" "--port" "8080")
fi
(
set -x
sanic grzegorz.app "''${SPIS_MEG[@]}" "$@"
)
'';
};
in {
packages = {
inherit (pkgs) grzegorz;
grzegorz-run = entrypoint;
};
apps = { packages = forAllSystems ({ system, pkgs, ...}: rec {
default.type = "app"; sanic-openapi = with pkgs.python3.pkgs; buildPythonPackage rec {
default.program = "${entrypoint}/bin/grzegorz-run"; pname = "sanic-openapi";
version = "21.12.0";
src = fetchPypi {
inherit pname version;
hash = "sha256-fNpiI00IyWX3OeqsawWejyRNhwYdlzNcVyh/1q4Wv1I=";
}; };
})); propagatedBuildInputs = [ sanic pyyaml ];
doCheck = false;
};
grzegorz = with pkgs.python3.pkgs; buildPythonPackage {
pname = "grzegorz";
version = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).tool.poetry.version;
format = "pyproject";
src = ./.;
postInstall = ''
'';
nativeBuildInputs = [ poetry-core ];
propagatedBuildInputs = [ sanic sanic-openapi youtube-dl mpv ];
doCheck = false;
};
grzegorz-run = pkgs.writeShellApplication {
name = "grzegorz-run";
runtimeInputs = [ grzegorz pkgs.mpv ];
text = ''
TOOMANYARGS=()
if test -z "$*"; then
>&2 echo "DEBUG: No args provided, running with defaults...."
TOOMANYARGS=("--host" "::" "--port" "8080")
fi
(
set -x
sanic grzegorz.app "''${TOOMANYARGS[@]}" "$@"
)
'';
};
});
apps = forAllSystems ({ system, pkgs, ...}: {
default.type = "app";
default.program = "${self.packages.${system}.grzegorz-run}/bin/grzegorz-run";
});
};
} }

View File

@ -7,10 +7,10 @@ license = "MIT"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.7,<4.0" python = ">=3.7,<4.0"
mpv = "^0.1" # TODO: do we use this? mpv = ">=0.1" # TODO: do we use this?
youtube_dl = "^2021.12.17" youtube_dl = "^2021.12.17"
sanic = "^21.12.2" sanic = ">=21.12.2"
sanic-openapi = "^21.6.1" sanic-openapi = ">=21.6.1"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
python-lsp-server = {extras = ["all"], version = "^1.3.3"} python-lsp-server = {extras = ["all"], version = "^1.3.3"}