From 3e950a0cbecc9d00a65b50d8ecdc96bca4fa32ae Mon Sep 17 00:00:00 2001 From: xarvex Date: Sun, 1 Sep 2024 21:26:34 -0500 Subject: [PATCH 1/2] fix(direnv)!: gitignore .envrc A common workflow is to have a local .envrc, allow contributors to do so. Still provide the recommended Nix-based setup, for those who wish to use it. That file can then be copied to or symlinked to `.envrc`. --- .envrc => .envrc.recommended | 3 +++ .gitignore | 1 + 2 files changed, 4 insertions(+) rename .envrc => .envrc.recommended (82%) diff --git a/.envrc b/.envrc.recommended similarity index 82% rename from .envrc rename to .envrc.recommended index e84ab0f8..94dd6bc2 100644 --- a/.envrc +++ b/.envrc.recommended @@ -1,4 +1,7 @@ # vi: ft=bash +# +# If you wish to use this file, copy or symlink it to `.envrc` for direnv to read it. +# This will use the flake development shell. if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w=" diff --git a/.gitignore b/.gitignore index 459e6d88..7b493926 100644 --- a/.gitignore +++ b/.gitignore @@ -254,5 +254,6 @@ compile_commands.json TagStudio.ini # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,qt +.envrc .direnv .devenv From 3e2fb1282c2262df85d54ff66164de1eaf1ea0e8 Mon Sep 17 00:00:00 2001 From: xarvex Date: Tue, 3 Sep 2024 00:11:59 -0500 Subject: [PATCH 2/2] feat(flake): expose formatter Fixes: #433 --- flake.nix | 111 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 45 deletions(-) diff --git a/flake.nix b/flake.nix index 86529cc1..566423fb 100644 --- a/flake.nix +++ b/flake.nix @@ -27,19 +27,35 @@ systems.url = "github:nix-systems/default-linux"; }; - outputs = { flake-parts, nixpkgs, nixpkgs-qt6, self, systems, ... }@inputs: + outputs = + { + flake-parts, + nixpkgs, + nixpkgs-qt6, + self, + systems, + ... + }@inputs: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.devenv.flakeModule ]; systems = import systems; - perSystem = { config, pkgs, system, ... }: + perSystem = + { + config, + pkgs, + system, + ... + }: let inherit (nixpkgs) lib; qt6Pkgs = import nixpkgs-qt6 { inherit system; }; in { + formatter = pkgs.nixfmt-rfc-style; + devenv.shells = rec { default = tagstudio; @@ -68,50 +84,53 @@ name = "TagStudio"; # Derived from previous flake iteration. - packages = (with pkgs; [ - cmake - binutils - coreutils - dbus - fontconfig - freetype - gdb - glib - libGL - libGLU - libgcc - libxkbcommon - mypy - ruff - xorg.libxcb - zstd - ]) - ++ (with qt6Pkgs; [ - qt6.full - qt6.qtbase - qt6.qtwayland - qtcreator - ]); + packages = + (with pkgs; [ + cmake + binutils + coreutils + dbus + fontconfig + freetype + gdb + glib + libGL + libGLU + libgcc + libxkbcommon + mypy + ruff + xorg.libxcb + zstd + ]) + ++ (with qt6Pkgs; [ + qt6.full + qt6.qtbase + qt6.qtwayland + qtcreator + ]); enterShell = let - setQtEnv = pkgs.runCommand "set-qt-env" - { - buildInputs = with qt6Pkgs.qt6; [ - qtbase - ]; + setQtEnv = + pkgs.runCommand "set-qt-env" + { + buildInputs = with qt6Pkgs.qt6; [ + qtbase + ]; - nativeBuildInputs = (with pkgs; [ - makeShellWrapper - ]) - ++ (with qt6Pkgs.qt6; [ - wrapQtAppsHook - ]); - } - '' - makeShellWrapper "$(type -p sh)" "$out" "''${qtWrapperArgs[@]}" - sed "/^exec/d" -i "$out" - ''; + nativeBuildInputs = + (with pkgs; [ + makeShellWrapper + ]) + ++ (with qt6Pkgs.qt6; [ + wrapQtAppsHook + ]); + } + '' + makeShellWrapper "$(type -p sh)" "$out" "''${qtWrapperArgs[@]}" + sed "/^exec/d" -i "$out" + ''; in '' source ${setQtEnv} @@ -162,9 +181,11 @@ quiet = true; requirements = let - excludeDeps = req: deps: builtins.concatStringsSep "\n" - (builtins.filter (line: !(lib.any (elem: lib.hasPrefix elem line) deps)) - (lib.splitString "\n" req)); + excludeDeps = + req: deps: + builtins.concatStringsSep "\n" ( + builtins.filter (line: !(lib.any (elem: lib.hasPrefix elem line) deps)) (lib.splitString "\n" req) + ); in '' ${builtins.readFile ./requirements.txt}