Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add Nix Flake #122

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Dreaming-Codes
Copy link

@Dreaming-Codes Dreaming-Codes commented Feb 15, 2025

Closes #120

I want to preface this by saying that I am not a Nix expert. Even though I use NixOS and rely on it to manage all my projects, I have never truly learned Nix. As a result, this flake might not be state-of-the-art.
I'm opening this as a draft to share the work I've done so far. I still haven't managed to get it working because there seem to be issues with PNPM workspaces.
A special thanks to @fromtheeast710 for his Rust Tauri flake template.

@HuakunShen
Copy link
Member

I am watching some nix videos.
I know nix but never had a chance to learn it.
If there is any nix expert, please help.

@mou
Copy link

mou commented Feb 18, 2025

I'm not an expert or package maintainer, but I want to share my observations on this topic. Repackaging AppImage or other binary distributions is much easier and could bootstrap the process. It's not preferable, but it might attract more attention and invite more people to improve.

https://wiki.nixos.org/wiki/Appimage

I want to help here but will be available only in three weeks from now (

@ghost ghost mentioned this pull request Feb 23, 2025
3 tasks
@genga898
Copy link

genga898 commented Mar 7, 2025

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

@Dreaming-Codes
Copy link
Author

Dreaming-Codes commented Mar 7, 2025

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

apps/desktop doesn't have it's own pnpm lock since it's a workspace member

@genga898
Copy link

genga898 commented Mar 7, 2025

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

apps/desktop doesn't have it's own pnpm lock since it's a workspace member

That's what I was referring to, since there isn't a lockfile in the apps/desktop directory, there's no need for inheriting the src in fetchDeps.

@Dreaming-Codes
Copy link
Author

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

apps/desktop doesn't have it's own pnpm lock since it's a workspace member

That's what I was referring to, since there isn't a lockfile in the apps/desktop directory, there's no need for inheriting the src in fetchDeps.

fetchDeps require src arg

@genga898
Copy link

genga898 commented Mar 7, 2025

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

apps/desktop doesn't have it's own pnpm lock since it's a workspace member

That's what I was referring to, since there isn't a lockfile in the apps/desktop directory, there's no need for inheriting the src in fetchDeps.

fetchDeps require src arg

I haven't seen it being specifically required in the docs, aside from that, would specify the source root be of any help ?

@Dreaming-Codes
Copy link
Author

Dreaming-Codes commented Mar 7, 2025

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

apps/desktop doesn't have it's own pnpm lock since it's a workspace member

That's what I was referring to, since there isn't a lockfile in the apps/desktop directory, there's no need for inheriting the src in fetchDeps.

fetchDeps require src arg

I haven't seen it being specifically required in the docs, aside from that, would specify the source root be of any help ?

Honestly I don't even know where the docs of that option are but if I remove it it says that either src or srcs needs to be defined. I've already tried specifying the source root but had no luck

@genga898
Copy link

genga898 commented Mar 7, 2025

@Dreaming-Codes wouldn't the fact that you're inheriting the src in your pnpmDeps be problematic since you're specifying the lockfile manually from the project root not the source root which is apps/desktop.

apps/desktop doesn't have it's own pnpm lock since it's a workspace member

That's what I was referring to, since there isn't a lockfile in the apps/desktop directory, there's no need for inheriting the src in fetchDeps.

fetchDeps require src arg

I haven't seen it being specifically required in the docs, aside from that, would specify the source root be of any help ?

Honestly I don't even know where the docs of that option are but if I remove it it says that either src or srcs needs to be defined. I've already tried specifying the source root but had no luck

Define the src as the project root rather than inheriting it, the root directory is where the lockfile can be found, that would probably remove the need for the lockfile argument in fetchDeps.

buildAndTestSubdir = cargoRoot;

pnpmDeps = pnpm.fetchDeps {
inherit pname version src;
Copy link

@genga898 genga898 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inherit pname version src;
inherit pname version;
src = ./.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't

@genga898
Copy link

genga898 commented Mar 7, 2025

@Dreaming-Codes Sorry for the extra ping, I made a few edits and it now finds the lockfile and fetches the deps, only issue is it does not configure the store, this is the edit

          pnpmDeps = pnpm.fetchDeps {
            inherit pname version;
            src = ./.;
            hash = "sha256-25uQRLB9ZqAJxbOIP2RwCAL5v3XBEaDl/MSsX1z0Ucw=";
          };

          pnpmRoot = ./.;

This is the current error:

error: builder for '/nix/store/yxmklkfajzz095rg9i1ay4qxw584fxvz-kunkun-0.0.0.drv' failed with exit code 243;
       last 25 log lines:
       > /nix/store/wg7lsdyjpsjnsa6r8x8xksh4g4l87s19-mgalc1m038ysafbdb6mbgklqpwys9p43-source /build/desktop
       > Configuring pnpm store
       > Installing dependencies
       >WARNUnsupported engine: wanted: {"node":">=22"} (current: {"node":"v20.18.3","pnpm":"9.15.5"})
       > Scope: all 28 workspace projects
       > Lockfile is up to date, resolution step is skipped
       > Progress: resolved 1, reused 0, downloaded 0, added 0
       > Packages: +2130
       >
       > Progress: resolved 1, reused 0, downloaded 0, added 0
       > Progress: resolved 2130, reused 0, downloaded 0, added 0
       >EACCESEACCES: permission denied, mkdir '/nix/store/wg7lsdyjpsjnsa6r8x8xksh4g4l87s19-mgalc1m038ysafbdb6mbgklqpwys9p43-source/node_modules'
       >
       > pnpm: EACCES: permission denied, mkdir '/nix/store/wg7lsdyjpsjnsa6r8x8xksh4g4l87s19-mgalc1m038ysafbdb6mbgklqpwys9p43-source/node_modules'
       >     at async Object.mkdir (node:internal/fs/promises:858:10)
       >     at async Promise.all (index 1862)
       >     at async headlessInstall (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:145678:9)
       >     at async _install (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:185046:33)
       >     at async mutateModules (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:184904:23)
       >     at async recursive (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:186424:50)
       >     at async installDeps (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:186732:11)
       >     at async /nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:223175:21
       >     at async main (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:223134:34)
       >     at async runPnpm (/nix/store/h0mpqbm4a8g4j52pyxdh4lv8fklhx379-pnpm-9.15.5/libexec/pnpm/dist/pnpm.cjs:223406:5)
       > Progress: resolved 2130, reused 0, downloaded 0, added 0
       For full logs, run 'nix log /nix/store/yxmklkfajzz095rg9i1ay4qxw584fxvz-kunkun-0.0.0.drv'.
       ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] Add Nix Flake Support
4 participants