/ flake.nix
flake.nix
1 { 2 inputs = { 3 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; 4 }; 5 6 outputs = 7 { nixpkgs, ... }: 8 let 9 defaultSystems = [ 10 "x86_64-linux" 11 "x86_64-darwin" 12 "aarch64-linux" 13 "aarch64-darwin" 14 ]; 15 eachDefaultSystem = 16 f: 17 builtins.listToAttrs ( 18 map (system: { 19 name = system; 20 value = f rec { 21 inherit system; 22 pkgs = import nixpkgs { 23 inherit system; 24 config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "dyalog" ]; 25 }; 26 27 python = pkgs.python313.withPackages ( 28 p: with p; [ 29 z3-solver 30 numpy 31 networkx 32 sympy 33 shapely 34 ] 35 ); 36 37 # pypy = pkgs.pypy310.withPackages ( 38 # p: with p; [ 39 # z3-solver 40 # numpy 41 # networkx 42 # sympy 43 # ] 44 # ); 45 46 downloadInput = pkgs.stdenvNoCC.mkDerivation { 47 name = "aoc-download-input"; 48 dontUnpack = true; 49 nativeBuildInputs = with pkgs; [ makeWrapper ]; 50 installPhase = '' 51 mkdir -p $out/bin 52 cp ${./scripts/download_input.sh} $out/bin/aoc-download-input 53 chmod +x $out/bin/* 54 wrapProgram $out/bin/* --set PATH ${ 55 with pkgs; 56 lib.makeBinPath [ 57 bash 58 coreutils 59 curl 60 gnugrep 61 termdown 62 less 63 glibc 64 ] 65 } 66 ''; 67 }; 68 getSession = pkgs.python3.pkgs.buildPythonApplication { 69 name = "aoc-get-session"; 70 pyproject = false; 71 dontUnpack = true; 72 installPhase = "mkdir -p $out/bin; cp ${./scripts/get_session.py} $out/bin/aoc-get-session; chmod +x $out/bin/*"; 73 propagatedBuildInputs = with pkgs.python3.pkgs; [ 74 requests 75 pycrypto 76 ]; 77 }; 78 pruneLeaderboard = pkgs.python3.pkgs.buildPythonApplication { 79 name = "aoc-prune-leaderboard"; 80 pyproject = false; 81 dontUnpack = true; 82 installPhase = "mkdir -p $out/bin; cp ${./scripts/prune_leaderboard.py} $out/bin/aoc-prune-leaderboard; chmod +x $out/bin/*"; 83 propagatedBuildInputs = with pkgs.python3.pkgs; [ requests ]; 84 }; 85 fetchRanks = pkgs.python3.pkgs.buildPythonApplication { 86 name = "aoc-fetch-ranks"; 87 pyproject = false; 88 dontUnpack = true; 89 installPhase = "mkdir -p $out/bin; cp ${./scripts/fetch_ranks.py} $out/bin/aoc-fetch-ranks; chmod +x $out/bin/*"; 90 propagatedBuildInputs = with pkgs.python3.pkgs; [ 91 requests 92 beautifulsoup4 93 ]; 94 }; 95 live = pkgs.python3.pkgs.buildPythonApplication { 96 name = "aoc-live"; 97 pyproject = false; 98 dontUnpack = true; 99 installPhase = "mkdir -p $out/bin; cp ${./scripts/live.py} $out/bin/aoc-live; chmod +x $out/bin/*"; 100 makeWrapperArgs = [ "--set AOC_PYTHON ${python}/bin/python" ]; 101 propagatedBuildInputs = with pkgs.python3.pkgs; [ 102 requests 103 beautifulsoup4 104 pyperclip 105 watchdog 106 ]; 107 }; 108 }; 109 }) defaultSystems 110 ); 111 in 112 { 113 devShells = eachDefaultSystem ( 114 { 115 system, 116 pkgs, 117 downloadInput, 118 getSession, 119 pruneLeaderboard, 120 fetchRanks, 121 live, 122 python, 123 # pypy, 124 ... 125 }: 126 { 127 default = pkgs.mkShell { 128 buildInputs = [ 129 downloadInput 130 getSession 131 pruneLeaderboard 132 fetchRanks 133 live 134 pkgs.z3 135 ]; 136 packages = with pkgs; [ 137 just 138 jq 139 hyperfine 140 141 # Python 142 python 143 # pypy 144 145 # Haskell 146 (haskellPackages.ghcWithPackages ( 147 p: with p; [ 148 split 149 regex-tdfa 150 ] 151 )) 152 haskell-language-server 153 ormolu # haskell code formatter 154 155 # APL 156 # (dyalog.override { 157 # acceptLicense = true; 158 # }) 159 160 # Uiua 161 (uiua-unstable.override { windowSupport = true; }) 162 163 # Nushell 164 nushell 165 166 # Ruby 167 ruby 168 solargraph 169 170 # Lean 171 lean4 172 173 # Par 174 par-lang 175 ]; 176 PYTHONPATH = "."; 177 LIBCLANG_PATH = with pkgs; lib.makeLibraryPath [ llvmPackages.clang-unwrapped.lib ]; 178 LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [ z3.lib ]; 179 CPATH = 180 with pkgs; 181 lib.makeSearchPath "include" [ 182 musl.dev 183 llvmPackages.clang-unwrapped.lib 184 z3.dev 185 ]; 186 UIUA_RECURSION_LIMIT = 1000; 187 }; 188 } 189 ); 190 }; 191 }