247 lines
11 KiB
Nix
247 lines
11 KiB
Nix
{
|
|
inputs.haskell-nix.url = "github:input-output-hk/haskell.nix";
|
|
inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
|
|
inputs.flake-utils.follows = "haskell-nix/flake-utils";
|
|
|
|
inputs.encoding = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/encoding.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.memcached-binary = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/memcached-binary.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.conduit-resumablesink = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/conduit-resumablesink.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.HaskellNet-SSL = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/HaskellNet-SSL.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.ldap-client = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/ldap-client.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.serversession = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/serversession.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.xss-sanitize = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/xss-sanitize.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.colonnade = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/colonnade.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.minio-hs = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/minio-hs.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.cryptoids = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/cryptoids.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.zip-stream = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/zip-stream.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.yesod = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/yesod.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.cryptonite = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/cryptonite.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.esqueleto = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/esqueleto.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
|
|
inputs.tail-DateTime = {
|
|
url = "git+ssh://git@gitlab2.rz.ifi.lmu.de/uni2work/tail.DateTime.git?ref=uni2work";
|
|
flake = false;
|
|
};
|
|
inputs.fontawesome-token = {
|
|
url = "path:/etc/fontawesome-token";
|
|
flake = false;
|
|
};
|
|
|
|
outputs = inputs@{ self, nixpkgs, flake-utils, haskell-nix, ... }: flake-utils.lib.eachSystem ["x86_64-linux"]
|
|
(system:
|
|
let pkgs = import nixpkgs {
|
|
inherit system overlays;
|
|
config.allowUnfree = true;
|
|
};
|
|
overlays =
|
|
let
|
|
frontendSource = pkgs.lib.sourceByRegex ./. [
|
|
"^(assets|frontend)(/.*)?$"
|
|
"^config(/(favicon\.json|robots\.txt))?$"
|
|
"^(webpack|postcss)\.config\.js$"
|
|
"^(package|jsconfig)\.json$"
|
|
"^\.babelrc$"
|
|
];
|
|
backendSource = pkgs.lib.sourceByRegex ./. [
|
|
"^(package|stack-flake)\.yaml$"
|
|
"^stack\.yaml\.lock$"
|
|
"^(assets|app|hlint|load|messages|models|src|templates|test|testdata|wflint)(/.*)?$"
|
|
"^config(/(archive-types|mimetypes|personalised-sheet-files-collate|settings\.yml|submission-blacklist|test-settings\.yml|video-types|wordlist\.txt))?$"
|
|
"^routes$"
|
|
];
|
|
in [
|
|
(import ./nix/maildev)
|
|
haskell-nix.overlay
|
|
(final: prev: {
|
|
uniworx-node-dependencies = (prev.callPackage ./nix/frontend {}).nodeDependencies.override (oldArgs: {
|
|
dependencies =
|
|
let
|
|
srcOverrides = {
|
|
"tail.datetime" = inputs.tail-DateTime;
|
|
"@fortawesome/fontawesome-pro" = prev.fetchurl {
|
|
url = "https://npm.fontawesome.com/@fortawesome/fontawesome-pro/-/5.14.0/fontawesome-pro-5.14.0.tgz";
|
|
curlOpts = "-H @${prev.writeText "headers.txt" "Authorization: Bearer ${builtins.readFile inputs.fontawesome-token}"}";
|
|
hash = "sha256-jGvPrTKKL0rCWRZUEnJEmrOdHyQYs3M5709B1hjmFw4=";
|
|
};
|
|
};
|
|
in map (dep: dep // { src = srcOverrides."${dep.packageName}" or dep.src; }) oldArgs.dependencies;
|
|
});
|
|
})
|
|
(final: prev: {
|
|
uniworx-well-known = prev.stdenv.mkDerivation {
|
|
name = "uniworx-well-known";
|
|
src = frontendSource;
|
|
|
|
phases = ["unpackPhase" "buildPhase" "installPhase" "fixupPhase"];
|
|
|
|
buildPhase = ''
|
|
ln -s ${prev.uniworx-node-dependencies}/lib/node_modules ./node_modules
|
|
export PATH="${prev.uniworx-node-dependencies}/bin:${prev.exiftool}/bin:$PATH"
|
|
webpack --progress
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp -r --reflink=auto well-known $out/.nix-well-known
|
|
'';
|
|
|
|
outputHashMode = "recursive";
|
|
outputHashAlgo = "sha256";
|
|
outputHash = "tDaffdAT5EGPKdDJ2ovo9XSGdV48W3Efqe+iBmakh6g=";
|
|
};
|
|
})
|
|
(final: prev: {
|
|
uniworx-frontend = prev.stdenv.mkDerivation {
|
|
name = "uniworx-frontend";
|
|
srcs = [frontendSource prev.uniworx-well-known];
|
|
sourceRoot = "source";
|
|
|
|
phases = ["unpackPhase" "buildPhase" "installPhase"];
|
|
|
|
postUnpack = ''
|
|
cp -pr --reflink=auto uniworx-well-known/. $sourceRoot
|
|
'';
|
|
|
|
buildPhase = ''
|
|
ln -s ${prev.uniworx-node-dependencies}/lib/node_modules ./node_modules
|
|
export PATH="${prev.uniworx-node-dependencies}/bin:$PATH"
|
|
webpack --progress
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out $out/config
|
|
cp -r --reflink=auto well-known static $out
|
|
cp -r --reflink=auto config/webpack.yml $out/config
|
|
'';
|
|
};
|
|
})
|
|
(final: prev: {
|
|
uniworx = final.haskell-nix.stackProject {
|
|
src = prev.stdenv.mkDerivation {
|
|
name = "uniworx-src";
|
|
src = backendSource;
|
|
|
|
phases = ["unpackPhase" "patchPhase" "installPhase"];
|
|
|
|
patchPhase = ''
|
|
substitute stack-flake.yaml stack.yaml \
|
|
${prev.lib.concatMapStringsSep " \\\n" (pkgName: "--replace @${pkgName}@ ${inputs."${pkgName}"}") haskellInputs}
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp -pr --reflink=auto ./. $out
|
|
'';
|
|
};
|
|
compiler-nix-name = "ghc8104";
|
|
# stack-sha256 = "1n7z294ldv2rjkfj1vs3kqmnbp34m2scrmyrp5kwmga9vp86fd9z";
|
|
modules = [
|
|
{
|
|
packages = {
|
|
encoding.src = inputs.encoding;
|
|
memcached-binary.src = inputs.memcached-binary;
|
|
conduit-resumablesink.src = inputs.conduit-resumablesink;
|
|
HaskellNet-SSL.src = inputs.HaskellNet-SSL;
|
|
ldap-client.src = inputs.ldap-client;
|
|
serversession.src = "${inputs.serversession}/serversession";
|
|
serversession-backend-acid-state.src = "${inputs.serversession}/serversession-backend-acid-state";
|
|
xss-sanitize.src = inputs.xss-sanitize;
|
|
colonnade.src = "${inputs.colonnade}/colonnade";
|
|
minio-hs.src = inputs.minio-hs;
|
|
cryptoids-class.src = "${inputs.cryptoids}/cryptoids-class";
|
|
cryptoids-types.src = "${inputs.cryptoids}/cryptoids-types";
|
|
cryptoids.src = "${inputs.cryptoids}/cryptoids";
|
|
filepath-crypto.src = "${inputs.cryptoids}/filepath-crypto";
|
|
uuid-crypto.src = "${inputs.cryptoids}/uuid-crypto";
|
|
zip-stream.src = inputs.zip-stream;
|
|
yesod.src = "${inputs.yesod}/yesod";
|
|
yesod-core.src = "${inputs.yesod}/yesod-core";
|
|
yesod-static.src = "${inputs.yesod}/yesod-static";
|
|
yesod-persistent.src = "${inputs.yesod}/yesod-persistent";
|
|
yesod-form.src = "${inputs.yesod}/yesod-form";
|
|
yesod-auth.src = "${inputs.yesod}/yesod-auth";
|
|
yesod-test.src = "${inputs.yesod}/yesod-test";
|
|
cryptonite.src = inputs.cryptonite;
|
|
esqueleto.src = inputs.esqueleto;
|
|
};
|
|
}
|
|
{
|
|
packages.uniworx = {
|
|
postUnpack = ''
|
|
cp -pr --reflink=auto ${prev.uniworx-frontend}/. $sourceRoot
|
|
chmod a+w -R $sourceRoot
|
|
'';
|
|
preBuild = ''
|
|
export TZDIR=${final.tzdata}/share/zoneinfo
|
|
'';
|
|
components.library.build-tools = with final.pkgs; [ llvm_9 ];
|
|
components.exes.uniworx.build-tools = with final.pkgs; [ llvm_9 ];
|
|
components.exes.uniworxdb.build-tools = with final.pkgs; [ llvm_9 ];
|
|
components.exes.uniworxload.build-tools = with final.pkgs; [ llvm_9 ];
|
|
components.exes.uniworx-wflint.build-tools = with final.pkgs; [ llvm_9 ];
|
|
components.tests.yesod.build-tools = with final.pkgs; [ llvm_9 ];
|
|
components.tests.hlint.build-tools = with final.pkgs; [ llvm_9 ];
|
|
};
|
|
}
|
|
];
|
|
};
|
|
})
|
|
];
|
|
haskellInputs = ["encoding" "memcached-binary" "conduit-resumablesink" "HaskellNet-SSL" "ldap-client" "serversession" "xss-sanitize" "colonnade" "minio-hs" "cryptoids" "zip-stream" "yesod" "cryptonite" "esqueleto"];
|
|
|
|
haskellFlake = pkgs.uniworx.flake {};
|
|
in {
|
|
packages = haskellFlake.packages // { inherit (pkgs) uniworx-node-dependencies uniworx-well-known uniworx-frontend; inherit (pkgs.uniworx.stack-nix.passthru) calculateMaterializedSha; };
|
|
inherit (haskellFlake) checks apps;
|
|
|
|
devShell = import ./shell.nix { inherit pkgs; };
|
|
|
|
legacyPackages = pkgs;
|
|
|
|
defaultPackage = haskellFlake.packages."uniworx:exe:uniworx";
|
|
}
|
|
);
|
|
}
|