From adb98a13d150abe9a85b33f901b81e6546270b39 Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 19 Dec 2023 06:45:01 +0800 Subject: [PATCH] add cyaron --- cyaron.nix | 33 +++++++++++++++++++++++++++++++++ default.nix | 2 +- flake.lock | 8 ++++---- flake.nix | 4 +++- judge.nix | 2 ++ sandbox.nix | 39 --------------------------------------- 6 files changed, 43 insertions(+), 45 deletions(-) create mode 100644 cyaron.nix delete mode 100644 sandbox.nix diff --git a/cyaron.nix b/cyaron.nix new file mode 100644 index 0000000..098daf9 --- /dev/null +++ b/cyaron.nix @@ -0,0 +1,33 @@ +{ system ? builtins.currentSystem +, pkgs ? import { system = system; } +}: +let + xeger = pkgs.python3Packages.buildPythonPackage rec { + pname = "xeger"; + version = "0.4.0"; + format = "wheel"; + propagatedBuildInputs = with pkgs.python3Packages; [ + setuptools + ]; + src = pkgs.fetchPypi { + inherit pname version format; + sha256 = "sha256-oPVE+vRaxWopr05ii9HmmWM08JBFjXimFYFJDfGq0lI="; + python = "py3"; + dist = "py3"; + }; + }; +in +pkgs.python3Packages.buildPythonPackage rec { + pname = "cyaron"; + version = "0.5.0"; + propagatedBuildInputs = with pkgs.python3Packages; [ + setuptools + colorful + xeger + ]; + doCheck = false; + src = pkgs.fetchPypi { + inherit pname version; + sha256 = "sha256-B0kLUoP7YstDckfAdVmuB4rUmw+g9l/6It6boTuSsII="; + }; +} diff --git a/default.nix b/default.nix index 4eef45e..321f4ac 100644 --- a/default.nix +++ b/default.nix @@ -16,7 +16,7 @@ let mongodb6-cn = callPackage ./mongodb.nix { version = "6.0.12"; mirror = tuna; inherit system; }; mongodb5-cn = callPackage ./mongodb.nix { version = "5.0.10"; mirror = tuna; inherit system; }; mongodb4-cn = callPackage ./mongodb.nix { version = "4.4.16"; mirror = tuna; inherit system; }; - sandbox = callPackage ./sandbox.nix { inherit system; }; + cyaron = callPackage ./cyaron.nix { inherit system; }; gcc = callPackage ./gccWithCache.nix { inherit system; }; judge = callPackage ./judge.nix { inherit system; }; }; diff --git a/flake.lock b/flake.lock index 7d41548..2084296 100644 --- a/flake.lock +++ b/flake.lock @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1700403855, - "narHash": "sha256-Q0Uzjik9kUTN9pd/kp52XJi5kletBhy29ctBlAG+III=", + "lastModified": 1702780907, + "narHash": "sha256-blbrBBXjjZt6OKTcYX1jpe9SRof2P9ZYWPzq22tzXAA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0c5678df521e1407884205fe3ce3cf1d7df297db", + "rev": "1e2e384c5b7c50dbf8e9c441a9e58d85f408b01f", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.05", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index a89e70f..5aba8a4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05; + inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.11; inputs.flake-utils.url = github:numtide/flake-utils; outputs = { self, nixpkgs, flake-utils }: @@ -7,6 +7,8 @@ { packages.judge = (import ./judge.nix) { pkgs = nixpkgs.legacyPackages.${system}; system = system; }; + packages.cyaron = (import ./cyaron.nix) + { pkgs = nixpkgs.legacyPackages.${system}; system = system; }; packages.mongodb = (import ./mongodb.nix) { pkgs = nixpkgs.legacyPackages.${system}; system = system; }; } diff --git a/judge.nix b/judge.nix index ff72993..1c3bce4 100644 --- a/judge.nix +++ b/judge.nix @@ -7,6 +7,7 @@ let gcc = import ./gccWithCache.nix { inherit pkgs; inherit system; }; php = pkgs.php.withExtensions ({ enabled, all }: [ ]); + cyaron = import ./cyaron.nix { inherit pkgs; inherit system; }; in pkgs.buildEnv { name = "judge${if minimal then "-minimal" else ""}"; @@ -50,6 +51,7 @@ pkgs.buildEnv { numpy tkinter pillow + cyaron ])) else [ ]) ++ (if system == "x86_64-linux" then [ pkgs.julia-bin ] else [ ]); diff --git a/sandbox.nix b/sandbox.nix deleted file mode 100644 index f1ba1c3..0000000 --- a/sandbox.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ - system ? builtins.currentSystem, - pkgs ? import { system = system; }, - version ? "1.6.10" -}: - -with pkgs.lib; -let - sha256dict = { - "1.5.4x86_64-linux" = "sha256-fpSRP3jQCWebAsEa1K/71Hw+q6pwOfLcrO5f29sa8qk="; - "1.5.4aarch64-linux" = "sha256-2JZp69BLAwWUJp3EHtAKmuzpt+XsjokSQN/+faTvXCI="; - "1.6.2x86_64-linux" = "sha256:1mlxxx27zax0r0ikny0sjk85a6mbkhaz2b11670sjckp9j659pvs"; - "1.6.2aarch64-linux" = "sha256:0wlf8q93hbmn3qyg577v2r9vbvyqvlsk36r10mwxyddf784yb3kg"; - "1.6.7x86_64-linux" = "sha256:0grjz3as2rss12sh73jxphhbkdi623a3afsg7b77llsqqiw82r5b"; - "1.6.7aarch64-linux" = "sha256:1bxacx8dqadkbxv5jymny60wn8g5bgjrzpyqscfbvjfrrpjmqr42"; - "1.6.10x86_64-linux" = "sha256:13zj8bixw43hqnx4x5kg48f04k73jvm0bd7j5j8xxir009xpj95b"; - "1.6.10aarch64-linux" = "sha256:0bl5z9hb8chw5bhr8jhg4j08r3yzk0qlhf7fjh16nfb5vzsnynm1"; - }; - systemMap = { - "x86_64-linux" = "linux_amd64"; - "aarch64-linux" = "linux_arm64"; - }; - versionDetail = concatStrings [version system]; - src = builtins.fetchurl { - name = "hydro-sandbox-${version}.gz"; - url = "https://hydro.ac/download/executorserver_${version}_${getAttr system systemMap}.gz"; - sha256 = if hasAttr versionDetail sha256dict then getAttr versionDetail sha256dict else ""; - }; -in derivation { - name = "hydro-sandbox-${version}"; - system = system; - # https://github.com/NixOS/nix/issues/2176 - builder = "${pkgs.busybox}/bin/sh"; - args = ["-c" '' - ${pkgs.busybox}/bin/mkdir -p $out/bin && \ - ${pkgs.busybox}/bin/gunzip -d ${src} -c >$out/bin/hydro-sandbox && \ - ${pkgs.busybox}/bin/chmod +x $out/bin/hydro-sandbox - '']; -} \ No newline at end of file