From 134d338ab8eab6ced0918d52e6907f5dadac4b35 Mon Sep 17 00:00:00 2001 From: Rien Maertens Date: Thu, 24 Oct 2024 10:24:19 +0200 Subject: [PATCH] Generate docker image using flake --- flake.nix | 19 +++++++++++++++++++ package.nix | 20 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 9b7b29a07..d95bf5594 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,25 @@ packages = rec { default = dolos-cli; dolos-cli = pkgs.callPackage (import ./package.nix) {}; + dolos-docker-image = pkgs.dockerTools.buildImage { + name = "ghcr.io/dodona-edu/dolos-cli"; + tag = "latest"; + copyToRoot = pkgs.buildEnv { + name = "image-root"; + paths = [ dolos-cli ]; + pathsToLink = [ "/bin" ]; + }; + runAsRoot = '' + mkdir -p /dolos + ''; + config = { + Cmd = [ "/bin/dolos" ]; + WorkingDir = "/dolos"; + }; + }; + dolos-load-docker = pkgs.writeShellScriptBin "dolos-load-docker" '' + docker load < ${dolos-docker-image} + ''; }; overlays.default = final: prev: { dolos-cli = final.callPackage (import ./package.nix) {}; diff --git a/package.nix b/package.nix index 28aba8cbd..8ec1aa358 100644 --- a/package.nix +++ b/package.nix @@ -7,9 +7,25 @@ buildNpmPackage rec { pname = "dolos"; version = "2.7.1"; - src = ./.; + srcs = [ + ./package.json + ./package-lock.json + ./tsconfig.global.json + ./core + ./parsers + ./lib + ./web + ./cli + ]; - npmDepsHash = "sha256-qgAdXhohaIyQffkiIWxVXeE3c4JRTgbjxrNFI9dlaNs="; + unpackPhase = '' + for src in $srcs; do + cp -r $src ./$(stripHash $src) + chmod -R 700 ./$(stripHash $src) + done + ''; + + npmDepsHash = "sha256-XMATCZS/j5bcGjfUQnaFC2mPCv47+3tgIfruTYUQhN4="; npmWorkspace="cli";