Skip to content

Commit 211bcd2

Browse files
committed
switch to nix flakes and upgrade many envs
1 parent 83550ca commit 211bcd2

File tree

11 files changed

+233
-150
lines changed

11 files changed

+233
-150
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
name: "Build"
1+
name: build
22
on:
33
push:
4+
branches: [master]
5+
46
jobs:
57
build:
68
runs-on: ubuntu-latest
79
steps:
8-
- uses: actions/checkout@v2.3.4
9-
- uses: cachix/install-nix-action@v13
10-
with:
11-
nix_path: nixpkgs=channel:nixos-unstable
12-
- uses: cachix/cachix-action@v9
13-
with:
14-
name: soha
15-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
16-
- run: nix-build
10+
- uses: actions/checkout@v3
11+
- uses: cachix/install-nix-action@v20
12+
with:
13+
nix_path: nixpkgs=channel:nixos-unstable-small
14+
- uses: cachix/cachix-action@v12
15+
with:
16+
name: luogu-judge
17+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
18+
- run: nix flake show --json | jq '.packages."x86_64-linux"|keys[]' | xargs -I {} nix build .#{}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
result
22
result-*
3+
profile-test
4+
profile-test-*
5+
profiles

checker/default.nix

Lines changed: 0 additions & 18 deletions
This file was deleted.

checker/overlay.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
self: super: let
2+
inherit(super) stdenv;
3+
in {
4+
ljudge-checker = stdenv.mkDerivation (with super; {
5+
pname = "ljudge-checkers";
6+
version = "0.1.0";
7+
src = ./src;
8+
9+
buildInputs = [ cmake ];
10+
configurePhase = "cmake .";
11+
buildPhase = "make";
12+
installPhase = ''
13+
mkdir -p $out/bin
14+
mv {noip,strict}-checker $out/bin
15+
'';
16+
});
17+
}

default.nix

Lines changed: 0 additions & 82 deletions
This file was deleted.

flake.lock

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
description = "Luogu Judge Environment";
3+
inputs = {
4+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
5+
nixpkgs_gcc930.url = "github:NixOS/nixpkgs/99cd95772761842712f77c291d26443ee039d862";
6+
rust-overlay.url = "github:oxalica/rust-overlay";
7+
};
8+
outputs = inputs@{ self, nixpkgs, nixpkgs_gcc930, rust-overlay, ... }: let
9+
system = "x86_64-linux";
10+
11+
inherit(nixpkgs) lib;
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
overlays = [
15+
rust-overlay.overlays.default
16+
(self: super: {
17+
gcc930 = nixpkgs_gcc930.legacyPackages.${super.system}.gcc9;
18+
})
19+
(import ./gcc/overlay.nix)
20+
(import ./checker/overlay.nix)
21+
];
22+
};
23+
24+
createEnv = name: packages: (pkgs.buildEnv {
25+
name = "ljudge-env_${builtins.replaceStrings ["/"] ["_"] name}";
26+
paths = with pkgs; [
27+
coreutils bash
28+
ljudge-checker
29+
] ++ packages;
30+
});
31+
in {
32+
packages."${system}" = lib.mapAttrs createEnv (with pkgs; {
33+
text = [gnutar gzip];
34+
gcc = [luogu-gcc];
35+
gcc-930 = [luogu-gcc930];
36+
rustc = [rust-bin.nightly.latest.default];
37+
ghc = [ghc];
38+
python3-c = [(python311.withPackages (p: with p; [
39+
numpy
40+
]))];
41+
python3-py = [pypy3];
42+
pascal-fpc = [fpc];
43+
go = [go];
44+
php = [(php82.buildEnv {
45+
extensions = { all, ... }: with all; [
46+
opcache ctype posix filter bcmath
47+
iconv mbstring readline gmp
48+
];
49+
})];
50+
ruby = [ruby];
51+
js-node = [nodejs_20];
52+
perl = [perl];
53+
java-8 = [jdk8_headless];
54+
java-21 = [jdk21_headless];
55+
kotlin-jvm = [(kotlin.override { jre = jdk21_headless; })];
56+
scala = [(scala.override { jre = jdk21_headless; })];
57+
lua = [lua];
58+
mono = [mono]; # TODO: use dotnet
59+
ocaml = [ocaml];
60+
julia = [julia];
61+
});
62+
# packages."${system}" = {
63+
# text = createJudgeProfile "text" [gnutar gzip];
64+
65+
# # C-family: GCC
66+
# gcc = pkgs.luogu-gcc;
67+
# gcc9 = pkgs.luogu-gcc-9;
68+
69+
# # Rust
70+
# rust = pkgs.rust-bin.nightly.latest.default;
71+
# };
72+
};
73+
}

gcc-luogu/default.nix

Lines changed: 0 additions & 26 deletions
This file was deleted.

gcc/overlay.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
self: super: let
2+
pname = "luogu-gcc";
3+
4+
applyLuogu = gcc: let
5+
cc = gcc.cc.overrideAttrs(a: with a; {
6+
inherit pname;
7+
patches = patches ++ [
8+
./disable-pragma-and-attribute-for-optimize.patch
9+
];
10+
});
11+
in super.wrapCC(cc);
12+
in {
13+
luogu-gcc = applyLuogu(super.gcc13);
14+
luogu-gcc930 = applyLuogu(super.gcc930);
15+
}

0 commit comments

Comments
 (0)