From 8838fd67b95ae0c608947a1991087cf3f8611dae Mon Sep 17 00:00:00 2001 From: Lucas <43530291+LuckShiba@users.noreply.github.com> Date: Mon, 8 Dec 2025 08:22:07 -0300 Subject: [PATCH] nix: add dev-shell (#944) * nix: add dev-shell * docs: add Nix dev shell in contributing docs --- .gitignore | 37 ++------------ CONTRIBUTING.md | 15 ++++++ flake.nix | 133 ++++++++++++++++++++++++++++++------------------ 3 files changed, 103 insertions(+), 82 deletions(-) diff --git a/.gitignore b/.gitignore index 53792558..7a6f5846 100644 --- a/.gitignore +++ b/.gitignore @@ -102,39 +102,6 @@ go.work.sum # .idea/ # .vscode/ -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with `go test -c` -*.test - -# Code coverage profiles and other test artifacts -*.out -coverage.* -*.coverprofile -profile.cov - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work -go.work.sum - -# env file -.env - -# Editor/IDE -# .idea/ -# .vscode/ - bin/ # Extracted source trees in Ubuntu package directories @@ -142,3 +109,7 @@ distro/ubuntu/*/dms-git-repo/ distro/ubuntu/*/DankMaterialShell-*/ distro/ubuntu/danklinux/*/dsearch-*/ distro/ubuntu/danklinux/*/dgop-*/ + +# direnv +.envrc +.direnv/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6bf43d68..69e94df2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,21 @@ Enable pre-commit hooks to catch CI failures before pushing: git config core.hooksPath .githooks ``` +### Nix Development Shell + +If you have Nix installed with flakes enabled, you can use the provided development shell which includes all necessary dependencies: + +```bash +nix develop +``` + +This will provide: +- Go 1.24 toolchain (go, gopls, delve, go-tools) and GNU Make +- Quickshell and required QML packages +- Properly configured QML2_IMPORT_PATH + +The dev shell automatically creates the `.qmlls.ini` file in the `quickshell/` directory. + ## VSCode Setup This is a monorepo, the easiest thing to do is to open an editor in either `quickshell`, `core`, or both depending on which part of the project you are working on. diff --git a/flake.nix b/flake.nix index 50e23287..62ac5662 100644 --- a/flake.nix +++ b/flake.nix @@ -52,67 +52,69 @@ + "_" + (self.shortRev or "dirty"); in { - dms-shell = pkgs.buildGoModule (let - rootSrc = ./.; - in { - inherit version; - pname = "dms-shell"; - src = ./core; - vendorHash = "sha256-2PCqiW4frxME8IlmwWH5ktznhd/G1bah5Ae4dp0HPTQ="; + dms-shell = pkgs.buildGoModule ( + let + rootSrc = ./.; + in { + inherit version; + pname = "dms-shell"; + src = ./core; + vendorHash = "sha256-2PCqiW4frxME8IlmwWH5ktznhd/G1bah5Ae4dp0HPTQ="; - subPackages = ["cmd/dms"]; + subPackages = ["cmd/dms"]; - ldflags = [ - "-s" - "-w" - "-X main.Version=${version}" - ]; + ldflags = [ + "-s" + "-w" + "-X main.Version=${version}" + ]; - nativeBuildInputs = [ - pkgs.installShellFiles - pkgs.makeWrapper - ]; + nativeBuildInputs = with pkgs; [ + installShellFiles + .makeWrapper + ]; - postInstall = '' - mkdir -p $out/share/quickshell/dms - cp -r ${rootSrc}/quickshell/. $out/share/quickshell/dms/ + postInstall = '' + mkdir -p $out/share/quickshell/dms + cp -r ${rootSrc}/quickshell/. $out/share/quickshell/dms/ - chmod u+w $out/share/quickshell/dms/VERSION - echo "${version}" > $out/share/quickshell/dms/VERSION + chmod u+w $out/share/quickshell/dms/VERSION + echo "${version}" > $out/share/quickshell/dms/VERSION - # Install desktop file and icon - install -D ${rootSrc}/assets/dms-open.desktop \ - $out/share/applications/dms-open.desktop - install -D ${rootSrc}/core/assets/danklogo.svg \ - $out/share/hicolor/scalable/apps/danklogo.svg + # Install desktop file and icon + install -D ${rootSrc}/assets/dms-open.desktop \ + $out/share/applications/dms-open.desktop + install -D ${rootSrc}/core/assets/danklogo.svg \ + $out/share/hicolor/scalable/apps/danklogo.svg - wrapProgram $out/bin/dms --add-flags "-c $out/share/quickshell/dms" + wrapProgram $out/bin/dms --add-flags "-c $out/share/quickshell/dms" - install -Dm644 ${rootSrc}/assets/systemd/dms.service \ - $out/lib/systemd/user/dms.service + install -Dm644 ${rootSrc}/assets/systemd/dms.service \ + $out/lib/systemd/user/dms.service - substituteInPlace $out/lib/systemd/user/dms.service \ - --replace-fail /usr/bin/dms $out/bin/dms \ - --replace-fail /usr/bin/pkill ${pkgs.procps}/bin/pkill + substituteInPlace $out/lib/systemd/user/dms.service \ + --replace-fail /usr/bin/dms $out/bin/dms \ + --replace-fail /usr/bin/pkill ${pkgs.procps}/bin/pkill - substituteInPlace $out/share/quickshell/dms/Modules/Greetd/assets/dms-greeter \ - --replace-fail /bin/bash ${pkgs.bashInteractive}/bin/bash + substituteInPlace $out/share/quickshell/dms/Modules/Greetd/assets/dms-greeter \ + --replace-fail /bin/bash ${pkgs.bashInteractive}/bin/bash - installShellCompletion --cmd dms \ - --bash <($out/bin/dms completion bash) \ - --fish <($out/bin/dms completion fish) \ - --zsh <($out/bin/dms completion zsh) - ''; + installShellCompletion --cmd dms \ + --bash <($out/bin/dms completion bash) \ + --fish <($out/bin/dms completion fish) \ + --zsh <($out/bin/dms completion zsh) + ''; - meta = { - description = "Desktop shell for wayland compositors built with Quickshell & GO"; - homepage = "https://danklinux.com"; - changelog = "https://github.com/AvengeMedia/DankMaterialShell/releases/tag/v${version}"; - license = pkgs.lib.licenses.mit; - mainProgram = "dms"; - platforms = pkgs.lib.platforms.linux; - }; - }); + meta = { + description = "Desktop shell for wayland compositors built with Quickshell & GO"; + homepage = "https://danklinux.com"; + changelog = "https://github.com/AvengeMedia/DankMaterialShell/releases/tag/v${version}"; + license = pkgs.lib.licenses.mit; + mainProgram = "dms"; + platforms = pkgs.lib.platforms.linux; + }; + } + ); default = self.packages.${system}.dms-shell; } @@ -125,5 +127,38 @@ nixosModules.dankMaterialShell = mkModuleWithDmsPkgs ./distro/nix/nixos.nix; nixosModules.greeter = mkModuleWithDmsPkgs ./distro/nix/greeter.nix; + + devShells = forEachSystem ( + system: pkgs: let + qmlPkgs = + [ + quickshell.packages.${system}.default + ] + ++ (with pkgs.kdePackages; [ + qtdeclarative + kirigami.unwrapped + sonnet + qtmultimedia + ]); + in { + default = pkgs.mkShell { + buildInputs = with pkgs; + [ + go_1_24 + gopls + delve + go-tools + gnumake + ] + ++ qmlPkgs; + + shellHook = '' + touch quickshell/.qmlls.ini 2>/dev/null + ''; + + QML2_IMPORT_PATH = pkgs.lib.concatStringsSep ":" (map (o: "${o}/lib/qt-6/qml") qmlPkgs); + }; + } + ); }; }