From 5c642737bbca3b7ad39414179f5a072d5a4b0649 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Mon, 14 Aug 2023 18:17:16 +0200 Subject: [PATCH] chore: change to devenv --- .envrc | 3 + .gitignore | 389 ++----------------------------------------------- .gitlab-ci.yml | 64 ++++++++ Makefile | 102 ------------- Taskfile.yml | 48 ++++++ devenv.lock | 190 ++++++++++++++++++++++++ devenv.nix | 149 +++++++++++++++++++ devenv.yaml | 7 + 8 files changed, 477 insertions(+), 475 deletions(-) create mode 100644 .envrc create mode 100644 .gitlab-ci.yml delete mode 100644 Makefile create mode 100644 Taskfile.yml create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6de8a8a --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" + +use devenv \ No newline at end of file diff --git a/.gitignore b/.gitignore index b17bdca..13bb7b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,5 @@ - -# Makefile comes from update -Makefile.example - -# Vendor -/development/vendor/ -/deployment/vendor/ - -# Created by https://www.toptal.com/developers/gitignore/api/intellij+iml,phpunit,git,vim,visualstudiocode,phpstorm,go,intellij+all,netbeans,dbeaver,node,yarn -# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+iml,phpunit,git,vim,visualstudiocode,phpstorm,go,intellij+all,netbeans,dbeaver,node,yarn - -### DBeaver ### -# ide config file -.dbeaver-data-sources*.xml - -### Git ### -# Created by git for backups. To disable backups in Git: -# git config --global mergetool.keepBackup false -*.orig - -# Created by git when using merge tools for conflicts -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* -*_BACKUP_*.txt -*_BASE_*.txt -*_LOCAL_*.txt -*_REMOTE_*.txt +# Created by https://www.toptal.com/developers/gitignore/api/intellij,go +# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,go ### Go ### # If you prefer the allow list template instead of the deny list, see community template: @@ -55,7 +28,7 @@ go.work /vendor/ /Godeps/ -### Intellij+all ### +### Intellij ### # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 @@ -134,272 +107,7 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser -### Intellij+all Patch ### -# Ignore everything but code style settings and run configurations -# that are supposed to be shared within teams. - -.idea/* - -!.idea/codeStyles -!.idea/runConfigurations - -### Intellij+iml ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff - -# AWS User-specific - -# Generated files - -# Sensitive or high-churn files - -# Gradle - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake - -# Mongo Explorer plugin - -# File-based project format - -# IntelliJ - -# mpeltonen/sbt-idea plugin - -# JIRA plugin - -# Cursive Clojure plugin - -# SonarLint plugin - -# Crashlytics plugin (for Android Studio and IntelliJ) - -# Editor-based Rest Client - -# Android studio 3.1+ serialized cache file - -### Intellij+iml Patch ### -# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 - -*.iml -modules.xml -.idea/misc.xml -*.ipr - -### NetBeans ### -**/nbproject/private/ -**/nbproject/Makefile-*.mk -**/nbproject/Package-*.bash -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ - -### Node ### -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -### Node Patch ### -# Serverless Webpack directories -.webpack/ - -# Optional stylelint cache - -# SvelteKit build / generate output -.svelte-kit - -### PhpStorm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff - -# AWS User-specific - -# Generated files - -# Sensitive or high-churn files - -# Gradle - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake - -# Mongo Explorer plugin - -# File-based project format - -# IntelliJ - -# mpeltonen/sbt-idea plugin - -# JIRA plugin - -# Cursive Clojure plugin - -# SonarLint plugin - -# Crashlytics plugin (for Android Studio and IntelliJ) - -# Editor-based Rest Client - -# Android studio 3.1+ serialized cache file - -### PhpStorm Patch ### +### Intellij Patch ### # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 # *.iml @@ -423,7 +131,8 @@ dist # Cache file creation bug # See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/ACHE_FILE +.idea/$CACHE_FILE$ + # CodeStream plugin # https://plugins.jetbrains.com/plugin/12206-codestream .idea/codestream.xml @@ -432,81 +141,15 @@ dist # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij .idea/**/azureSettings.xml -### PHPUnit ### -# Covers PHPUnit -# Reference: https://phpunit.de/ +# End of https://www.toptal.com/developers/gitignore/api/intellij,go +# Devenv +.devenv* +devenv.local.nix -# Generated files -.phpunit.result.cache -.phpunit.cache - -# PHPUnit -/app/phpunit.xml -/phpunit.xml - -# Build data -/build/ - -### Vim ### -# Swap -[._]*.s[a-v][a-z] -!*.svg # comment out if you don't need vector files -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Session -Session.vim -Sessionx.vim - -# Temporary -.netrwhist -*~ -# Auto-generated tag files -tags -# Persistent undo -[._]*.un~ - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets - -# Local History for Visual Studio Code -.history/ - -# Built Visual Studio Code Extensions -*.vsix - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -# Support for Project snippet scope -.vscode/*.code-snippets - -# Ignore code-workspaces -*.code-workspace - -### yarn ### -# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored - -.yarn/* -!.yarn/releases -!.yarn/patches -!.yarn/plugins -!.yarn/sdks -!.yarn/versions - -# if you are NOT using Zero-installs, then: -# comment the following lines -!.yarn/cache - -# and uncomment the following lines -# .pnp.* +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml +/Session.vim diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..7b2885e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,64 @@ +image: docker-registry.schukai.com:443/nixos-ci-devenv:latest + +services: + - docker:dind + + +variables: + # The repo name as used in + # https://github.com/nix-community/NUR/blob/master/repos.json + NIXOS_VERSION: "23.05" + NIXPKGS_ALLOW_UNFREE: "1" + NIXPKGS_ALLOW_INSECURE: "1" + DOCKER_DRIVER: overlay2 + GIT_DEPTH: 10 + + +stages: + - test + - deploy + +before_script: + - nix shell nixpkgs#coreutils-full -c mkdir -p /certs/client/ + - nix shell nixpkgs#coreutils-full -c ln -fs /etc/ssl/certs/ca-bundle.crt /certs/client/ca.pem + - echo > .env-gitlab-ci + - variables=("HOME=$HOME" "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" "CI_REPOSITORY_URL=$CI_REPOSITORY_URL" "GITLAB_TOKEN=$GITLAB_TOKEN" "CI_JOB_TOKEN=$CI_JOB_TOKEN" "GITLAB_USER_EMAIL=$GITLAB_USER_EMAIL" "GITLAB_USER_NAME=\"$GITLAB_USER_NAME\"" "CI_REGISTRY_USER=$CI_REGISTRY_USER" "CI_PROJECT_ID=$CI_PROJECT_ID" "CI_PROJECT_DIR=$CI_PROJECT_DIR" "CI_API_V4_URL=$CI_API_V4_URL" "CI_PROJECT_NAME=$CI_PROJECT_NAME" "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA"); for var in "${variables[@]}"; do echo "$var" >> .env-gitlab-ci; done + - cat .env-gitlab-ci + +after_script: + - if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi + +test: + stage: test + tags: + - nixos + script: + - devenv shell test-lib + + cache: + - key: nixos + paths: + - /nix/store + + artifacts: + paths: + - dist + +deploy: + stage: deploy + tags: + - nixos + script: + - devenv shell -c deploy-lib + + when: on_success + + cache: + - key: nixos + paths: + - /nix/store + + + artifacts: + paths: + - dist diff --git a/Makefile b/Makefile deleted file mode 100644 index 85b1232..0000000 --- a/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -############################################################################################# -############################################################################################# -## -## PROJECT-DEFINITIONS -## -############################################################################################# -############################################################################################# - -COMPONENT_NAME := html-engine - -############################################################################################# -############################################################################################# -## -## MORE GENERAL BLOCK WITH STANDARD DEFINITIONS -## -############################################################################################# -############################################################################################# - -# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 -THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) -PROJECT_ROOT:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)/ -THIS_MAKEFILE:=$(PROJECT_ROOT)$(THIS_MAKEFILE_PATH) - -# include project.mk only if it exists --include $(PROJECT_ROOT)project.mk - - -# Define the location of Makefiles -MAKEFILE_IMPORT_PATH?=$(PROJECT_ROOT)makefiles/ - -# include project.mk only if it exists --include $(MAKEFILE_IMPORT_PATH)project.mk - -############################################################################################# -############################################################################################# -## -## INCLUSION OF VARIOUS STANDARD RULES -## -############################################################################################# -############################################################################################# - -#include $(MAKEFILE_IMPORT_PATH)directories-standard.mk -include $(MAKEFILE_IMPORT_PATH)directories-go-lib.mk -#include $(MAKEFILE_IMPORT_PATH)directories-go-utilities.mk -#include $(MAKEFILE_IMPORT_PATH)directories-platform-part.mk -#include $(MAKEFILE_IMPORT_PATH)jsdoc.mk -include $(MAKEFILE_IMPORT_PATH)output.mk -include $(MAKEFILE_IMPORT_PATH)placeholder.mk -#include $(MAKEFILE_IMPORT_PATH)conan.mk -#include $(MAKEFILE_IMPORT_PATH)s3.mk -#include $(MAKEFILE_IMPORT_PATH)readme-standard.mk -#include $(MAKEFILE_IMPORT_PATH)readme-webcomponents.mk -#include $(MAKEFILE_IMPORT_PATH)readme-go-utilities.mk -include $(MAKEFILE_IMPORT_PATH)readme-go-lib.mk -#include $(MAKEFILE_IMPORT_PATH)readme-platform-part.mk -include $(MAKEFILE_IMPORT_PATH)licenses.mk -include $(MAKEFILE_IMPORT_PATH)license-agpl3.mk -#include $(MAKEFILE_IMPORT_PATH)license-unlicensed.mk -#include $(MAKEFILE_IMPORT_PATH)license-all-rights-reserved.mk -#include $(MAKEFILE_IMPORT_PATH)jsdoc-json.mk -include $(MAKEFILE_IMPORT_PATH)go.mk -include $(MAKEFILE_IMPORT_PATH)changelog.mk -#include $(MAKEFILE_IMPORT_PATH)docman.mk -#include $(MAKEFILE_IMPORT_PATH)reqman.mk -include $(MAKEFILE_IMPORT_PATH)git.mk -include $(MAKEFILE_IMPORT_PATH)gitignore.mk -include $(MAKEFILE_IMPORT_PATH)color.mk -include $(MAKEFILE_IMPORT_PATH)version.mk -#include $(MAKEFILE_IMPORT_PATH)docker.mk -#include $(MAKEFILE_IMPORT_PATH)node.mk -include $(MAKEFILE_IMPORT_PATH)terminal.mk -include $(MAKEFILE_IMPORT_PATH)target-go-fetch-licenses.mk -include $(MAKEFILE_IMPORT_PATH)target-add-licenses.mk -include $(MAKEFILE_IMPORT_PATH)target-deploy-tool.mk -#include $(MAKEFILE_IMPORT_PATH)target-jsdoc-build.mk -#include $(MAKEFILE_IMPORT_PATH)target-docman.mk -#include $(MAKEFILE_IMPORT_PATH)target-caddy.mk -#include $(MAKEFILE_IMPORT_PATH)target-conan.mk -#include $(MAKEFILE_IMPORT_PATH)target-phpunit.mk -#include $(MAKEFILE_IMPORT_PATH)target-jekyll.mk -include $(MAKEFILE_IMPORT_PATH)target-update-makefiles.mk -include $(MAKEFILE_IMPORT_PATH)target-help.mk -include $(MAKEFILE_IMPORT_PATH)target-go-build.mk -#include $(MAKEFILE_IMPORT_PATH)target-node-build.mk -#include $(MAKEFILE_IMPORT_PATH)target-node-test.mk -#include $(MAKEFILE_IMPORT_PATH)target-npm-publish.mk -#include $(MAKEFILE_IMPORT_PATH)target-npm.mk -include $(MAKEFILE_IMPORT_PATH)target-git.mk -#include $(MAKEFILE_IMPORT_PATH)target-init-standard.mk -#include $(MAKEFILE_IMPORT_PATH)target-init-webcomponent.mk -#include $(MAKEFILE_IMPORT_PATH)target-init-go-utilities.mk -#nclude $(MAKEFILE_IMPORT_PATH)target-init-go-lib.mk -#include $(MAKEFILE_IMPORT_PATH)target-init-platform-part.mk -include $(MAKEFILE_IMPORT_PATH)target-version.mk -include $(MAKEFILE_IMPORT_PATH)target-variable.mk -include $(MAKEFILE_IMPORT_PATH)terminal-check.mk - - -############################################################################################# - -# include target-project.mk only if it exists --include $(MAKEFILE_IMPORT_PATH)target-project.mk diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..7febe83 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,48 @@ +# https://taskfile.dev + +version: '3' + +tasks: + default: + cmds: + - task --list-all + silent: true + test: + desc: Execute unit tests in Go. + cmds: + - echo "Execute unit tests in Go." + - go test -cover -v ./... + + test-fuzz: + desc: Conduct fuzzing tests.# + cmds: + - echo "Conduct fuzzing tests." + - go test -v -fuzztime=30s -fuzz=Fuzz ./... + + add-licenses: + desc: Attach license headers to Go files. + cmds: + - echo "Attach license headers to Go files." + - addlicense -c "schukai GmbH" -s -l "AGPL-3.0" ./*.go + silent: true + + check: + desc: Confirm repository status. + cmds: + - git diff-index --quiet HEAD || (echo "There are uncommitted changes after running make. Please commit or stash them before running make."; exit 1) + silent: true + + build: + desc: Compile the application, + aliases: + - b + vars: + DEVENV_ROOT: + sh: echo "$DEVENV_ROOT" + + cmds: + - devenv shell build-app + sources: + - source/**/*.go + - source/**/*.mod + - dist/** diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..8993ca8 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,190 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1692003204, + "narHash": "sha256-gO2DXwXuArjpywgtRTDb3aKscWMbnI7YwFaqvV46yv0=", + "owner": "cachix", + "repo": "devenv", + "rev": "ade3ae522baf366296598e232b7b063d81740bbb", + "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": 1691950488, + "narHash": "sha256-iUNEeudc4dGjx+HsHccnGiuZUVE/nhjXuQ1DVCsHIUY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "720e61ed8de116eec48d6baea1d54469b536b985", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "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" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1691950488, + "narHash": "sha256-iUNEeudc4dGjx+HsHccnGiuZUVE/nhjXuQ1DVCsHIUY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "720e61ed8de116eec48d6baea1d54469b536b985", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-23.05", + "type": "indirect" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1691747570, + "narHash": "sha256-J3fnIwJtHVQ0tK2JMBv4oAmII+1mCdXdpeCxtIsrL2A=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "c5ac3aa3324bd8aebe8622a3fc92eeb3975d317a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "version": "version" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "version": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1690668568, + "narHash": "sha256-jzixQKFFW4oxO0S4GYqbkFCXzhBd6com6Z9+MtVKakU=", + "ref": "refs/heads/master", + "rev": "3838f03165b726e47d586c04a1821749375e1001", + "revCount": 37, + "type": "git", + "url": "https://gitlab.schukai.com/oss/utilities/version.git" + }, + "original": { + "type": "git", + "url": "https://gitlab.schukai.com/oss/utilities/version.git" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..2568f0c --- /dev/null +++ b/devenv.nix @@ -0,0 +1,149 @@ +{ pkgs, inputs, phps, lib, config, modulesPath,... }: + +{ + + # https://devenv.sh/packages/ + packages = [ + inputs.version.defaultPackage."${builtins.currentSystem}" + pkgs.git + pkgs.gcc12 + pkgs.go-task + pkgs.blackbox + pkgs.blackbox-terminal + pkgs.jq + pkgs.delve + pkgs.gdlv + pkgs.wget + pkgs.glab + pkgs.unixtools.xxd + pkgs.libffi + pkgs.zlib + pkgs.procps + pkgs.php81Extensions.xdebug + pkgs.ranger + pkgs.meld + pkgs.gnused + pkgs.coreutils-full + pkgs.gnugrep + pkgs.gnumake + pkgs.util-linux + pkgs.httpie + pkgs.netcat + pkgs.memcached + pkgs.fd + ]; + + + # https://devenv.sh/languages/ + # languages.nix.enable = true; + languages = { + go = { enable = true; }; + }; + + difftastic.enable = true; + + + # This script is executed when the app is built + # You can use it to build the app + scripts.test-lib.exec = '' +#!${pkgs.bash}/bin/bash +#set -euo pipefail +set -x + +PATH="''${PATH}":${pkgs.coreutils}/bin +PATH="''${PATH}":${pkgs.findutils}/bin +PATH="''${PATH}":${pkgs.jq}/bin/ +PATH="''${PATH}":${pkgs.rsync}/bin/ +PATH="''${PATH}":${pkgs.bash}/bin/ +PATH="''${PATH}":${pkgs.curl}/bin/ +PATH="''${PATH}":${pkgs.moreutils}/bin/ +PATH="''${PATH}":${pkgs.gnutar}/bin +PATH="''${PATH}":${pkgs.gzip}/bin/ +PATH="''${PATH}":${pkgs.procps}/bin/ +PATH="''${PATH}":${pkgs.exa}/bin/ +PATH="''${PATH}":${pkgs.git}/bin/ +PATH="''${PATH}":${pkgs.gnugrep}/bin/ +PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/ + +export -f PATH + +task test + +''; + + # This scritp is used to deploy the app to the gitlab registry + # It is used by the gitlab-ci.yml file + # The environment variables are set in the gitlab project settings + scripts.deploy-lib.exec = '' +#!${pkgs.bash}/bin/bash + +PATH="''${PATH}":${pkgs.coreutils}/bin +PATH="''${PATH}":${pkgs.jq}/bin/ +PATH="''${PATH}":${pkgs.curl}/bin/ +PATH="''${PATH}":${pkgs.moreutils}/bin/ +PATH="''${PATH}":${pkgs.gnutar}/bin +PATH="''${PATH}":${pkgs.gzip}/bin/ +PATH="''${PATH}":${pkgs.exa}/bin/ +PATH="''${PATH}":${pkgs.git}/bin/ +PATH="''${PATH}":${inputs.version.defaultPackage."${builtins.currentSystem}"}/bin/ + +export PATH + +if [[ -f .env-gitlab-ci ]]; then + source .env-gitlab-ci + rm .env-gitlab-ci +fi + +set -x +## if $HOME not set, set it to current directory +if [[ -z "''${HOME}" ]]; then + HOME=$(pwd) +fi + +export HOME + +git config user.email "''${GITLAB_USER_EMAIL}" +git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}" +git config pull.rebase true +git config http.sslVerify "false" +git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@} + +git fetch --all --tags --unshallow +git reset --hard origin/master +git checkout $CI_COMMIT_REF_NAME +git pull origin $CI_COMMIT_REF_NAME + +if [ ! -z "''${CI_PROJECT_DIR}" ]; then + echo "CI_PROJECT_DIR is set, using it as project root." + project_root=$(realpath "''${CI_PROJECT_DIR}")/ +elif [ ! -z "''${DEVENV_ROOT}" ]; then + echo "DEVENV_ROOT is set, using it as project root." + project_root=$(realpath "''${DEVENV_ROOT}")/ +else + echo "Error: DEVENV_ROOT or CI_PROJECT_DIR environment variables are not set." + exit 1 +fi + +if [ ! -d "''${project_root}" ]; then + echo "Error: Project root directory does not seem to be valid." + echo "Check the DEVENV_ROOT or CI_PROJECT_DIR environment variables." + exit 1 +fi + +if [ -z "'CI_JOB_TOKEN" ]; then + echo "Error: CI_JOB_TOKEN variable is not set." + exit 1 +fi + +git --no-pager log --decorate=short --pretty=oneline +gitVersion=v$(version predict) +git tag -a $gitVersion -m"chore: bump version" +git --no-pager log --decorate=short --pretty=oneline +git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags + +echo "done" + +''; + + +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..525a6f0 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,7 @@ +inputs: + nixpkgs: + url: github:nixos/nixpkgs/nixos-23.05 + + version: + url: git+https://gitlab.schukai.com/oss/utilities/version.git + flake: true -- GitLab