chore(shell.nix): resort to new prepare-env script instead of shellHook and use in gitlab-ci

This commit is contained in:
Sarah Vaupel 2024-06-20 14:38:12 +02:00
parent 951078114a
commit f90a244cd4
2 changed files with 16 additions and 11 deletions

View File

@ -127,7 +127,7 @@ backend lint:
- *stack-cache - *stack-cache
script: script:
- "ls -a ." # TODO: debug only - "ls -a ." # TODO: debug only
- "nix shell .#gnumake .#stack --command make backend-lint-prod" - "nix shell .#gnumake .#stack .#tzdata --command \"prepare-env && make backend-lint-prod\""
before_script: *nix-before before_script: *nix-before
needs: needs:
- job: backend dependencies - job: backend dependencies
@ -164,7 +164,7 @@ backend build:
cache: cache:
- *stack-cache - *stack-cache
script: script:
- "nix shell .#gnumake .#coreutils .#stack --command make backend-build-prod" - "nix shell .#gnumake .#coreutils .#stack .#tzdata --command \"prepare-env && make backend-build-prod\""
- cp $(stack path --dist-dir)/build/hlint/hlint bin/test-hlint - cp $(stack path --dist-dir)/build/hlint/hlint bin/test-hlint
- cp $(stack path --dist-dir)/build/yesod/yesod bin/test-yesod - cp $(stack path --dist-dir)/build/yesod/yesod bin/test-yesod
before_script: *nix-before before_script: *nix-before
@ -249,7 +249,7 @@ uniworx:exe:uniworxload:
frontend test: frontend test:
stage: test stage: test
script: script:
- "nix shell .#gnumake .#nodejs-14_x --command make frontend-test" - "nix shell .#gnumake .#nodejs-14_x .#chromium .#tzdata --command \"prepare-env && make frontend-test\""
before_script: *nix-before before_script: *nix-before
cache: *frontend-cache cache: *frontend-cache
needs: needs:

View File

@ -262,21 +262,26 @@ let
git diff $(cut -d '-' -f 1 <(curl -sH 'Accept: text/plain' https://uni2work.ifi.lmu.de/version)) git diff $(cut -d '-' -f 1 <(curl -sH 'Accept: text/plain' https://uni2work.ifi.lmu.de/version))
''; '';
prepareEnv = pkgs.writeScriptBin "prepare-env" ''
#!${pkgs.zsh}/bin/zsh
export TZDIR=${pkgs.tzdata}/share/zoneinfo
export CHROME_BIN=${pkgs.chromium}/bin/chromium
echo "prepareEnv has been executed"
echo "TZDIR: $TZDIR"
echo "CHROME_BIN: $CHROME_BIN"
'';
in pkgs.mkShell { in pkgs.mkShell {
name = "fradrive"; name = "fradrive";
shellHook = '' shellHook = ''
${pkgs.lib.optionalString (nixpkgsPath != null) '' ${pkgs.lib.optionalString (nixpkgsPath != null) ''
export NIX_PATH=nixpkgs=${nixpkgsPath} export NIX_PATH=nixpkgs=${nixpkgsPath}
''} ''}
prepare-env
export TZDIR=${pkgs.tzdata}/share/zoneinfo
export CHROME_BIN=${pkgs.chromium}/bin/chromium
echo "shellHook has been executed"
echo "TZDIR: $TZDIR"
echo "CHROME_BIN: $CHROME_BIN"
''; '';
nativeBuildInputs = [develop inDevelop killallUni2work diffRunning] nativeBuildInputs = [develop inDevelop killallUni2work diffRunning prepareEnv]
++ (with pkgs; ++ (with pkgs;
[ stdenv coreutils stack nodejs-14_x postgresql_12 openldap exiftool memcached minio minio-client [ stdenv coreutils stack nodejs-14_x postgresql_12 openldap exiftool memcached minio minio-client
gup reuse pre-commit gup reuse pre-commit