Systemsicherheit/flake.nix

103 lines
2.8 KiB
Nix
Raw Permalink Normal View History

2024-05-27 11:10:14 +02:00
{
description = "LaTeX Documents for Systemsicherheit";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
};
outputs = { self, nixpkgs }: let
assignments = [
"Assignment 4 - Protokollsicherheit (Praxis)"
"Assignment 5 - Software Security - Teil 1"
"Assignment 6 - Software Security - Teil 2"
2024-05-27 11:10:14 +02:00
];
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
] (system: function {
inherit system;
2024-07-03 16:32:57 +02:00
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
2024-05-27 11:10:14 +02:00
});
forAllAssignments = function:
nixpkgs.lib.genAttrs assignments (assignment: function assignment);
texPackages = pkgs: pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-full latex-bin latexmk;
};
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
version = builtins.substring 0 8 lastModifiedDate;
2024-05-27 11:10:14 +02:00
in rec {
2024-07-03 16:32:57 +02:00
packages =
forAllSystems({system, pkgs}: forAllAssignments(assignment: let
tex = texPackages pkgs;
document = pkgs.stdenvNoCC.mkDerivation rec {
name = assignment;
src = self;
buildInputs = [ pkgs.coreutils tex ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
export PATH="${pkgs.lib.makeBinPath buildInputs}";
mkdir -p .cache/texmf-var
cd "./${assignment}"
env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \
latexmk -interaction=nonstopmode -pdf -lualatex \
"./abgabe.tex"
'';
installPhase = ''
mkdir -p $out
cp *.pdf $out/
'';
};
in document) // {
default = packages.${system}.${pkgs.lib.last assignments};
"Assignment 7" = pkgs.signatureProxy;
});
2024-05-27 11:10:14 +02:00
devShells = forAllSystems({pkgs, ...}: let
tex = texPackages pkgs;
in {
default = pkgs.mkShell {
packages = [ pkgs.coreutils tex ];
};
});
overlay = final: prev: with final; {
signatureProxy = stdenv.mkDerivation {
pname = "SignatureProxy";
inherit version;
src = ./7-SGX_Hands-on;
buildScript = ''
make
'';
installScript = ''
mkdir -p $out/bin
cp app $out/bin
cp enclave.so $out/bin
'';
nativeBuildInputs = with pkgs; [
clang
glibc
sgx-sdk
gmp.dev
openssl.dev
pkg-config
];
env = {
SGX_SDK = pkgs.sgx-sdk;
SGX_MODE = "SIM";
};
};
};
2024-05-27 11:10:14 +02:00
};
2024-05-27 11:10:14 +02:00
}