From d6bfa8fe6b634b0e8fa48073d3e3a2036f21f521 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Tue, 15 Apr 2025 22:36:48 +0200 Subject: [PATCH] devenv: add environment Signed-off-by: Patrizio Bekerle --- .envrc | 8 +++- .gitignore | 10 +++++ devenv.lock | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++ devenv.nix | 69 +++++++++++++++++++++++++++++++++++ devenv.yaml | 5 +++ justfile | 2 +- 6 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml diff --git a/.envrc b/.envrc index 53e2e99e8..fd7df1dca 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,8 @@ -use nix +#use nix #use flake + +export DIRENV_WARN_TIMEOUT=20s + +eval "$(devenv direnvrc)" + +use devenv diff --git a/.gitignore b/.gitignore index 5e3c56388..b5fe562ce 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,13 @@ ui_*.h /src/QOwnNotes secrets/* + +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 000000000..8581e957e --- /dev/null +++ b/devenv.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1744725539, + "owner": "cachix", + "repo": "devenv", + "rev": "e35cb7bb6e6424b83560b5ae0896f75263942191", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1742649964, + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744463964, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": [ + "git-hooks" + ] + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 000000000..036cacabb --- /dev/null +++ b/devenv.nix @@ -0,0 +1,69 @@ +{ + pkgs, + config, + ... +}: + +{ + # https://devenv.sh/supported-languages/cplusplus/ + languages.cplusplus.enable = true; + + # https://devenv.sh/packages/ + packages = + with pkgs; + with qt6; + [ + just + crowdin-cli + cmake + qmake + qttools + wrapQtAppsHook + pkg-config + libclang # for clang-format + procs # fetches process info + gawk # for parsing procs output + fzf # for interactive process selection + + # for ./build-systems/github/build-github-src.sh + coreutils + gh + + # for shell scripts + findutils + gnused + ripgrep + librsvg + imagemagick + libicns + + # Packages for treefmt + libclang + nodePackages.prettier + shfmt + nixfmt-rfc-style + statix + taplo + cmake-format + ]; + + # https://devenv.sh/git-hooks/ + git-hooks.hooks.treefmt.enable = true; + + # This script updates the symlinks to the qmake binaries in the nix store + # The symlinks are to be used in Qt Creator and CLion + scripts.update-qmake-symlinks.exec = '' + BIN_DIR="''${DEVENV_ROOT}/bin" + echo "Updating qmake symlinks in ''${BIN_DIR}..." + + mkdir -p "''${BIN_DIR}" + ln -sf "${pkgs.kdePackages.qtbase}/bin/qmake" "''${BIN_DIR}/qmake6" + ln -sf "${pkgs.libsForQt5.qt5.qtbase.dev}/bin/qmake" "''${BIN_DIR}/qmake5" + ''; + + enterShell = '' + update-qmake-symlinks + ''; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 000000000..d30402df6 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,5 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + # url: github:cachix/devenv-nixpkgs/rolling + url: github:NixOS/nixpkgs/nixos-unstable diff --git a/justfile b/justfile index b56a87421..c2c79239b 100644 --- a/justfile +++ b/justfile @@ -175,7 +175,7 @@ fix-settings-ui-file: # Attach to the QOwnNotes process with lurk [group('debug')] process-trace: - sudo lurk --attach `procs QOwnNotes | fzf --height 40% --layout reverse | awk '{print $1}'` + nix-shell -p lurk --run "sudo lurk --attach `procs QOwnNotes | fzf --height 40% --layout reverse | awk '{print $1}'`" # Generate the icons for the whole project based on icons/icon.svg and icons/icon-dark.svg [group('icons')]