Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "mixnet",
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"updateContentCommand": "devenv ci",
"workspaceFolder": "/workspace",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"customizations": {
"vscode": {
"extensions": [
// run commands on save
// https://marketplace.visualstudio.com/items?itemName=fsevenm.run-it-on
"fsevenm.run-it-on",

// Docker for Visual Studio Code
"ms-azuretools.vscode-docker",

// direnv support
"mkhl.direnv",

// Nix language support
"jnoortheen.nix-ide",

// Markdown support and previsualization
"yzhang.markdown-all-in-one",

// Debugging
"vadimcn.vscode-lldb",

// Allows to use Alt+Q (or Option+Q in mac) to rewrap lines
"stkb.rewrap",

// TOML support, for poetry
"tamasfe.even-better-toml",

// For java support
"vscjava.vscode-java-pack"
]
}
}
}
12 changes: 12 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.6"
services:
devcontainer:
image: ghcr.io/cachix/devenv:latest
volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspace:cached
# Required for ptrace-based debuggers like C++, Go, and Rust
cap_add:
- SYS_PTRACE
security_opt:
- label:disable
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.devenv
.devenv.flake.nix
result
156 changes: 156 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1690413082,
"narHash": "sha256-CPR3WcnrrIiDZJiMo4RlyZB0M3576pHmtlTUnMUTugA=",
"owner": "cachix",
"repo": "devenv",
"rev": "148c4a21e50428728e97f3cdf59166b6007db8a7",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1690327932,
"narHash": "sha256-Fv7PYZxN4eo0K6zXhHG/vOc+e2iuqQ5ywDrh0yeRjP0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a9b47d85504bdd199e90846622c76aa0bfeabfac",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1689668210,
"narHash": "sha256-XAATwDkaUxH958yXLs1lcEOmU6pSEIkatY3qjqk8X0E=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "eb433bff05b285258be76513add6f6c57b441775",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
28 changes: 28 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ pkgs, config, lib, ... }:

{
# https://devenv.sh/basics/
env.GREET = "devenv";

# https://devenv.sh/packages/
packages = [
pkgs.git
pkgs.ack

# to create containers
pkgs.docker

pkgs.libffi
];

enterShell = ''
git --version
'';

# https://devenv.sh/languages/
languages.nix.enable = true;
languages.java = {
enable = true;
jdk.package = pkgs.jdk8;
};
}
64 changes: 64 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
description = "A simple flake for building and installing the mixnet.";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (let
mixnetModule = (import ./mixnet-module.nix);
in {
imports = [];
systems = [ "x86_64-linux" ];

# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
perSystem = perSystemInputs@{ config, self', inputs', pkgs, system, lib, ... }:
{
packages = rec {
mixnet = mixnetModule (perSystemInputs);
default = mixnet;
};
};
flake = {};
});
}
47 changes: 47 additions & 0 deletions mixnet-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ pkgs, jvmMemorySize ? "-Xmx4000m", ... }:
pkgs.stdenv.mkDerivation rec {
pname = "mixnet";
version = "9.0.0";
src = ./.;

nativeBuildInputs = [
pkgs.python3Minimal
pkgs.gnum4
pkgs.automake
pkgs.makeWrapper
pkgs.patchelf
pkgs.autoconf
pkgs.jdk8
];
buildInputs = [
pkgs.jre8
pkgs.gmp
];

configureFlags = [
"--enable-jgmpmee"
"--enable-jecn"
];

makeFlags = [
"JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8"
"JVM_MEMORY_SIZE=${jvmMemorySize}"
];

installPhase = ''
echo "edu-install-phase: start"
mkdir -p $out/bin
mkdir -p $out/share/java
mkdir -p $out/lib
find mixnet/bin -type f -not -name '*.src' -exec cp {} $out/bin \;
find . -name "*.jar" -exec cp {} $out/share/java \;
find . -name "*.so*" -exec cp {} $out/lib \;
patchelf --remove-rpath $out/lib/*.so*;
echo "edu-install-phase: stop"
'';
# TODO:
# - convert patchelf into a find -exec
# - add a find -exec wrapProgram to bins
# - nix flake update in eo

}
Loading